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
148,300
gobs/cmd
internal/internal.go
PushScope
func (ctx *Context) PushScope(vars map[string]string, args []string) { scope := make(Arguments) for k, v := range vars { scope[k] = v } for i, v := range args { k := strconv.Itoa(i) scope[k] = v } if args != nil { scope["*"] = strings.Join(args[1:], " ") // all args scope["#"] = strconv.Itoa(len(args...
go
func (ctx *Context) PushScope(vars map[string]string, args []string) { scope := make(Arguments) for k, v := range vars { scope[k] = v } for i, v := range args { k := strconv.Itoa(i) scope[k] = v } if args != nil { scope["*"] = strings.Join(args[1:], " ") // all args scope["#"] = strconv.Itoa(len(args...
[ "func", "(", "ctx", "*", "Context", ")", "PushScope", "(", "vars", "map", "[", "string", "]", "string", ",", "args", "[", "]", "string", ")", "{", "scope", ":=", "make", "(", "Arguments", ")", "\n\n", "for", "k", ",", "v", ":=", "range", "vars", ...
// // PushScope pushes a new scope for variables, with the associated dvalues //
[ "PushScope", "pushes", "a", "new", "scope", "for", "variables", "with", "the", "associated", "dvalues" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L126-L144
148,301
gobs/cmd
internal/internal.go
PopScope
func (ctx *Context) PopScope() { l := len(ctx.scopes) if l == 0 { panic("no scopes") } ctx.scopes = ctx.scopes[:l-1] }
go
func (ctx *Context) PopScope() { l := len(ctx.scopes) if l == 0 { panic("no scopes") } ctx.scopes = ctx.scopes[:l-1] }
[ "func", "(", "ctx", "*", "Context", ")", "PopScope", "(", ")", "{", "l", ":=", "len", "(", "ctx", ".", "scopes", ")", "\n", "if", "l", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "ctx", ".", "scopes", "=", "ctx", ".", ...
// // PopScope removes the current scope, restoring the previous one //
[ "PopScope", "removes", "the", "current", "scope", "restoring", "the", "previous", "one" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L149-L156
148,302
gobs/cmd
internal/internal.go
GetScope
func (ctx *Context) GetScope(scope Scope) Arguments { i := len(ctx.scopes) - 1 // index of local scope if i < 0 { panic("no scopes") } switch scope { case GlobalScope: i = 0 // index of global scope case ParentScope: if i > 0 { i -= 1 // index of parent scope } } return ctx.scopes[i] }
go
func (ctx *Context) GetScope(scope Scope) Arguments { i := len(ctx.scopes) - 1 // index of local scope if i < 0 { panic("no scopes") } switch scope { case GlobalScope: i = 0 // index of global scope case ParentScope: if i > 0 { i -= 1 // index of parent scope } } return ctx.scopes[i] }
[ "func", "(", "ctx", "*", "Context", ")", "GetScope", "(", "scope", "Scope", ")", "Arguments", "{", "i", ":=", "len", "(", "ctx", ".", "scopes", ")", "-", "1", "// index of local scope", "\n", "if", "i", "<", "0", "{", "panic", "(", "\"", "\"", ")",...
// // GetScope returns the variable sets for the specified scope //
[ "GetScope", "returns", "the", "variable", "sets", "for", "the", "specified", "scope" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L161-L178
148,303
gobs/cmd
internal/internal.go
SetVar
func (ctx *Context) SetVar(k string, v interface{}, scope Scope) { i := len(ctx.scopes) - 1 // index of local scope if i < 0 { panic("no scopes") } switch scope { case GlobalScope: i = 0 // index of global scope case ParentScope: if i > 0 { i -= 1 // index of parent scope } } ctx.scopes[i][k] = fm...
go
func (ctx *Context) SetVar(k string, v interface{}, scope Scope) { i := len(ctx.scopes) - 1 // index of local scope if i < 0 { panic("no scopes") } switch scope { case GlobalScope: i = 0 // index of global scope case ParentScope: if i > 0 { i -= 1 // index of parent scope } } ctx.scopes[i][k] = fm...
[ "func", "(", "ctx", "*", "Context", ")", "SetVar", "(", "k", "string", ",", "v", "interface", "{", "}", ",", "scope", "Scope", ")", "{", "i", ":=", "len", "(", "ctx", ".", "scopes", ")", "-", "1", "// index of local scope", "\n", "if", "i", "<", ...
// // SetVar sets a variable in the current, parent or global scope //
[ "SetVar", "sets", "a", "variable", "in", "the", "current", "parent", "or", "global", "scope" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L183-L200
148,304
gobs/cmd
internal/internal.go
UnsetVar
func (ctx *Context) UnsetVar(k string, scope Scope) { i := len(ctx.scopes) - 1 // index of local scope if i < 0 { panic("no scopes") } switch scope { case GlobalScope: i = 0 // index of global scope case ParentScope: if i > 0 { i -= 1 // index of parent scope } } if _, ok := ctx.scopes[i][k]; ok {...
go
func (ctx *Context) UnsetVar(k string, scope Scope) { i := len(ctx.scopes) - 1 // index of local scope if i < 0 { panic("no scopes") } switch scope { case GlobalScope: i = 0 // index of global scope case ParentScope: if i > 0 { i -= 1 // index of parent scope } } if _, ok := ctx.scopes[i][k]; ok {...
[ "func", "(", "ctx", "*", "Context", ")", "UnsetVar", "(", "k", "string", ",", "scope", "Scope", ")", "{", "i", ":=", "len", "(", "ctx", ".", "scopes", ")", "-", "1", "// index of local scope", "\n", "if", "i", "<", "0", "{", "panic", "(", "\"", "...
// // UnsetVar removes a variable from the current, parent or global scope //
[ "UnsetVar", "removes", "a", "variable", "from", "the", "current", "parent", "or", "global", "scope" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L205-L224
148,305
gobs/cmd
internal/internal.go
SetScanner
func (ctx *Context) SetScanner(curr BasicScanner) (prev BasicScanner) { prev, ctx.scanner = ctx.scanner, curr return }
go
func (ctx *Context) SetScanner(curr BasicScanner) (prev BasicScanner) { prev, ctx.scanner = ctx.scanner, curr return }
[ "func", "(", "ctx", "*", "Context", ")", "SetScanner", "(", "curr", "BasicScanner", ")", "(", "prev", "BasicScanner", ")", "{", "prev", ",", "ctx", ".", "scanner", "=", "ctx", ".", "scanner", ",", "curr", "\n", "return", "\n", "}" ]
// // SetScanner sets the current scanner and return the previos one //
[ "SetScanner", "sets", "the", "current", "scanner", "and", "return", "the", "previos", "one" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L372-L375
148,306
gobs/cmd
internal/internal.go
ScanLiner
func (ctx *Context) ScanLiner() BasicScanner { return ctx.SetScanner(&ScanLiner{line: ctx.line}) }
go
func (ctx *Context) ScanLiner() BasicScanner { return ctx.SetScanner(&ScanLiner{line: ctx.line}) }
[ "func", "(", "ctx", "*", "Context", ")", "ScanLiner", "(", ")", "BasicScanner", "{", "return", "ctx", ".", "SetScanner", "(", "&", "ScanLiner", "{", "line", ":", "ctx", ".", "line", "}", ")", "\n", "}" ]
// // ScanLiner sets the current scanner to a "liner" scanner //
[ "ScanLiner", "sets", "the", "current", "scanner", "to", "a", "liner", "scanner" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L380-L382
148,307
gobs/cmd
internal/internal.go
ScanBlock
func (ctx *Context) ScanBlock(block []string) BasicScanner { return ctx.SetScanner(&ScanLines{lines: block}) }
go
func (ctx *Context) ScanBlock(block []string) BasicScanner { return ctx.SetScanner(&ScanLines{lines: block}) }
[ "func", "(", "ctx", "*", "Context", ")", "ScanBlock", "(", "block", "[", "]", "string", ")", "BasicScanner", "{", "return", "ctx", ".", "SetScanner", "(", "&", "ScanLines", "{", "lines", ":", "block", "}", ")", "\n", "}" ]
// // ScanBlock sets the current scanner to a block scanner //
[ "ScanBlock", "sets", "the", "current", "scanner", "to", "a", "block", "scanner" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L387-L389
148,308
gobs/cmd
internal/internal.go
ScanReader
func (ctx *Context) ScanReader(r io.Reader) BasicScanner { return ctx.SetScanner(&ScanReader{sr: bufio.NewScanner(r)}) }
go
func (ctx *Context) ScanReader(r io.Reader) BasicScanner { return ctx.SetScanner(&ScanReader{sr: bufio.NewScanner(r)}) }
[ "func", "(", "ctx", "*", "Context", ")", "ScanReader", "(", "r", "io", ".", "Reader", ")", "BasicScanner", "{", "return", "ctx", ".", "SetScanner", "(", "&", "ScanReader", "{", "sr", ":", "bufio", ".", "NewScanner", "(", "r", ")", "}", ")", "\n", "...
// // ScanReader sets the current scanner to an io.Reader scanner //
[ "ScanReader", "sets", "the", "current", "scanner", "to", "an", "io", ".", "Reader", "scanner" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/internal/internal.go#L394-L396
148,309
FiloSottile/b2
file.go
DeleteFile
func (c *Client) DeleteFile(id, name string) error { res, err := c.doRequest("b2_delete_file_version", map[string]interface{}{ "fileId": id, "fileName": name, }) if err != nil { return err } drainAndClose(res.Body) return nil }
go
func (c *Client) DeleteFile(id, name string) error { res, err := c.doRequest("b2_delete_file_version", map[string]interface{}{ "fileId": id, "fileName": name, }) if err != nil { return err } drainAndClose(res.Body) return nil }
[ "func", "(", "c", "*", "Client", ")", "DeleteFile", "(", "id", ",", "name", "string", ")", "error", "{", "res", ",", "err", ":=", "c", ".", "doRequest", "(", "\"", "\"", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":...
// DeleteFile deletes a file version.
[ "DeleteFile", "deletes", "a", "file", "version", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/file.go#L10-L19
148,310
FiloSottile/b2
file.go
GetFileInfoByID
func (c *Client) GetFileInfoByID(id string) (*FileInfo, error) { res, err := c.doRequest("b2_get_file_info", map[string]interface{}{ "fileId": id, }) if err != nil { return nil, err } defer drainAndClose(res.Body) var fi *fileInfoObj if err := json.NewDecoder(res.Body).Decode(&fi); err != nil { return nil,...
go
func (c *Client) GetFileInfoByID(id string) (*FileInfo, error) { res, err := c.doRequest("b2_get_file_info", map[string]interface{}{ "fileId": id, }) if err != nil { return nil, err } defer drainAndClose(res.Body) var fi *fileInfoObj if err := json.NewDecoder(res.Body).Decode(&fi); err != nil { return nil,...
[ "func", "(", "c", "*", "Client", ")", "GetFileInfoByID", "(", "id", "string", ")", "(", "*", "FileInfo", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "doRequest", "(", "\"", "\"", ",", "map", "[", "string", "]", "interface", "{", "}...
// GetFileInfoByID obtains a FileInfo for a given ID. // // The ID can refer to any file version or "hide" action in any bucket.
[ "GetFileInfoByID", "obtains", "a", "FileInfo", "for", "a", "given", "ID", ".", "The", "ID", "can", "refer", "to", "any", "file", "version", "or", "hide", "action", "in", "any", "bucket", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/file.go#L70-L83
148,311
FiloSottile/b2
file.go
GetFileInfoByName
func (b *Bucket) GetFileInfoByName(name string) (*FileInfo, error) { l := b.ListFiles(name) l.SetPageCount(1) if l.Next() { if l.FileInfo().Name == name { return l.FileInfo(), nil } } if err := l.Err(); err != nil { return nil, l.Err() } return nil, FileNotFoundError }
go
func (b *Bucket) GetFileInfoByName(name string) (*FileInfo, error) { l := b.ListFiles(name) l.SetPageCount(1) if l.Next() { if l.FileInfo().Name == name { return l.FileInfo(), nil } } if err := l.Err(); err != nil { return nil, l.Err() } return nil, FileNotFoundError }
[ "func", "(", "b", "*", "Bucket", ")", "GetFileInfoByName", "(", "name", "string", ")", "(", "*", "FileInfo", ",", "error", ")", "{", "l", ":=", "b", ".", "ListFiles", "(", "name", ")", "\n", "l", ".", "SetPageCount", "(", "1", ")", "\n", "if", "l...
// GetFileInfoByName obtains a FileInfo for a given name. // // If the file doesn't exist, FileNotFoundError is returned. // If multiple versions of the file exist, only the latest is returned.
[ "GetFileInfoByName", "obtains", "a", "FileInfo", "for", "a", "given", "name", ".", "If", "the", "file", "doesn", "t", "exist", "FileNotFoundError", "is", "returned", ".", "If", "multiple", "versions", "of", "the", "file", "exist", "only", "the", "latest", "i...
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/file.go#L91-L103
148,312
FiloSottile/b2
file.go
SetPageCount
func (l *Listing) SetPageCount(n int) { if n > 1000 { n = 1000 } l.nextPageCount = n }
go
func (l *Listing) SetPageCount(n int) { if n > 1000 { n = 1000 } l.nextPageCount = n }
[ "func", "(", "l", "*", "Listing", ")", "SetPageCount", "(", "n", "int", ")", "{", "if", "n", ">", "1000", "{", "n", "=", "1000", "\n", "}", "\n", "l", ".", "nextPageCount", "=", "n", "\n", "}" ]
// SetPageCount controls the number of results to be fetched with each API // call. The maximum n is 1000, higher values are automatically limited to 1000. // // SetPageCount does not limit the number of results returned by a Listing.
[ "SetPageCount", "controls", "the", "number", "of", "results", "to", "be", "fetched", "with", "each", "API", "call", ".", "The", "maximum", "n", "is", "1000", "higher", "values", "are", "automatically", "limited", "to", "1000", ".", "SetPageCount", "does", "n...
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/file.go#L136-L141
148,313
FiloSottile/b2
file.go
Next
func (l *Listing) Next() bool { if l.err != nil { return false } if len(l.objects) > 0 { l.objects = l.objects[:len(l.objects)-1] } if len(l.objects) > 0 { return true } if l.nextName == nil { return false // end of iteration } data := map[string]interface{}{ "bucketId": l.b.ID, "startFileNam...
go
func (l *Listing) Next() bool { if l.err != nil { return false } if len(l.objects) > 0 { l.objects = l.objects[:len(l.objects)-1] } if len(l.objects) > 0 { return true } if l.nextName == nil { return false // end of iteration } data := map[string]interface{}{ "bucketId": l.b.ID, "startFileNam...
[ "func", "(", "l", "*", "Listing", ")", "Next", "(", ")", "bool", "{", "if", "l", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "if", "len", "(", "l", ".", "objects", ")", ">", "0", "{", "l", ".", "objects", "=", "l", "."...
// Next calls the list API if needed and prepares the FileInfo results. // It returns true on success, or false if there is no next result // or an error happened while preparing it. Err should be // consulted to distinguish between the two cases.
[ "Next", "calls", "the", "list", "API", "if", "needed", "and", "prepares", "the", "FileInfo", "results", ".", "It", "returns", "true", "on", "success", "or", "false", "if", "there", "is", "no", "next", "result", "or", "an", "error", "happened", "while", "...
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/file.go#L147-L195
148,314
Luzifer/rconfig
config.go
Usage
func Usage() { if fs != nil && fs.Parsed() { fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) fs.PrintDefaults() } }
go
func Usage() { if fs != nil && fs.Parsed() { fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) fs.PrintDefaults() } }
[ "func", "Usage", "(", ")", "{", "if", "fs", "!=", "nil", "&&", "fs", ".", "Parsed", "(", ")", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "os", ".", "Args", "[", "0", "]", ")", "\n", "fs", ".", "PrintD...
// Usage prints a basic usage with the corresponding defaults for the flags to // os.Stdout. The defaults are derived from the `default` struct-tag and the ENV.
[ "Usage", "prints", "a", "basic", "usage", "with", "the", "corresponding", "defaults", "for", "the", "flags", "to", "os", ".", "Stdout", ".", "The", "defaults", "are", "derived", "from", "the", "default", "struct", "-", "tag", "and", "the", "ENV", "." ]
c7e01474351034c26b8819dce35db36fd6ae539f
https://github.com/Luzifer/rconfig/blob/c7e01474351034c26b8819dce35db36fd6ae539f/config.go#L93-L98
148,315
FactomProject/goleveldb
leveldb/memdb/memdb.go
Delete
func (p *DB) Delete(key []byte) error { p.mu.Lock() defer p.mu.Unlock() node, exact := p.findGE(key, true) if !exact { return ErrNotFound } h := p.nodeData[node+nHeight] for i, n := range p.prevNode[:h] { m := n + 4 + i p.nodeData[m] = p.nodeData[p.nodeData[m]+nNext+i] } p.kvSize -= p.nodeData[node+nK...
go
func (p *DB) Delete(key []byte) error { p.mu.Lock() defer p.mu.Unlock() node, exact := p.findGE(key, true) if !exact { return ErrNotFound } h := p.nodeData[node+nHeight] for i, n := range p.prevNode[:h] { m := n + 4 + i p.nodeData[m] = p.nodeData[p.nodeData[m]+nNext+i] } p.kvSize -= p.nodeData[node+nK...
[ "func", "(", "p", "*", "DB", ")", "Delete", "(", "key", "[", "]", "byte", ")", "error", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "node", ",", "exact", ":=", "p", ".", "findG...
// Delete deletes the value for the given key. It returns ErrNotFound if // the DB does not contain the key. // // It is safe to modify the contents of the arguments after Delete returns.
[ "Delete", "deletes", "the", "value", "for", "the", "given", "key", ".", "It", "returns", "ErrNotFound", "if", "the", "DB", "does", "not", "contain", "the", "key", ".", "It", "is", "safe", "to", "modify", "the", "contents", "of", "the", "arguments", "afte...
e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f
https://github.com/FactomProject/goleveldb/blob/e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f/leveldb/memdb/memdb.go#L321-L339
148,316
jlhawn/go-crypto
sha256/sha256.go
New224
func New224() crypto.ResumableHash { d := new(digest) d.is224 = true d.Reset() return d }
go
func New224() crypto.ResumableHash { d := new(digest) d.is224 = true d.Reset() return d }
[ "func", "New224", "(", ")", "crypto", ".", "ResumableHash", "{", "d", ":=", "new", "(", "digest", ")", "\n", "d", ".", "is224", "=", "true", "\n", "d", ".", "Reset", "(", ")", "\n", "return", "d", "\n", "}" ]
// New224 returns a new crypto.ResumableHash computing the SHA224 checksum.
[ "New224", "returns", "a", "new", "crypto", ".", "ResumableHash", "computing", "the", "SHA224", "checksum", "." ]
cd738dde20f0b3782516181b0866c9bb9db47401
https://github.com/jlhawn/go-crypto/blob/cd738dde20f0b3782516181b0866c9bb9db47401/sha256/sha256.go#L88-L93
148,317
FactomProject/goleveldb
leveldb/table.go
create
func (t *tOps) create() (*tWriter, error) { fd := storage.FileDesc{storage.TypeTable, t.s.allocFileNum()} fw, err := t.s.stor.Create(fd) if err != nil { return nil, err } return &tWriter{ t: t, fd: fd, w: fw, tw: table.NewWriter(fw, t.s.o.Options), }, nil }
go
func (t *tOps) create() (*tWriter, error) { fd := storage.FileDesc{storage.TypeTable, t.s.allocFileNum()} fw, err := t.s.stor.Create(fd) if err != nil { return nil, err } return &tWriter{ t: t, fd: fd, w: fw, tw: table.NewWriter(fw, t.s.o.Options), }, nil }
[ "func", "(", "t", "*", "tOps", ")", "create", "(", ")", "(", "*", "tWriter", ",", "error", ")", "{", "fd", ":=", "storage", ".", "FileDesc", "{", "storage", ".", "TypeTable", ",", "t", ".", "s", ".", "allocFileNum", "(", ")", "}", "\n", "fw", "...
// Creates an empty table and returns table writer.
[ "Creates", "an", "empty", "table", "and", "returns", "table", "writer", "." ]
e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f
https://github.com/FactomProject/goleveldb/blob/e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f/leveldb/table.go#L301-L313
148,318
FactomProject/goleveldb
leveldb/table.go
newTableOps
func newTableOps(s *session) *tOps { var ( cacher cache.Cacher bcache *cache.Cache bpool *util.BufferPool ) if s.o.GetOpenFilesCacheCapacity() > 0 { cacher = cache.NewLRU(s.o.GetOpenFilesCacheCapacity()) } if !s.o.GetDisableBlockCache() { var bcacher cache.Cacher if s.o.GetBlockCacheCapacity() > 0 { ...
go
func newTableOps(s *session) *tOps { var ( cacher cache.Cacher bcache *cache.Cache bpool *util.BufferPool ) if s.o.GetOpenFilesCacheCapacity() > 0 { cacher = cache.NewLRU(s.o.GetOpenFilesCacheCapacity()) } if !s.o.GetDisableBlockCache() { var bcacher cache.Cacher if s.o.GetBlockCacheCapacity() > 0 { ...
[ "func", "newTableOps", "(", "s", "*", "session", ")", "*", "tOps", "{", "var", "(", "cacher", "cache", ".", "Cacher", "\n", "bcache", "*", "cache", ".", "Cache", "\n", "bpool", "*", "util", ".", "BufferPool", "\n", ")", "\n", "if", "s", ".", "o", ...
// Creates new initialized table ops instance.
[ "Creates", "new", "initialized", "table", "ops", "instance", "." ]
e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f
https://github.com/FactomProject/goleveldb/blob/e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f/leveldb/table.go#L442-L468
148,319
Luzifer/rconfig
vardefault_providers.go
VarDefaultsFromYAMLFile
func VarDefaultsFromYAMLFile(filename string) map[string]string { data, err := ioutil.ReadFile(filename) if err != nil { return make(map[string]string) } return VarDefaultsFromYAML(data) }
go
func VarDefaultsFromYAMLFile(filename string) map[string]string { data, err := ioutil.ReadFile(filename) if err != nil { return make(map[string]string) } return VarDefaultsFromYAML(data) }
[ "func", "VarDefaultsFromYAMLFile", "(", "filename", "string", ")", "map", "[", "string", "]", "string", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "make", "(", "map", "...
// VarDefaultsFromYAMLFile reads contents of a file and calls VarDefaultsFromYAML
[ "VarDefaultsFromYAMLFile", "reads", "contents", "of", "a", "file", "and", "calls", "VarDefaultsFromYAML" ]
c7e01474351034c26b8819dce35db36fd6ae539f
https://github.com/Luzifer/rconfig/blob/c7e01474351034c26b8819dce35db36fd6ae539f/vardefault_providers.go#L10-L17
148,320
Luzifer/rconfig
vardefault_providers.go
VarDefaultsFromYAML
func VarDefaultsFromYAML(in []byte) map[string]string { out := make(map[string]string) err := yaml.Unmarshal(in, &out) if err != nil { return make(map[string]string) } return out }
go
func VarDefaultsFromYAML(in []byte) map[string]string { out := make(map[string]string) err := yaml.Unmarshal(in, &out) if err != nil { return make(map[string]string) } return out }
[ "func", "VarDefaultsFromYAML", "(", "in", "[", "]", "byte", ")", "map", "[", "string", "]", "string", "{", "out", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "err", ":=", "yaml", ".", "Unmarshal", "(", "in", ",", "&", "out", ...
// VarDefaultsFromYAML creates a vardefaults map from YAML raw data
[ "VarDefaultsFromYAML", "creates", "a", "vardefaults", "map", "from", "YAML", "raw", "data" ]
c7e01474351034c26b8819dce35db36fd6ae539f
https://github.com/Luzifer/rconfig/blob/c7e01474351034c26b8819dce35db36fd6ae539f/vardefault_providers.go#L20-L27
148,321
jlhawn/go-crypto
sha512/sha512.go
New384
func New384() crypto.ResumableHash { d := new(digest) d.is384 = true d.Reset() return d }
go
func New384() crypto.ResumableHash { d := new(digest) d.is384 = true d.Reset() return d }
[ "func", "New384", "(", ")", "crypto", ".", "ResumableHash", "{", "d", ":=", "new", "(", "digest", ")", "\n", "d", ".", "is384", "=", "true", "\n", "d", ".", "Reset", "(", ")", "\n", "return", "d", "\n", "}" ]
// New384 returns a new crypto.ResumableHash computing the SHA384 checksum.
[ "New384", "returns", "a", "new", "crypto", ".", "ResumableHash", "computing", "the", "SHA384", "checksum", "." ]
cd738dde20f0b3782516181b0866c9bb9db47401
https://github.com/jlhawn/go-crypto/blob/cd738dde20f0b3782516181b0866c9bb9db47401/sha512/sha512.go#L88-L93
148,322
FactomProject/goleveldb
leveldb/db_transaction.go
Commit
func (tr *Transaction) Commit() error { if err := tr.db.ok(); err != nil { return err } tr.lk.Lock() defer tr.lk.Unlock() if tr.closed { return errTransactionDone } if err := tr.flush(); err != nil { // Return error, lets user decide either to retry or discard // transaction. return err } if len(tr....
go
func (tr *Transaction) Commit() error { if err := tr.db.ok(); err != nil { return err } tr.lk.Lock() defer tr.lk.Unlock() if tr.closed { return errTransactionDone } if err := tr.flush(); err != nil { // Return error, lets user decide either to retry or discard // transaction. return err } if len(tr....
[ "func", "(", "tr", "*", "Transaction", ")", "Commit", "(", ")", "error", "{", "if", "err", ":=", "tr", ".", "db", ".", "ok", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "tr", ".", "lk", ".", "Lock", "(", ")", ...
// Commit commits the transaction. If error is not nil, then the transaction is // not committed, it can then either be retried or discarded. // // Other methods should not be called after transaction has been committed.
[ "Commit", "commits", "the", "transaction", ".", "If", "error", "is", "not", "nil", "then", "the", "transaction", "is", "not", "committed", "it", "can", "then", "either", "be", "retried", "or", "discarded", ".", "Other", "methods", "should", "not", "be", "c...
e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f
https://github.com/FactomProject/goleveldb/blob/e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f/leveldb/db_transaction.go#L186-L245
148,323
mgood/go-posix
lexer.go
evalStream
func evalStream(mapping Getter, stream chan item) (string, error) { var buf bytes.Buffer for item := range stream { text, err := item.Eval(mapping, stream) if err != nil { return "", err } buf.WriteString(text) } return buf.String(), nil }
go
func evalStream(mapping Getter, stream chan item) (string, error) { var buf bytes.Buffer for item := range stream { text, err := item.Eval(mapping, stream) if err != nil { return "", err } buf.WriteString(text) } return buf.String(), nil }
[ "func", "evalStream", "(", "mapping", "Getter", ",", "stream", "chan", "item", ")", "(", "string", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "for", "item", ":=", "range", "stream", "{", "text", ",", "err", ":=", "item", "....
// Returns the evaluation of the stream items against the given mapping. // // If all items are evaluated without errors, returns the concatenated results, // or it returns the first error encountered.
[ "Returns", "the", "evaluation", "of", "the", "stream", "items", "against", "the", "given", "mapping", ".", "If", "all", "items", "are", "evaluated", "without", "errors", "returns", "the", "concatenated", "results", "or", "it", "returns", "the", "first", "error...
948c005421f5d716f5d89cd8940e722240713663
https://github.com/mgood/go-posix/blob/948c005421f5d716f5d89cd8940e722240713663/lexer.go#L126-L138
148,324
mgood/go-posix
lexer.go
bracketedStream
func bracketedStream(stream chan item) chan item { c := make(chan item) go func() { for item := range stream { if _, ok := item.(itemEndBracket); ok { close(c) return } c <- item } c <- itemUnexpectedEOF('}') }() return c }
go
func bracketedStream(stream chan item) chan item { c := make(chan item) go func() { for item := range stream { if _, ok := item.(itemEndBracket); ok { close(c) return } c <- item } c <- itemUnexpectedEOF('}') }() return c }
[ "func", "bracketedStream", "(", "stream", "chan", "item", ")", "chan", "item", "{", "c", ":=", "make", "(", "chan", "item", ")", "\n", "go", "func", "(", ")", "{", "for", "item", ":=", "range", "stream", "{", "if", "_", ",", "ok", ":=", "item", "...
// Returns a sub-stream with the items up until the next end bracket.
[ "Returns", "a", "sub", "-", "stream", "with", "the", "items", "up", "until", "the", "next", "end", "bracket", "." ]
948c005421f5d716f5d89cd8940e722240713663
https://github.com/mgood/go-posix/blob/948c005421f5d716f5d89cd8940e722240713663/lexer.go#L141-L154
148,325
FactomProject/goleveldb
leveldb/session_util.go
newManifest
func (s *session) newManifest(rec *sessionRecord, v *version) (err error) { fd := storage.FileDesc{storage.TypeManifest, s.allocFileNum()} writer, err := s.stor.Create(fd) if err != nil { return } jw := journal.NewWriter(writer) if v == nil { v = s.version() defer v.release() } if rec == nil { rec = &s...
go
func (s *session) newManifest(rec *sessionRecord, v *version) (err error) { fd := storage.FileDesc{storage.TypeManifest, s.allocFileNum()} writer, err := s.stor.Create(fd) if err != nil { return } jw := journal.NewWriter(writer) if v == nil { v = s.version() defer v.release() } if rec == nil { rec = &s...
[ "func", "(", "s", "*", "session", ")", "newManifest", "(", "rec", "*", "sessionRecord", ",", "v", "*", "version", ")", "(", "err", "error", ")", "{", "fd", ":=", "storage", ".", "FileDesc", "{", "storage", ".", "TypeManifest", ",", "s", ".", "allocFi...
// Create a new manifest file; need external synchronization.
[ "Create", "a", "new", "manifest", "file", ";", "need", "external", "synchronization", "." ]
e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f
https://github.com/FactomProject/goleveldb/blob/e7800c6976c5d75f0a9c5e9e0e2ff8086940e58f/leveldb/session_util.go#L192-L246
148,326
FiloSottile/b2
b2.go
UnwrapError
func UnwrapError(err error) (b2Err *Error, ok bool) { if e, ok := err.(*url.Error); ok { err = e.Err } if e, ok := err.(*Error); ok { return e, true } return nil, false }
go
func UnwrapError(err error) (b2Err *Error, ok bool) { if e, ok := err.(*url.Error); ok { err = e.Err } if e, ok := err.(*Error); ok { return e, true } return nil, false }
[ "func", "UnwrapError", "(", "err", "error", ")", "(", "b2Err", "*", "Error", ",", "ok", "bool", ")", "{", "if", "e", ",", "ok", ":=", "err", ".", "(", "*", "url", ".", "Error", ")", ";", "ok", "{", "err", "=", "e", ".", "Err", "\n", "}", "\...
// UnwrapError attempts to extract the Error that caused err. If there is no // Error object to unwrap, ok is false and err is nil. That does not mean that // the original error should be ignored.
[ "UnwrapError", "attempts", "to", "extract", "the", "Error", "that", "caused", "err", ".", "If", "there", "is", "no", "Error", "object", "to", "unwrap", "ok", "is", "false", "and", "err", "is", "nil", ".", "That", "does", "not", "mean", "that", "the", "...
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L71-L79
148,327
FiloSottile/b2
b2.go
LoginInfo
func (c *Client) LoginInfo(refresh bool) (*LoginInfo, error) { if refresh { if err := c.login(nil); err != nil { return nil, err } } return c.loginInfo.Load().(*LoginInfo), nil }
go
func (c *Client) LoginInfo(refresh bool) (*LoginInfo, error) { if refresh { if err := c.login(nil); err != nil { return nil, err } } return c.loginInfo.Load().(*LoginInfo), nil }
[ "func", "(", "c", "*", "Client", ")", "LoginInfo", "(", "refresh", "bool", ")", "(", "*", "LoginInfo", ",", "error", ")", "{", "if", "refresh", "{", "if", "err", ":=", "c", ".", "login", "(", "nil", ")", ";", "err", "!=", "nil", "{", "return", ...
// LoginInfo returns the LoginInfo object currently in use. If refresh is // true, it obtains a new one before returning. // // Note that once you obtain this there is no guarantee on its freshness, // and it will eventually expire.
[ "LoginInfo", "returns", "the", "LoginInfo", "object", "currently", "in", "use", ".", "If", "refresh", "is", "true", "it", "obtains", "a", "new", "one", "before", "returning", ".", "Note", "that", "once", "you", "obtain", "this", "there", "is", "no", "guara...
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L105-L112
148,328
FiloSottile/b2
b2.go
NewClient
func NewClient(accountID, applicationKey string, httpClient *http.Client) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient } c := &Client{ accountID: accountID, applicationKey: applicationKey, hc: httpClient, } if err := c.login(nil); err != nil { return nil, e...
go
func NewClient(accountID, applicationKey string, httpClient *http.Client) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient } c := &Client{ accountID: accountID, applicationKey: applicationKey, hc: httpClient, } if err := c.login(nil); err != nil { return nil, e...
[ "func", "NewClient", "(", "accountID", ",", "applicationKey", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "(", "*", "Client", ",", "error", ")", "{", "if", "httpClient", "==", "nil", "{", "httpClient", "=", "http", ".", "DefaultClient", ...
// NewClient calls b2_authorize_account and returns an authenticated Client. // httpClient can be nil, in which case http.DefaultClient will be used.
[ "NewClient", "calls", "b2_authorize_account", "and", "returns", "an", "authenticated", "Client", ".", "httpClient", "can", "be", "nil", "in", "which", "case", "http", ".", "DefaultClient", "will", "be", "used", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L130-L147
148,329
FiloSottile/b2
b2.go
drainAndClose
func drainAndClose(body io.ReadCloser) { io.CopyN(ioutil.Discard, body, 10*1024) body.Close() }
go
func drainAndClose(body io.ReadCloser) { io.CopyN(ioutil.Discard, body, 10*1024) body.Close() }
[ "func", "drainAndClose", "(", "body", "io", ".", "ReadCloser", ")", "{", "io", ".", "CopyN", "(", "ioutil", ".", "Discard", ",", "body", ",", "10", "*", "1024", ")", "\n", "body", ".", "Close", "(", ")", "\n", "}" ]
// drainAndClose will make an attempt at flushing and closing the body so that the // underlying connection can be reused. It will not read more than 10KB.
[ "drainAndClose", "will", "make", "an", "attempt", "at", "flushing", "and", "closing", "the", "body", "so", "that", "the", "underlying", "connection", "can", "be", "reused", ".", "It", "will", "not", "read", "more", "than", "10KB", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L268-L271
148,330
FiloSottile/b2
b2.go
BucketByID
func (c *Client) BucketByID(id string) *Bucket { return &Bucket{ID: id, c: c} }
go
func (c *Client) BucketByID(id string) *Bucket { return &Bucket{ID: id, c: c} }
[ "func", "(", "c", "*", "Client", ")", "BucketByID", "(", "id", "string", ")", "*", "Bucket", "{", "return", "&", "Bucket", "{", "ID", ":", "id", ",", "c", ":", "c", "}", "\n", "}" ]
// BucketByID returns a Bucket bound to the Client. It does NOT check that the // bucket actually exists, or perform any network operation.
[ "BucketByID", "returns", "a", "Bucket", "bound", "to", "the", "Client", ".", "It", "does", "NOT", "check", "that", "the", "bucket", "actually", "exists", "or", "perform", "any", "network", "operation", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L293-L295
148,331
FiloSottile/b2
b2.go
BucketByName
func (c *Client) BucketByName(name string, createIfNotExists bool) (*BucketInfo, error) { bs, err := c.Buckets() if err != nil { return nil, err } for _, b := range bs { if b.Name == name { return b, nil } } if !createIfNotExists { return nil, errors.New("bucket not found: " + name) } return c.Create...
go
func (c *Client) BucketByName(name string, createIfNotExists bool) (*BucketInfo, error) { bs, err := c.Buckets() if err != nil { return nil, err } for _, b := range bs { if b.Name == name { return b, nil } } if !createIfNotExists { return nil, errors.New("bucket not found: " + name) } return c.Create...
[ "func", "(", "c", "*", "Client", ")", "BucketByName", "(", "name", "string", ",", "createIfNotExists", "bool", ")", "(", "*", "BucketInfo", ",", "error", ")", "{", "bs", ",", "err", ":=", "c", ".", "Buckets", "(", ")", "\n", "if", "err", "!=", "nil...
// BucketByName returns the Bucket with the given name. If such a bucket is not // found and createIfNotExists is true, CreateBucket is called with allPublic set // to false. Otherwise, an error is returned.
[ "BucketByName", "returns", "the", "Bucket", "with", "the", "given", "name", ".", "If", "such", "a", "bucket", "is", "not", "found", "and", "createIfNotExists", "is", "true", "CreateBucket", "is", "called", "with", "allPublic", "set", "to", "false", ".", "Oth...
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L300-L314
148,332
FiloSottile/b2
b2.go
Buckets
func (c *Client) Buckets() ([]*BucketInfo, error) { res, err := c.doRequest("b2_list_buckets", map[string]interface{}{ "accountId": c.accountID, }) if err != nil { return nil, err } defer drainAndClose(res.Body) var buckets struct { Buckets []struct { BucketID, BucketName, BucketType string } } if er...
go
func (c *Client) Buckets() ([]*BucketInfo, error) { res, err := c.doRequest("b2_list_buckets", map[string]interface{}{ "accountId": c.accountID, }) if err != nil { return nil, err } defer drainAndClose(res.Body) var buckets struct { Buckets []struct { BucketID, BucketName, BucketType string } } if er...
[ "func", "(", "c", "*", "Client", ")", "Buckets", "(", ")", "(", "[", "]", "*", "BucketInfo", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "doRequest", "(", "\"", "\"", ",", "map", "[", "string", "]", "interface", "{", "}", "{", ...
// Buckets returns a list of buckets sorted by name.
[ "Buckets", "returns", "a", "list", "of", "buckets", "sorted", "by", "name", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L317-L345
148,333
FiloSottile/b2
b2.go
CreateBucket
func (c *Client) CreateBucket(name string, allPublic bool) (*BucketInfo, error) { bucketType := "allPrivate" if allPublic { bucketType = "allPublic" } res, err := c.doRequest("b2_create_bucket", map[string]interface{}{ "accountId": c.accountID, "bucketName": name, "bucketType": bucketType, }) if err != n...
go
func (c *Client) CreateBucket(name string, allPublic bool) (*BucketInfo, error) { bucketType := "allPrivate" if allPublic { bucketType = "allPublic" } res, err := c.doRequest("b2_create_bucket", map[string]interface{}{ "accountId": c.accountID, "bucketName": name, "bucketType": bucketType, }) if err != n...
[ "func", "(", "c", "*", "Client", ")", "CreateBucket", "(", "name", "string", ",", "allPublic", "bool", ")", "(", "*", "BucketInfo", ",", "error", ")", "{", "bucketType", ":=", "\"", "\"", "\n", "if", "allPublic", "{", "bucketType", "=", "\"", "\"", "...
// CreateBucket creates a bucket with b2_create_bucket. If allPublic is true, // files in this bucket can be downloaded by anybody.
[ "CreateBucket", "creates", "a", "bucket", "with", "b2_create_bucket", ".", "If", "allPublic", "is", "true", "files", "in", "this", "bucket", "can", "be", "downloaded", "by", "anybody", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L349-L376
148,334
FiloSottile/b2
b2.go
Delete
func (b *Bucket) Delete() error { res, err := b.c.doRequest("b2_delete_bucket", map[string]interface{}{ "accountId": b.c.accountID, "bucketId": b.ID, }) if err != nil { return err } drainAndClose(res.Body) return nil }
go
func (b *Bucket) Delete() error { res, err := b.c.doRequest("b2_delete_bucket", map[string]interface{}{ "accountId": b.c.accountID, "bucketId": b.ID, }) if err != nil { return err } drainAndClose(res.Body) return nil }
[ "func", "(", "b", "*", "Bucket", ")", "Delete", "(", ")", "error", "{", "res", ",", "err", ":=", "b", ".", "c", ".", "doRequest", "(", "\"", "\"", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "b", ".", "c", "...
// Delete calls b2_delete_bucket. After this call succeeds the Bucket object // becomes invalid and any other calls will fail.
[ "Delete", "calls", "b2_delete_bucket", ".", "After", "this", "call", "succeeds", "the", "Bucket", "object", "becomes", "invalid", "and", "any", "other", "calls", "will", "fail", "." ]
b197f7a2c317098d18afe80f0d6789782d52a090
https://github.com/FiloSottile/b2/blob/b197f7a2c317098d18afe80f0d6789782d52a090/b2.go#L380-L390
148,335
jlhawn/go-crypto
crypto.go
New
func (h Hash) New() ResumableHash { if h > 0 && h < maxHash { f := hashes[h] if f != nil { return f() } } panic("crypto: requested hash function #" + strconv.Itoa(int(h)) + " is unavailable") }
go
func (h Hash) New() ResumableHash { if h > 0 && h < maxHash { f := hashes[h] if f != nil { return f() } } panic("crypto: requested hash function #" + strconv.Itoa(int(h)) + " is unavailable") }
[ "func", "(", "h", "Hash", ")", "New", "(", ")", "ResumableHash", "{", "if", "h", ">", "0", "&&", "h", "<", "maxHash", "{", "f", ":=", "hashes", "[", "h", "]", "\n", "if", "f", "!=", "nil", "{", "return", "f", "(", ")", "\n", "}", "\n", "}",...
// New returns a new ResumableHash calculating the given hash function. New panics // if the hash function is not linked into the binary.
[ "New", "returns", "a", "new", "ResumableHash", "calculating", "the", "given", "hash", "function", ".", "New", "panics", "if", "the", "hash", "function", "is", "not", "linked", "into", "the", "binary", "." ]
cd738dde20f0b3782516181b0866c9bb9db47401
https://github.com/jlhawn/go-crypto/blob/cd738dde20f0b3782516181b0866c9bb9db47401/crypto.go#L64-L72
148,336
jlhawn/go-crypto
sha256/resume.go
State
func (d *digest) State() ([]byte, error) { var buf bytes.Buffer encoder := gob.NewEncoder(&buf) // We encode this way so that we do not have // to export these fields of the digest struct. vals := []interface{}{ d.h, d.x, d.nx, d.len, d.is224, } for _, val := range vals { if err := encoder.Encode(val); err...
go
func (d *digest) State() ([]byte, error) { var buf bytes.Buffer encoder := gob.NewEncoder(&buf) // We encode this way so that we do not have // to export these fields of the digest struct. vals := []interface{}{ d.h, d.x, d.nx, d.len, d.is224, } for _, val := range vals { if err := encoder.Encode(val); err...
[ "func", "(", "d", "*", "digest", ")", "State", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "encoder", ":=", "gob", ".", "NewEncoder", "(", "&", "buf", ")", "\n\n", "// We encode this way so tha...
// State returns a snapshot of the state of the digest.
[ "State", "returns", "a", "snapshot", "of", "the", "state", "of", "the", "digest", "." ]
cd738dde20f0b3782516181b0866c9bb9db47401
https://github.com/jlhawn/go-crypto/blob/cd738dde20f0b3782516181b0866c9bb9db47401/sha256/resume.go#L14-L31
148,337
jlhawn/go-crypto
sha256/resume.go
Restore
func (d *digest) Restore(state []byte) error { decoder := gob.NewDecoder(bytes.NewReader(state)) // We decode this way so that we do not have // to export these fields of the digest struct. vals := []interface{}{ &d.h, &d.x, &d.nx, &d.len, &d.is224, } for _, val := range vals { if err := decoder.Decode(val)...
go
func (d *digest) Restore(state []byte) error { decoder := gob.NewDecoder(bytes.NewReader(state)) // We decode this way so that we do not have // to export these fields of the digest struct. vals := []interface{}{ &d.h, &d.x, &d.nx, &d.len, &d.is224, } for _, val := range vals { if err := decoder.Decode(val)...
[ "func", "(", "d", "*", "digest", ")", "Restore", "(", "state", "[", "]", "byte", ")", "error", "{", "decoder", ":=", "gob", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "state", ")", ")", "\n\n", "// We decode this way so that we do not have", "...
// Restore resets the digest to the given state.
[ "Restore", "resets", "the", "digest", "to", "the", "given", "state", "." ]
cd738dde20f0b3782516181b0866c9bb9db47401
https://github.com/jlhawn/go-crypto/blob/cd738dde20f0b3782516181b0866c9bb9db47401/sha256/resume.go#L34-L50
148,338
TV4/env
env.go
String
func (c *client) String(key, fallback string) string { if v := c.Getenv(key); v != "" { return v } return fallback }
go
func (c *client) String(key, fallback string) string { if v := c.Getenv(key); v != "" { return v } return fallback }
[ "func", "(", "c", "*", "client", ")", "String", "(", "key", ",", "fallback", "string", ")", "string", "{", "if", "v", ":=", "c", ".", "Getenv", "(", "key", ")", ";", "v", "!=", "\"", "\"", "{", "return", "v", "\n", "}", "\n\n", "return", "fallb...
// String returns a string from the ENV, or fallback variable
[ "String", "returns", "a", "string", "from", "the", "ENV", "or", "fallback", "variable" ]
67268deb0d812467fba857cde331c7df97200601
https://github.com/TV4/env/blob/67268deb0d812467fba857cde331c7df97200601/env.go#L146-L152
148,339
stretchr/pat
start/start.go
StopAll
func StopAll(stopGrace time.Duration, startStoppers ...StartStopper) <-chan stop.Signal { stoppers := make([]stop.Stopper, len(startStoppers)) for i, ss := range startStoppers { stoppers[i] = ss.(stop.Stopper) } return stop.All(stopGrace, stoppers...) }
go
func StopAll(stopGrace time.Duration, startStoppers ...StartStopper) <-chan stop.Signal { stoppers := make([]stop.Stopper, len(startStoppers)) for i, ss := range startStoppers { stoppers[i] = ss.(stop.Stopper) } return stop.All(stopGrace, stoppers...) }
[ "func", "StopAll", "(", "stopGrace", "time", ".", "Duration", ",", "startStoppers", "...", "StartStopper", ")", "<-", "chan", "stop", ".", "Signal", "{", "stoppers", ":=", "make", "(", "[", "]", "stop", ".", "Stopper", ",", "len", "(", "startStoppers", "...
// StopAll stops all StartStopper types and returns another channel // which will close once all things have finished stopping. // For more information, see stop.All.
[ "StopAll", "stops", "all", "StartStopper", "types", "and", "returns", "another", "channel", "which", "will", "close", "once", "all", "things", "have", "finished", "stopping", ".", "For", "more", "information", "see", "stop", ".", "All", "." ]
f7fe051f2b9bcaca162b38de4f93c9a8457160b9
https://github.com/stretchr/pat/blob/f7fe051f2b9bcaca162b38de4f93c9a8457160b9/start/start.go#L77-L83
148,340
gugemichael/nimo4go
config.go
NewConfigLoader
func NewConfigLoader(file *os.File) *ConfigLoader { return &ConfigLoader{conf: file, separator: DefaultSeparator} }
go
func NewConfigLoader(file *os.File) *ConfigLoader { return &ConfigLoader{conf: file, separator: DefaultSeparator} }
[ "func", "NewConfigLoader", "(", "file", "*", "os", ".", "File", ")", "*", "ConfigLoader", "{", "return", "&", "ConfigLoader", "{", "conf", ":", "file", ",", "separator", ":", "DefaultSeparator", "}", "\n", "}" ]
// NewConfigLoader new loader
[ "NewConfigLoader", "new", "loader" ]
cbcfac21339d78efaed9ed09dcba7296d9976118
https://github.com/gugemichael/nimo4go/blob/cbcfac21339d78efaed9ed09dcba7296d9976118/config.go#L36-L38
148,341
stretchr/pat
sleep/sleep.go
New
func New() Sleeper { abort := make(chan struct{}) return &sleeper{ sleep: func(d time.Duration) Action { select { case <-abort: return Abort case <-time.After(d): return carryon } }, abort: abort, } }
go
func New() Sleeper { abort := make(chan struct{}) return &sleeper{ sleep: func(d time.Duration) Action { select { case <-abort: return Abort case <-time.After(d): return carryon } }, abort: abort, } }
[ "func", "New", "(", ")", "Sleeper", "{", "abort", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "return", "&", "sleeper", "{", "sleep", ":", "func", "(", "d", "time", ".", "Duration", ")", "Action", "{", "select", "{", "case", "<-", "...
// New creates a new Sleeper.
[ "New", "creates", "a", "new", "Sleeper", "." ]
f7fe051f2b9bcaca162b38de4f93c9a8457160b9
https://github.com/stretchr/pat/blob/f7fe051f2b9bcaca162b38de4f93c9a8457160b9/sleep/sleep.go#L56-L69
148,342
cirello-io/HumorChecker
checker.go
Analyze
func Analyze(phrase string) FullScore { analysis := calculateScore(phrase) return FullScore{ Score: analysis.positivityScore - analysis.negativityScore, Comparative: analysis.positivityComparative - analysis.negativityComparative, Positive: renderPositiveScore(analysis), Negative: renderNegativeS...
go
func Analyze(phrase string) FullScore { analysis := calculateScore(phrase) return FullScore{ Score: analysis.positivityScore - analysis.negativityScore, Comparative: analysis.positivityComparative - analysis.negativityComparative, Positive: renderPositiveScore(analysis), Negative: renderNegativeS...
[ "func", "Analyze", "(", "phrase", "string", ")", "FullScore", "{", "analysis", ":=", "calculateScore", "(", "phrase", ")", "\n\n", "return", "FullScore", "{", "Score", ":", "analysis", ".", "positivityScore", "-", "analysis", ".", "negativityScore", ",", "Comp...
// Analyze calculates overall sentiment
[ "Analyze", "calculates", "overall", "sentiment" ]
647d77cd770c2df9de26a583a2d950f3038828d7
https://github.com/cirello-io/HumorChecker/blob/647d77cd770c2df9de26a583a2d950f3038828d7/checker.go#L150-L159
148,343
cirello-io/supervisor
supervisor.go
Cancelations
func (s *Supervisor) Cancelations() map[string]context.CancelFunc { svclist := make(map[string]context.CancelFunc) s.mu.Lock() for k, v := range s.cancelations { svclist[k] = v } s.mu.Unlock() return svclist }
go
func (s *Supervisor) Cancelations() map[string]context.CancelFunc { svclist := make(map[string]context.CancelFunc) s.mu.Lock() for k, v := range s.cancelations { svclist[k] = v } s.mu.Unlock() return svclist }
[ "func", "(", "s", "*", "Supervisor", ")", "Cancelations", "(", ")", "map", "[", "string", "]", "context", ".", "CancelFunc", "{", "svclist", ":=", "make", "(", "map", "[", "string", "]", "context", ".", "CancelFunc", ")", "\n", "s", ".", "mu", ".", ...
// Cancelations return a list of services names and their cancelation calls. // These calls be used to force a service restart.
[ "Cancelations", "return", "a", "list", "of", "services", "names", "and", "their", "cancelation", "calls", ".", "These", "calls", "be", "used", "to", "force", "a", "service", "restart", "." ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/supervisor.go#L172-L180
148,344
cirello-io/supervisor
supervisor.go
Add
func (s *Supervisor) Add(service Service, opts ...ServiceOption) { s.addService(service, opts...) }
go
func (s *Supervisor) Add(service Service, opts ...ServiceOption) { s.addService(service, opts...) }
[ "func", "(", "s", "*", "Supervisor", ")", "Add", "(", "service", "Service", ",", "opts", "...", "ServiceOption", ")", "{", "s", ".", "addService", "(", "service", ",", "opts", "...", ")", "\n", "}" ]
// Add inserts into the Supervisor tree a new permanent service. If the // Supervisor is already started, it will start it automatically.
[ "Add", "inserts", "into", "the", "Supervisor", "tree", "a", "new", "permanent", "service", ".", "If", "the", "Supervisor", "is", "already", "started", "it", "will", "start", "it", "automatically", "." ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/supervisor.go#L184-L186
148,345
cirello-io/supervisor
supervisor.go
AddFunc
func (s *Supervisor) AddFunc(f func(context.Context), opts ...ServiceOption) string { svc := &funcsvc{ id: funcSvcID(), f: f, } s.addService(svc, opts...) return svc.String() }
go
func (s *Supervisor) AddFunc(f func(context.Context), opts ...ServiceOption) string { svc := &funcsvc{ id: funcSvcID(), f: f, } s.addService(svc, opts...) return svc.String() }
[ "func", "(", "s", "*", "Supervisor", ")", "AddFunc", "(", "f", "func", "(", "context", ".", "Context", ")", ",", "opts", "...", "ServiceOption", ")", "string", "{", "svc", ":=", "&", "funcsvc", "{", "id", ":", "funcSvcID", "(", ")", ",", "f", ":", ...
// AddFunc inserts into the Supervisor tree a new permanent anonymous service. // If the Supervisor is already started, it will start it automatically.
[ "AddFunc", "inserts", "into", "the", "Supervisor", "tree", "a", "new", "permanent", "anonymous", "service", ".", "If", "the", "Supervisor", "is", "already", "started", "it", "will", "start", "it", "automatically", "." ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/supervisor.go#L190-L197
148,346
cirello-io/supervisor
supervisor.go
Remove
func (s *Supervisor) Remove(name string) { s.prepare() s.mu.Lock() defer s.mu.Unlock() if _, ok := s.services[name]; !ok { return } delete(s.services, name) for i, n := range s.svcorder { if name == n { s.svcorder = append(s.svcorder[:i], s.svcorder[i+1:]...) break } } if c, ok := s.termination...
go
func (s *Supervisor) Remove(name string) { s.prepare() s.mu.Lock() defer s.mu.Unlock() if _, ok := s.services[name]; !ok { return } delete(s.services, name) for i, n := range s.svcorder { if name == n { s.svcorder = append(s.svcorder[:i], s.svcorder[i+1:]...) break } } if c, ok := s.termination...
[ "func", "(", "s", "*", "Supervisor", ")", "Remove", "(", "name", "string", ")", "{", "s", ".", "prepare", "(", ")", "\n\n", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "_", ",", ...
// Remove stops the service in the Supervisor tree and remove from it.
[ "Remove", "stops", "the", "service", "in", "the", "Supervisor", "tree", "and", "remove", "from", "it", "." ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/supervisor.go#L220-L246
148,347
cirello-io/supervisor
supervisor.go
Services
func (s *Supervisor) Services() map[string]Service { svclist := make(map[string]Service) s.mu.Lock() for k, v := range s.services { svclist[k] = v.svc } s.mu.Unlock() return svclist }
go
func (s *Supervisor) Services() map[string]Service { svclist := make(map[string]Service) s.mu.Lock() for k, v := range s.services { svclist[k] = v.svc } s.mu.Unlock() return svclist }
[ "func", "(", "s", "*", "Supervisor", ")", "Services", "(", ")", "map", "[", "string", "]", "Service", "{", "svclist", ":=", "make", "(", "map", "[", "string", "]", "Service", ")", "\n", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "k", "...
// Services return a list of services
[ "Services", "return", "a", "list", "of", "services" ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/supervisor.go#L264-L272
148,348
nanobox-io/nanobox-boxfile
boxfile.go
NewFromPath
func NewFromPath(path string) Boxfile { raw, _ := ioutil.ReadFile(path) return New(raw) }
go
func NewFromPath(path string) Boxfile { raw, _ := ioutil.ReadFile(path) return New(raw) }
[ "func", "NewFromPath", "(", "path", "string", ")", "Boxfile", "{", "raw", ",", "_", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "return", "New", "(", "raw", ")", "\n", "}" ]
// NewFromPath creates a new boxfile from a file instead of raw bytes
[ "NewFromPath", "creates", "a", "new", "boxfile", "from", "a", "file", "instead", "of", "raw", "bytes" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L18-L21
148,349
nanobox-io/nanobox-boxfile
boxfile.go
New
func New(raw []byte) Boxfile { box := Boxfile{ raw: raw, Parsed: make(map[string]interface{}), } box.parse() return box }
go
func New(raw []byte) Boxfile { box := Boxfile{ raw: raw, Parsed: make(map[string]interface{}), } box.parse() return box }
[ "func", "New", "(", "raw", "[", "]", "byte", ")", "Boxfile", "{", "box", ":=", "Boxfile", "{", "raw", ":", "raw", ",", "Parsed", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ",", "}", "\n", "box", ".", "parse", "(", ...
// New returns a boxfile object from raw data
[ "New", "returns", "a", "boxfile", "object", "from", "raw", "data" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L24-L31
148,350
nanobox-io/nanobox-boxfile
boxfile.go
Node
func (self Boxfile) Node(name string) (box Boxfile) { switch self.Parsed[name].(type) { case map[string]interface{}: box.Parsed = self.Parsed[name].(map[string]interface{}) box.FillRaw() box.Valid = true case map[interface{}]interface{}: box.Parsed = convertMap(self.Parsed[name].(map[interface{}]i...
go
func (self Boxfile) Node(name string) (box Boxfile) { switch self.Parsed[name].(type) { case map[string]interface{}: box.Parsed = self.Parsed[name].(map[string]interface{}) box.FillRaw() box.Valid = true case map[interface{}]interface{}: box.Parsed = convertMap(self.Parsed[name].(map[interface{}]i...
[ "func", "(", "self", "Boxfile", ")", "Node", "(", "name", "string", ")", "(", "box", "Boxfile", ")", "{", "switch", "self", ".", "Parsed", "[", "name", "]", ".", "(", "type", ")", "{", "case", "map", "[", "string", "]", "interface", "{", "}", ":"...
// Node returns just a specific node from the boxfile // if the object is a sub hash it returns a boxfile object // this allows Node to be chained if you know the data
[ "Node", "returns", "just", "a", "specific", "node", "from", "the", "boxfile", "if", "the", "object", "is", "a", "sub", "hash", "it", "returns", "a", "boxfile", "object", "this", "allows", "Node", "to", "be", "chained", "if", "you", "know", "the", "data" ...
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L43-L57
148,351
nanobox-io/nanobox-boxfile
boxfile.go
convertArray
func convertArray(in []interface{}) []interface{} { rtn := []interface{}{} for _, val := range in { var newValue interface{} switch val.(type) { case []interface{}: newValue = convertArray(val.([]interface{})) case map[interface{}]interface{}: newValue = convertMap(val.(map[inter...
go
func convertArray(in []interface{}) []interface{} { rtn := []interface{}{} for _, val := range in { var newValue interface{} switch val.(type) { case []interface{}: newValue = convertArray(val.([]interface{})) case map[interface{}]interface{}: newValue = convertMap(val.(map[inter...
[ "func", "convertArray", "(", "in", "[", "]", "interface", "{", "}", ")", "[", "]", "interface", "{", "}", "{", "rtn", ":=", "[", "]", "interface", "{", "}", "{", "}", "\n", "for", "_", ",", "val", ":=", "range", "in", "{", "var", "newValue", "i...
// convert any sub values in an array that may be a map of interface interfaces
[ "convert", "any", "sub", "values", "in", "an", "array", "that", "may", "be", "a", "map", "of", "interface", "interfaces" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L88-L103
148,352
nanobox-io/nanobox-boxfile
boxfile.go
Nodes
func (b Boxfile) Nodes(types ...string) (rtn []string) { if len(types) == 0 { for key, _ := range b.Parsed { rtn = append(rtn, key) } return } for _, t := range types { for key, _ := range b.Parsed { nodeType := regexp.MustCompile(`\..+`).ReplaceAllString(key, "") switch t { ...
go
func (b Boxfile) Nodes(types ...string) (rtn []string) { if len(types) == 0 { for key, _ := range b.Parsed { rtn = append(rtn, key) } return } for _, t := range types { for key, _ := range b.Parsed { nodeType := regexp.MustCompile(`\..+`).ReplaceAllString(key, "") switch t { ...
[ "func", "(", "b", "Boxfile", ")", "Nodes", "(", "types", "...", "string", ")", "(", "rtn", "[", "]", "string", ")", "{", "if", "len", "(", "types", ")", "==", "0", "{", "for", "key", ",", "_", ":=", "range", "b", ".", "Parsed", "{", "rtn", "=...
// list nodes // allow the user to specify which types of nodes your interested in
[ "list", "nodes", "allow", "the", "user", "to", "specify", "which", "types", "of", "nodes", "your", "interested", "in" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L204-L238
148,353
nanobox-io/nanobox-boxfile
boxfile.go
Merge
func (self *Boxfile) Merge(box Boxfile) { for key, val := range box.Parsed { switch self.Parsed[key].(type) { case map[string]interface{}, map[interface{}]interface{}: sub := self.Node(key) sub.Merge(box.Node(key)) self.Parsed[key] = sub.Parsed default: self.Parsed[key] = val }...
go
func (self *Boxfile) Merge(box Boxfile) { for key, val := range box.Parsed { switch self.Parsed[key].(type) { case map[string]interface{}, map[interface{}]interface{}: sub := self.Node(key) sub.Merge(box.Node(key)) self.Parsed[key] = sub.Parsed default: self.Parsed[key] = val }...
[ "func", "(", "self", "*", "Boxfile", ")", "Merge", "(", "box", "Boxfile", ")", "{", "for", "key", ",", "val", ":=", "range", "box", ".", "Parsed", "{", "switch", "self", ".", "Parsed", "[", "key", "]", ".", "(", "type", ")", "{", "case", "map", ...
// Merge puts a new boxfile data ontop of your existing boxfile
[ "Merge", "puts", "a", "new", "boxfile", "data", "ontop", "of", "your", "existing", "boxfile" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L241-L252
148,354
nanobox-io/nanobox-boxfile
boxfile.go
MergeProc
func (self *Boxfile) MergeProc(box Boxfile) { for key, val := range box.Parsed { self.Parsed[key] = map[string]interface{}{"exec": val} } }
go
func (self *Boxfile) MergeProc(box Boxfile) { for key, val := range box.Parsed { self.Parsed[key] = map[string]interface{}{"exec": val} } }
[ "func", "(", "self", "*", "Boxfile", ")", "MergeProc", "(", "box", "Boxfile", ")", "{", "for", "key", ",", "val", ":=", "range", "box", ".", "Parsed", "{", "self", ".", "Parsed", "[", "key", "]", "=", "map", "[", "string", "]", "interface", "{", ...
// MergeProc drops a procfile into the existing boxfile
[ "MergeProc", "drops", "a", "procfile", "into", "the", "existing", "boxfile" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L255-L259
148,355
nanobox-io/nanobox-boxfile
boxfile.go
AddStorageNode
func (self *Boxfile) AddStorageNode() { for _, node := range self.Nodes() { name := regexp.MustCompile(`\d+`).ReplaceAllString(node, "") if (name == "web" || name == "worker") && self.Node(node).Value("network_dirs") != nil { found := false for _, storage := range self.Node(node).Node("network_dir...
go
func (self *Boxfile) AddStorageNode() { for _, node := range self.Nodes() { name := regexp.MustCompile(`\d+`).ReplaceAllString(node, "") if (name == "web" || name == "worker") && self.Node(node).Value("network_dirs") != nil { found := false for _, storage := range self.Node(node).Node("network_dir...
[ "func", "(", "self", "*", "Boxfile", ")", "AddStorageNode", "(", ")", "{", "for", "_", ",", "node", ":=", "range", "self", ".", "Nodes", "(", ")", "{", "name", ":=", "regexp", ".", "MustCompile", "(", "`\\d+`", ")", ".", "ReplaceAllString", "(", "nod...
// Adds any missing storage nodes that are implied in the web => network_dirs but not // explicitly placed inside the root as a nfs node
[ "Adds", "any", "missing", "storage", "nodes", "that", "are", "implied", "in", "the", "web", "=", ">", "network_dirs", "but", "not", "explicitly", "placed", "inside", "the", "root", "as", "a", "nfs", "node" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L263-L283
148,356
nanobox-io/nanobox-boxfile
boxfile.go
FillRaw
func (b *Boxfile) FillRaw() { b.raw, _ = goyaml.Marshal(b.Parsed) }
go
func (b *Boxfile) FillRaw() { b.raw, _ = goyaml.Marshal(b.Parsed) }
[ "func", "(", "b", "*", "Boxfile", ")", "FillRaw", "(", ")", "{", "b", ".", "raw", ",", "_", "=", "goyaml", ".", "Marshal", "(", "b", ".", "Parsed", ")", "\n", "}" ]
// FillRaw is used when a boxfile is create from an existing boxfile and we want to // see what the raw would look like
[ "FillRaw", "is", "used", "when", "a", "boxfile", "is", "create", "from", "an", "existing", "boxfile", "and", "we", "want", "to", "see", "what", "the", "raw", "would", "look", "like" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L291-L293
148,357
nanobox-io/nanobox-boxfile
boxfile.go
parse
func (b *Boxfile) parse() { // if im given no data it is not a valid boxfile if len(b.raw) == 0 { b.Valid = false return } err := goyaml.Unmarshal(b.raw, &b.Parsed) if err != nil { b.Valid = false } else { b.Valid = true } b.ensureValid() }
go
func (b *Boxfile) parse() { // if im given no data it is not a valid boxfile if len(b.raw) == 0 { b.Valid = false return } err := goyaml.Unmarshal(b.raw, &b.Parsed) if err != nil { b.Valid = false } else { b.Valid = true } b.ensureValid() }
[ "func", "(", "b", "*", "Boxfile", ")", "parse", "(", ")", "{", "// if im given no data it is not a valid boxfile", "if", "len", "(", "b", ".", "raw", ")", "==", "0", "{", "b", ".", "Valid", "=", "false", "\n", "return", "\n", "}", "\n", "err", ":=", ...
// parse takes raw data and converts it to a map structure
[ "parse", "takes", "raw", "data", "and", "converts", "it", "to", "a", "map", "structure" ]
2fc39f6df5e0eb78582c906c60673a627cff7284
https://github.com/nanobox-io/nanobox-boxfile/blob/2fc39f6df5e0eb78582c906c60673a627cff7284/boxfile.go#L296-L310
148,358
nanobox-io/nanobox-router
health.go
readBodyString
func readBodyString(body io.ReadCloser) string { buf := new(bytes.Buffer) _, err := buf.ReadFrom(body) if err != nil { lumber.Trace("Failed to read body into string - %s", err.Error()) return "" } return buf.String() }
go
func readBodyString(body io.ReadCloser) string { buf := new(bytes.Buffer) _, err := buf.ReadFrom(body) if err != nil { lumber.Trace("Failed to read body into string - %s", err.Error()) return "" } return buf.String() }
[ "func", "readBodyString", "(", "body", "io", ".", "ReadCloser", ")", "string", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "_", ",", "err", ":=", "buf", ".", "ReadFrom", "(", "body", ")", "\n", "if", "err", "!=", "nil", "{", ...
// readBodyString reads the request body into a string for comparing
[ "readBodyString", "reads", "the", "request", "body", "into", "a", "string", "for", "comparing" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/health.go#L83-L92
148,359
nanobox-io/nanobox-router
health.go
checkHeader
func checkHeader(expected string, headers http.Header) bool { headerBits := strings.Split(expected, ":") if len(headerBits) != 2 { lumber.Trace("Failed to check header - bad format") return false } // check if it matches return headers.Get(headerBits[0]) == headerBits[1] }
go
func checkHeader(expected string, headers http.Header) bool { headerBits := strings.Split(expected, ":") if len(headerBits) != 2 { lumber.Trace("Failed to check header - bad format") return false } // check if it matches return headers.Get(headerBits[0]) == headerBits[1] }
[ "func", "checkHeader", "(", "expected", "string", ",", "headers", "http", ".", "Header", ")", "bool", "{", "headerBits", ":=", "strings", ".", "Split", "(", "expected", ",", "\"", "\"", ")", "\n", "if", "len", "(", "headerBits", ")", "!=", "2", "{", ...
// checkHeader checks if the contents of a specified header match
[ "checkHeader", "checks", "if", "the", "contents", "of", "a", "specified", "header", "match" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/health.go#L95-L104
148,360
cirello-io/supervisor
easy/easy.go
Add
func Add(ctx context.Context, f func(context.Context), opts ...supervisor.ServiceOption) (string, error) { name, ok := extractName(ctx) if !ok { return "", ErrNoSupervisorAttached } mu.Lock() svr, ok := supervisors[name] mu.Unlock() if !ok { panic("supervisor not found") } opts = append([]supervisor.Servic...
go
func Add(ctx context.Context, f func(context.Context), opts ...supervisor.ServiceOption) (string, error) { name, ok := extractName(ctx) if !ok { return "", ErrNoSupervisorAttached } mu.Lock() svr, ok := supervisors[name] mu.Unlock() if !ok { panic("supervisor not found") } opts = append([]supervisor.Servic...
[ "func", "Add", "(", "ctx", "context", ".", "Context", ",", "f", "func", "(", "context", ".", "Context", ")", ",", "opts", "...", "supervisor", ".", "ServiceOption", ")", "(", "string", ",", "error", ")", "{", "name", ",", "ok", ":=", "extractName", "...
// Add inserts supervised function to the attached supervisor, it launches // automatically. If the context is not correctly prepared, it returns an // ErrNoSupervisorAttached error. By default, the restart policy is Permanent.
[ "Add", "inserts", "supervised", "function", "to", "the", "attached", "supervisor", "it", "launches", "automatically", ".", "If", "the", "context", "is", "not", "correctly", "prepared", "it", "returns", "an", "ErrNoSupervisorAttached", "error", ".", "By", "default"...
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/easy/easy.go#L79-L93
148,361
cirello-io/supervisor
easy/easy.go
Remove
func Remove(ctx context.Context, name string) error { name, ok := extractName(ctx) if !ok { return ErrNoSupervisorAttached } mu.Lock() svr, ok := supervisors[name] mu.Unlock() if !ok { panic("supervisor not found") } svr.Remove(name) return nil }
go
func Remove(ctx context.Context, name string) error { name, ok := extractName(ctx) if !ok { return ErrNoSupervisorAttached } mu.Lock() svr, ok := supervisors[name] mu.Unlock() if !ok { panic("supervisor not found") } svr.Remove(name) return nil }
[ "func", "Remove", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "name", ",", "ok", ":=", "extractName", "(", "ctx", ")", "\n", "if", "!", "ok", "{", "return", "ErrNoSupervisorAttached", "\n", "}", "\n", "mu", ".", "...
// Remove stops and removes the given service from the attached supervisor. If // the context is not correctly prepared, it returns an ErrNoSupervisorAttached // error
[ "Remove", "stops", "and", "removes", "the", "given", "service", "from", "the", "attached", "supervisor", ".", "If", "the", "context", "is", "not", "correctly", "prepared", "it", "returns", "an", "ErrNoSupervisorAttached", "error" ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/easy/easy.go#L98-L111
148,362
cirello-io/supervisor
easy/easy.go
WithContext
func WithContext(ctx context.Context, opts ...SupervisorOption) context.Context { chosenName := fmt.Sprintf("supervisor-%d", rand.Uint64()) svr := &supervisor.Supervisor{ Name: chosenName, MaxRestarts: supervisor.AlwaysRestart, Log: func(interface{}) {}, } for _, opt := range opts { opt(svr)...
go
func WithContext(ctx context.Context, opts ...SupervisorOption) context.Context { chosenName := fmt.Sprintf("supervisor-%d", rand.Uint64()) svr := &supervisor.Supervisor{ Name: chosenName, MaxRestarts: supervisor.AlwaysRestart, Log: func(interface{}) {}, } for _, opt := range opts { opt(svr)...
[ "func", "WithContext", "(", "ctx", "context", ".", "Context", ",", "opts", "...", "SupervisorOption", ")", "context", ".", "Context", "{", "chosenName", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "rand", ".", "Uint64", "(", ")", ")", "\n\n", "s...
// WithContext takes a context and prepare it to be used by easy supervisor // package. Internally, it creates a supervisor in group mode. In this mode, // every time a service dies, the whole supervisor is restarted.
[ "WithContext", "takes", "a", "context", "and", "prepare", "it", "to", "be", "used", "by", "easy", "supervisor", "package", ".", "Internally", "it", "creates", "a", "supervisor", "in", "group", "mode", ".", "In", "this", "mode", "every", "time", "a", "servi...
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/easy/easy.go#L116-L137
148,363
cirello-io/supervisor
easy/easy.go
WithLogger
func WithLogger(logger func(a ...interface{})) SupervisorOption { return func(s *supervisor.Supervisor) { s.Log = func(v interface{}) { logger(v) } } }
go
func WithLogger(logger func(a ...interface{})) SupervisorOption { return func(s *supervisor.Supervisor) { s.Log = func(v interface{}) { logger(v) } } }
[ "func", "WithLogger", "(", "logger", "func", "(", "a", "...", "interface", "{", "}", ")", ")", "SupervisorOption", "{", "return", "func", "(", "s", "*", "supervisor", ".", "Supervisor", ")", "{", "s", ".", "Log", "=", "func", "(", "v", "interface", "...
// WithLogger attaches a log function to the supervisor
[ "WithLogger", "attaches", "a", "log", "function", "to", "the", "supervisor" ]
9187b93bf5c1bf73b1a9884dfed11f993e79df21
https://github.com/cirello-io/supervisor/blob/9187b93bf5c1bf73b1a9884dfed11f993e79df21/easy/easy.go#L143-L149
148,364
nanobox-io/nanobox-router
handler.go
subdomainMatch
func subdomainMatch(requestHost string, r Route) bool { // if there is no subdomain, no need to worry about matching if r.SubDomain == "" { return true } subdomain := "" hostBits := strings.Split(requestHost, ".") if len(hostBits) > 2 { subdomain = strings.Join(hostBits[:len(hostBits)-2], ".") lumber.Trace...
go
func subdomainMatch(requestHost string, r Route) bool { // if there is no subdomain, no need to worry about matching if r.SubDomain == "" { return true } subdomain := "" hostBits := strings.Split(requestHost, ".") if len(hostBits) > 2 { subdomain = strings.Join(hostBits[:len(hostBits)-2], ".") lumber.Trace...
[ "func", "subdomainMatch", "(", "requestHost", "string", ",", "r", "Route", ")", "bool", "{", "// if there is no subdomain, no need to worry about matching", "if", "r", ".", "SubDomain", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n\n", "subdomain", ":=",...
// subdomainMatch checks if the request has a subdomain and if we have routes // that match that subdomain
[ "subdomainMatch", "checks", "if", "the", "request", "has", "a", "subdomain", "and", "if", "we", "have", "routes", "that", "match", "that", "subdomain" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/handler.go#L158-L174
148,365
nanobox-io/nanobox-router
handler.go
domainMatch
func domainMatch(requestHost string, r Route) bool { // if there is no domain, no need to worry about matching if r.Domain == "" { return true } domain := "" hostBits := strings.Split(requestHost, ".") if len(hostBits) >= 2 { domain = strings.Join(hostBits[len(hostBits)-2:], ".") lumber.Trace("[NANOBOX-ROUT...
go
func domainMatch(requestHost string, r Route) bool { // if there is no domain, no need to worry about matching if r.Domain == "" { return true } domain := "" hostBits := strings.Split(requestHost, ".") if len(hostBits) >= 2 { domain = strings.Join(hostBits[len(hostBits)-2:], ".") lumber.Trace("[NANOBOX-ROUT...
[ "func", "domainMatch", "(", "requestHost", "string", ",", "r", "Route", ")", "bool", "{", "// if there is no domain, no need to worry about matching", "if", "r", ".", "Domain", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "domain", ":=", "\"", "\"...
// domainMatch checks if the route has a domain and if the request matches
[ "domainMatch", "checks", "if", "the", "route", "has", "a", "domain", "and", "if", "the", "request", "matches" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/handler.go#L177-L191
148,366
nanobox-io/nanobox-router
handler.go
pathMatch
func pathMatch(requestPath string, r Route) bool { // if there is no path, no need to worry about matching (default to "/") if r.Path == "" { return true } match := false switch r.Path[len(r.Path)-1] { case '/': // check for parent dir match match = strings.HasPrefix(requestPath, r.Path) case '*': // che...
go
func pathMatch(requestPath string, r Route) bool { // if there is no path, no need to worry about matching (default to "/") if r.Path == "" { return true } match := false switch r.Path[len(r.Path)-1] { case '/': // check for parent dir match match = strings.HasPrefix(requestPath, r.Path) case '*': // che...
[ "func", "pathMatch", "(", "requestPath", "string", ",", "r", "Route", ")", "bool", "{", "// if there is no path, no need to worry about matching (default to \"/\")", "if", "r", ".", "Path", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "match", ":=", ...
// pathMatch checks if the route has a path and if the request matches
[ "pathMatch", "checks", "if", "the", "route", "has", "a", "path", "and", "if", "the", "request", "matches" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/handler.go#L194-L213
148,367
nanobox-io/nanobox-router
tls.go
SetDefaultCert
func SetDefaultCert(cert, key string) error { if cert == "" || key == "" { return fmt.Errorf("Default certificate cannot be empty") } c, err := tls.X509KeyPair([]byte(cert), []byte(key)) if err != nil { return fmt.Errorf("Failed to create cert from provided info - %s", err.Error()) } defaultCert = c certMu...
go
func SetDefaultCert(cert, key string) error { if cert == "" || key == "" { return fmt.Errorf("Default certificate cannot be empty") } c, err := tls.X509KeyPair([]byte(cert), []byte(key)) if err != nil { return fmt.Errorf("Failed to create cert from provided info - %s", err.Error()) } defaultCert = c certMu...
[ "func", "SetDefaultCert", "(", "cert", ",", "key", "string", ")", "error", "{", "if", "cert", "==", "\"", "\"", "||", "key", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "c", ",", "err", ":=", ...
// SetDefaultCert sets the default cert.
[ "SetDefaultCert", "sets", "the", "default", "cert", "." ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/tls.go#L112-L128
148,368
nanobox-io/nanobox-router
tls.go
UpdateCerts
func UpdateCerts(newKeys []KeyPair) error { newCerts := []tls.Certificate{} certs := []tls.Certificate{} for _, newKey := range newKeys { // create a Certificate from KeyPair cert, err := tls.X509KeyPair([]byte(newKey.Cert), []byte(newKey.Key)) if err == nil { newCerts = append(newCerts, cert) } else { ...
go
func UpdateCerts(newKeys []KeyPair) error { newCerts := []tls.Certificate{} certs := []tls.Certificate{} for _, newKey := range newKeys { // create a Certificate from KeyPair cert, err := tls.X509KeyPair([]byte(newKey.Cert), []byte(newKey.Key)) if err == nil { newCerts = append(newCerts, cert) } else { ...
[ "func", "UpdateCerts", "(", "newKeys", "[", "]", "KeyPair", ")", "error", "{", "newCerts", ":=", "[", "]", "tls", ".", "Certificate", "{", "}", "\n", "certs", ":=", "[", "]", "tls", ".", "Certificate", "{", "}", "\n", "for", "_", ",", "newKey", ":=...
// UpdateCerts replaces registered certificates with a new set and restart the // secure web server
[ "UpdateCerts", "replaces", "registered", "certificates", "with", "a", "new", "set", "and", "restart", "the", "secure", "web", "server" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/tls.go#L132-L166
148,369
stretchr/pat
stop/stop.go
All
func All(wait time.Duration, stoppers ...Stopper) <-chan Signal { all := Make() go func() { var allChans []<-chan Signal for _, stopper := range stoppers { go stopper.Stop(wait) allChans = append(allChans, stopper.StopChan()) } for _, ch := range allChans { <-ch } close(all) }() return all }
go
func All(wait time.Duration, stoppers ...Stopper) <-chan Signal { all := Make() go func() { var allChans []<-chan Signal for _, stopper := range stoppers { go stopper.Stop(wait) allChans = append(allChans, stopper.StopChan()) } for _, ch := range allChans { <-ch } close(all) }() return all }
[ "func", "All", "(", "wait", "time", ".", "Duration", ",", "stoppers", "...", "Stopper", ")", "<-", "chan", "Signal", "{", "all", ":=", "Make", "(", ")", "\n", "go", "func", "(", ")", "{", "var", "allChans", "[", "]", "<-", "chan", "Signal", "\n", ...
// All stops all Stopper types and returns another channel // which will close once all things have finished stopping.
[ "All", "stops", "all", "Stopper", "types", "and", "returns", "another", "channel", "which", "will", "close", "once", "all", "things", "have", "finished", "stopping", "." ]
f7fe051f2b9bcaca162b38de4f93c9a8457160b9
https://github.com/stretchr/pat/blob/f7fe051f2b9bcaca162b38de4f93c9a8457160b9/stop/stop.go#L43-L57
148,370
gugemichael/nimo4go
logger.go
NewLogHelper
func NewLogHelper(v ...interface{}) (*LogHelper, error) { mask := os.O_APPEND | os.O_RDWR | os.O_CREATE mylog := LogHelper{} // use stdout & stderr if len(v) == 0 { mylog.Logger[0] = log.New(os.Stdout, "TRACE - ", FLAGS) mylog.Logger[1] = log.New(os.Stderr, "ERROR - ", FLAGS) return &mylog, nil } fileName ...
go
func NewLogHelper(v ...interface{}) (*LogHelper, error) { mask := os.O_APPEND | os.O_RDWR | os.O_CREATE mylog := LogHelper{} // use stdout & stderr if len(v) == 0 { mylog.Logger[0] = log.New(os.Stdout, "TRACE - ", FLAGS) mylog.Logger[1] = log.New(os.Stderr, "ERROR - ", FLAGS) return &mylog, nil } fileName ...
[ "func", "NewLogHelper", "(", "v", "...", "interface", "{", "}", ")", "(", "*", "LogHelper", ",", "error", ")", "{", "mask", ":=", "os", ".", "O_APPEND", "|", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", "\n", "mylog", ":=", "LogHelper", "{", "}...
// NewLogHelper new logger
[ "NewLogHelper", "new", "logger" ]
cbcfac21339d78efaed9ed09dcba7296d9976118
https://github.com/gugemichael/nimo4go/blob/cbcfac21339d78efaed9ed09dcba7296d9976118/logger.go#L37-L68
148,371
CenturyLinkCloud/clc-sdk
api/api.go
NewConfig
func NewConfig(username, password string) (Config, error) { alias := os.Getenv("CLC_ALIAS") agent := userAgentDefault if v := os.Getenv("CLC_USER_AGENT"); v != "" { agent = v } base := baseUriDefault if v := os.Getenv("CLC_BASE_URL"); v != "" { base = v } uri, err := url.Parse(base) return Config{ User: ...
go
func NewConfig(username, password string) (Config, error) { alias := os.Getenv("CLC_ALIAS") agent := userAgentDefault if v := os.Getenv("CLC_USER_AGENT"); v != "" { agent = v } base := baseUriDefault if v := os.Getenv("CLC_BASE_URL"); v != "" { base = v } uri, err := url.Parse(base) return Config{ User: ...
[ "func", "NewConfig", "(", "username", ",", "password", "string", ")", "(", "Config", ",", "error", ")", "{", "alias", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "agent", ":=", "userAgentDefault", "\n", "if", "v", ":=", "os", ".", "Getenv"...
// NewConfig takes credentials and returns a Config object that may be further customized. // Defaults for Alias, BaseURL, and UserAgent will be taken from respective env vars.
[ "NewConfig", "takes", "credentials", "and", "returns", "a", "Config", "object", "that", "may", "be", "further", "customized", ".", "Defaults", "for", "Alias", "BaseURL", "and", "UserAgent", "will", "be", "taken", "from", "respective", "env", "vars", "." ]
f62483cfb14defc08e6de8ae223fa75f9f95f264
https://github.com/CenturyLinkCloud/clc-sdk/blob/f62483cfb14defc08e6de8ae223fa75f9f95f264/api/api.go#L182-L202
148,372
nanobox-io/nanobox-router
router.go
UpdateRoutes
func UpdateRoutes(newRoutes []Route) error { for i := range newRoutes { if newRoutes[i].ExpectedCode == 0 { newRoutes[i].ExpectedCode = 200 } if newRoutes[i].Timeout == 0 { newRoutes[i].Timeout = 3000 } if newRoutes[i].Attempts == 0 { newRoutes[i].Attempts = 3 } for _, tgt := range newRoutes[i]....
go
func UpdateRoutes(newRoutes []Route) error { for i := range newRoutes { if newRoutes[i].ExpectedCode == 0 { newRoutes[i].ExpectedCode = 200 } if newRoutes[i].Timeout == 0 { newRoutes[i].Timeout = 3000 } if newRoutes[i].Attempts == 0 { newRoutes[i].Attempts = 3 } for _, tgt := range newRoutes[i]....
[ "func", "UpdateRoutes", "(", "newRoutes", "[", "]", "Route", ")", "error", "{", "for", "i", ":=", "range", "newRoutes", "{", "if", "newRoutes", "[", "i", "]", ".", "ExpectedCode", "==", "0", "{", "newRoutes", "[", "i", "]", ".", "ExpectedCode", "=", ...
// UpdateRoutes replaces registered routes with a new set and initializes their // proxies, if needed
[ "UpdateRoutes", "replaces", "registered", "routes", "with", "a", "new", "set", "and", "initializes", "their", "proxies", "if", "needed" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/router.go#L77-L105
148,373
nanobox-io/nanobox-router
router.go
initProxy
func (self *proxy) initProxy() error { if self.reverseProxy == nil { uri, err := url.Parse(self.targetUrl) if err != nil { return err } self.reverseProxy = NewSingleHostReverseProxy(uri, self.fwdPath, IgnoreUpstreamCerts, self.prefixPath) self.healthy = true // assume newly added nodes are healthy lumbe...
go
func (self *proxy) initProxy() error { if self.reverseProxy == nil { uri, err := url.Parse(self.targetUrl) if err != nil { return err } self.reverseProxy = NewSingleHostReverseProxy(uri, self.fwdPath, IgnoreUpstreamCerts, self.prefixPath) self.healthy = true // assume newly added nodes are healthy lumbe...
[ "func", "(", "self", "*", "proxy", ")", "initProxy", "(", ")", "error", "{", "if", "self", ".", "reverseProxy", "==", "nil", "{", "uri", ",", "err", ":=", "url", ".", "Parse", "(", "self", ".", "targetUrl", ")", "\n", "if", "err", "!=", "nil", "{...
// initProxy establishes the ReverseProxy
[ "initProxy", "establishes", "the", "ReverseProxy" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/router.go#L113-L124
148,374
nanobox-io/nanobox-router
router.go
Start
func Start(httpAddress, tlsAddress string) error { err := StartHTTP(httpAddress) if err != nil { return err } return StartTLS(tlsAddress) }
go
func Start(httpAddress, tlsAddress string) error { err := StartHTTP(httpAddress) if err != nil { return err } return StartTLS(tlsAddress) }
[ "func", "Start", "(", "httpAddress", ",", "tlsAddress", "string", ")", "error", "{", "err", ":=", "StartHTTP", "(", "httpAddress", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "StartTLS", "(", "tlsAddress", ")", ...
// Start starts both http and tls servers
[ "Start", "starts", "both", "http", "and", "tls", "servers" ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/router.go#L127-L133
148,375
nanobox-io/nanobox-router
http.go
StartHTTP
func StartHTTP(address string) error { var err error if httpListener != nil { httpListener.Close() } if address != "" { httpAddress = address } if httpAddress == "" { return fmt.Errorf("HTTP address not defined") } httpListener, err = net.Listen("tcp", httpAddress) if err != nil { return err } htt...
go
func StartHTTP(address string) error { var err error if httpListener != nil { httpListener.Close() } if address != "" { httpAddress = address } if httpAddress == "" { return fmt.Errorf("HTTP address not defined") } httpListener, err = net.Listen("tcp", httpAddress) if err != nil { return err } htt...
[ "func", "StartHTTP", "(", "address", "string", ")", "error", "{", "var", "err", "error", "\n", "if", "httpListener", "!=", "nil", "{", "httpListener", ".", "Close", "(", ")", "\n", "}", "\n\n", "if", "address", "!=", "\"", "\"", "{", "httpAddress", "="...
// Start the Http Listener. Intentionally handles http requests the same way as // tls.
[ "Start", "the", "Http", "Listener", ".", "Intentionally", "handles", "http", "requests", "the", "same", "way", "as", "tls", "." ]
8468a5929ca1694e7802bf4d462c66e82345e0b3
https://github.com/nanobox-io/nanobox-router/blob/8468a5929ca1694e7802bf4d462c66e82345e0b3/http.go#L25-L53
148,376
wendal/errors
errors.go
New
func New(text string) error { if AddStack { text += "\n" + string(debug.Stack()) } return &errorString{text} }
go
func New(text string) error { if AddStack { text += "\n" + string(debug.Stack()) } return &errorString{text} }
[ "func", "New", "(", "text", "string", ")", "error", "{", "if", "AddStack", "{", "text", "+=", "\"", "\\n", "\"", "+", "string", "(", "debug", ".", "Stack", "(", ")", ")", "\n", "}", "\n", "return", "&", "errorString", "{", "text", "}", "\n", "}" ...
// New returns an error that formats as the given text.
[ "New", "returns", "an", "error", "that", "formats", "as", "the", "given", "text", "." ]
7f31f4b264ec95ca86f90649fe4dca4a2a690f4a
https://github.com/wendal/errors/blob/7f31f4b264ec95ca86f90649fe4dca4a2a690f4a/errors.go#L16-L21
148,377
Financial-Times/service-status-go
httphandlers/buildinfo.go
BuildInfoHandler
func BuildInfoHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set(contentType, applicationJSON) if methodSupported(w, r) { if err := json.NewEncoder(w).Encode(buildinfo.GetBuildInfo()); err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write(error(err.Error())) } } }
go
func BuildInfoHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set(contentType, applicationJSON) if methodSupported(w, r) { if err := json.NewEncoder(w).Encode(buildinfo.GetBuildInfo()); err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write(error(err.Error())) } } }
[ "func", "BuildInfoHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "w", ".", "Header", "(", ")", ".", "Set", "(", "contentType", ",", "applicationJSON", ")", "\n", "if", "methodSupported", "(", "w", ",...
//BuildInfoHandler provides a JSON representation of the build-info.
[ "BuildInfoHandler", "provides", "a", "JSON", "representation", "of", "the", "build", "-", "info", "." ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/httphandlers/buildinfo.go#L17-L25
148,378
Financial-Times/service-status-go
httphandlers/ping.go
PingHandler
func PingHandler(w http.ResponseWriter, r *http.Request) { if methodSupported(w, r) { fmt.Fprintf(w, "pong") } }
go
func PingHandler(w http.ResponseWriter, r *http.Request) { if methodSupported(w, r) { fmt.Fprintf(w, "pong") } }
[ "func", "PingHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "methodSupported", "(", "w", ",", "r", ")", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\"", ")", "\n", "}", "\n\n", "}" ...
// PingHandler is a simple handler that always responds with pong as text
[ "PingHandler", "is", "a", "simple", "handler", "that", "always", "responds", "with", "pong", "as", "text" ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/httphandlers/ping.go#L16-L21
148,379
Financial-Times/service-status-go
httphandlers/good_to_go.go
NewGoodToGoHandler
func NewGoodToGoHandler(checker gtg.StatusChecker) func(http.ResponseWriter, *http.Request) { return goodToGoChecker{checker}.GoodToGoHandler }
go
func NewGoodToGoHandler(checker gtg.StatusChecker) func(http.ResponseWriter, *http.Request) { return goodToGoChecker{checker}.GoodToGoHandler }
[ "func", "NewGoodToGoHandler", "(", "checker", "gtg", ".", "StatusChecker", ")", "func", "(", "http", ".", "ResponseWriter", ",", "*", "http", ".", "Request", ")", "{", "return", "goodToGoChecker", "{", "checker", "}", ".", "GoodToGoHandler", "\n", "}" ]
// NewGoodToGoHandler is used to construct a new GoodToGoHandler
[ "NewGoodToGoHandler", "is", "used", "to", "construct", "a", "new", "GoodToGoHandler" ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/httphandlers/good_to_go.go#L18-L20
148,380
Financial-Times/service-status-go
httphandlers/good_to_go.go
GoodToGoHandler
func (checker goodToGoChecker) GoodToGoHandler(w http.ResponseWriter, r *http.Request) { if methodSupported(w, r) { w.Header().Set(contentType, plainText) w.Header().Set(cacheControl, noCache) status := checker.RunCheck() if status.GoodToGo { w.WriteHeader(http.StatusOK) w.Write([]byte(status.Message)) ...
go
func (checker goodToGoChecker) GoodToGoHandler(w http.ResponseWriter, r *http.Request) { if methodSupported(w, r) { w.Header().Set(contentType, plainText) w.Header().Set(cacheControl, noCache) status := checker.RunCheck() if status.GoodToGo { w.WriteHeader(http.StatusOK) w.Write([]byte(status.Message)) ...
[ "func", "(", "checker", "goodToGoChecker", ")", "GoodToGoHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "methodSupported", "(", "w", ",", "r", ")", "{", "w", ".", "Header", "(", ")", ".", "Se...
// GoodToGoHandler runs the status checks and sends an HTTP status message
[ "GoodToGoHandler", "runs", "the", "status", "checks", "and", "sends", "an", "HTTP", "status", "message" ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/httphandlers/good_to_go.go#L23-L36
148,381
Financial-Times/service-status-go
gtg/good_to_go.go
FailFastSequentialChecker
func FailFastSequentialChecker(checkers []StatusChecker) (checker StatusChecker) { f := func() Status { for i := range checkers { status := checkers[i].RunCheck() if !status.GoodToGo { return status } } status := Status{ GoodToGo: true, Message: "OK", } return status } return f }
go
func FailFastSequentialChecker(checkers []StatusChecker) (checker StatusChecker) { f := func() Status { for i := range checkers { status := checkers[i].RunCheck() if !status.GoodToGo { return status } } status := Status{ GoodToGo: true, Message: "OK", } return status } return f }
[ "func", "FailFastSequentialChecker", "(", "checkers", "[", "]", "StatusChecker", ")", "(", "checker", "StatusChecker", ")", "{", "f", ":=", "func", "(", ")", "Status", "{", "for", "i", ":=", "range", "checkers", "{", "status", ":=", "checkers", "[", "i", ...
// FailFastSequentialChecker composes multiple checkers into one that are executed in sequence. Execution stops as soon as on checker fails.
[ "FailFastSequentialChecker", "composes", "multiple", "checkers", "into", "one", "that", "are", "executed", "in", "sequence", ".", "Execution", "stops", "as", "soon", "as", "on", "checker", "fails", "." ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/gtg/good_to_go.go#L24-L39
148,382
Financial-Times/service-status-go
gtg/good_to_go.go
FailAtEndSequentialChecker
func FailAtEndSequentialChecker(checkers []StatusChecker) (checker StatusChecker) { f := func() Status { result := Status{ GoodToGo: true, Message: "OK", } for i := range checkers { status := checkers[i].RunCheck() if !status.GoodToGo { result.GoodToGo = false if result.Message == "OK" { ...
go
func FailAtEndSequentialChecker(checkers []StatusChecker) (checker StatusChecker) { f := func() Status { result := Status{ GoodToGo: true, Message: "OK", } for i := range checkers { status := checkers[i].RunCheck() if !status.GoodToGo { result.GoodToGo = false if result.Message == "OK" { ...
[ "func", "FailAtEndSequentialChecker", "(", "checkers", "[", "]", "StatusChecker", ")", "(", "checker", "StatusChecker", ")", "{", "f", ":=", "func", "(", ")", "Status", "{", "result", ":=", "Status", "{", "GoodToGo", ":", "true", ",", "Message", ":", "\"",...
// FailAtEndSequentialChecker composes multiple checkers into one that are executed in sequence. All checkers are executed.
[ "FailAtEndSequentialChecker", "composes", "multiple", "checkers", "into", "one", "that", "are", "executed", "in", "sequence", ".", "All", "checkers", "are", "executed", "." ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/gtg/good_to_go.go#L42-L62
148,383
Financial-Times/service-status-go
gtg/good_to_go.go
FailFastParallelCheck
func FailFastParallelCheck(checkers []StatusChecker) StatusChecker { fn := func() Status { statusChannel := make(chan Status, len(checkers)) for idx := range checkers { check := checkers[idx] go func() { status := check() statusChannel <- status }() } for range checkers { select { case s...
go
func FailFastParallelCheck(checkers []StatusChecker) StatusChecker { fn := func() Status { statusChannel := make(chan Status, len(checkers)) for idx := range checkers { check := checkers[idx] go func() { status := check() statusChannel <- status }() } for range checkers { select { case s...
[ "func", "FailFastParallelCheck", "(", "checkers", "[", "]", "StatusChecker", ")", "StatusChecker", "{", "fn", ":=", "func", "(", ")", "Status", "{", "statusChannel", ":=", "make", "(", "chan", "Status", ",", "len", "(", "checkers", ")", ")", "\n", "for", ...
// FailFastParallelCheck creates a composite checker that will run all checkers simultaneously. As soon as any of the checkers fail then the other checkers are ignored.
[ "FailFastParallelCheck", "creates", "a", "composite", "checker", "that", "will", "run", "all", "checkers", "simultaneously", ".", "As", "soon", "as", "any", "of", "the", "checkers", "fail", "then", "the", "other", "checkers", "are", "ignored", "." ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/gtg/good_to_go.go#L65-L86
148,384
Financial-Times/service-status-go
gtg/good_to_go.go
RunCheck
func (check StatusChecker) RunCheck() Status { statusChannel := make(chan Status, 1) go func() { status := check() if status.GoodToGo { status.Message = "OK" } statusChannel <- status }() select { case status := <-statusChannel: return status case <-time.After(time.Second * time.Duration(timeout)): ...
go
func (check StatusChecker) RunCheck() Status { statusChannel := make(chan Status, 1) go func() { status := check() if status.GoodToGo { status.Message = "OK" } statusChannel <- status }() select { case status := <-statusChannel: return status case <-time.After(time.Second * time.Duration(timeout)): ...
[ "func", "(", "check", "StatusChecker", ")", "RunCheck", "(", ")", "Status", "{", "statusChannel", ":=", "make", "(", "chan", "Status", ",", "1", ")", "\n", "go", "func", "(", ")", "{", "status", ":=", "check", "(", ")", "\n", "if", "status", ".", "...
// RunCheck executes a checker and returns the result as a status
[ "RunCheck", "executes", "a", "checker", "and", "returns", "the", "result", "as", "a", "status" ]
3f5199736a3d7ae52394c63aac36834786825e21
https://github.com/Financial-Times/service-status-go/blob/3f5199736a3d7ae52394c63aac36834786825e21/gtg/good_to_go.go#L89-L104
148,385
robfig/pathtree
tree.go
addLeaf
func (n *Node) addLeaf(leaf *Leaf) error { extension := stripExtensionFromLastSegment(leaf.Wildcards) if extension != "" { if n.extensions == nil { n.extensions = make(map[string]*Leaf) } if n.extensions[extension] != nil { return errors.New("duplicate path") } n.extensions[extension] = leaf return ...
go
func (n *Node) addLeaf(leaf *Leaf) error { extension := stripExtensionFromLastSegment(leaf.Wildcards) if extension != "" { if n.extensions == nil { n.extensions = make(map[string]*Leaf) } if n.extensions[extension] != nil { return errors.New("duplicate path") } n.extensions[extension] = leaf return ...
[ "func", "(", "n", "*", "Node", ")", "addLeaf", "(", "leaf", "*", "Leaf", ")", "error", "{", "extension", ":=", "stripExtensionFromLastSegment", "(", "leaf", ".", "Wildcards", ")", "\n", "if", "extension", "!=", "\"", "\"", "{", "if", "n", ".", "extensi...
// Adds a leaf to a terminal node. // If the last wildcard contains an extension, add it to the 'extensions' map.
[ "Adds", "a", "leaf", "to", "a", "terminal", "node", ".", "If", "the", "last", "wildcard", "contains", "an", "extension", "add", "it", "to", "the", "extensions", "map", "." ]
41257a1839e945fce74afd070e02bab2ea2c776a
https://github.com/robfig/pathtree/blob/41257a1839e945fce74afd070e02bab2ea2c776a/tree.go#L77-L95
148,386
robfig/pathtree
tree.go
Find
func (n *Node) Find(key string) (leaf *Leaf, expansions []string) { if len(key) == 0 || key[0] != '/' { return nil, nil } return n.find(splitPath(key), nil) }
go
func (n *Node) Find(key string) (leaf *Leaf, expansions []string) { if len(key) == 0 || key[0] != '/' { return nil, nil } return n.find(splitPath(key), nil) }
[ "func", "(", "n", "*", "Node", ")", "Find", "(", "key", "string", ")", "(", "leaf", "*", "Leaf", ",", "expansions", "[", "]", "string", ")", "{", "if", "len", "(", "key", ")", "==", "0", "||", "key", "[", "0", "]", "!=", "'/'", "{", "return",...
// Find a given path. Any wildcards traversed along the way are expanded and // returned, along with the value.
[ "Find", "a", "given", "path", ".", "Any", "wildcards", "traversed", "along", "the", "way", "are", "expanded", "and", "returned", "along", "with", "the", "value", "." ]
41257a1839e945fce74afd070e02bab2ea2c776a
https://github.com/robfig/pathtree/blob/41257a1839e945fce74afd070e02bab2ea2c776a/tree.go#L144-L150
148,387
robfig/pathtree
tree.go
stripExtensionFromLastSegment
func stripExtensionFromLastSegment(segments []string) string { if len(segments) == 0 { return "" } lastSegment := segments[len(segments)-1] prefix, extension := extensionForPath(lastSegment) if extension != "" { segments[len(segments)-1] = prefix } return extension }
go
func stripExtensionFromLastSegment(segments []string) string { if len(segments) == 0 { return "" } lastSegment := segments[len(segments)-1] prefix, extension := extensionForPath(lastSegment) if extension != "" { segments[len(segments)-1] = prefix } return extension }
[ "func", "stripExtensionFromLastSegment", "(", "segments", "[", "]", "string", ")", "string", "{", "if", "len", "(", "segments", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "lastSegment", ":=", "segments", "[", "len", "(", "segments", ")",...
// stripExtensionFromLastSegment determines if a string slice representing a path // ends with a file extension, removes the extension from the input, and returns it.
[ "stripExtensionFromLastSegment", "determines", "if", "a", "string", "slice", "representing", "a", "path", "ends", "with", "a", "file", "extension", "removes", "the", "extension", "from", "the", "input", "and", "returns", "it", "." ]
41257a1839e945fce74afd070e02bab2ea2c776a
https://github.com/robfig/pathtree/blob/41257a1839e945fce74afd070e02bab2ea2c776a/tree.go#L218-L228
148,388
remind101/kinesumer
kinesumer.go
getRecordsThrottle
func getRecordsThrottle(d time.Duration) <-chan time.Time { if d == 0 { d = DefaultGetRecordsThrottle } return time.NewTicker(d).C }
go
func getRecordsThrottle(d time.Duration) <-chan time.Time { if d == 0 { d = DefaultGetRecordsThrottle } return time.NewTicker(d).C }
[ "func", "getRecordsThrottle", "(", "d", "time", ".", "Duration", ")", "<-", "chan", "time", ".", "Time", "{", "if", "d", "==", "0", "{", "d", "=", "DefaultGetRecordsThrottle", "\n", "}", "\n\n", "return", "time", ".", "NewTicker", "(", "d", ")", ".", ...
// getRecordsThrottle returns a channel that will tick every time d has elapsed. // If d is 0, DefaultGetRecordsThrottle will be used.
[ "getRecordsThrottle", "returns", "a", "channel", "that", "will", "tick", "every", "time", "d", "has", "elapsed", ".", "If", "d", "is", "0", "DefaultGetRecordsThrottle", "will", "be", "used", "." ]
2d4f00f055ea7b474c72f181ed4578af370c5376
https://github.com/remind101/kinesumer/blob/2d4f00f055ea7b474c72f181ed4578af370c5376/kinesumer.go#L285-L291
148,389
remind101/kinesumer
reader.go
copy
func (r *Reader) copy(b []byte) (n int) { n += copy(b, r.buf) if len(r.buf) >= n { // If there's still some buffered data left, truncate the buffer // and return. r.buf = r.buf[n:] } if len(r.buf) == 0 { r.done() } return }
go
func (r *Reader) copy(b []byte) (n int) { n += copy(b, r.buf) if len(r.buf) >= n { // If there's still some buffered data left, truncate the buffer // and return. r.buf = r.buf[n:] } if len(r.buf) == 0 { r.done() } return }
[ "func", "(", "r", "*", "Reader", ")", "copy", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ")", "{", "n", "+=", "copy", "(", "b", ",", "r", ".", "buf", ")", "\n", "if", "len", "(", "r", ".", "buf", ")", ">=", "n", "{", "// If there's...
// copy copies as much as it can from r.buf into b. If it succeeds in copying // all of the data, r.done is called.
[ "copy", "copies", "as", "much", "as", "it", "can", "from", "r", ".", "buf", "into", "b", ".", "If", "it", "succeeds", "in", "copying", "all", "of", "the", "data", "r", ".", "done", "is", "called", "." ]
2d4f00f055ea7b474c72f181ed4578af370c5376
https://github.com/remind101/kinesumer/blob/2d4f00f055ea7b474c72f181ed4578af370c5376/reader.go#L64-L77
148,390
pivotal-cf-experimental/warrant
internal/network/errors.go
Error
func (e UnexpectedStatusError) Error() string { return fmt.Sprintf("Warrant UnexpectedStatusError: %d %s", e.Status, e.Body) }
go
func (e UnexpectedStatusError) Error() string { return fmt.Sprintf("Warrant UnexpectedStatusError: %d %s", e.Status, e.Body) }
[ "func", "(", "e", "UnexpectedStatusError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Status", ",", "e", ".", "Body", ")", "\n", "}" ]
// Error returns a string representation of the UnexpectedStatusError.
[ "Error", "returns", "a", "string", "representation", "of", "the", "UnexpectedStatusError", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/internal/network/errors.go#L80-L82
148,391
drewlanenga/govector
vectors.go
Copy
func (x Vector) Copy() Vector { y := make(Vector, len(x)) copy(y, x) return y }
go
func (x Vector) Copy() Vector { y := make(Vector, len(x)) copy(y, x) return y }
[ "func", "(", "x", "Vector", ")", "Copy", "(", ")", "Vector", "{", "y", ":=", "make", "(", "Vector", ",", "len", "(", "x", ")", ")", "\n", "copy", "(", "y", ",", "x", ")", "\n", "return", "y", "\n", "}" ]
// Copy returns a copy the input vector. This is useful for functions that // perform modification and shuffling on the order of the input vector.
[ "Copy", "returns", "a", "copy", "the", "input", "vector", ".", "This", "is", "useful", "for", "functions", "that", "perform", "modification", "and", "shuffling", "on", "the", "order", "of", "the", "input", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L26-L30
148,392
drewlanenga/govector
vectors.go
Smooth
func (x Vector) Smooth(left, right uint) Vector { n := uint(len(x)) smoothed := make(Vector, n) for index := uint(0); index < n; index++ { var leftmost uint if left < index { leftmost = index - left } rightmost := index + right + 1 if rightmost > n { rightmost = n } window := x[leftmost:rightm...
go
func (x Vector) Smooth(left, right uint) Vector { n := uint(len(x)) smoothed := make(Vector, n) for index := uint(0); index < n; index++ { var leftmost uint if left < index { leftmost = index - left } rightmost := index + right + 1 if rightmost > n { rightmost = n } window := x[leftmost:rightm...
[ "func", "(", "x", "Vector", ")", "Smooth", "(", "left", ",", "right", "uint", ")", "Vector", "{", "n", ":=", "uint", "(", "len", "(", "x", ")", ")", "\n", "smoothed", ":=", "make", "(", "Vector", ",", "n", ")", "\n\n", "for", "index", ":=", "ui...
// Smooth takes a sliding window average of vector. Indices i and j refer to the // the number of points you'd like to consider before and after a point in // the average.
[ "Smooth", "takes", "a", "sliding", "window", "average", "of", "vector", ".", "Indices", "i", "and", "j", "refer", "to", "the", "the", "number", "of", "points", "you", "d", "like", "to", "consider", "before", "and", "after", "a", "point", "in", "the", "...
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L35-L55
148,393
drewlanenga/govector
vectors.go
Sum
func (x Vector) Sum() float64 { s := 0.0 for _, v := range x { s += v } return s }
go
func (x Vector) Sum() float64 { s := 0.0 for _, v := range x { s += v } return s }
[ "func", "(", "x", "Vector", ")", "Sum", "(", ")", "float64", "{", "s", ":=", "0.0", "\n", "for", "_", ",", "v", ":=", "range", "x", "{", "s", "+=", "v", "\n", "}", "\n", "return", "s", "\n", "}" ]
// Sum returns the sum of the vector.
[ "Sum", "returns", "the", "sum", "of", "the", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L76-L82
148,394
drewlanenga/govector
vectors.go
Abs
func (x Vector) Abs() Vector { y := x.Copy() for i, _ := range y { y[i] = math.Abs(y[i]) } return y }
go
func (x Vector) Abs() Vector { y := x.Copy() for i, _ := range y { y[i] = math.Abs(y[i]) } return y }
[ "func", "(", "x", "Vector", ")", "Abs", "(", ")", "Vector", "{", "y", ":=", "x", ".", "Copy", "(", ")", "\n\n", "for", "i", ",", "_", ":=", "range", "y", "{", "y", "[", "i", "]", "=", "math", ".", "Abs", "(", "y", "[", "i", "]", ")", "\...
// Abs returns the absolute values of the vector elements.
[ "Abs", "returns", "the", "absolute", "values", "of", "the", "vector", "elements", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L85-L93
148,395
drewlanenga/govector
vectors.go
Cumsum
func (x Vector) Cumsum() Vector { y := make(Vector, len(x)) y[0] = x[0] i := 1 for i < len(x) { y[i] = x[i] + y[i-1] i++ } return y }
go
func (x Vector) Cumsum() Vector { y := make(Vector, len(x)) y[0] = x[0] i := 1 for i < len(x) { y[i] = x[i] + y[i-1] i++ } return y }
[ "func", "(", "x", "Vector", ")", "Cumsum", "(", ")", "Vector", "{", "y", ":=", "make", "(", "Vector", ",", "len", "(", "x", ")", ")", "\n\n", "y", "[", "0", "]", "=", "x", "[", "0", "]", "\n\n", "i", ":=", "1", "\n", "for", "i", "<", "len...
// Cumsum returns the cumulative sum of the vector.
[ "Cumsum", "returns", "the", "cumulative", "sum", "of", "the", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L96-L108
148,396
drewlanenga/govector
vectors.go
Mean
func (x Vector) Mean() float64 { s := x.Sum() n := float64(len(x)) return s / n }
go
func (x Vector) Mean() float64 { s := x.Sum() n := float64(len(x)) return s / n }
[ "func", "(", "x", "Vector", ")", "Mean", "(", ")", "float64", "{", "s", ":=", "x", ".", "Sum", "(", ")", "\n\n", "n", ":=", "float64", "(", "len", "(", "x", ")", ")", "\n\n", "return", "s", "/", "n", "\n", "}" ]
// Mean returns the mean of the vector.
[ "Mean", "returns", "the", "mean", "of", "the", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L111-L117
148,397
drewlanenga/govector
vectors.go
weightedSum
func (x Vector) weightedSum(w Vector) (float64, error) { if len(x) != len(w) { return NA, fmt.Errorf("Length of weights unequal to vector length") } ws := 0.0 for i, _ := range x { ws += x[i] * w[i] } return ws, nil }
go
func (x Vector) weightedSum(w Vector) (float64, error) { if len(x) != len(w) { return NA, fmt.Errorf("Length of weights unequal to vector length") } ws := 0.0 for i, _ := range x { ws += x[i] * w[i] } return ws, nil }
[ "func", "(", "x", "Vector", ")", "weightedSum", "(", "w", "Vector", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "x", ")", "!=", "len", "(", "w", ")", "{", "return", "NA", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n...
// weightedSum returns the weighted sum of the vector. This is really only useful in // calculating the weighted mean.
[ "weightedSum", "returns", "the", "weighted", "sum", "of", "the", "vector", ".", "This", "is", "really", "only", "useful", "in", "calculating", "the", "weighted", "mean", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L121-L131
148,398
drewlanenga/govector
vectors.go
WeightedMean
func (x Vector) WeightedMean(w Vector) (float64, error) { ws, err := x.weightedSum(w) if err != nil { return NA, err } sw := w.Sum() return ws / sw, nil }
go
func (x Vector) WeightedMean(w Vector) (float64, error) { ws, err := x.weightedSum(w) if err != nil { return NA, err } sw := w.Sum() return ws / sw, nil }
[ "func", "(", "x", "Vector", ")", "WeightedMean", "(", "w", "Vector", ")", "(", "float64", ",", "error", ")", "{", "ws", ",", "err", ":=", "x", ".", "weightedSum", "(", "w", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NA", ",", "err", "...
// WeightedMean returns the weighted mean of the vector for a given vector of weights.
[ "WeightedMean", "returns", "the", "weighted", "mean", "of", "the", "vector", "for", "a", "given", "vector", "of", "weights", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L134-L142
148,399
drewlanenga/govector
vectors.go
MeanVar
func (x Vector) MeanVar() (float64, float64) { m := x.Mean() v := x.variance(m) return m, v }
go
func (x Vector) MeanVar() (float64, float64) { m := x.Mean() v := x.variance(m) return m, v }
[ "func", "(", "x", "Vector", ")", "MeanVar", "(", ")", "(", "float64", ",", "float64", ")", "{", "m", ":=", "x", ".", "Mean", "(", ")", "\n", "v", ":=", "x", ".", "variance", "(", "m", ")", "\n", "return", "m", ",", "v", "\n", "}" ]
// MeanVar returns both the mean and the variance of the vector
[ "MeanVar", "returns", "both", "the", "mean", "and", "the", "variance", "of", "the", "vector" ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L166-L170