id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
147,800
crossdock/crossdock-go
assert/assertion_forward.go
Zero
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { return Zero(a.t, i, msgAndArgs...) }
go
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { return Zero(a.t, i, msgAndArgs...) }
[ "func", "(", "a", "*", "Assertions", ")", "Zero", "(", "i", "interface", "{", "}", ",", "msgAndArgs", "...", "interface", "{", "}", ")", "bool", "{", "return", "Zero", "(", "a", ".", "t", ",", "i", ",", "msgAndArgs", "...", ")", "\n", "}" ]
// Zero asserts that i is the zero value for its type and returns the truth.
[ "Zero", "asserts", "that", "i", "is", "the", "zero", "value", "for", "its", "type", "and", "returns", "the", "truth", "." ]
049aabb0122b03bc9bd30cab8f3f91fb60166361
https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/assert/assertion_forward.go#L385-L387
147,801
fjl/memsize
memsize.go
Scan
func Scan(v interface{}) Sizes { rv := reflect.ValueOf(v) if rv.Kind() != reflect.Ptr || rv.IsNil() { panic("value to scan must be non-nil pointer") } stopTheWorld("memsize scan") defer startTheWorld() ctx := newContext() ctx.scan(invalidAddr, rv, false) ctx.s.BitmapSize = ctx.seen.size() ctx.s.BitmapUtili...
go
func Scan(v interface{}) Sizes { rv := reflect.ValueOf(v) if rv.Kind() != reflect.Ptr || rv.IsNil() { panic("value to scan must be non-nil pointer") } stopTheWorld("memsize scan") defer startTheWorld() ctx := newContext() ctx.scan(invalidAddr, rv, false) ctx.s.BitmapSize = ctx.seen.size() ctx.s.BitmapUtili...
[ "func", "Scan", "(", "v", "interface", "{", "}", ")", "Sizes", "{", "rv", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "rv", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "||", "rv", ".", "IsNil", "(", ")", "{", "panic", ...
// Scan traverses all objects reachable from v and counts how much memory // is used per type. The value must be a non-nil pointer to any value.
[ "Scan", "traverses", "all", "objects", "reachable", "from", "v", "and", "counts", "how", "much", "memory", "is", "used", "per", "type", ".", "The", "value", "must", "be", "a", "non", "-", "nil", "pointer", "to", "any", "value", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/memsize.go#L15-L29
147,802
fjl/memsize
memsize.go
Report
func (s Sizes) Report() string { type typLine struct { name string count uintptr total uintptr } tab := []typLine{{"ALL", 0, s.Total}} for _, typ := range s.ByType { tab[0].count += typ.Count } maxname := 0 for typ, s := range s.ByType { line := typLine{typ.String(), s.Count, s.Total} tab = append(t...
go
func (s Sizes) Report() string { type typLine struct { name string count uintptr total uintptr } tab := []typLine{{"ALL", 0, s.Total}} for _, typ := range s.ByType { tab[0].count += typ.Count } maxname := 0 for typ, s := range s.ByType { line := typLine{typ.String(), s.Count, s.Total} tab = append(t...
[ "func", "(", "s", "Sizes", ")", "Report", "(", ")", "string", "{", "type", "typLine", "struct", "{", "name", "string", "\n", "count", "uintptr", "\n", "total", "uintptr", "\n", "}", "\n", "tab", ":=", "[", "]", "typLine", "{", "{", "\"", "\"", ",",...
// Report returns a human-readable report.
[ "Report", "returns", "a", "human", "-", "readable", "report", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/memsize.go#L50-L78
147,803
fjl/memsize
memsize.go
addValue
func (s *Sizes) addValue(v reflect.Value, size uintptr) { s.Total += size rs := s.ByType[v.Type()] if rs == nil { rs = new(TypeSize) s.ByType[v.Type()] = rs } rs.Total += size rs.Count++ }
go
func (s *Sizes) addValue(v reflect.Value, size uintptr) { s.Total += size rs := s.ByType[v.Type()] if rs == nil { rs = new(TypeSize) s.ByType[v.Type()] = rs } rs.Total += size rs.Count++ }
[ "func", "(", "s", "*", "Sizes", ")", "addValue", "(", "v", "reflect", ".", "Value", ",", "size", "uintptr", ")", "{", "s", ".", "Total", "+=", "size", "\n", "rs", ":=", "s", ".", "ByType", "[", "v", ".", "Type", "(", ")", "]", "\n", "if", "rs...
// addValue is called during scan and adds the memory of given object.
[ "addValue", "is", "called", "during", "scan", "and", "adds", "the", "memory", "of", "given", "object", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/memsize.go#L81-L90
147,804
fjl/memsize
memsize.go
scan
func (c *context) scan(addr address, v reflect.Value, add bool) (extraSize uintptr) { size := v.Type().Size() var marked uintptr if addr.valid() { marked = c.seen.countRange(uintptr(addr), size) if marked == size { return 0 // Skip if we have already seen the whole object. } c.seen.markRange(uintptr(addr)...
go
func (c *context) scan(addr address, v reflect.Value, add bool) (extraSize uintptr) { size := v.Type().Size() var marked uintptr if addr.valid() { marked = c.seen.countRange(uintptr(addr), size) if marked == size { return 0 // Skip if we have already seen the whole object. } c.seen.markRange(uintptr(addr)...
[ "func", "(", "c", "*", "context", ")", "scan", "(", "addr", "address", ",", "v", "reflect", ".", "Value", ",", "add", "bool", ")", "(", "extraSize", "uintptr", ")", "{", "size", ":=", "v", ".", "Type", "(", ")", ".", "Size", "(", ")", "\n", "va...
// scan walks all objects below v, determining their size. It returns the size of the // previously unscanned parts of the object.
[ "scan", "walks", "all", "objects", "below", "v", "determining", "their", "size", ".", "It", "returns", "the", "size", "of", "the", "previously", "unscanned", "parts", "of", "the", "object", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/memsize.go#L106-L127
147,805
fjl/memsize
type.go
isPointer
func (tc *typCache) isPointer(typ reflect.Type) bool { return tc.info(typ).isPointer }
go
func (tc *typCache) isPointer(typ reflect.Type) bool { return tc.info(typ).isPointer }
[ "func", "(", "tc", "*", "typCache", ")", "isPointer", "(", "typ", "reflect", ".", "Type", ")", "bool", "{", "return", "tc", ".", "info", "(", "typ", ")", ".", "isPointer", "\n", "}" ]
// isPointer returns true for pointer-ish values. The notion of // pointer includes everything but plain values, i.e. slices, maps // channels, interfaces are 'pointer', too.
[ "isPointer", "returns", "true", "for", "pointer", "-", "ish", "values", ".", "The", "notion", "of", "pointer", "includes", "everything", "but", "plain", "values", "i", ".", "e", ".", "slices", "maps", "channels", "interfaces", "are", "pointer", "too", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/type.go#L48-L50
147,806
fjl/memsize
type.go
needScan
func (tc *typCache) needScan(typ reflect.Type) bool { return tc.info(typ).needScan }
go
func (tc *typCache) needScan(typ reflect.Type) bool { return tc.info(typ).needScan }
[ "func", "(", "tc", "*", "typCache", ")", "needScan", "(", "typ", "reflect", ".", "Type", ")", "bool", "{", "return", "tc", ".", "info", "(", "typ", ")", ".", "needScan", "\n", "}" ]
// needScan reports whether a value of the type needs to be scanned // recursively because it may contain pointers.
[ "needScan", "reports", "whether", "a", "value", "of", "the", "type", "needs", "to", "be", "scanned", "recursively", "because", "it", "may", "contain", "pointers", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/type.go#L54-L56
147,807
fjl/memsize
type.go
HumanSize
func HumanSize(bytes uintptr) string { switch { case bytes < 1024: return fmt.Sprintf("%d B", bytes) case bytes < 1024*1024: return fmt.Sprintf("%.3f KB", float64(bytes)/1024) default: return fmt.Sprintf("%.3f MB", float64(bytes)/1024/1024) } }
go
func HumanSize(bytes uintptr) string { switch { case bytes < 1024: return fmt.Sprintf("%d B", bytes) case bytes < 1024*1024: return fmt.Sprintf("%.3f KB", float64(bytes)/1024) default: return fmt.Sprintf("%.3f MB", float64(bytes)/1024/1024) } }
[ "func", "HumanSize", "(", "bytes", "uintptr", ")", "string", "{", "switch", "{", "case", "bytes", "<", "1024", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "bytes", ")", "\n", "case", "bytes", "<", "1024", "*", "1024", ":", "return", ...
// HumanSize formats the given number of bytes as a readable string.
[ "HumanSize", "formats", "the", "given", "number", "of", "bytes", "as", "a", "readable", "string", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/type.go#L110-L119
147,808
fjl/memsize
bitmap.go
markRange
func (b *bitmap) markRange(addr, n uintptr) { for end := addr + n; addr < end; { block, baddr := b.block(addr) for i := baddr; i < bmBlockRange && addr < end; i++ { block.mark(i) addr++ } } }
go
func (b *bitmap) markRange(addr, n uintptr) { for end := addr + n; addr < end; { block, baddr := b.block(addr) for i := baddr; i < bmBlockRange && addr < end; i++ { block.mark(i) addr++ } } }
[ "func", "(", "b", "*", "bitmap", ")", "markRange", "(", "addr", ",", "n", "uintptr", ")", "{", "for", "end", ":=", "addr", "+", "n", ";", "addr", "<", "end", ";", "{", "block", ",", "baddr", ":=", "b", ".", "block", "(", "addr", ")", "\n", "f...
// markRange sets n consecutive bits starting at addr.
[ "markRange", "sets", "n", "consecutive", "bits", "starting", "at", "addr", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L24-L32
147,809
fjl/memsize
bitmap.go
isMarked
func (b *bitmap) isMarked(addr uintptr) bool { block, baddr := b.block(addr) return block.isMarked(baddr) }
go
func (b *bitmap) isMarked(addr uintptr) bool { block, baddr := b.block(addr) return block.isMarked(baddr) }
[ "func", "(", "b", "*", "bitmap", ")", "isMarked", "(", "addr", "uintptr", ")", "bool", "{", "block", ",", "baddr", ":=", "b", ".", "block", "(", "addr", ")", "\n", "return", "block", ".", "isMarked", "(", "baddr", ")", "\n", "}" ]
// isMarked returns the value of the bit at the given address.
[ "isMarked", "returns", "the", "value", "of", "the", "bit", "at", "the", "given", "address", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L35-L38
147,810
fjl/memsize
bitmap.go
block
func (b *bitmap) block(addr uintptr) (*bmBlock, uintptr) { index := addr / bmBlockRange block := b.blocks[index] if block == nil { block = new(bmBlock) b.blocks[index] = block } return block, addr % bmBlockRange }
go
func (b *bitmap) block(addr uintptr) (*bmBlock, uintptr) { index := addr / bmBlockRange block := b.blocks[index] if block == nil { block = new(bmBlock) b.blocks[index] = block } return block, addr % bmBlockRange }
[ "func", "(", "b", "*", "bitmap", ")", "block", "(", "addr", "uintptr", ")", "(", "*", "bmBlock", ",", "uintptr", ")", "{", "index", ":=", "addr", "/", "bmBlockRange", "\n", "block", ":=", "b", ".", "blocks", "[", "index", "]", "\n", "if", "block", ...
// block finds the block corresponding to the given memory address. // It also returns the block's starting address.
[ "block", "finds", "the", "block", "corresponding", "to", "the", "given", "memory", "address", ".", "It", "also", "returns", "the", "block", "s", "starting", "address", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L58-L66
147,811
fjl/memsize
bitmap.go
size
func (b *bitmap) size() uintptr { return uintptr(len(b.blocks)) * bmBlockWords * uintptrBytes }
go
func (b *bitmap) size() uintptr { return uintptr(len(b.blocks)) * bmBlockWords * uintptrBytes }
[ "func", "(", "b", "*", "bitmap", ")", "size", "(", ")", "uintptr", "{", "return", "uintptr", "(", "len", "(", "b", ".", "blocks", ")", ")", "*", "bmBlockWords", "*", "uintptrBytes", "\n", "}" ]
// size returns the sum of the byte sizes of all blocks.
[ "size", "returns", "the", "sum", "of", "the", "byte", "sizes", "of", "all", "blocks", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L69-L71
147,812
fjl/memsize
bitmap.go
utilization
func (b *bitmap) utilization() float32 { var avg float32 for _, block := range b.blocks { avg += float32(block.count(0, bmBlockRange-1)) / float32(bmBlockRange) } return avg / float32(len(b.blocks)) }
go
func (b *bitmap) utilization() float32 { var avg float32 for _, block := range b.blocks { avg += float32(block.count(0, bmBlockRange-1)) / float32(bmBlockRange) } return avg / float32(len(b.blocks)) }
[ "func", "(", "b", "*", "bitmap", ")", "utilization", "(", ")", "float32", "{", "var", "avg", "float32", "\n", "for", "_", ",", "block", ":=", "range", "b", ".", "blocks", "{", "avg", "+=", "float32", "(", "block", ".", "count", "(", "0", ",", "bm...
// utilization returns the mean percentage of one bits across all blocks.
[ "utilization", "returns", "the", "mean", "percentage", "of", "one", "bits", "across", "all", "blocks", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L74-L80
147,813
fjl/memsize
bitmap.go
mark
func (b *bmBlock) mark(i uintptr) { b[i/uintptrBits] |= 1 << (i % uintptrBits) }
go
func (b *bmBlock) mark(i uintptr) { b[i/uintptrBits] |= 1 << (i % uintptrBits) }
[ "func", "(", "b", "*", "bmBlock", ")", "mark", "(", "i", "uintptr", ")", "{", "b", "[", "i", "/", "uintptrBits", "]", "|=", "1", "<<", "(", "i", "%", "uintptrBits", ")", "\n", "}" ]
// mark sets the i'th bit to one.
[ "mark", "sets", "the", "i", "th", "bit", "to", "one", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L86-L88
147,814
fjl/memsize
bitmap.go
isMarked
func (b *bmBlock) isMarked(i uintptr) bool { return (b[i/uintptrBits] & (1 << (i % uintptrBits))) != 0 }
go
func (b *bmBlock) isMarked(i uintptr) bool { return (b[i/uintptrBits] & (1 << (i % uintptrBits))) != 0 }
[ "func", "(", "b", "*", "bmBlock", ")", "isMarked", "(", "i", "uintptr", ")", "bool", "{", "return", "(", "b", "[", "i", "/", "uintptrBits", "]", "&", "(", "1", "<<", "(", "i", "%", "uintptrBits", ")", ")", ")", "!=", "0", "\n", "}" ]
// isMarked returns the value of the i'th bit.
[ "isMarked", "returns", "the", "value", "of", "the", "i", "th", "bit", "." ]
2a09253e352a56f419bd88effab0483f52da4c7d
https://github.com/fjl/memsize/blob/2a09253e352a56f419bd88effab0483f52da4c7d/bitmap.go#L91-L93
147,815
cortesi/moddwatch
filter/filter.go
MatchAny
func MatchAny(path string, patterns []string) (bool, error) { for _, pattern := range patterns { match, err := doublestar.Match(pattern, filepath.ToSlash(path)) if err != nil { return false, err } else if match { return true, nil } } return false, nil }
go
func MatchAny(path string, patterns []string) (bool, error) { for _, pattern := range patterns { match, err := doublestar.Match(pattern, filepath.ToSlash(path)) if err != nil { return false, err } else if match { return true, nil } } return false, nil }
[ "func", "MatchAny", "(", "path", "string", ",", "patterns", "[", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "for", "_", ",", "pattern", ":=", "range", "patterns", "{", "match", ",", "err", ":=", "doublestar", ".", "Match", "(", "pattern...
// MatchAny checks whether the given path matches any of the specified patterns.
[ "MatchAny", "checks", "whether", "the", "given", "path", "matches", "any", "of", "the", "specified", "patterns", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/filter/filter.go#L11-L21
147,816
cortesi/moddwatch
filter/filter.go
File
func File( path string, includePatterns []string, excludePatterns []string, ) (string, error) { if excluded, err := MatchAny(path, excludePatterns); err != nil { return "", err } else if excluded { return "", nil } if included, err := MatchAny(path, includePatterns); err != nil { return "", err } else if ...
go
func File( path string, includePatterns []string, excludePatterns []string, ) (string, error) { if excluded, err := MatchAny(path, excludePatterns); err != nil { return "", err } else if excluded { return "", nil } if included, err := MatchAny(path, includePatterns); err != nil { return "", err } else if ...
[ "func", "File", "(", "path", "string", ",", "includePatterns", "[", "]", "string", ",", "excludePatterns", "[", "]", "string", ",", ")", "(", "string", ",", "error", ")", "{", "if", "excluded", ",", "err", ":=", "MatchAny", "(", "path", ",", "excludePa...
// File determines if a path matches a set of include and exclude patterns. At // least one include pattern and no exclude patterns must match.
[ "File", "determines", "if", "a", "path", "matches", "a", "set", "of", "include", "and", "exclude", "patterns", ".", "At", "least", "one", "include", "pattern", "and", "no", "exclude", "patterns", "must", "match", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/filter/filter.go#L25-L41
147,817
cortesi/moddwatch
filter/filter.go
Files
func Files( files []string, includePatterns []string, excludePatterns []string, ) ([]string, error) { ret := []string{} for _, file := range files { path, err := File(file, includePatterns, excludePatterns) if err != nil || path == "" { continue } ret = append(ret, path) } return ret, nil }
go
func Files( files []string, includePatterns []string, excludePatterns []string, ) ([]string, error) { ret := []string{} for _, file := range files { path, err := File(file, includePatterns, excludePatterns) if err != nil || path == "" { continue } ret = append(ret, path) } return ret, nil }
[ "func", "Files", "(", "files", "[", "]", "string", ",", "includePatterns", "[", "]", "string", ",", "excludePatterns", "[", "]", "string", ",", ")", "(", "[", "]", "string", ",", "error", ")", "{", "ret", ":=", "[", "]", "string", "{", "}", "\n", ...
// Files filters an array of files using filter.File.
[ "Files", "filters", "an", "array", "of", "files", "using", "filter", ".", "File", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/filter/filter.go#L44-L58
147,818
cortesi/moddwatch
filter/filter.go
SplitPattern
func SplitPattern(pattern string) (string, string) { base := pattern trail := "" split := strings.IndexAny(pattern, "*{}?[]") if split >= 0 { base = pattern[:split] trail = pattern[split:] } return base, trail }
go
func SplitPattern(pattern string) (string, string) { base := pattern trail := "" split := strings.IndexAny(pattern, "*{}?[]") if split >= 0 { base = pattern[:split] trail = pattern[split:] } return base, trail }
[ "func", "SplitPattern", "(", "pattern", "string", ")", "(", "string", ",", "string", ")", "{", "base", ":=", "pattern", "\n", "trail", ":=", "\"", "\"", "\n\n", "split", ":=", "strings", ".", "IndexAny", "(", "pattern", ",", "\"", "\"", ")", "\n", "i...
// SplitPattern splits a pattern into a root directory and a trailing pattern // specifier.
[ "SplitPattern", "splits", "a", "pattern", "into", "a", "root", "directory", "and", "a", "trailing", "pattern", "specifier", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/filter/filter.go#L62-L72
147,819
cortesi/moddwatch
watch.go
isUnder
func isUnder(parent string, child string) bool { parent = filepath.ToSlash(parent) child = filepath.ToSlash(child) off := strings.Index(child, parent) if off == 0 && (len(child) == len(parent) || child[len(parent)] == '/') { return true } return false }
go
func isUnder(parent string, child string) bool { parent = filepath.ToSlash(parent) child = filepath.ToSlash(child) off := strings.Index(child, parent) if off == 0 && (len(child) == len(parent) || child[len(parent)] == '/') { return true } return false }
[ "func", "isUnder", "(", "parent", "string", ",", "child", "string", ")", "bool", "{", "parent", "=", "filepath", ".", "ToSlash", "(", "parent", ")", "\n", "child", "=", "filepath", ".", "ToSlash", "(", "child", ")", "\n", "off", ":=", "strings", ".", ...
// isUnder takes two absolute paths, and returns true if child is under parent.
[ "isUnder", "takes", "two", "absolute", "paths", "and", "returns", "true", "if", "child", "is", "under", "parent", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L21-L29
147,820
cortesi/moddwatch
watch.go
All
func (mod Mod) All() []string { all := make(map[string]bool) for _, p := range mod.Changed { all[p] = true } for _, p := range mod.Added { all[p] = true } return _keys(all) }
go
func (mod Mod) All() []string { all := make(map[string]bool) for _, p := range mod.Changed { all[p] = true } for _, p := range mod.Added { all[p] = true } return _keys(all) }
[ "func", "(", "mod", "Mod", ")", "All", "(", ")", "[", "]", "string", "{", "all", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "for", "_", ",", "p", ":=", "range", "mod", ".", "Changed", "{", "all", "[", "p", "]", "=", "t...
// All returns a single list of all files changed or added - deleted files are // not included.
[ "All", "returns", "a", "single", "list", "of", "all", "files", "changed", "or", "added", "-", "deleted", "files", "are", "not", "included", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L84-L93
147,821
cortesi/moddwatch
watch.go
Has
func (mod Mod) Has(p string) bool { for _, v := range mod.All() { if filepath.Clean(p) == filepath.Clean(v) { return true } } return false }
go
func (mod Mod) Has(p string) bool { for _, v := range mod.All() { if filepath.Clean(p) == filepath.Clean(v) { return true } } return false }
[ "func", "(", "mod", "Mod", ")", "Has", "(", "p", "string", ")", "bool", "{", "for", "_", ",", "v", ":=", "range", "mod", ".", "All", "(", ")", "{", "if", "filepath", ".", "Clean", "(", "p", ")", "==", "filepath", ".", "Clean", "(", "v", ")", ...
// Has checks if a given Mod includes a specified file
[ "Has", "checks", "if", "a", "given", "Mod", "includes", "a", "specified", "file" ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L96-L103
147,822
cortesi/moddwatch
watch.go
Empty
func (mod Mod) Empty() bool { if (len(mod.Changed) + len(mod.Deleted) + len(mod.Added)) > 0 { return false } return true }
go
func (mod Mod) Empty() bool { if (len(mod.Changed) + len(mod.Deleted) + len(mod.Added)) > 0 { return false } return true }
[ "func", "(", "mod", "Mod", ")", "Empty", "(", ")", "bool", "{", "if", "(", "len", "(", "mod", ".", "Changed", ")", "+", "len", "(", "mod", ".", "Deleted", ")", "+", "len", "(", "mod", ".", "Added", ")", ")", ">", "0", "{", "return", "false", ...
// Empty checks if this mod set is empty
[ "Empty", "checks", "if", "this", "mod", "set", "is", "empty" ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L106-L111
147,823
cortesi/moddwatch
watch.go
Join
func (mod Mod) Join(b Mod) Mod { return Mod{ Changed: joinLists(mod.Changed, b.Changed), Deleted: joinLists(mod.Deleted, b.Deleted), Added: joinLists(mod.Added, b.Added), } }
go
func (mod Mod) Join(b Mod) Mod { return Mod{ Changed: joinLists(mod.Changed, b.Changed), Deleted: joinLists(mod.Deleted, b.Deleted), Added: joinLists(mod.Added, b.Added), } }
[ "func", "(", "mod", "Mod", ")", "Join", "(", "b", "Mod", ")", "Mod", "{", "return", "Mod", "{", "Changed", ":", "joinLists", "(", "mod", ".", "Changed", ",", "b", ".", "Changed", ")", ",", "Deleted", ":", "joinLists", "(", "mod", ".", "Deleted", ...
// Join two Mods together, resulting in a new structure where each modification // list is sorted alphabetically.
[ "Join", "two", "Mods", "together", "resulting", "in", "a", "new", "structure", "where", "each", "modification", "list", "is", "sorted", "alphabetically", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L133-L139
147,824
cortesi/moddwatch
watch.go
Filter
func (mod Mod) Filter(root string, includes []string, excludes []string) (*Mod, error) { changed, err := filter.Files(mod.Changed, includes, excludes) if err != nil { return nil, err } deleted, err := filter.Files(mod.Deleted, includes, excludes) if err != nil { return nil, err } added, err := filter.Files(m...
go
func (mod Mod) Filter(root string, includes []string, excludes []string) (*Mod, error) { changed, err := filter.Files(mod.Changed, includes, excludes) if err != nil { return nil, err } deleted, err := filter.Files(mod.Deleted, includes, excludes) if err != nil { return nil, err } added, err := filter.Files(m...
[ "func", "(", "mod", "Mod", ")", "Filter", "(", "root", "string", ",", "includes", "[", "]", "string", ",", "excludes", "[", "]", "string", ")", "(", "*", "Mod", ",", "error", ")", "{", "changed", ",", "err", ":=", "filter", ".", "Files", "(", "mo...
// Filter applies a filter, returning a new Mod structure
[ "Filter", "applies", "a", "filter", "returning", "a", "new", "Mod", "structure" ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L142-L156
147,825
cortesi/moddwatch
watch.go
batch
func batch(lullTime time.Duration, maxTime time.Duration, exists existenceChecker, ch chan notify.EventInfo) *Mod { added := make(map[string]bool) removed := make(map[string]bool) changed := make(map[string]bool) renamed := make(map[string]bool) // Have we had a modification in the last lull hadLullMod := false ...
go
func batch(lullTime time.Duration, maxTime time.Duration, exists existenceChecker, ch chan notify.EventInfo) *Mod { added := make(map[string]bool) removed := make(map[string]bool) changed := make(map[string]bool) renamed := make(map[string]bool) // Have we had a modification in the last lull hadLullMod := false ...
[ "func", "batch", "(", "lullTime", "time", ".", "Duration", ",", "maxTime", "time", ".", "Duration", ",", "exists", "existenceChecker", ",", "ch", "chan", "notify", ".", "EventInfo", ")", "*", "Mod", "{", "added", ":=", "make", "(", "map", "[", "string", ...
// This function batches events up, and emits just a list of paths for files // considered changed. It applies some heuristics to deal with short-lived // temporary files and unreliable filesystem events. There are all sorts of // challenges here, that mean we can only do a mediocre job as it stands. // // - There's no...
[ "This", "function", "batches", "events", "up", "and", "emits", "just", "a", "list", "of", "paths", "for", "files", "considered", "changed", ".", "It", "applies", "some", "heuristics", "to", "deal", "with", "short", "-", "lived", "temporary", "files", "and", ...
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L249-L285
147,826
cortesi/moddwatch
watch.go
Stop
func (w *Watcher) Stop() { w.Lock() defer w.Unlock() if !w.closed { notify.Stop(w.evtch) close(w.modch) w.closed = true } }
go
func (w *Watcher) Stop() { w.Lock() defer w.Unlock() if !w.closed { notify.Stop(w.evtch) close(w.modch) w.closed = true } }
[ "func", "(", "w", "*", "Watcher", ")", "Stop", "(", ")", "{", "w", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "Unlock", "(", ")", "\n", "if", "!", "w", ".", "closed", "{", "notify", ".", "Stop", "(", "w", ".", "evtch", ")", "\n", "clos...
// Stop watching, and close the channel passed to watch. This function can // safely be called concurrently.
[ "Stop", "watching", "and", "close", "the", "channel", "passed", "to", "watch", ".", "This", "function", "can", "safely", "be", "called", "concurrently", "." ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L306-L314
147,827
cortesi/moddwatch
watch.go
enclosingDir
func enclosingDir(path string) string { for { if stat, err := os.Lstat(path); err == nil { if stat.IsDir() { return path } } if path == "" { return "" } path = filepath.Dir(path) } }
go
func enclosingDir(path string) string { for { if stat, err := os.Lstat(path); err == nil { if stat.IsDir() { return path } } if path == "" { return "" } path = filepath.Dir(path) } }
[ "func", "enclosingDir", "(", "path", "string", ")", "string", "{", "for", "{", "if", "stat", ",", "err", ":=", "os", ".", "Lstat", "(", "path", ")", ";", "err", "==", "nil", "{", "if", "stat", ".", "IsDir", "(", ")", "{", "return", "path", "\n", ...
// Find the nearest enclosing directory
[ "Find", "the", "nearest", "enclosing", "directory" ]
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L317-L329
147,828
cortesi/moddwatch
watch.go
baseDirs
func baseDirs(root string, includePatterns []string) ([]string, []string) { root = filepath.FromSlash(root) bases := make([]string, len(includePatterns)) newincludes := includePatterns[:] for i, v := range includePatterns { bdir, trailer := filter.SplitPattern(v) if !filepath.IsAbs(bdir) { bdir = filepath.Jo...
go
func baseDirs(root string, includePatterns []string) ([]string, []string) { root = filepath.FromSlash(root) bases := make([]string, len(includePatterns)) newincludes := includePatterns[:] for i, v := range includePatterns { bdir, trailer := filter.SplitPattern(v) if !filepath.IsAbs(bdir) { bdir = filepath.Jo...
[ "func", "baseDirs", "(", "root", "string", ",", "includePatterns", "[", "]", "string", ")", "(", "[", "]", "string", ",", "[", "]", "string", ")", "{", "root", "=", "filepath", ".", "FromSlash", "(", "root", ")", "\n", "bases", ":=", "make", "(", "...
// Given a set of include patterns relative to a root, which directories do we // need to monitor for changes? Returns a modified set of includes ready to pass // to a post filter, and a set of base directories
[ "Given", "a", "set", "of", "include", "patterns", "relative", "to", "a", "root", "which", "directories", "do", "we", "need", "to", "monitor", "for", "changes?", "Returns", "a", "modified", "set", "of", "includes", "ready", "to", "pass", "to", "a", "post", ...
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L334-L374
147,829
cortesi/moddwatch
watch.go
List
func List(root string, includePatterns []string, excludePatterns []string) ([]string, error) { root = filepath.FromSlash(root) newincludes, bases := baseDirs(root, includePatterns) ret := []string{} for _, b := range bases { err := filepath.Walk( b, func(p string, fi os.FileInfo, err error) error { if e...
go
func List(root string, includePatterns []string, excludePatterns []string) ([]string, error) { root = filepath.FromSlash(root) newincludes, bases := baseDirs(root, includePatterns) ret := []string{} for _, b := range bases { err := filepath.Walk( b, func(p string, fi os.FileInfo, err error) error { if e...
[ "func", "List", "(", "root", "string", ",", "includePatterns", "[", "]", "string", ",", "excludePatterns", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "root", "=", "filepath", ".", "FromSlash", "(", "root", ")", "\n", "n...
// List all files under the root that match the specified patterns. The file // list returned is a catalogue of all files currently on disk that could occur // in a Mod structure for a corresponding watch. // // All paths returned are slash-delimited and normalised. If a path lies under // the specified root, it is con...
[ "List", "all", "files", "under", "the", "root", "that", "match", "the", "specified", "patterns", ".", "The", "file", "list", "returned", "is", "a", "catalogue", "of", "all", "files", "currently", "on", "disk", "that", "could", "occur", "in", "a", "Mod", ...
d27f53de245eb09b9e475d498cc01c91ba8e89c8
https://github.com/cortesi/moddwatch/blob/d27f53de245eb09b9e475d498cc01c91ba8e89c8/watch.go#L454-L486
147,830
markphelps/optional
string.go
Get
func (s String) Get() (string, error) { if !s.Present() { var zero string return zero, errors.New("value not present") } return *s.value, nil }
go
func (s String) Get() (string, error) { if !s.Present() { var zero string return zero, errors.New("value not present") } return *s.value, nil }
[ "func", "(", "s", "String", ")", "Get", "(", ")", "(", "string", ",", "error", ")", "{", "if", "!", "s", ".", "Present", "(", ")", "{", "var", "zero", "string", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}...
// Get returns the string value or an error if not present.
[ "Get", "returns", "the", "string", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/string.go#L27-L33
147,831
markphelps/optional
string.go
OrElse
func (s String) OrElse(v string) string { if s.Present() { return *s.value } return v }
go
func (s String) OrElse(v string) string { if s.Present() { return *s.value } return v }
[ "func", "(", "s", "String", ")", "OrElse", "(", "v", "string", ")", "string", "{", "if", "s", ".", "Present", "(", ")", "{", "return", "*", "s", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the string value or a default value if the value is not present.
[ "OrElse", "returns", "the", "string", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/string.go#L41-L46
147,832
markphelps/optional
int16.go
Get
func (i Int16) Get() (int16, error) { if !i.Present() { var zero int16 return zero, errors.New("value not present") } return *i.value, nil }
go
func (i Int16) Get() (int16, error) { if !i.Present() { var zero int16 return zero, errors.New("value not present") } return *i.value, nil }
[ "func", "(", "i", "Int16", ")", "Get", "(", ")", "(", "int16", ",", "error", ")", "{", "if", "!", "i", ".", "Present", "(", ")", "{", "var", "zero", "int16", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Get returns the int16 value or an error if not present.
[ "Get", "returns", "the", "int16", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int16.go#L27-L33
147,833
markphelps/optional
int16.go
OrElse
func (i Int16) OrElse(v int16) int16 { if i.Present() { return *i.value } return v }
go
func (i Int16) OrElse(v int16) int16 { if i.Present() { return *i.value } return v }
[ "func", "(", "i", "Int16", ")", "OrElse", "(", "v", "int16", ")", "int16", "{", "if", "i", ".", "Present", "(", ")", "{", "return", "*", "i", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the int16 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "int16", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int16.go#L41-L46
147,834
markphelps/optional
float64.go
Get
func (f Float64) Get() (float64, error) { if !f.Present() { var zero float64 return zero, errors.New("value not present") } return *f.value, nil }
go
func (f Float64) Get() (float64, error) { if !f.Present() { var zero float64 return zero, errors.New("value not present") } return *f.value, nil }
[ "func", "(", "f", "Float64", ")", "Get", "(", ")", "(", "float64", ",", "error", ")", "{", "if", "!", "f", ".", "Present", "(", ")", "{", "var", "zero", "float64", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// Get returns the float64 value or an error if not present.
[ "Get", "returns", "the", "float64", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/float64.go#L27-L33
147,835
markphelps/optional
float64.go
OrElse
func (f Float64) OrElse(v float64) float64 { if f.Present() { return *f.value } return v }
go
func (f Float64) OrElse(v float64) float64 { if f.Present() { return *f.value } return v }
[ "func", "(", "f", "Float64", ")", "OrElse", "(", "v", "float64", ")", "float64", "{", "if", "f", ".", "Present", "(", ")", "{", "return", "*", "f", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the float64 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "float64", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/float64.go#L41-L46
147,836
markphelps/optional
float32.go
Get
func (f Float32) Get() (float32, error) { if !f.Present() { var zero float32 return zero, errors.New("value not present") } return *f.value, nil }
go
func (f Float32) Get() (float32, error) { if !f.Present() { var zero float32 return zero, errors.New("value not present") } return *f.value, nil }
[ "func", "(", "f", "Float32", ")", "Get", "(", ")", "(", "float32", ",", "error", ")", "{", "if", "!", "f", ".", "Present", "(", ")", "{", "var", "zero", "float32", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// Get returns the float32 value or an error if not present.
[ "Get", "returns", "the", "float32", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/float32.go#L27-L33
147,837
markphelps/optional
float32.go
OrElse
func (f Float32) OrElse(v float32) float32 { if f.Present() { return *f.value } return v }
go
func (f Float32) OrElse(v float32) float32 { if f.Present() { return *f.value } return v }
[ "func", "(", "f", "Float32", ")", "OrElse", "(", "v", "float32", ")", "float32", "{", "if", "f", ".", "Present", "(", ")", "{", "return", "*", "f", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the float32 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "float32", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/float32.go#L41-L46
147,838
markphelps/optional
uint16.go
Get
func (u Uint16) Get() (uint16, error) { if !u.Present() { var zero uint16 return zero, errors.New("value not present") } return *u.value, nil }
go
func (u Uint16) Get() (uint16, error) { if !u.Present() { var zero uint16 return zero, errors.New("value not present") } return *u.value, nil }
[ "func", "(", "u", "Uint16", ")", "Get", "(", ")", "(", "uint16", ",", "error", ")", "{", "if", "!", "u", ".", "Present", "(", ")", "{", "var", "zero", "uint16", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}...
// Get returns the uint16 value or an error if not present.
[ "Get", "returns", "the", "uint16", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint16.go#L27-L33
147,839
markphelps/optional
uint16.go
OrElse
func (u Uint16) OrElse(v uint16) uint16 { if u.Present() { return *u.value } return v }
go
func (u Uint16) OrElse(v uint16) uint16 { if u.Present() { return *u.value } return v }
[ "func", "(", "u", "Uint16", ")", "OrElse", "(", "v", "uint16", ")", "uint16", "{", "if", "u", ".", "Present", "(", ")", "{", "return", "*", "u", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the uint16 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "uint16", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint16.go#L41-L46
147,840
markphelps/optional
uint64.go
Get
func (u Uint64) Get() (uint64, error) { if !u.Present() { var zero uint64 return zero, errors.New("value not present") } return *u.value, nil }
go
func (u Uint64) Get() (uint64, error) { if !u.Present() { var zero uint64 return zero, errors.New("value not present") } return *u.value, nil }
[ "func", "(", "u", "Uint64", ")", "Get", "(", ")", "(", "uint64", ",", "error", ")", "{", "if", "!", "u", ".", "Present", "(", ")", "{", "var", "zero", "uint64", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}...
// Get returns the uint64 value or an error if not present.
[ "Get", "returns", "the", "uint64", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint64.go#L27-L33
147,841
markphelps/optional
uint64.go
OrElse
func (u Uint64) OrElse(v uint64) uint64 { if u.Present() { return *u.value } return v }
go
func (u Uint64) OrElse(v uint64) uint64 { if u.Present() { return *u.value } return v }
[ "func", "(", "u", "Uint64", ")", "OrElse", "(", "v", "uint64", ")", "uint64", "{", "if", "u", ".", "Present", "(", ")", "{", "return", "*", "u", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the uint64 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "uint64", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint64.go#L41-L46
147,842
markphelps/optional
bool.go
Get
func (b Bool) Get() (bool, error) { if !b.Present() { var zero bool return zero, errors.New("value not present") } return *b.value, nil }
go
func (b Bool) Get() (bool, error) { if !b.Present() { var zero bool return zero, errors.New("value not present") } return *b.value, nil }
[ "func", "(", "b", "Bool", ")", "Get", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "!", "b", ".", "Present", "(", ")", "{", "var", "zero", "bool", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// Get returns the bool value or an error if not present.
[ "Get", "returns", "the", "bool", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/bool.go#L27-L33
147,843
markphelps/optional
bool.go
OrElse
func (b Bool) OrElse(v bool) bool { if b.Present() { return *b.value } return v }
go
func (b Bool) OrElse(v bool) bool { if b.Present() { return *b.value } return v }
[ "func", "(", "b", "Bool", ")", "OrElse", "(", "v", "bool", ")", "bool", "{", "if", "b", ".", "Present", "(", ")", "{", "return", "*", "b", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the bool value or a default value if the value is not present.
[ "OrElse", "returns", "the", "bool", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/bool.go#L41-L46
147,844
markphelps/optional
uint8.go
Get
func (u Uint8) Get() (uint8, error) { if !u.Present() { var zero uint8 return zero, errors.New("value not present") } return *u.value, nil }
go
func (u Uint8) Get() (uint8, error) { if !u.Present() { var zero uint8 return zero, errors.New("value not present") } return *u.value, nil }
[ "func", "(", "u", "Uint8", ")", "Get", "(", ")", "(", "uint8", ",", "error", ")", "{", "if", "!", "u", ".", "Present", "(", ")", "{", "var", "zero", "uint8", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Get returns the uint8 value or an error if not present.
[ "Get", "returns", "the", "uint8", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint8.go#L27-L33
147,845
markphelps/optional
uint8.go
OrElse
func (u Uint8) OrElse(v uint8) uint8 { if u.Present() { return *u.value } return v }
go
func (u Uint8) OrElse(v uint8) uint8 { if u.Present() { return *u.value } return v }
[ "func", "(", "u", "Uint8", ")", "OrElse", "(", "v", "uint8", ")", "uint8", "{", "if", "u", ".", "Present", "(", ")", "{", "return", "*", "u", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the uint8 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "uint8", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint8.go#L41-L46
147,846
markphelps/optional
uintptr.go
Get
func (u Uintptr) Get() (uintptr, error) { if !u.Present() { var zero uintptr return zero, errors.New("value not present") } return *u.value, nil }
go
func (u Uintptr) Get() (uintptr, error) { if !u.Present() { var zero uintptr return zero, errors.New("value not present") } return *u.value, nil }
[ "func", "(", "u", "Uintptr", ")", "Get", "(", ")", "(", "uintptr", ",", "error", ")", "{", "if", "!", "u", ".", "Present", "(", ")", "{", "var", "zero", "uintptr", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// Get returns the uintptr value or an error if not present.
[ "Get", "returns", "the", "uintptr", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uintptr.go#L27-L33
147,847
markphelps/optional
uintptr.go
OrElse
func (u Uintptr) OrElse(v uintptr) uintptr { if u.Present() { return *u.value } return v }
go
func (u Uintptr) OrElse(v uintptr) uintptr { if u.Present() { return *u.value } return v }
[ "func", "(", "u", "Uintptr", ")", "OrElse", "(", "v", "uintptr", ")", "uintptr", "{", "if", "u", ".", "Present", "(", ")", "{", "return", "*", "u", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the uintptr value or a default value if the value is not present.
[ "OrElse", "returns", "the", "uintptr", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uintptr.go#L41-L46
147,848
markphelps/optional
int32.go
Get
func (i Int32) Get() (int32, error) { if !i.Present() { var zero int32 return zero, errors.New("value not present") } return *i.value, nil }
go
func (i Int32) Get() (int32, error) { if !i.Present() { var zero int32 return zero, errors.New("value not present") } return *i.value, nil }
[ "func", "(", "i", "Int32", ")", "Get", "(", ")", "(", "int32", ",", "error", ")", "{", "if", "!", "i", ".", "Present", "(", ")", "{", "var", "zero", "int32", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Get returns the int32 value or an error if not present.
[ "Get", "returns", "the", "int32", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int32.go#L27-L33
147,849
markphelps/optional
int32.go
OrElse
func (i Int32) OrElse(v int32) int32 { if i.Present() { return *i.value } return v }
go
func (i Int32) OrElse(v int32) int32 { if i.Present() { return *i.value } return v }
[ "func", "(", "i", "Int32", ")", "OrElse", "(", "v", "int32", ")", "int32", "{", "if", "i", ".", "Present", "(", ")", "{", "return", "*", "i", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the int32 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "int32", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int32.go#L41-L46
147,850
markphelps/optional
byte.go
Get
func (b Byte) Get() (byte, error) { if !b.Present() { var zero byte return zero, errors.New("value not present") } return *b.value, nil }
go
func (b Byte) Get() (byte, error) { if !b.Present() { var zero byte return zero, errors.New("value not present") } return *b.value, nil }
[ "func", "(", "b", "Byte", ")", "Get", "(", ")", "(", "byte", ",", "error", ")", "{", "if", "!", "b", ".", "Present", "(", ")", "{", "var", "zero", "byte", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// Get returns the byte value or an error if not present.
[ "Get", "returns", "the", "byte", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/byte.go#L27-L33
147,851
markphelps/optional
byte.go
OrElse
func (b Byte) OrElse(v byte) byte { if b.Present() { return *b.value } return v }
go
func (b Byte) OrElse(v byte) byte { if b.Present() { return *b.value } return v }
[ "func", "(", "b", "Byte", ")", "OrElse", "(", "v", "byte", ")", "byte", "{", "if", "b", ".", "Present", "(", ")", "{", "return", "*", "b", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the byte value or a default value if the value is not present.
[ "OrElse", "returns", "the", "byte", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/byte.go#L41-L46
147,852
markphelps/optional
error.go
Get
func (e Error) Get() (error, error) { if !e.Present() { var zero error return zero, errors.New("value not present") } return *e.value, nil }
go
func (e Error) Get() (error, error) { if !e.Present() { var zero error return zero, errors.New("value not present") } return *e.value, nil }
[ "func", "(", "e", "Error", ")", "Get", "(", ")", "(", "error", ",", "error", ")", "{", "if", "!", "e", ".", "Present", "(", ")", "{", "var", "zero", "error", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Get returns the error value or an error if not present.
[ "Get", "returns", "the", "error", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/error.go#L27-L33
147,853
markphelps/optional
error.go
OrElse
func (e Error) OrElse(v error) error { if e.Present() { return *e.value } return v }
go
func (e Error) OrElse(v error) error { if e.Present() { return *e.value } return v }
[ "func", "(", "e", "Error", ")", "OrElse", "(", "v", "error", ")", "error", "{", "if", "e", ".", "Present", "(", ")", "{", "return", "*", "e", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the error value or a default value if the value is not present.
[ "OrElse", "returns", "the", "error", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/error.go#L41-L46
147,854
markphelps/optional
uint.go
Get
func (u Uint) Get() (uint, error) { if !u.Present() { var zero uint return zero, errors.New("value not present") } return *u.value, nil }
go
func (u Uint) Get() (uint, error) { if !u.Present() { var zero uint return zero, errors.New("value not present") } return *u.value, nil }
[ "func", "(", "u", "Uint", ")", "Get", "(", ")", "(", "uint", ",", "error", ")", "{", "if", "!", "u", ".", "Present", "(", ")", "{", "var", "zero", "uint", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// Get returns the uint value or an error if not present.
[ "Get", "returns", "the", "uint", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint.go#L27-L33
147,855
markphelps/optional
uint.go
OrElse
func (u Uint) OrElse(v uint) uint { if u.Present() { return *u.value } return v }
go
func (u Uint) OrElse(v uint) uint { if u.Present() { return *u.value } return v }
[ "func", "(", "u", "Uint", ")", "OrElse", "(", "v", "uint", ")", "uint", "{", "if", "u", ".", "Present", "(", ")", "{", "return", "*", "u", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the uint value or a default value if the value is not present.
[ "OrElse", "returns", "the", "uint", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint.go#L41-L46
147,856
markphelps/optional
complex128.go
Get
func (c Complex128) Get() (complex128, error) { if !c.Present() { var zero complex128 return zero, errors.New("value not present") } return *c.value, nil }
go
func (c Complex128) Get() (complex128, error) { if !c.Present() { var zero complex128 return zero, errors.New("value not present") } return *c.value, nil }
[ "func", "(", "c", "Complex128", ")", "Get", "(", ")", "(", "complex128", ",", "error", ")", "{", "if", "!", "c", ".", "Present", "(", ")", "{", "var", "zero", "complex128", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", ...
// Get returns the complex128 value or an error if not present.
[ "Get", "returns", "the", "complex128", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/complex128.go#L27-L33
147,857
markphelps/optional
complex128.go
OrElse
func (c Complex128) OrElse(v complex128) complex128 { if c.Present() { return *c.value } return v }
go
func (c Complex128) OrElse(v complex128) complex128 { if c.Present() { return *c.value } return v }
[ "func", "(", "c", "Complex128", ")", "OrElse", "(", "v", "complex128", ")", "complex128", "{", "if", "c", ".", "Present", "(", ")", "{", "return", "*", "c", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the complex128 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "complex128", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/complex128.go#L41-L46
147,858
markphelps/optional
int8.go
Get
func (i Int8) Get() (int8, error) { if !i.Present() { var zero int8 return zero, errors.New("value not present") } return *i.value, nil }
go
func (i Int8) Get() (int8, error) { if !i.Present() { var zero int8 return zero, errors.New("value not present") } return *i.value, nil }
[ "func", "(", "i", "Int8", ")", "Get", "(", ")", "(", "int8", ",", "error", ")", "{", "if", "!", "i", ".", "Present", "(", ")", "{", "var", "zero", "int8", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// Get returns the int8 value or an error if not present.
[ "Get", "returns", "the", "int8", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int8.go#L27-L33
147,859
markphelps/optional
int8.go
OrElse
func (i Int8) OrElse(v int8) int8 { if i.Present() { return *i.value } return v }
go
func (i Int8) OrElse(v int8) int8 { if i.Present() { return *i.value } return v }
[ "func", "(", "i", "Int8", ")", "OrElse", "(", "v", "int8", ")", "int8", "{", "if", "i", ".", "Present", "(", ")", "{", "return", "*", "i", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the int8 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "int8", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int8.go#L41-L46
147,860
markphelps/optional
uint32.go
Get
func (u Uint32) Get() (uint32, error) { if !u.Present() { var zero uint32 return zero, errors.New("value not present") } return *u.value, nil }
go
func (u Uint32) Get() (uint32, error) { if !u.Present() { var zero uint32 return zero, errors.New("value not present") } return *u.value, nil }
[ "func", "(", "u", "Uint32", ")", "Get", "(", ")", "(", "uint32", ",", "error", ")", "{", "if", "!", "u", ".", "Present", "(", ")", "{", "var", "zero", "uint32", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}...
// Get returns the uint32 value or an error if not present.
[ "Get", "returns", "the", "uint32", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint32.go#L27-L33
147,861
markphelps/optional
uint32.go
OrElse
func (u Uint32) OrElse(v uint32) uint32 { if u.Present() { return *u.value } return v }
go
func (u Uint32) OrElse(v uint32) uint32 { if u.Present() { return *u.value } return v }
[ "func", "(", "u", "Uint32", ")", "OrElse", "(", "v", "uint32", ")", "uint32", "{", "if", "u", ".", "Present", "(", ")", "{", "return", "*", "u", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the uint32 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "uint32", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/uint32.go#L41-L46
147,862
markphelps/optional
rune.go
Get
func (r Rune) Get() (rune, error) { if !r.Present() { var zero rune return zero, errors.New("value not present") } return *r.value, nil }
go
func (r Rune) Get() (rune, error) { if !r.Present() { var zero rune return zero, errors.New("value not present") } return *r.value, nil }
[ "func", "(", "r", "Rune", ")", "Get", "(", ")", "(", "rune", ",", "error", ")", "{", "if", "!", "r", ".", "Present", "(", ")", "{", "var", "zero", "rune", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// Get returns the rune value or an error if not present.
[ "Get", "returns", "the", "rune", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/rune.go#L27-L33
147,863
markphelps/optional
rune.go
OrElse
func (r Rune) OrElse(v rune) rune { if r.Present() { return *r.value } return v }
go
func (r Rune) OrElse(v rune) rune { if r.Present() { return *r.value } return v }
[ "func", "(", "r", "Rune", ")", "OrElse", "(", "v", "rune", ")", "rune", "{", "if", "r", ".", "Present", "(", ")", "{", "return", "*", "r", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the rune value or a default value if the value is not present.
[ "OrElse", "returns", "the", "rune", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/rune.go#L41-L46
147,864
markphelps/optional
int64.go
Get
func (i Int64) Get() (int64, error) { if !i.Present() { var zero int64 return zero, errors.New("value not present") } return *i.value, nil }
go
func (i Int64) Get() (int64, error) { if !i.Present() { var zero int64 return zero, errors.New("value not present") } return *i.value, nil }
[ "func", "(", "i", "Int64", ")", "Get", "(", ")", "(", "int64", ",", "error", ")", "{", "if", "!", "i", ".", "Present", "(", ")", "{", "var", "zero", "int64", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Get returns the int64 value or an error if not present.
[ "Get", "returns", "the", "int64", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int64.go#L27-L33
147,865
markphelps/optional
int64.go
OrElse
func (i Int64) OrElse(v int64) int64 { if i.Present() { return *i.value } return v }
go
func (i Int64) OrElse(v int64) int64 { if i.Present() { return *i.value } return v }
[ "func", "(", "i", "Int64", ")", "OrElse", "(", "v", "int64", ")", "int64", "{", "if", "i", ".", "Present", "(", ")", "{", "return", "*", "i", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the int64 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "int64", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int64.go#L41-L46
147,866
markphelps/optional
complex64.go
Get
func (c Complex64) Get() (complex64, error) { if !c.Present() { var zero complex64 return zero, errors.New("value not present") } return *c.value, nil }
go
func (c Complex64) Get() (complex64, error) { if !c.Present() { var zero complex64 return zero, errors.New("value not present") } return *c.value, nil }
[ "func", "(", "c", "Complex64", ")", "Get", "(", ")", "(", "complex64", ",", "error", ")", "{", "if", "!", "c", ".", "Present", "(", ")", "{", "var", "zero", "complex64", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "...
// Get returns the complex64 value or an error if not present.
[ "Get", "returns", "the", "complex64", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/complex64.go#L27-L33
147,867
markphelps/optional
complex64.go
OrElse
func (c Complex64) OrElse(v complex64) complex64 { if c.Present() { return *c.value } return v }
go
func (c Complex64) OrElse(v complex64) complex64 { if c.Present() { return *c.value } return v }
[ "func", "(", "c", "Complex64", ")", "OrElse", "(", "v", "complex64", ")", "complex64", "{", "if", "c", ".", "Present", "(", ")", "{", "return", "*", "c", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the complex64 value or a default value if the value is not present.
[ "OrElse", "returns", "the", "complex64", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/complex64.go#L41-L46
147,868
markphelps/optional
int.go
Get
func (i Int) Get() (int, error) { if !i.Present() { var zero int return zero, errors.New("value not present") } return *i.value, nil }
go
func (i Int) Get() (int, error) { if !i.Present() { var zero int return zero, errors.New("value not present") } return *i.value, nil }
[ "func", "(", "i", "Int", ")", "Get", "(", ")", "(", "int", ",", "error", ")", "{", "if", "!", "i", ".", "Present", "(", ")", "{", "var", "zero", "int", "\n", "return", "zero", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n"...
// Get returns the int value or an error if not present.
[ "Get", "returns", "the", "int", "value", "or", "an", "error", "if", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int.go#L27-L33
147,869
markphelps/optional
int.go
OrElse
func (i Int) OrElse(v int) int { if i.Present() { return *i.value } return v }
go
func (i Int) OrElse(v int) int { if i.Present() { return *i.value } return v }
[ "func", "(", "i", "Int", ")", "OrElse", "(", "v", "int", ")", "int", "{", "if", "i", ".", "Present", "(", ")", "{", "return", "*", "i", ".", "value", "\n", "}", "\n", "return", "v", "\n", "}" ]
// OrElse returns the int value or a default value if the value is not present.
[ "OrElse", "returns", "the", "int", "value", "or", "a", "default", "value", "if", "the", "value", "is", "not", "present", "." ]
27b12d0a0f7d33be788b2533d2166ccdc49f145c
https://github.com/markphelps/optional/blob/27b12d0a0f7d33be788b2533d2166ccdc49f145c/int.go#L41-L46
147,870
Financial-Times/http-handlers-go
httphandlers/http_handlers.go
HTTPMetricsHandler
func HTTPMetricsHandler(registry metrics.Registry, h http.Handler) http.Handler { return httpMetricsHandler{registry, h} }
go
func HTTPMetricsHandler(registry metrics.Registry, h http.Handler) http.Handler { return httpMetricsHandler{registry, h} }
[ "func", "HTTPMetricsHandler", "(", "registry", "metrics", ".", "Registry", ",", "h", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "httpMetricsHandler", "{", "registry", ",", "h", "}", "\n", "}" ]
// HTTPMetricsHandler records metrics for each request
[ "HTTPMetricsHandler", "records", "metrics", "for", "each", "request" ]
2c20324ab8870523a84bdb7dae60872b0b42ed14
https://github.com/Financial-Times/http-handlers-go/blob/2c20324ab8870523a84bdb7dae60872b0b42ed14/httphandlers/http_handlers.go#L16-L18
147,871
Financial-Times/http-handlers-go
httphandlers/http_handlers.go
TransactionAwareRequestLoggingHandler
func TransactionAwareRequestLoggingHandler(logger *log.Logger, h http.Handler) http.Handler { return transactionAwareRequestLoggingHandler{logger, h} }
go
func TransactionAwareRequestLoggingHandler(logger *log.Logger, h http.Handler) http.Handler { return transactionAwareRequestLoggingHandler{logger, h} }
[ "func", "TransactionAwareRequestLoggingHandler", "(", "logger", "*", "log", ".", "Logger", ",", "h", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "transactionAwareRequestLoggingHandler", "{", "logger", ",", "h", "}", "\n", "}" ]
// TransactionAwareRequestLoggingHandler finds a transactionID on a request header or generates one, and makes sure it gets logged // using the supplied logrus.Logger
[ "TransactionAwareRequestLoggingHandler", "finds", "a", "transactionID", "on", "a", "request", "header", "or", "generates", "one", "and", "makes", "sure", "it", "gets", "logged", "using", "the", "supplied", "logrus", ".", "Logger" ]
2c20324ab8870523a84bdb7dae60872b0b42ed14
https://github.com/Financial-Times/http-handlers-go/blob/2c20324ab8870523a84bdb7dae60872b0b42ed14/httphandlers/http_handlers.go#L32-L34
147,872
Financial-Times/http-handlers-go
httphandlers/http_handlers.go
writeRequestLog
func writeRequestLog(logger *log.Logger, req *http.Request, transactionID string, url url.URL, responseTime time.Duration, status, size int) { username := "-" if url.User != nil { if name := url.User.Username(); name != "" { username = name } } host, _, err := net.SplitHostPort(req.RemoteAddr) if err != n...
go
func writeRequestLog(logger *log.Logger, req *http.Request, transactionID string, url url.URL, responseTime time.Duration, status, size int) { username := "-" if url.User != nil { if name := url.User.Username(); name != "" { username = name } } host, _, err := net.SplitHostPort(req.RemoteAddr) if err != n...
[ "func", "writeRequestLog", "(", "logger", "*", "log", ".", "Logger", ",", "req", "*", "http", ".", "Request", ",", "transactionID", "string", ",", "url", "url", ".", "URL", ",", "responseTime", "time", ".", "Duration", ",", "status", ",", "size", "int", ...
// writeRequestLog writes a log entry to the supplied logrus logger. // ts is the timestamp with which the entry should be logged. // trnasactionID is a unique id for this request. // status and size are used to provide the response HTTP status and size.
[ "writeRequestLog", "writes", "a", "log", "entry", "to", "the", "supplied", "logrus", "logger", ".", "ts", "is", "the", "timestamp", "with", "which", "the", "entry", "should", "be", "logged", ".", "trnasactionID", "is", "a", "unique", "id", "for", "this", "...
2c20324ab8870523a84bdb7dae60872b0b42ed14
https://github.com/Financial-Times/http-handlers-go/blob/2c20324ab8870523a84bdb7dae60872b0b42ed14/httphandlers/http_handlers.go#L147-L187
147,873
getlantern/netx
copy.go
BidiCopy
func BidiCopy(out net.Conn, in net.Conn, bufOut []byte, bufIn []byte) (outErr error, inErr error) { stop := uint32(0) outErrCh := make(chan error, 1) inErrCh := make(chan error, 1) go doCopy(out, in, bufIn, outErrCh, &stop) go doCopy(in, out, bufOut, inErrCh, &stop) return <-outErrCh, <-inErrCh }
go
func BidiCopy(out net.Conn, in net.Conn, bufOut []byte, bufIn []byte) (outErr error, inErr error) { stop := uint32(0) outErrCh := make(chan error, 1) inErrCh := make(chan error, 1) go doCopy(out, in, bufIn, outErrCh, &stop) go doCopy(in, out, bufOut, inErrCh, &stop) return <-outErrCh, <-inErrCh }
[ "func", "BidiCopy", "(", "out", "net", ".", "Conn", ",", "in", "net", ".", "Conn", ",", "bufOut", "[", "]", "byte", ",", "bufIn", "[", "]", "byte", ")", "(", "outErr", "error", ",", "inErr", "error", ")", "{", "stop", ":=", "uint32", "(", "0", ...
// BidiCopy copies between in and out in both directions using the specified // buffers, returning the errors from copying to out and copying to in.
[ "BidiCopy", "copies", "between", "in", "and", "out", "in", "both", "directions", "using", "the", "specified", "buffers", "returning", "the", "errors", "from", "copying", "to", "out", "and", "copying", "to", "in", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/copy.go#L18-L25
147,874
getlantern/netx
copy.go
doCopy
func doCopy(dst net.Conn, src net.Conn, buf []byte, errCh chan error, stop *uint32) { var err error defer func() { atomic.StoreUint32(stop, 1) dst.SetReadDeadline(time.Now().Add(copyTimeout)) errCh <- err }() defer func() { p := recover() if p != nil { err = errors.New("Panic while copying: %v", p) ...
go
func doCopy(dst net.Conn, src net.Conn, buf []byte, errCh chan error, stop *uint32) { var err error defer func() { atomic.StoreUint32(stop, 1) dst.SetReadDeadline(time.Now().Add(copyTimeout)) errCh <- err }() defer func() { p := recover() if p != nil { err = errors.New("Panic while copying: %v", p) ...
[ "func", "doCopy", "(", "dst", "net", ".", "Conn", ",", "src", "net", ".", "Conn", ",", "buf", "[", "]", "byte", ",", "errCh", "chan", "error", ",", "stop", "*", "uint32", ")", "{", "var", "err", "error", "\n", "defer", "func", "(", ")", "{", "a...
// doCopy is based on io.copyBuffer
[ "doCopy", "is", "based", "on", "io", ".", "copyBuffer" ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/copy.go#L28-L74
147,875
getlantern/netx
copy.go
IsTimeout
func IsTimeout(err error) bool { if nerr, ok := err.(net.Error); ok && nerr.Timeout() { return true } return false }
go
func IsTimeout(err error) bool { if nerr, ok := err.(net.Error); ok && nerr.Timeout() { return true } return false }
[ "func", "IsTimeout", "(", "err", "error", ")", "bool", "{", "if", "nerr", ",", "ok", ":=", "err", ".", "(", "net", ".", "Error", ")", ";", "ok", "&&", "nerr", ".", "Timeout", "(", ")", "{", "return", "true", "\n", "}", "\n", "return", "false", ...
// IsTimeout indicates whether the given error is a network timeout error
[ "IsTimeout", "indicates", "whether", "the", "given", "error", "is", "a", "network", "timeout", "error" ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/copy.go#L77-L82
147,876
getlantern/netx
wrap.go
WalkWrapped
func WalkWrapped(conn net.Conn, cb func(net.Conn) bool) { for { if !cb(conn) { return } switch t := conn.(type) { case WrappedConn: conn = t.Wrapped() default: return } } }
go
func WalkWrapped(conn net.Conn, cb func(net.Conn) bool) { for { if !cb(conn) { return } switch t := conn.(type) { case WrappedConn: conn = t.Wrapped() default: return } } }
[ "func", "WalkWrapped", "(", "conn", "net", ".", "Conn", ",", "cb", "func", "(", "net", ".", "Conn", ")", "bool", ")", "{", "for", "{", "if", "!", "cb", "(", "conn", ")", "{", "return", "\n", "}", "\n", "switch", "t", ":=", "conn", ".", "(", "...
// WalkWrapped walks the tree of wrapped conns, calling the callback. If // callback returns false, the walk stops.
[ "WalkWrapped", "walks", "the", "tree", "of", "wrapped", "conns", "calling", "the", "callback", ".", "If", "callback", "returns", "false", "the", "walk", "stops", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/wrap.go#L15-L27
147,877
getlantern/netx
netx.go
Dial
func Dial(network string, addr string) (net.Conn, error) { return DialTimeout(network, addr, defaultDialTimeout) }
go
func Dial(network string, addr string) (net.Conn, error) { return DialTimeout(network, addr, defaultDialTimeout) }
[ "func", "Dial", "(", "network", "string", ",", "addr", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "return", "DialTimeout", "(", "network", ",", "addr", ",", "defaultDialTimeout", ")", "\n", "}" ]
// Dial is like DialTimeout using a default timeout of 1 minute.
[ "Dial", "is", "like", "DialTimeout", "using", "a", "default", "timeout", "of", "1", "minute", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/netx.go#L27-L29
147,878
getlantern/netx
netx.go
DialUDP
func DialUDP(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error) { return dialUDP.Load().(func(string, *net.UDPAddr, *net.UDPAddr) (*net.UDPConn, error))(network, laddr, raddr) }
go
func DialUDP(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error) { return dialUDP.Load().(func(string, *net.UDPAddr, *net.UDPAddr) (*net.UDPConn, error))(network, laddr, raddr) }
[ "func", "DialUDP", "(", "network", "string", ",", "laddr", ",", "raddr", "*", "net", ".", "UDPAddr", ")", "(", "*", "net", ".", "UDPConn", ",", "error", ")", "{", "return", "dialUDP", ".", "Load", "(", ")", ".", "(", "func", "(", "string", ",", "...
// DialUDP acts like Dial but for UDP networks.
[ "DialUDP", "acts", "like", "Dial", "but", "for", "UDP", "networks", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/netx.go#L32-L34
147,879
getlantern/netx
netx.go
ListenUDP
func ListenUDP(network string, laddr *net.UDPAddr) (*net.UDPConn, error) { return listenUDP.Load().(func(network string, laddr *net.UDPAddr) (*net.UDPConn, error))(network, laddr) }
go
func ListenUDP(network string, laddr *net.UDPAddr) (*net.UDPConn, error) { return listenUDP.Load().(func(network string, laddr *net.UDPAddr) (*net.UDPConn, error))(network, laddr) }
[ "func", "ListenUDP", "(", "network", "string", ",", "laddr", "*", "net", ".", "UDPAddr", ")", "(", "*", "net", ".", "UDPConn", ",", "error", ")", "{", "return", "listenUDP", ".", "Load", "(", ")", ".", "(", "func", "(", "network", "string", ",", "l...
// ListenUDP acts like ListenPacket for UDP networks.
[ "ListenUDP", "acts", "like", "ListenPacket", "for", "UDP", "networks", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/netx.go#L52-L54
147,880
getlantern/netx
netx.go
OverrideDialUDP
func OverrideDialUDP(dialFN func(net string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)) { dialUDP.Store(dialFN) }
go
func OverrideDialUDP(dialFN func(net string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)) { dialUDP.Store(dialFN) }
[ "func", "OverrideDialUDP", "(", "dialFN", "func", "(", "net", "string", ",", "laddr", ",", "raddr", "*", "net", ".", "UDPAddr", ")", "(", "*", "net", ".", "UDPConn", ",", "error", ")", ")", "{", "dialUDP", ".", "Store", "(", "dialFN", ")", "\n", "}...
// OverrideDialUDP overrides the global dialUDP function.
[ "OverrideDialUDP", "overrides", "the", "global", "dialUDP", "function", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/netx.go#L62-L64
147,881
getlantern/netx
netx.go
OverrideListenUDP
func OverrideListenUDP(listenFN func(network string, laddr *net.UDPAddr) (*net.UDPConn, error)) { listenUDP.Store(listenFN) }
go
func OverrideListenUDP(listenFN func(network string, laddr *net.UDPAddr) (*net.UDPConn, error)) { listenUDP.Store(listenFN) }
[ "func", "OverrideListenUDP", "(", "listenFN", "func", "(", "network", "string", ",", "laddr", "*", "net", ".", "UDPAddr", ")", "(", "*", "net", ".", "UDPConn", ",", "error", ")", ")", "{", "listenUDP", ".", "Store", "(", "listenFN", ")", "\n", "}" ]
// OverrideListenUDP overrides the global listenUDP function.
[ "OverrideListenUDP", "overrides", "the", "global", "listenUDP", "function", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/netx.go#L67-L69
147,882
getlantern/netx
netx.go
OverrideResolveUDP
func OverrideResolveUDP(resolveFN func(net string, addr string) (*net.UDPAddr, error)) { resolveUDPAddr.Store(resolveFN) }
go
func OverrideResolveUDP(resolveFN func(net string, addr string) (*net.UDPAddr, error)) { resolveUDPAddr.Store(resolveFN) }
[ "func", "OverrideResolveUDP", "(", "resolveFN", "func", "(", "net", "string", ",", "addr", "string", ")", "(", "*", "net", ".", "UDPAddr", ",", "error", ")", ")", "{", "resolveUDPAddr", ".", "Store", "(", "resolveFN", ")", "\n", "}" ]
// OverrideResolveUDP overrides the global resolveUDP function.
[ "OverrideResolveUDP", "overrides", "the", "global", "resolveUDP", "function", "." ]
9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a
https://github.com/getlantern/netx/blob/9912de6f94fd1dd35a2f3af9a9ce5650d1a10b7a/netx.go#L86-L88
147,883
vektra/errors
details.go
Details
func Details(err error) map[string]string { dets := map[string]string{} addDetails(err, dets) return dets }
go
func Details(err error) map[string]string { dets := map[string]string{} addDetails(err, dets) return dets }
[ "func", "Details", "(", "err", "error", ")", "map", "[", "string", "]", "string", "{", "dets", ":=", "map", "[", "string", "]", "string", "{", "}", "\n\n", "addDetails", "(", "err", ",", "dets", ")", "\n\n", "return", "dets", "\n", "}" ]
// Derive a map of detailed information about an error. // For HereErrors, map includes a "location" key // For CauseErrors, map includes one or more "cause" keys // For TraceErrors, map includes a "trace" key // For ContextErrors, map includes a "context" key // For SubjectErrors, map includes a "subject" key
[ "Derive", "a", "map", "of", "detailed", "information", "about", "an", "error", ".", "For", "HereErrors", "map", "includes", "a", "location", "key", "For", "CauseErrors", "map", "includes", "one", "or", "more", "cause", "keys", "For", "TraceErrors", "map", "i...
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/details.go#L47-L53
147,884
vektra/errors
checking.go
Unwrap
func Unwrap(err error) error { for { switch specific := err.(type) { case *HereError: err = specific.error case *CauseError: err = specific.error case *TraceError: err = specific.error case *ContextError: err = specific.error case *SubjectError: err = specific.error default: return err ...
go
func Unwrap(err error) error { for { switch specific := err.(type) { case *HereError: err = specific.error case *CauseError: err = specific.error case *TraceError: err = specific.error case *ContextError: err = specific.error case *SubjectError: err = specific.error default: return err ...
[ "func", "Unwrap", "(", "err", "error", ")", "error", "{", "for", "{", "switch", "specific", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "HereError", ":", "err", "=", "specific", ".", "error", "\n", "case", "*", "CauseError", ":", "err", "...
// Remove any Here, Cause, Trace, Context or Subject wrappers from err
[ "Remove", "any", "Here", "Cause", "Trace", "Context", "or", "Subject", "wrappers", "from", "err" ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/checking.go#L4-L21
147,885
vektra/errors
print.go
Print
func Print(err error, out io.Writer) { switch specific := err.(type) { case *HereError: out.Write([]byte(" from: " + specific.FullLocation() + "\n")) Print(specific.error, out) case *CauseError: Print(specific.error, out) out.Write([]byte("cause: " + specific.cause.Error() + "\n")) if cause, ok := specifi...
go
func Print(err error, out io.Writer) { switch specific := err.(type) { case *HereError: out.Write([]byte(" from: " + specific.FullLocation() + "\n")) Print(specific.error, out) case *CauseError: Print(specific.error, out) out.Write([]byte("cause: " + specific.cause.Error() + "\n")) if cause, ok := specifi...
[ "func", "Print", "(", "err", "error", ",", "out", "io", ".", "Writer", ")", "{", "switch", "specific", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "HereError", ":", "out", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\"", "+", "sp...
// Print out the information within err to out. This understands // errors that use Here, Cause, and Trace.
[ "Print", "out", "the", "information", "within", "err", "to", "out", ".", "This", "understands", "errors", "that", "use", "Here", "Cause", "and", "Trace", "." ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/print.go#L10-L37
147,886
vektra/errors
errors.go
Here
func Here(orig error) error { if orig == nil { return nil } // If the error is already a Here, then don't redecorate it because we want // to preserve the most accurate info, which is upstream of this call. if he, ok := orig.(*HereError); ok { return he } pc, file, line, ok := runtime.Caller(1) if ok { ...
go
func Here(orig error) error { if orig == nil { return nil } // If the error is already a Here, then don't redecorate it because we want // to preserve the most accurate info, which is upstream of this call. if he, ok := orig.(*HereError); ok { return he } pc, file, line, ok := runtime.Caller(1) if ok { ...
[ "func", "Here", "(", "orig", "error", ")", "error", "{", "if", "orig", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// If the error is already a Here, then don't redecorate it because we want", "// to preserve the most accurate info, which is upstream of this call.", ...
// Wrap an error with location information derived from the caller location
[ "Wrap", "an", "error", "with", "location", "information", "derived", "from", "the", "caller", "location" ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/errors.go#L38-L60
147,887
vektra/errors
errors.go
Location
func (h *HereError) Location() string { lastSlash := strings.LastIndex(h.loc, "/") secondLastSlash := strings.LastIndex(h.loc[:lastSlash], "/") return h.loc[secondLastSlash+1:] }
go
func (h *HereError) Location() string { lastSlash := strings.LastIndex(h.loc, "/") secondLastSlash := strings.LastIndex(h.loc[:lastSlash], "/") return h.loc[secondLastSlash+1:] }
[ "func", "(", "h", "*", "HereError", ")", "Location", "(", ")", "string", "{", "lastSlash", ":=", "strings", ".", "LastIndex", "(", "h", ".", "loc", ",", "\"", "\"", ")", "\n", "secondLastSlash", ":=", "strings", ".", "LastIndex", "(", "h", ".", "loc"...
// Return a short version of the location information
[ "Return", "a", "short", "version", "of", "the", "location", "information" ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/errors.go#L73-L78
147,888
vektra/errors
errors.go
Cause
func Cause(err error, cause error) error { if err == nil { return nil } return &CauseError{ error: err, cause: cause, } }
go
func Cause(err error, cause error) error { if err == nil { return nil } return &CauseError{ error: err, cause: cause, } }
[ "func", "Cause", "(", "err", "error", ",", "cause", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "CauseError", "{", "error", ":", "err", ",", "cause", ":", "cause", ",", "}", "\n", ...
// Wraps an error containing the information about what caused this error
[ "Wraps", "an", "error", "containing", "the", "information", "about", "what", "caused", "this", "error" ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/errors.go#L87-L96
147,889
vektra/errors
errors.go
Trace
func Trace(err error) error { if err == nil { return nil } buf := make([]byte, 1024) sz := runtime.Stack(buf, false) return &TraceError{ error: err, trace: string(buf[:sz]), } }
go
func Trace(err error) error { if err == nil { return nil } buf := make([]byte, 1024) sz := runtime.Stack(buf, false) return &TraceError{ error: err, trace: string(buf[:sz]), } }
[ "func", "Trace", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "1024", ")", "\n", "sz", ":=", "runtime", ".", "Stack", "(", "buf", ","...
// Wraps an error with a stacktrace derived from the calling location
[ "Wraps", "an", "error", "with", "a", "stacktrace", "derived", "from", "the", "calling", "location" ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/errors.go#L110-L122
147,890
vektra/errors
errors.go
Error
func (c *SubjectError) Error() string { return fmt.Sprintf("%s: %s", c.error.Error(), c.subject) }
go
func (c *SubjectError) Error() string { return fmt.Sprintf("%s: %s", c.error.Error(), c.subject) }
[ "func", "(", "c", "*", "SubjectError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "error", ".", "Error", "(", ")", ",", "c", ".", "subject", ")", "\n", "}" ]
// Return a string containing the context as well as the underlying error // This uses fmt.Sprintf's %s to convert the subject to a string.
[ "Return", "a", "string", "containing", "the", "context", "as", "well", "as", "the", "underlying", "error", "This", "uses", "fmt", ".", "Sprintf", "s", "%s", "to", "convert", "the", "subject", "to", "a", "string", "." ]
c64d83aba85aa4392895aadeefabbd24e89f3580
https://github.com/vektra/errors/blob/c64d83aba85aa4392895aadeefabbd24e89f3580/errors.go#L182-L184
147,891
tredoe/term
readline/buffer.go
insertRune
func (b *buffer) insertRune(r rune) error { var useRefresh bool b.grow(b.size + 1) // Check if there is free space for one more character // Avoid a full update of the line. if b.pos == b.size { char := make([]byte, utf8.UTFMax) utf8.EncodeRune(char, r) if _, err := term.Output.Write(char); err != nil { ...
go
func (b *buffer) insertRune(r rune) error { var useRefresh bool b.grow(b.size + 1) // Check if there is free space for one more character // Avoid a full update of the line. if b.pos == b.size { char := make([]byte, utf8.UTFMax) utf8.EncodeRune(char, r) if _, err := term.Output.Write(char); err != nil { ...
[ "func", "(", "b", "*", "buffer", ")", "insertRune", "(", "r", "rune", ")", "error", "{", "var", "useRefresh", "bool", "\n\n", "b", ".", "grow", "(", "b", ".", "size", "+", "1", ")", "// Check if there is free space for one more character", "\n\n", "// Avoid ...
// == Output // insertRune inserts a character in the cursor position.
[ "==", "Output", "insertRune", "inserts", "a", "character", "in", "the", "cursor", "position", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L54-L80
147,892
tredoe/term
readline/buffer.go
insertRunes
func (b *buffer) insertRunes(runes []rune) error { for _, r := range runes { if err := b.insertRune(r); err != nil { return err } } return nil }
go
func (b *buffer) insertRunes(runes []rune) error { for _, r := range runes { if err := b.insertRune(r); err != nil { return err } } return nil }
[ "func", "(", "b", "*", "buffer", ")", "insertRunes", "(", "runes", "[", "]", "rune", ")", "error", "{", "for", "_", ",", "r", ":=", "range", "runes", "{", "if", "err", ":=", "b", ".", "insertRune", "(", "r", ")", ";", "err", "!=", "nil", "{", ...
// insertRunes inserts several characters.
[ "insertRunes", "inserts", "several", "characters", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L83-L90
147,893
tredoe/term
readline/buffer.go
toBytes
func (b *buffer) toBytes() []byte { chars := make([]byte, b.size*utf8.UTFMax) var end, runeLen int // == Each character (as integer) is encoded to []byte for i := 0; i < b.size; i++ { if i != 0 { runeLen = utf8.EncodeRune(chars[end:], b.data[i]) end += runeLen } else { runeLen = utf8.EncodeRune(chars,...
go
func (b *buffer) toBytes() []byte { chars := make([]byte, b.size*utf8.UTFMax) var end, runeLen int // == Each character (as integer) is encoded to []byte for i := 0; i < b.size; i++ { if i != 0 { runeLen = utf8.EncodeRune(chars[end:], b.data[i]) end += runeLen } else { runeLen = utf8.EncodeRune(chars,...
[ "func", "(", "b", "*", "buffer", ")", "toBytes", "(", ")", "[", "]", "byte", "{", "chars", ":=", "make", "(", "[", "]", "byte", ",", "b", ".", "size", "*", "utf8", ".", "UTFMax", ")", "\n", "var", "end", ",", "runeLen", "int", "\n\n", "// == Ea...
// toBytes returns a slice of the contents of the buffer.
[ "toBytes", "returns", "a", "slice", "of", "the", "contents", "of", "the", "buffer", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L93-L108
147,894
tredoe/term
readline/buffer.go
refresh
func (b *buffer) refresh() (err error) { lastLine, _ := b.pos2xy(b.size) posLine, posColumn := b.pos2xy(b.pos) // To the first line. for ln := posLine; ln > 0; ln-- { if _, err = term.Output.Write(ToPreviousLine); err != nil { return outputError(err.Error()) } } // == Write the line if _, err = term.Out...
go
func (b *buffer) refresh() (err error) { lastLine, _ := b.pos2xy(b.size) posLine, posColumn := b.pos2xy(b.pos) // To the first line. for ln := posLine; ln > 0; ln-- { if _, err = term.Output.Write(ToPreviousLine); err != nil { return outputError(err.Error()) } } // == Write the line if _, err = term.Out...
[ "func", "(", "b", "*", "buffer", ")", "refresh", "(", ")", "(", "err", "error", ")", "{", "lastLine", ",", "_", ":=", "b", ".", "pos2xy", "(", "b", ".", "size", ")", "\n", "posLine", ",", "posColumn", ":=", "b", ".", "pos2xy", "(", "b", ".", ...
// refresh refreshes the line.
[ "refresh", "refreshes", "the", "line", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L114-L147
147,895
tredoe/term
readline/buffer.go
start
func (b *buffer) start() (err error) { if b.pos == b.promptLen { return } for ln, _ := b.pos2xy(b.pos); ln > 0; ln-- { if _, err = term.Output.Write(CursorUp); err != nil { return outputError(err.Error()) } } if _, err = fmt.Fprintf(term.Output, "\r\033[%dC", b.promptLen); err != nil { return outputEr...
go
func (b *buffer) start() (err error) { if b.pos == b.promptLen { return } for ln, _ := b.pos2xy(b.pos); ln > 0; ln-- { if _, err = term.Output.Write(CursorUp); err != nil { return outputError(err.Error()) } } if _, err = fmt.Fprintf(term.Output, "\r\033[%dC", b.promptLen); err != nil { return outputEr...
[ "func", "(", "b", "*", "buffer", ")", "start", "(", ")", "(", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "promptLen", "{", "return", "\n", "}", "\n\n", "for", "ln", ",", "_", ":=", "b", ".", "pos2xy", "(", "b", ".", "p...
// == Movement // start moves the cursor at the start.
[ "==", "Movement", "start", "moves", "the", "cursor", "at", "the", "start", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L152-L168
147,896
tredoe/term
readline/buffer.go
end
func (b *buffer) end() (lines int, err error) { if b.pos == b.size { return } lastLine, lastColumn := b.pos2xy(b.size) for ln, _ := b.pos2xy(b.pos); ln < lastLine; ln++ { if _, err = term.Output.Write(CursorDown); err != nil { return 0, outputError(err.Error()) } } if _, err = fmt.Fprintf(term.Output,...
go
func (b *buffer) end() (lines int, err error) { if b.pos == b.size { return } lastLine, lastColumn := b.pos2xy(b.size) for ln, _ := b.pos2xy(b.pos); ln < lastLine; ln++ { if _, err = term.Output.Write(CursorDown); err != nil { return 0, outputError(err.Error()) } } if _, err = fmt.Fprintf(term.Output,...
[ "func", "(", "b", "*", "buffer", ")", "end", "(", ")", "(", "lines", "int", ",", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "size", "{", "return", "\n", "}", "\n\n", "lastLine", ",", "lastColumn", ":=", "b", ".", "pos2xy",...
// end moves the cursor at the end. // Returns the number of lines that fill in the data.
[ "end", "moves", "the", "cursor", "at", "the", "end", ".", "Returns", "the", "number", "of", "lines", "that", "fill", "in", "the", "data", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L172-L190
147,897
tredoe/term
readline/buffer.go
backward
func (b *buffer) backward() (start bool, err error) { if b.pos == b.promptLen { return true, nil } b.pos-- // If position is on the same line. if _, col := b.pos2xy(b.pos); col != 0 { if _, err = term.Output.Write(CursorBackward); err != nil { return false, outputError(err.Error()) } } else { if _, er...
go
func (b *buffer) backward() (start bool, err error) { if b.pos == b.promptLen { return true, nil } b.pos-- // If position is on the same line. if _, col := b.pos2xy(b.pos); col != 0 { if _, err = term.Output.Write(CursorBackward); err != nil { return false, outputError(err.Error()) } } else { if _, er...
[ "func", "(", "b", "*", "buffer", ")", "backward", "(", ")", "(", "start", "bool", ",", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "promptLen", "{", "return", "true", ",", "nil", "\n", "}", "\n", "b", ".", "pos", "--", "\...
// backward moves the cursor one character backward. // Returns a boolean to know if the cursor is at the beginning of the line.
[ "backward", "moves", "the", "cursor", "one", "character", "backward", ".", "Returns", "a", "boolean", "to", "know", "if", "the", "cursor", "is", "at", "the", "beginning", "of", "the", "line", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L194-L214
147,898
tredoe/term
readline/buffer.go
forward
func (b *buffer) forward() (end bool, err error) { if b.pos == b.size { return true, nil } b.pos++ if _, col := b.pos2xy(b.pos); col != 0 { if _, err = term.Output.Write(CursorForward); err != nil { return false, outputError(err.Error()) } } else { if _, err = term.Output.Write(ToNextLine); err != nil ...
go
func (b *buffer) forward() (end bool, err error) { if b.pos == b.size { return true, nil } b.pos++ if _, col := b.pos2xy(b.pos); col != 0 { if _, err = term.Output.Write(CursorForward); err != nil { return false, outputError(err.Error()) } } else { if _, err = term.Output.Write(ToNextLine); err != nil ...
[ "func", "(", "b", "*", "buffer", ")", "forward", "(", ")", "(", "end", "bool", ",", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "size", "{", "return", "true", ",", "nil", "\n", "}", "\n", "b", ".", "pos", "++", "\n\n", ...
// forward moves the cursor one character forward. // Returns a boolean to know if the cursor is at the end of the line.
[ "forward", "moves", "the", "cursor", "one", "character", "forward", ".", "Returns", "a", "boolean", "to", "know", "if", "the", "cursor", "is", "at", "the", "end", "of", "the", "line", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L218-L234
147,899
tredoe/term
readline/buffer.go
swap
func (b *buffer) swap() error { if b.pos == b.promptLen { return nil } if b.pos < b.size { aux := b.data[b.pos-1] b.data[b.pos-1] = b.data[b.pos] b.data[b.pos] = aux b.pos++ // End of line } else { aux := b.data[b.pos-2] b.data[b.pos-2] = b.data[b.pos-1] b.data[b.pos-1] = aux } return b.refresh...
go
func (b *buffer) swap() error { if b.pos == b.promptLen { return nil } if b.pos < b.size { aux := b.data[b.pos-1] b.data[b.pos-1] = b.data[b.pos] b.data[b.pos] = aux b.pos++ // End of line } else { aux := b.data[b.pos-2] b.data[b.pos-2] = b.data[b.pos-1] b.data[b.pos-1] = aux } return b.refresh...
[ "func", "(", "b", "*", "buffer", ")", "swap", "(", ")", "error", "{", "if", "b", ".", "pos", "==", "b", ".", "promptLen", "{", "return", "nil", "\n", "}", "\n\n", "if", "b", ".", "pos", "<", "b", ".", "size", "{", "aux", ":=", "b", ".", "da...
// swap swaps the actual character by the previous one. If it is the end of the // line then it is swapped the 2nd previous by the previous one.
[ "swap", "swaps", "the", "actual", "character", "by", "the", "previous", "one", ".", "If", "it", "is", "the", "end", "of", "the", "line", "then", "it", "is", "swapped", "the", "2nd", "previous", "by", "the", "previous", "one", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L238-L255