id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
147,300
knq/ini
ini.go
LoadFile
func LoadFile(filename string) (*File, error) { // check if the file exists, return a new file if it doesn't if _, err := os.Stat(filename); os.IsNotExist(err) { file := NewFile() file.Filename = filename return file, nil } // if file exists, read and parse it f, err := os.Open(filename) if err != nil { ...
go
func LoadFile(filename string) (*File, error) { // check if the file exists, return a new file if it doesn't if _, err := os.Stat(filename); os.IsNotExist(err) { file := NewFile() file.Filename = filename return file, nil } // if file exists, read and parse it f, err := os.Open(filename) if err != nil { ...
[ "func", "LoadFile", "(", "filename", "string", ")", "(", "*", "File", ",", "error", ")", "{", "// check if the file exists, return a new file if it doesn't", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", ";", "os", ".", "IsNotExist", ...
// LoadFile loads ini data from a file with specified filename. // // If the filename doesn't exist, then an empty File is returned. The data can // then be written to disk using File.Save, or parser.File.Write.
[ "LoadFile", "loads", "ini", "data", "from", "a", "file", "with", "specified", "filename", ".", "If", "the", "filename", "doesn", "t", "exist", "then", "an", "empty", "File", "is", "returned", ".", "The", "data", "can", "then", "be", "written", "to", "dis...
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/ini.go#L113-L129
147,301
knq/ini
ini.go
fixEnding
func fixEnding(r io.Reader) ([]byte, error) { // read buf, err := ioutil.ReadAll(r) if err != nil { return nil, err } // add '\n' to end if not present if len(buf) == 0 || buf[len(buf)-1] != '\n' { return append(buf, '\n'), nil } return buf, nil }
go
func fixEnding(r io.Reader) ([]byte, error) { // read buf, err := ioutil.ReadAll(r) if err != nil { return nil, err } // add '\n' to end if not present if len(buf) == 0 || buf[len(buf)-1] != '\n' { return append(buf, '\n'), nil } return buf, nil }
[ "func", "fixEnding", "(", "r", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// read", "buf", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err...
// fixEnding fixes the file data in r, ensuring the file ends with \n.
[ "fixEnding", "fixes", "the", "file", "data", "in", "r", "ensuring", "the", "file", "ends", "with", "\\", "n", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/ini.go#L132-L144
147,302
thinkboy/log4go
log4go.go
Logf
func (log Logger) Logf(lvl level, format string, args ...interface{}) { log.intLogf(lvl, format, args...) }
go
func (log Logger) Logf(lvl level, format string, args ...interface{}) { log.intLogf(lvl, format, args...) }
[ "func", "(", "log", "Logger", ")", "Logf", "(", "lvl", "level", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "log", ".", "intLogf", "(", "lvl", ",", "format", ",", "args", "...", ")", "\n", "}" ]
// Logf logs a formatted log message at the given log level, using the caller as // its source.
[ "Logf", "logs", "a", "formatted", "log", "message", "at", "the", "given", "log", "level", "using", "the", "caller", "as", "its", "source", "." ]
4d8ec2bad0a636c242dd73235694c8123dc555d0
https://github.com/thinkboy/log4go/blob/4d8ec2bad0a636c242dd73235694c8123dc555d0/log4go.go#L300-L302
147,303
knq/ini
parser/file.go
NewFile
func NewFile(lines []*Line) *File { // create ret := &File{ lines: lines, sections: make([]*Section, 0), // copy manipulation funcs SectionManipFunc: SectionManipFunc, SectionNameFunc: SectionNameFunc, SectionCompFunc: nil, KeyManipFunc: KeyManipFunc, KeyCompFunc: KeyCompFunc, ValueMa...
go
func NewFile(lines []*Line) *File { // create ret := &File{ lines: lines, sections: make([]*Section, 0), // copy manipulation funcs SectionManipFunc: SectionManipFunc, SectionNameFunc: SectionNameFunc, SectionCompFunc: nil, KeyManipFunc: KeyManipFunc, KeyCompFunc: KeyCompFunc, ValueMa...
[ "func", "NewFile", "(", "lines", "[", "]", "*", "Line", ")", "*", "File", "{", "// create", "ret", ":=", "&", "File", "{", "lines", ":", "lines", ",", "sections", ":", "make", "(", "[", "]", "*", "Section", ",", "0", ")", ",", "// copy manipulation...
// NewFile creates a new ini.File from provided lines.
[ "NewFile", "creates", "a", "new", "ini", ".", "File", "from", "provided", "lines", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L42-L82
147,304
knq/ini
parser/file.go
String
func (f File) String() string { var buf bytes.Buffer for _, l := range f.lines { buf.WriteString(l.String()) } return buf.String() }
go
func (f File) String() string { var buf bytes.Buffer for _, l := range f.lines { buf.WriteString(l.String()) } return buf.String() }
[ "func", "(", "f", "File", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "_", ",", "l", ":=", "range", "f", ".", "lines", "{", "buf", ".", "WriteString", "(", "l", ".", "String", "(", ")", ")", "\n", ...
// String returns formatted ini file data. // // Satisfies fmt.Stringer interface.
[ "String", "returns", "formatted", "ini", "file", "data", ".", "Satisfies", "fmt", ".", "Stringer", "interface", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L87-L93
147,305
knq/ini
parser/file.go
Write
func (f *File) Write(filename string) error { file, err := os.Create(filename) if err != nil { return err } defer file.Close() _, err = file.WriteString(f.String()) return err }
go
func (f *File) Write(filename string) error { file, err := os.Create(filename) if err != nil { return err } defer file.Close() _, err = file.WriteString(f.String()) return err }
[ "func", "(", "f", "*", "File", ")", "Write", "(", "filename", "string", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "Create", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file"...
// Write to filename.
[ "Write", "to", "filename", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L101-L110
147,306
knq/ini
parser/file.go
SectionNames
func (f *File) SectionNames() []string { names := make([]string, len(f.sections)) for i, s := range f.sections { names[i] = s.Name() } return names }
go
func (f *File) SectionNames() []string { names := make([]string, len(f.sections)) for i, s := range f.sections { names[i] = s.Name() } return names }
[ "func", "(", "f", "*", "File", ")", "SectionNames", "(", ")", "[", "]", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "f", ".", "sections", ")", ")", "\n", "for", "i", ",", "s", ":=", "range", "f", ".", "sect...
// SectionNames returns all section names from File. // // Section names are passed through SectionNameFunc.
[ "SectionNames", "returns", "all", "section", "names", "from", "File", ".", "Section", "names", "are", "passed", "through", "SectionNameFunc", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L130-L136
147,307
knq/ini
parser/file.go
AddSection
func (f *File) AddSection(name string) *Section { return f.AddSectionRaw(f.SectionManipFunc(name)) }
go
func (f *File) AddSection(name string) *Section { return f.AddSectionRaw(f.SectionManipFunc(name)) }
[ "func", "(", "f", "*", "File", ")", "AddSection", "(", "name", "string", ")", "*", "Section", "{", "return", "f", ".", "AddSectionRaw", "(", "f", ".", "SectionManipFunc", "(", "name", ")", ")", "\n", "}" ]
// AddSection adds a Section to File. // // Section name is passed through file's SectionManipFunc. // // Returns the created Section.
[ "AddSection", "adds", "a", "Section", "to", "File", ".", "Section", "name", "is", "passed", "through", "file", "s", "SectionManipFunc", ".", "Returns", "the", "created", "Section", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L178-L180
147,308
knq/ini
parser/file.go
getSection
func (f *File) getSection(name string) (*Section, int) { n := f.SectionManipFunc(name) // blank section isn't actually defined ... if f.sectionNameComp(n, "") { return f.sections[0], 0 } // loop through lines and find section for idx, line := range f.lines { if s, ok := line.item.(*Section); ok && f.section...
go
func (f *File) getSection(name string) (*Section, int) { n := f.SectionManipFunc(name) // blank section isn't actually defined ... if f.sectionNameComp(n, "") { return f.sections[0], 0 } // loop through lines and find section for idx, line := range f.lines { if s, ok := line.item.(*Section); ok && f.section...
[ "func", "(", "f", "*", "File", ")", "getSection", "(", "name", "string", ")", "(", "*", "Section", ",", "int", ")", "{", "n", ":=", "f", ".", "SectionManipFunc", "(", "name", ")", "\n\n", "// blank section isn't actually defined ...", "if", "f", ".", "se...
// getSection Get a section and its starting line number.
[ "getSection", "Get", "a", "section", "and", "its", "starting", "line", "number", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L196-L212
147,309
knq/ini
parser/file.go
GetSection
func (f *File) GetSection(name string) *Section { s, _ := f.getSection(name) return s }
go
func (f *File) GetSection(name string) *Section { s, _ := f.getSection(name) return s }
[ "func", "(", "f", "*", "File", ")", "GetSection", "(", "name", "string", ")", "*", "Section", "{", "s", ",", "_", ":=", "f", ".", "getSection", "(", "name", ")", "\n", "return", "s", "\n", "}" ]
// GetSection returns a Section with provided name from File.
[ "GetSection", "returns", "a", "Section", "with", "provided", "name", "from", "File", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L215-L218
147,310
knq/ini
parser/file.go
SetMap
func (f *File) SetMap(values map[string]map[string]string) { for name, keys := range values { section := f.GetSection(name) if section == nil { section = f.AddSection(name) } for k, v := range keys { section.SetKey(k, v) } } }
go
func (f *File) SetMap(values map[string]map[string]string) { for name, keys := range values { section := f.GetSection(name) if section == nil { section = f.AddSection(name) } for k, v := range keys { section.SetKey(k, v) } } }
[ "func", "(", "f", "*", "File", ")", "SetMap", "(", "values", "map", "[", "string", "]", "map", "[", "string", "]", "string", ")", "{", "for", "name", ",", "keys", ":=", "range", "values", "{", "section", ":=", "f", ".", "GetSection", "(", "name", ...
// SetMap sets all section and key values from provided map. // // Replaces values if the key already exists, or adds them otherwise.
[ "SetMap", "sets", "all", "section", "and", "key", "values", "from", "provided", "map", ".", "Replaces", "values", "if", "the", "key", "already", "exists", "or", "adds", "them", "otherwise", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L223-L234
147,311
knq/ini
parser/file.go
GetMap
func (f *File) GetMap() map[string]map[string]string { ret := make(map[string]map[string]string) for _, section := range f.sections { s := make(map[string]string) for _, key := range section.keys { s[f.KeyManipFunc(key)] = f.ValueManipFunc(section.GetRaw(key)) } ret[section.Name()] = s } return ret }
go
func (f *File) GetMap() map[string]map[string]string { ret := make(map[string]map[string]string) for _, section := range f.sections { s := make(map[string]string) for _, key := range section.keys { s[f.KeyManipFunc(key)] = f.ValueManipFunc(section.GetRaw(key)) } ret[section.Name()] = s } return ret }
[ "func", "(", "f", "*", "File", ")", "GetMap", "(", ")", "map", "[", "string", "]", "map", "[", "string", "]", "string", "{", "ret", ":=", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "string", ")", "\n\n", "for", "_", ",",...
// GetMap returns all sections and key values as map.
[ "GetMap", "returns", "all", "sections", "and", "key", "values", "as", "map", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L237-L250
147,312
knq/ini
parser/file.go
SetMapFlat
func (f *File) SetMapFlat(values map[string]string) { for key, value := range values { f.SetKey(key, value) } }
go
func (f *File) SetMapFlat(values map[string]string) { for key, value := range values { f.SetKey(key, value) } }
[ "func", "(", "f", "*", "File", ")", "SetMapFlat", "(", "values", "map", "[", "string", "]", "string", ")", "{", "for", "key", ",", "value", ":=", "range", "values", "{", "f", ".", "SetKey", "(", "key", ",", "value", ")", "\n", "}", "\n", "}" ]
// SetMapFlat sets section and key values from a flat map.
[ "SetMapFlat", "sets", "section", "and", "key", "values", "from", "a", "flat", "map", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L253-L257
147,313
knq/ini
parser/file.go
GetMapFlat
func (f *File) GetMapFlat() map[string]string { ret := make(map[string]string) for _, section := range f.sections { name := section.Name() if section.name != "" { name = fmt.Sprintf("%s%s", name, DefaultNameKeySeparator) } for _, key := range section.keys { ret[fmt.Sprintf("%s%s", name, key)] = f.Valu...
go
func (f *File) GetMapFlat() map[string]string { ret := make(map[string]string) for _, section := range f.sections { name := section.Name() if section.name != "" { name = fmt.Sprintf("%s%s", name, DefaultNameKeySeparator) } for _, key := range section.keys { ret[fmt.Sprintf("%s%s", name, key)] = f.Valu...
[ "func", "(", "f", "*", "File", ")", "GetMapFlat", "(", ")", "map", "[", "string", "]", "string", "{", "ret", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "for", "_", ",", "section", ":=", "range", "f", ".", "sections", "{"...
// GetMapFlat retrieves all sections and keys and values as flat map.
[ "GetMapFlat", "retrieves", "all", "sections", "and", "keys", "and", "values", "as", "flat", "map", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L260-L275
147,314
knq/ini
parser/file.go
RenameSection
func (f *File) RenameSection(name, value string) { f.RenameSectionRaw(name, f.SectionManipFunc(value)) }
go
func (f *File) RenameSection(name, value string) { f.RenameSectionRaw(name, f.SectionManipFunc(value)) }
[ "func", "(", "f", "*", "File", ")", "RenameSection", "(", "name", ",", "value", "string", ")", "{", "f", ".", "RenameSectionRaw", "(", "name", ",", "f", ".", "SectionManipFunc", "(", "value", ")", ")", "\n", "}" ]
// RenameSection renames a Section in File. // // Value will be passed through the File's SectionManipFunc.
[ "RenameSection", "renames", "a", "Section", "in", "File", ".", "Value", "will", "be", "passed", "through", "the", "File", "s", "SectionManipFunc", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L286-L288
147,315
knq/ini
parser/file.go
RemoveSection
func (f *File) RemoveSection(name string) { section, start := f.getSection(name) if section == nil { return } // save copy of line ending le := f.lines[0].le // find next section end := start + 1 for ; end < len(f.lines); end++ { if _, ok := f.lines[end].item.(*Section); ok { break } } // remove f...
go
func (f *File) RemoveSection(name string) { section, start := f.getSection(name) if section == nil { return } // save copy of line ending le := f.lines[0].le // find next section end := start + 1 for ; end < len(f.lines); end++ { if _, ok := f.lines[end].item.(*Section); ok { break } } // remove f...
[ "func", "(", "f", "*", "File", ")", "RemoveSection", "(", "name", "string", ")", "{", "section", ",", "start", ":=", "f", ".", "getSection", "(", "name", ")", "\n", "if", "section", "==", "nil", "{", "return", "\n", "}", "\n\n", "// save copy of line e...
// RemoveSection removes a Section and all related lines from File.
[ "RemoveSection", "removes", "a", "Section", "and", "all", "related", "lines", "from", "File", "." ]
a301e724bd355e60a16998da1c57e916ecea6ec8
https://github.com/knq/ini/blob/a301e724bd355e60a16998da1c57e916ecea6ec8/parser/file.go#L291-L328
147,316
octavore/naga
service/loader.go
load
func (s *Service) load(m Module) { moduleName := getModuleName(m) config, ok := s.configs[moduleName] if ok { panic("cycle: " + moduleName) } else if config != nil { BootPrintln("skipping already initialized module", moduleName) return } s.configs[moduleName] = nil config = &Config{parent: m, service: s} ...
go
func (s *Service) load(m Module) { moduleName := getModuleName(m) config, ok := s.configs[moduleName] if ok { panic("cycle: " + moduleName) } else if config != nil { BootPrintln("skipping already initialized module", moduleName) return } s.configs[moduleName] = nil config = &Config{parent: m, service: s} ...
[ "func", "(", "s", "*", "Service", ")", "load", "(", "m", "Module", ")", "{", "moduleName", ":=", "getModuleName", "(", "m", ")", "\n", "config", ",", "ok", ":=", "s", ".", "configs", "[", "moduleName", "]", "\n", "if", "ok", "{", "panic", "(", "\...
// Loads m and its dependencies in topological order using DFS. // Populated the modules slice with dependencies of m and m in topological order. // Keeps state in s.configs.
[ "Loads", "m", "and", "its", "dependencies", "in", "topological", "order", "using", "DFS", ".", "Populated", "the", "modules", "slice", "with", "dependencies", "of", "m", "and", "m", "in", "topological", "order", ".", "Keeps", "state", "in", "s", ".", "conf...
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/loader.go#L10-L60
147,317
reconquest/barely
barely.go
SetStatus
func (bar *StatusBar) SetStatus(data interface{}) { bar.Lock() defer bar.Unlock() bar.status = data }
go
func (bar *StatusBar) SetStatus(data interface{}) { bar.Lock() defer bar.Unlock() bar.status = data }
[ "func", "(", "bar", "*", "StatusBar", ")", "SetStatus", "(", "data", "interface", "{", "}", ")", "{", "bar", ".", "Lock", "(", ")", "\n", "defer", "bar", ".", "Unlock", "(", ")", "\n\n", "bar", ".", "status", "=", "data", "\n", "}" ]
// SetStatus sets data which will be used in the template execution, which is // previously set through NewStatusBar function.
[ "SetStatus", "sets", "data", "which", "will", "be", "used", "in", "the", "template", "execution", "which", "is", "previously", "set", "through", "NewStatusBar", "function", "." ]
0f12e3bb2e13b4cdba2a41b604187163a861e087
https://github.com/reconquest/barely/blob/0f12e3bb2e13b4cdba2a41b604187163a861e087/barely.go#L59-L64
147,318
reconquest/barely
barely.go
Render
func (bar *StatusBar) Render(writer io.Writer) error { bar.Lock() defer bar.Unlock() buffer := &bytes.Buffer{} if bar.status == nil { return nil } err := bar.format.Execute(buffer, bar.status) if err != nil { return fmt.Errorf( `error during rendering status bar: %s`, err, ) } fmt.Fprintf(buffe...
go
func (bar *StatusBar) Render(writer io.Writer) error { bar.Lock() defer bar.Unlock() buffer := &bytes.Buffer{} if bar.status == nil { return nil } err := bar.format.Execute(buffer, bar.status) if err != nil { return fmt.Errorf( `error during rendering status bar: %s`, err, ) } fmt.Fprintf(buffe...
[ "func", "(", "bar", "*", "StatusBar", ")", "Render", "(", "writer", "io", ".", "Writer", ")", "error", "{", "bar", ".", "Lock", "(", ")", "\n", "defer", "bar", ".", "Unlock", "(", ")", "\n\n", "buffer", ":=", "&", "bytes", ".", "Buffer", "{", "}"...
// Render renders specified template and writes it to the specified writer. // // Also, render result will be remembered and will be used to generate clear // sequence which can be obtained from Clear method call.
[ "Render", "renders", "specified", "template", "and", "writes", "it", "to", "the", "specified", "writer", ".", "Also", "render", "result", "will", "be", "remembered", "and", "will", "be", "used", "to", "generate", "clear", "sequence", "which", "can", "be", "o...
0f12e3bb2e13b4cdba2a41b604187163a861e087
https://github.com/reconquest/barely/blob/0f12e3bb2e13b4cdba2a41b604187163a861e087/barely.go#L70-L104
147,319
reconquest/barely
barely.go
Clear
func (bar *StatusBar) Clear(writer io.Writer) { bar.Lock() defer bar.Unlock() if bar.last != "" { fmt.Fprint(writer, "\x1b[2K") } bar.last = "" }
go
func (bar *StatusBar) Clear(writer io.Writer) { bar.Lock() defer bar.Unlock() if bar.last != "" { fmt.Fprint(writer, "\x1b[2K") } bar.last = "" }
[ "func", "(", "bar", "*", "StatusBar", ")", "Clear", "(", "writer", "io", ".", "Writer", ")", "{", "bar", ".", "Lock", "(", ")", "\n", "defer", "bar", ".", "Unlock", "(", ")", "\n\n", "if", "bar", ".", "last", "!=", "\"", "\"", "{", "fmt", ".", ...
// Clear writes clear sequence in the specified writer, which is represented by // terminal erase line sequence.
[ "Clear", "writes", "clear", "sequence", "in", "the", "specified", "writer", "which", "is", "represented", "by", "terminal", "erase", "line", "sequence", "." ]
0f12e3bb2e13b4cdba2a41b604187163a861e087
https://github.com/reconquest/barely/blob/0f12e3bb2e13b4cdba2a41b604187163a861e087/barely.go#L108-L117
147,320
octavore/naga
service/module.go
getModuleName
func getModuleName(m Module) string { moduleType := reflect.TypeOf(m) if moduleType.Kind() == reflect.Ptr { moduleType = moduleType.Elem() } return moduleType.PkgPath() + "." + moduleType.Name() // todo: allow aliases }
go
func getModuleName(m Module) string { moduleType := reflect.TypeOf(m) if moduleType.Kind() == reflect.Ptr { moduleType = moduleType.Elem() } return moduleType.PkgPath() + "." + moduleType.Name() // todo: allow aliases }
[ "func", "getModuleName", "(", "m", "Module", ")", "string", "{", "moduleType", ":=", "reflect", ".", "TypeOf", "(", "m", ")", "\n", "if", "moduleType", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "moduleType", "=", "moduleType", ".", "Elem...
// getModuleName returns the name of the module via reflection
[ "getModuleName", "returns", "the", "name", "of", "the", "module", "via", "reflection" ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/module.go#L15-L21
147,321
octavore/naga
service/start.go
wait
func (s *Service) wait() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM, os.Kill) select { case sig := <-c: BootPrintln("[service] got signal:", sig) case <-s.stopper: BootPrintln("[service] app stop") } s.stop() }
go
func (s *Service) wait() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM, os.Kill) select { case sig := <-c: BootPrintln("[service] got signal:", sig) case <-s.stopper: BootPrintln("[service] app stop") } s.stop() }
[ "func", "(", "s", "*", "Service", ")", "wait", "(", ")", "{", "c", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "c", ",", "os", ".", "Interrupt", ",", "syscall", ".", "SIGTERM", ",", "os", ...
// wait blocks until a signal is received, or the stopper channel is closed
[ "wait", "blocks", "until", "a", "signal", "is", "received", "or", "the", "stopper", "channel", "is", "closed" ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/start.go#L54-L64
147,322
octavore/naga
service/service.go
New
func New(m Module) *Service { svc := NewApp(m) svc.commands["start"] = &Command{ Keyword: "start", Run: func(*CommandContext) { svc.start() }, ShortUsage: "Start the app", Usage: "Start running the app", } return svc }
go
func New(m Module) *Service { svc := NewApp(m) svc.commands["start"] = &Command{ Keyword: "start", Run: func(*CommandContext) { svc.start() }, ShortUsage: "Start the app", Usage: "Start running the app", } return svc }
[ "func", "New", "(", "m", "Module", ")", "*", "Service", "{", "svc", ":=", "NewApp", "(", "m", ")", "\n", "svc", ".", "commands", "[", "\"", "\"", "]", "=", "&", "Command", "{", "Keyword", ":", "\"", "\"", ",", "Run", ":", "func", "(", "*", "C...
// New creates a new service with Module m as the entry point
[ "New", "creates", "a", "new", "service", "with", "Module", "m", "as", "the", "entry", "point" ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/service.go#L40-L49
147,323
octavore/naga
service/service.go
NewApp
func NewApp(m Module) *Service { svc := loadEnv(m, GetEnvironment()) svc.commands["help"] = &Command{ Keyword: "help <command>", Run: func(ctx *CommandContext) { ctx.RequireExactlyNArgs(1) cmd := svc.commands[ctx.Args[0]] if cmd == nil { fmt.Printf("Unknown command: %s\n", ctx.Args[0]) return ...
go
func NewApp(m Module) *Service { svc := loadEnv(m, GetEnvironment()) svc.commands["help"] = &Command{ Keyword: "help <command>", Run: func(ctx *CommandContext) { ctx.RequireExactlyNArgs(1) cmd := svc.commands[ctx.Args[0]] if cmd == nil { fmt.Printf("Unknown command: %s\n", ctx.Args[0]) return ...
[ "func", "NewApp", "(", "m", "Module", ")", "*", "Service", "{", "svc", ":=", "loadEnv", "(", "m", ",", "GetEnvironment", "(", ")", ")", "\n", "svc", ".", "commands", "[", "\"", "\"", "]", "=", "&", "Command", "{", "Keyword", ":", "\"", "\"", ",",...
// NewApp creates a new app with Module m as the entry point. Unlike // New, `start` is not automatically registered.
[ "NewApp", "creates", "a", "new", "app", "with", "Module", "m", "as", "the", "entry", "point", ".", "Unlike", "New", "start", "is", "not", "automatically", "registered", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/service.go#L53-L75
147,324
octavore/naga
service/service.go
loadEnv
func loadEnv(m Module, env Environment) *Service { BootPrintln("[service] env is", env.String()) svc := &Service{ Env: env, stopper: make(chan bool), modules: []Module{}, configs: map[string]*Config{}, commands: map[string]*Command{}, started: sync.WaitGroup{}, } svc.started.Add(1) svc.load(m)...
go
func loadEnv(m Module, env Environment) *Service { BootPrintln("[service] env is", env.String()) svc := &Service{ Env: env, stopper: make(chan bool), modules: []Module{}, configs: map[string]*Config{}, commands: map[string]*Command{}, started: sync.WaitGroup{}, } svc.started.Add(1) svc.load(m)...
[ "func", "loadEnv", "(", "m", "Module", ",", "env", "Environment", ")", "*", "Service", "{", "BootPrintln", "(", "\"", "\"", ",", "env", ".", "String", "(", ")", ")", "\n", "svc", ":=", "&", "Service", "{", "Env", ":", "env", ",", "stopper", ":", ...
// Load the app with the given environment, and initializes // all modules recursively starting with m.
[ "Load", "the", "app", "with", "the", "given", "environment", "and", "initializes", "all", "modules", "recursively", "starting", "with", "m", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/service.go#L84-L97
147,325
octavore/naga
service/service.go
Usage
func (s *Service) Usage() { fmt.Printf("Usage of %s\n", os.Args[0]) if s.commands["help"] != nil { fmt.Printf(" %-16s %s\n", "help", s.commands["help"].ShortUsage) } if s.commands["start"] != nil { fmt.Printf(" %-16s %s\n", "start", s.commands["start"].ShortUsage) } for k, cmd := range s.commands { if...
go
func (s *Service) Usage() { fmt.Printf("Usage of %s\n", os.Args[0]) if s.commands["help"] != nil { fmt.Printf(" %-16s %s\n", "help", s.commands["help"].ShortUsage) } if s.commands["start"] != nil { fmt.Printf(" %-16s %s\n", "start", s.commands["start"].ShortUsage) } for k, cmd := range s.commands { if...
[ "func", "(", "s", "*", "Service", ")", "Usage", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "os", ".", "Args", "[", "0", "]", ")", "\n", "if", "s", ".", "commands", "[", "\"", "\"", "]", "!=", "nil", "{", "fmt", ".", ...
// Usage prints the usage for all registered commands.
[ "Usage", "prints", "the", "usage", "for", "all", "registered", "commands", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/service.go#L100-L114
147,326
octavore/naga
service/service.go
Run
func (s *Service) Run() { flag.Usage = s.Usage flag.Parse() args := flag.Args() if len(args) == 0 && s.defaultCommand != "" { args = append([]string{s.defaultCommand}, args...) } if len(args) == 0 { s.Usage() BootPrintln() return } err := s.RunCommand(args[0], args[1:]...) if err != nil { panic(err) ...
go
func (s *Service) Run() { flag.Usage = s.Usage flag.Parse() args := flag.Args() if len(args) == 0 && s.defaultCommand != "" { args = append([]string{s.defaultCommand}, args...) } if len(args) == 0 { s.Usage() BootPrintln() return } err := s.RunCommand(args[0], args[1:]...) if err != nil { panic(err) ...
[ "func", "(", "s", "*", "Service", ")", "Run", "(", ")", "{", "flag", ".", "Usage", "=", "s", ".", "Usage", "\n", "flag", ".", "Parse", "(", ")", "\n", "args", ":=", "flag", ".", "Args", "(", ")", "\n", "if", "len", "(", "args", ")", "==", "...
// Run parses arguments from the command line and passes them to RunCommand.
[ "Run", "parses", "arguments", "from", "the", "command", "line", "and", "passes", "them", "to", "RunCommand", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/service.go#L117-L133
147,327
octavore/naga
service/stop.go
stop
func (s *Service) stop() { dc := make(chan struct{}) go func() { for i := len(s.modules) - 1; i >= 0; i-- { n := getModuleName(s.modules[i]) c := s.configs[n] if c.Stop != nil { BootPrintln("[service] stopping", n) c.Stop() } } dc <- struct{}{} }() select { case <-dc: case <-time.After(...
go
func (s *Service) stop() { dc := make(chan struct{}) go func() { for i := len(s.modules) - 1; i >= 0; i-- { n := getModuleName(s.modules[i]) c := s.configs[n] if c.Stop != nil { BootPrintln("[service] stopping", n) c.Stop() } } dc <- struct{}{} }() select { case <-dc: case <-time.After(...
[ "func", "(", "s", "*", "Service", ")", "stop", "(", ")", "{", "dc", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "func", "(", ")", "{", "for", "i", ":=", "len", "(", "s", ".", "modules", ")", "-", "1", ";", "i", ">=", "...
// stop in reverse topological order
[ "stop", "in", "reverse", "topological", "order" ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/stop.go#L16-L35
147,328
octavore/naga
service/env.go
GetEnvironment
func GetEnvironment() Environment { v := strings.ToLower(os.Getenv(EnvVarName)) for env, l := range EnvMap { for _, e := range l { if e == v { return env } } } return EnvUnknown }
go
func GetEnvironment() Environment { v := strings.ToLower(os.Getenv(EnvVarName)) for env, l := range EnvMap { for _, e := range l { if e == v { return env } } } return EnvUnknown }
[ "func", "GetEnvironment", "(", ")", "Environment", "{", "v", ":=", "strings", ".", "ToLower", "(", "os", ".", "Getenv", "(", "EnvVarName", ")", ")", "\n", "for", "env", ",", "l", ":=", "range", "EnvMap", "{", "for", "_", ",", "e", ":=", "range", "l...
// GetEnvironment returns the app environment parsed from the // environment variable.
[ "GetEnvironment", "returns", "the", "app", "environment", "parsed", "from", "the", "environment", "variable", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/env.go#L63-L73
147,329
octavore/naga
service/command.go
UsageExit
func (c *CommandContext) UsageExit() { fmt.Println(c.cmd.Keyword) fmt.Println(c.cmd.Usage) os.Exit(0) }
go
func (c *CommandContext) UsageExit() { fmt.Println(c.cmd.Keyword) fmt.Println(c.cmd.Usage) os.Exit(0) }
[ "func", "(", "c", "*", "CommandContext", ")", "UsageExit", "(", ")", "{", "fmt", ".", "Println", "(", "c", ".", "cmd", ".", "Keyword", ")", "\n", "fmt", ".", "Println", "(", "c", ".", "cmd", ".", "Usage", ")", "\n", "os", ".", "Exit", "(", "0",...
// UsageExit prints the usage for the executed command and exits.
[ "UsageExit", "prints", "the", "usage", "for", "the", "executed", "command", "and", "exits", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/command.go#L51-L55
147,330
octavore/naga
service/command.go
RequireAtLeastNArgs
func (c *CommandContext) RequireAtLeastNArgs(n int) { if len(c.Args) < n { c.UsageExit() } }
go
func (c *CommandContext) RequireAtLeastNArgs(n int) { if len(c.Args) < n { c.UsageExit() } }
[ "func", "(", "c", "*", "CommandContext", ")", "RequireAtLeastNArgs", "(", "n", "int", ")", "{", "if", "len", "(", "c", ".", "Args", ")", "<", "n", "{", "c", ".", "UsageExit", "(", ")", "\n", "}", "\n", "}" ]
// RequireAtLeastNArgs is a helper function to ensure we have at least n args.
[ "RequireAtLeastNArgs", "is", "a", "helper", "function", "to", "ensure", "we", "have", "at", "least", "n", "args", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/command.go#L63-L67
147,331
octavore/naga
service/command.go
RequireExactlyNArgs
func (c *CommandContext) RequireExactlyNArgs(n int) { if len(c.Args) != n { c.UsageExit() } }
go
func (c *CommandContext) RequireExactlyNArgs(n int) { if len(c.Args) != n { c.UsageExit() } }
[ "func", "(", "c", "*", "CommandContext", ")", "RequireExactlyNArgs", "(", "n", "int", ")", "{", "if", "len", "(", "c", ".", "Args", ")", "!=", "n", "{", "c", ".", "UsageExit", "(", ")", "\n", "}", "\n", "}" ]
// RequireExactlyNArgs is a helper function to ensure we have at exactly n args.
[ "RequireExactlyNArgs", "is", "a", "helper", "function", "to", "ensure", "we", "have", "at", "exactly", "n", "args", "." ]
bacab51fe9fbeff12d4ca04accd07ffa21ef373e
https://github.com/octavore/naga/blob/bacab51fe9fbeff12d4ca04accd07ffa21ef373e/service/command.go#L70-L74
147,332
laincloud/deployd
engine/pod.go
tryCorrectIPAddress
func (pc *podController) tryCorrectIPAddress(c cluster.Cluster, id, fromIP, toIP string) bool { if err := c.DisconnectContainer(pc.spec.Namespace, id, true); err != nil { log.Errorf("%s fail to disconnect network %s to container %s, %s", pc, pc.spec.Namespace, id, err.Error()) // do not return false, try to connec...
go
func (pc *podController) tryCorrectIPAddress(c cluster.Cluster, id, fromIP, toIP string) bool { if err := c.DisconnectContainer(pc.spec.Namespace, id, true); err != nil { log.Errorf("%s fail to disconnect network %s to container %s, %s", pc, pc.spec.Namespace, id, err.Error()) // do not return false, try to connec...
[ "func", "(", "pc", "*", "podController", ")", "tryCorrectIPAddress", "(", "c", "cluster", ".", "Cluster", ",", "id", ",", "fromIP", ",", "toIP", "string", ")", "bool", "{", "if", "err", ":=", "c", ".", "DisconnectContainer", "(", "pc", ".", "spec", "."...
// tryCorrectIPAddress try to correct container's ip address to given ip. return true if successed, otherwise return false.
[ "tryCorrectIPAddress", "try", "to", "correct", "container", "s", "ip", "address", "to", "given", "ip", ".", "return", "true", "if", "successed", "otherwise", "return", "false", "." ]
e9d8307061a03612d4e9e91de682ec3a14dabdf0
https://github.com/laincloud/deployd/blob/e9d8307061a03612d4e9e91de682ec3a14dabdf0/engine/pod.go#L292-L307
147,333
ulule/gokvstores
redis.go
Get
func (r *RedisStore) Get(key string) (interface{}, error) { cmd := redis.NewCmd("get", key) if err := r.client.Process(cmd); err != nil { if err == redis.Nil { return nil, nil } return nil, err } return cmd.Val(), cmd.Err() }
go
func (r *RedisStore) Get(key string) (interface{}, error) { cmd := redis.NewCmd("get", key) if err := r.client.Process(cmd); err != nil { if err == redis.Nil { return nil, nil } return nil, err } return cmd.Val(), cmd.Err() }
[ "func", "(", "r", "*", "RedisStore", ")", "Get", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "cmd", ":=", "redis", ".", "NewCmd", "(", "\"", "\"", ",", "key", ")", "\n\n", "if", "err", ":=", "r", ".", "client"...
// Get returns value for the given key.
[ "Get", "returns", "value", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L85-L97
147,334
ulule/gokvstores
redis.go
Set
func (r *RedisStore) Set(key string, value interface{}) error { return r.client.Set(key, value, r.expiration).Err() }
go
func (r *RedisStore) Set(key string, value interface{}) error { return r.client.Set(key, value, r.expiration).Err() }
[ "func", "(", "r", "*", "RedisStore", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "return", "r", ".", "client", ".", "Set", "(", "key", ",", "value", ",", "r", ".", "expiration", ")", ".", "Err", "(", ...
// Set sets the value for the given key.
[ "Set", "sets", "the", "value", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L117-L119
147,335
ulule/gokvstores
redis.go
SetWithExpiration
func (r *RedisStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error { return r.client.Set(key, value, expiration).Err() }
go
func (r *RedisStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error { return r.client.Set(key, value, expiration).Err() }
[ "func", "(", "r", "*", "RedisStore", ")", "SetWithExpiration", "(", "key", "string", ",", "value", "interface", "{", "}", ",", "expiration", "time", ".", "Duration", ")", "error", "{", "return", "r", ".", "client", ".", "Set", "(", "key", ",", "value",...
// SetWithExpiration sets the value for the given key.
[ "SetWithExpiration", "sets", "the", "value", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L122-L124
147,336
ulule/gokvstores
redis.go
SetMap
func (r *RedisStore) SetMap(key string, values map[string]interface{}) error { newValues := make(map[string]string, len(values)) for k, v := range values { val, err := conv.String(v) if err != nil { return err } newValues[k] = val } return r.client.HMSet(key, newValues).Err() }
go
func (r *RedisStore) SetMap(key string, values map[string]interface{}) error { newValues := make(map[string]string, len(values)) for k, v := range values { val, err := conv.String(v) if err != nil { return err } newValues[k] = val } return r.client.HMSet(key, newValues).Err() }
[ "func", "(", "r", "*", "RedisStore", ")", "SetMap", "(", "key", "string", ",", "values", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "newValues", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "val...
// SetMap sets map for the given key.
[ "SetMap", "sets", "map", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L146-L159
147,337
ulule/gokvstores
redis.go
GetSlice
func (r *RedisStore) GetSlice(key string) ([]interface{}, error) { values, err := r.client.SMembers(key).Result() if err != nil { return nil, err } if len(values) == 0 { return nil, nil } newValues := make([]interface{}, len(values)) for _, v := range values { newValues = append(newValues, v) } return...
go
func (r *RedisStore) GetSlice(key string) ([]interface{}, error) { values, err := r.client.SMembers(key).Result() if err != nil { return nil, err } if len(values) == 0 { return nil, nil } newValues := make([]interface{}, len(values)) for _, v := range values { newValues = append(newValues, v) } return...
[ "func", "(", "r", "*", "RedisStore", ")", "GetSlice", "(", "key", "string", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "values", ",", "err", ":=", "r", ".", "client", ".", "SMembers", "(", "key", ")", ".", "Result", "(", ...
// GetSlice returns slice for the given key.
[ "GetSlice", "returns", "slice", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L167-L183
147,338
ulule/gokvstores
redis.go
SetSlice
func (r *RedisStore) SetSlice(key string, values []interface{}) error { for _, v := range values { if v != nil { if err := r.client.SAdd(key, v).Err(); err != nil { return err } } } return nil }
go
func (r *RedisStore) SetSlice(key string, values []interface{}) error { for _, v := range values { if v != nil { if err := r.client.SAdd(key, v).Err(); err != nil { return err } } } return nil }
[ "func", "(", "r", "*", "RedisStore", ")", "SetSlice", "(", "key", "string", ",", "values", "[", "]", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "v", ":=", "range", "values", "{", "if", "v", "!=", "nil", "{", "if", "err", ":=", "...
// SetSlice sets map for the given key.
[ "SetSlice", "sets", "map", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L186-L196
147,339
ulule/gokvstores
redis.go
Exists
func (r *RedisStore) Exists(key string) (bool, error) { cmd := r.client.Exists(key) return cmd.Val(), cmd.Err() }
go
func (r *RedisStore) Exists(key string) (bool, error) { cmd := r.client.Exists(key) return cmd.Val(), cmd.Err() }
[ "func", "(", "r", "*", "RedisStore", ")", "Exists", "(", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "cmd", ":=", "r", ".", "client", ".", "Exists", "(", "key", ")", "\n", "return", "cmd", ".", "Val", "(", ")", ",", "cmd", ".", ...
// Exists checks key existence.
[ "Exists", "checks", "key", "existence", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L204-L207
147,340
ulule/gokvstores
redis.go
Delete
func (r *RedisStore) Delete(key string) error { return r.client.Del(key).Err() }
go
func (r *RedisStore) Delete(key string) error { return r.client.Del(key).Err() }
[ "func", "(", "r", "*", "RedisStore", ")", "Delete", "(", "key", "string", ")", "error", "{", "return", "r", ".", "client", ".", "Del", "(", "key", ")", ".", "Err", "(", ")", "\n", "}" ]
// Delete deletes key.
[ "Delete", "deletes", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L210-L212
147,341
ulule/gokvstores
redis.go
NewRedisClientStore
func NewRedisClientStore(options *RedisClientOptions, expiration time.Duration) (KVStore, error) { opts := &redis.Options{ Network: options.Network, Addr: options.Addr, Dialer: options.Dialer, Password: options.Password, DB: options.DB, MaxRetr...
go
func NewRedisClientStore(options *RedisClientOptions, expiration time.Duration) (KVStore, error) { opts := &redis.Options{ Network: options.Network, Addr: options.Addr, Dialer: options.Dialer, Password: options.Password, DB: options.DB, MaxRetr...
[ "func", "NewRedisClientStore", "(", "options", "*", "RedisClientOptions", ",", "expiration", "time", ".", "Duration", ")", "(", "KVStore", ",", "error", ")", "{", "opts", ":=", "&", "redis", ".", "Options", "{", "Network", ":", "options", ".", "Network", "...
// NewRedisClientStore returns Redis client instance of KVStore.
[ "NewRedisClientStore", "returns", "Redis", "client", "instance", "of", "KVStore", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L242-L270
147,342
ulule/gokvstores
redis.go
NewRedisClusterStore
func NewRedisClusterStore(options *RedisClusterOptions, expiration time.Duration) (KVStore, error) { opts := &redis.ClusterOptions{ Addrs: options.Addrs, MaxRedirects: options.MaxRedirects, ReadOnly: options.ReadOnly, RouteByLatency: options.RouteByLatency, Password: ...
go
func NewRedisClusterStore(options *RedisClusterOptions, expiration time.Duration) (KVStore, error) { opts := &redis.ClusterOptions{ Addrs: options.Addrs, MaxRedirects: options.MaxRedirects, ReadOnly: options.ReadOnly, RouteByLatency: options.RouteByLatency, Password: ...
[ "func", "NewRedisClusterStore", "(", "options", "*", "RedisClusterOptions", ",", "expiration", "time", ".", "Duration", ")", "(", "KVStore", ",", "error", ")", "{", "opts", ":=", "&", "redis", ".", "ClusterOptions", "{", "Addrs", ":", "options", ".", "Addrs"...
// NewRedisClusterStore returns Redis cluster client instance of KVStore.
[ "NewRedisClusterStore", "returns", "Redis", "cluster", "client", "instance", "of", "KVStore", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L273-L299
147,343
ulule/gokvstores
redis.go
Pipeline
func (r *RedisStore) Pipeline(f func(r *RedisStore) error) ([]redis.Cmder, error) { pipe := r.client.Pipeline() redisPipeline := RedisPipeline{ pipeline: pipe, } store := &RedisStore{ client: redisPipeline, expiration: r.expiration, } err := f(store) if err != nil { return nil, err } cmds, err ...
go
func (r *RedisStore) Pipeline(f func(r *RedisStore) error) ([]redis.Cmder, error) { pipe := r.client.Pipeline() redisPipeline := RedisPipeline{ pipeline: pipe, } store := &RedisStore{ client: redisPipeline, expiration: r.expiration, } err := f(store) if err != nil { return nil, err } cmds, err ...
[ "func", "(", "r", "*", "RedisStore", ")", "Pipeline", "(", "f", "func", "(", "r", "*", "RedisStore", ")", "error", ")", "(", "[", "]", "redis", ".", "Cmder", ",", "error", ")", "{", "pipe", ":=", "r", ".", "client", ".", "Pipeline", "(", ")", "...
// Pipeline uses pipeline as a Redis client to execute multiple calls at once
[ "Pipeline", "uses", "pipeline", "as", "a", "Redis", "client", "to", "execute", "multiple", "calls", "at", "once" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L302-L321
147,344
ulule/gokvstores
redis.go
Exists
func (r RedisPipeline) Exists(key string) *redis.BoolCmd { return r.pipeline.Exists(key) }
go
func (r RedisPipeline) Exists(key string) *redis.BoolCmd { return r.pipeline.Exists(key) }
[ "func", "(", "r", "RedisPipeline", ")", "Exists", "(", "key", "string", ")", "*", "redis", ".", "BoolCmd", "{", "return", "r", ".", "pipeline", ".", "Exists", "(", "key", ")", "\n", "}" ]
// Exists implements RedisClient Exists for pipeline
[ "Exists", "implements", "RedisClient", "Exists", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L379-L381
147,345
ulule/gokvstores
redis.go
Del
func (r RedisPipeline) Del(keys ...string) *redis.IntCmd { return r.pipeline.Del(keys...) }
go
func (r RedisPipeline) Del(keys ...string) *redis.IntCmd { return r.pipeline.Del(keys...) }
[ "func", "(", "r", "RedisPipeline", ")", "Del", "(", "keys", "...", "string", ")", "*", "redis", ".", "IntCmd", "{", "return", "r", ".", "pipeline", ".", "Del", "(", "keys", "...", ")", "\n", "}" ]
// Del implements RedisClient Del for pipeline
[ "Del", "implements", "RedisClient", "Del", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L384-L386
147,346
ulule/gokvstores
redis.go
Process
func (r RedisPipeline) Process(cmd redis.Cmder) error { return r.pipeline.Process(cmd) }
go
func (r RedisPipeline) Process(cmd redis.Cmder) error { return r.pipeline.Process(cmd) }
[ "func", "(", "r", "RedisPipeline", ")", "Process", "(", "cmd", "redis", ".", "Cmder", ")", "error", "{", "return", "r", ".", "pipeline", ".", "Process", "(", "cmd", ")", "\n", "}" ]
// Process implements RedisClient Process for pipeline
[ "Process", "implements", "RedisClient", "Process", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L399-L401
147,347
ulule/gokvstores
redis.go
Get
func (r RedisPipeline) Get(key string) *redis.StringCmd { return r.pipeline.Get(key) }
go
func (r RedisPipeline) Get(key string) *redis.StringCmd { return r.pipeline.Get(key) }
[ "func", "(", "r", "RedisPipeline", ")", "Get", "(", "key", "string", ")", "*", "redis", ".", "StringCmd", "{", "return", "r", ".", "pipeline", ".", "Get", "(", "key", ")", "\n", "}" ]
// Get implements RedisClient Get for pipeline
[ "Get", "implements", "RedisClient", "Get", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L404-L406
147,348
ulule/gokvstores
redis.go
MGet
func (r RedisPipeline) MGet(keys ...string) *redis.SliceCmd { return r.pipeline.MGet(keys...) }
go
func (r RedisPipeline) MGet(keys ...string) *redis.SliceCmd { return r.pipeline.MGet(keys...) }
[ "func", "(", "r", "RedisPipeline", ")", "MGet", "(", "keys", "...", "string", ")", "*", "redis", ".", "SliceCmd", "{", "return", "r", ".", "pipeline", ".", "MGet", "(", "keys", "...", ")", "\n", "}" ]
// MGet implements RedisClient MGet for pipeline
[ "MGet", "implements", "RedisClient", "MGet", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L409-L411
147,349
ulule/gokvstores
redis.go
Set
func (r RedisPipeline) Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd { return r.pipeline.Set(key, value, expiration) }
go
func (r RedisPipeline) Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd { return r.pipeline.Set(key, value, expiration) }
[ "func", "(", "r", "RedisPipeline", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ",", "expiration", "time", ".", "Duration", ")", "*", "redis", ".", "StatusCmd", "{", "return", "r", ".", "pipeline", ".", "Set", "(", "key", ",...
// Set implements RedisClient Set for pipeline
[ "Set", "implements", "RedisClient", "Set", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L414-L416
147,350
ulule/gokvstores
redis.go
HDel
func (r RedisPipeline) HDel(key string, fields ...string) *redis.IntCmd { return r.pipeline.HDel(key, fields...) }
go
func (r RedisPipeline) HDel(key string, fields ...string) *redis.IntCmd { return r.pipeline.HDel(key, fields...) }
[ "func", "(", "r", "RedisPipeline", ")", "HDel", "(", "key", "string", ",", "fields", "...", "string", ")", "*", "redis", ".", "IntCmd", "{", "return", "r", ".", "pipeline", ".", "HDel", "(", "key", ",", "fields", "...", ")", "\n", "}" ]
// HDel implements RedisClient HDel for pipeline
[ "HDel", "implements", "RedisClient", "HDel", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L419-L421
147,351
ulule/gokvstores
redis.go
HGetAll
func (r RedisPipeline) HGetAll(key string) *redis.StringStringMapCmd { return r.pipeline.HGetAll(key) }
go
func (r RedisPipeline) HGetAll(key string) *redis.StringStringMapCmd { return r.pipeline.HGetAll(key) }
[ "func", "(", "r", "RedisPipeline", ")", "HGetAll", "(", "key", "string", ")", "*", "redis", ".", "StringStringMapCmd", "{", "return", "r", ".", "pipeline", ".", "HGetAll", "(", "key", ")", "\n", "}" ]
// HGetAll implements RedisClient HGetAll for pipeline
[ "HGetAll", "implements", "RedisClient", "HGetAll", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L424-L426
147,352
ulule/gokvstores
redis.go
HMSet
func (r RedisPipeline) HMSet(key string, fields map[string]string) *redis.StatusCmd { return r.pipeline.HMSet(key, fields) }
go
func (r RedisPipeline) HMSet(key string, fields map[string]string) *redis.StatusCmd { return r.pipeline.HMSet(key, fields) }
[ "func", "(", "r", "RedisPipeline", ")", "HMSet", "(", "key", "string", ",", "fields", "map", "[", "string", "]", "string", ")", "*", "redis", ".", "StatusCmd", "{", "return", "r", ".", "pipeline", ".", "HMSet", "(", "key", ",", "fields", ")", "\n", ...
// HMSet implements RedisClient HMSet for pipeline
[ "HMSet", "implements", "RedisClient", "HMSet", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L429-L431
147,353
ulule/gokvstores
redis.go
SMembers
func (r RedisPipeline) SMembers(key string) *redis.StringSliceCmd { return r.pipeline.SMembers(key) }
go
func (r RedisPipeline) SMembers(key string) *redis.StringSliceCmd { return r.pipeline.SMembers(key) }
[ "func", "(", "r", "RedisPipeline", ")", "SMembers", "(", "key", "string", ")", "*", "redis", ".", "StringSliceCmd", "{", "return", "r", ".", "pipeline", ".", "SMembers", "(", "key", ")", "\n", "}" ]
// SMembers implements RedisClient SMembers for pipeline
[ "SMembers", "implements", "RedisClient", "SMembers", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L434-L436
147,354
ulule/gokvstores
redis.go
SAdd
func (r RedisPipeline) SAdd(key string, members ...interface{}) *redis.IntCmd { return r.pipeline.SAdd(key, members...) }
go
func (r RedisPipeline) SAdd(key string, members ...interface{}) *redis.IntCmd { return r.pipeline.SAdd(key, members...) }
[ "func", "(", "r", "RedisPipeline", ")", "SAdd", "(", "key", "string", ",", "members", "...", "interface", "{", "}", ")", "*", "redis", ".", "IntCmd", "{", "return", "r", ".", "pipeline", ".", "SAdd", "(", "key", ",", "members", "...", ")", "\n", "}...
// SAdd implements RedisClient SAdd for pipeline
[ "SAdd", "implements", "RedisClient", "SAdd", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L439-L441
147,355
ulule/gokvstores
redis.go
Keys
func (r RedisPipeline) Keys(pattern string) *redis.StringSliceCmd { return r.pipeline.Keys(pattern) }
go
func (r RedisPipeline) Keys(pattern string) *redis.StringSliceCmd { return r.pipeline.Keys(pattern) }
[ "func", "(", "r", "RedisPipeline", ")", "Keys", "(", "pattern", "string", ")", "*", "redis", ".", "StringSliceCmd", "{", "return", "r", ".", "pipeline", ".", "Keys", "(", "pattern", ")", "\n", "}" ]
// Keys implements RedisClient Keys for pipeline
[ "Keys", "implements", "RedisClient", "Keys", "for", "pipeline" ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/redis.go#L444-L446
147,356
laincloud/deployd
engine/podgroup.go
OperateOver
func (pgCtrl *podGroupController) OperateOver() { pgCtrl.emitOperationEvent(OperationOver) atomic.StoreInt32((*int32)(&pgCtrl.opState), PGOpStateIdle) pgCtrl.EnableRefresh() }
go
func (pgCtrl *podGroupController) OperateOver() { pgCtrl.emitOperationEvent(OperationOver) atomic.StoreInt32((*int32)(&pgCtrl.opState), PGOpStateIdle) pgCtrl.EnableRefresh() }
[ "func", "(", "pgCtrl", "*", "podGroupController", ")", "OperateOver", "(", ")", "{", "pgCtrl", ".", "emitOperationEvent", "(", "OperationOver", ")", "\n", "atomic", ".", "StoreInt32", "(", "(", "*", "int32", ")", "(", "&", "pgCtrl", ".", "opState", ")", ...
// called by signle goroutine
[ "called", "by", "signle", "goroutine" ]
e9d8307061a03612d4e9e91de682ec3a14dabdf0
https://github.com/laincloud/deployd/blob/e9d8307061a03612d4e9e91de682ec3a14dabdf0/engine/podgroup.go#L76-L80
147,357
ulule/gokvstores
memory.go
Get
func (c *MemoryStore) Get(key string) (interface{}, error) { item, _ := c.cache.Get(key) return item, nil }
go
func (c *MemoryStore) Get(key string) (interface{}, error) { item, _ := c.cache.Get(key) return item, nil }
[ "func", "(", "c", "*", "MemoryStore", ")", "Get", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "item", ",", "_", ":=", "c", ".", "cache", ".", "Get", "(", "key", ")", "\n", "return", "item", ",", "nil", "\n", ...
// Get returns item from the cache.
[ "Get", "returns", "item", "from", "the", "cache", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/memory.go#L17-L20
147,358
ulule/gokvstores
memory.go
SetSlice
func (c *MemoryStore) SetSlice(key string, value []interface{}) error { c.cache.Set(key, value, c.expiration) return nil }
go
func (c *MemoryStore) SetSlice(key string, value []interface{}) error { c.cache.Set(key, value, c.expiration) return nil }
[ "func", "(", "c", "*", "MemoryStore", ")", "SetSlice", "(", "key", "string", ",", "value", "[", "]", "interface", "{", "}", ")", "error", "{", "c", ".", "cache", ".", "Set", "(", "key", ",", "value", ",", "c", ".", "expiration", ")", "\n", "retur...
// SetSlice sets slice for the given key.
[ "SetSlice", "sets", "slice", "for", "the", "given", "key", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/memory.go#L102-L105
147,359
ulule/gokvstores
memory.go
Exists
func (c *MemoryStore) Exists(key string) (bool, error) { if _, exists := c.cache.Get(key); exists { return true, nil } return false, nil }
go
func (c *MemoryStore) Exists(key string) (bool, error) { if _, exists := c.cache.Get(key); exists { return true, nil } return false, nil }
[ "func", "(", "c", "*", "MemoryStore", ")", "Exists", "(", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "_", ",", "exists", ":=", "c", ".", "cache", ".", "Get", "(", "key", ")", ";", "exists", "{", "return", "true", ",", "nil...
// Exists checks if the given key exists.
[ "Exists", "checks", "if", "the", "given", "key", "exists", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/memory.go#L148-L153
147,360
ulule/gokvstores
memory.go
NewMemoryStore
func NewMemoryStore(expiration time.Duration, cleanupInterval time.Duration) (KVStore, error) { return &MemoryStore{ cache: cache.New(expiration, cleanupInterval), expiration: time.Duration(expiration) * time.Second, cleanupInterval: cleanupInterval, }, nil }
go
func NewMemoryStore(expiration time.Duration, cleanupInterval time.Duration) (KVStore, error) { return &MemoryStore{ cache: cache.New(expiration, cleanupInterval), expiration: time.Duration(expiration) * time.Second, cleanupInterval: cleanupInterval, }, nil }
[ "func", "NewMemoryStore", "(", "expiration", "time", ".", "Duration", ",", "cleanupInterval", "time", ".", "Duration", ")", "(", "KVStore", ",", "error", ")", "{", "return", "&", "MemoryStore", "{", "cache", ":", "cache", ".", "New", "(", "expiration", ","...
// NewMemoryStore returns in-memory KVStore.
[ "NewMemoryStore", "returns", "in", "-", "memory", "KVStore", "." ]
217d26b78e746e2f98a25b8f8d627748d961b8f6
https://github.com/ulule/gokvstores/blob/217d26b78e746e2f98a25b8f8d627748d961b8f6/memory.go#L156-L162
147,361
maruel/subcommands
subcommands.go
initCommand
func initCommand(a Application, c *Command, r CommandRun, out io.Writer, helpUsed *bool) { r.GetFlags().Usage = getCommandUsageHandler(out, a, c, r, helpUsed) r.GetFlags().SetOutput(out) r.GetFlags().Init(c.Name(), flag.ContinueOnError) }
go
func initCommand(a Application, c *Command, r CommandRun, out io.Writer, helpUsed *bool) { r.GetFlags().Usage = getCommandUsageHandler(out, a, c, r, helpUsed) r.GetFlags().SetOutput(out) r.GetFlags().Init(c.Name(), flag.ContinueOnError) }
[ "func", "initCommand", "(", "a", "Application", ",", "c", "*", "Command", ",", "r", "CommandRun", ",", "out", "io", ".", "Writer", ",", "helpUsed", "*", "bool", ")", "{", "r", ".", "GetFlags", "(", ")", ".", "Usage", "=", "getCommandUsageHandler", "(",...
// Initializes the flags for a specific CommandRun.
[ "Initializes", "the", "flags", "for", "a", "specific", "CommandRun", "." ]
967e945be48bc4df686f64d0ff2aac67e9d1b6ec
https://github.com/maruel/subcommands/blob/967e945be48bc4df686f64d0ff2aac67e9d1b6ec/subcommands.go#L251-L255
147,362
maruel/subcommands
subcommands.go
FindCommand
func FindCommand(a Application, name string) *Command { for _, c := range a.GetCommands() { if c.Name() == name { return c } } return nil }
go
func FindCommand(a Application, name string) *Command { for _, c := range a.GetCommands() { if c.Name() == name { return c } } return nil }
[ "func", "FindCommand", "(", "a", "Application", ",", "name", "string", ")", "*", "Command", "{", "for", "_", ",", "c", ":=", "range", "a", ".", "GetCommands", "(", ")", "{", "if", "c", ".", "Name", "(", ")", "==", "name", "{", "return", "c", "\n"...
// FindCommand finds a Command by name and returns it if found.
[ "FindCommand", "finds", "a", "Command", "by", "name", "and", "returns", "it", "if", "found", "." ]
967e945be48bc4df686f64d0ff2aac67e9d1b6ec
https://github.com/maruel/subcommands/blob/967e945be48bc4df686f64d0ff2aac67e9d1b6ec/subcommands.go#L258-L265
147,363
maruel/subcommands
subcommands.go
FindNearestCommand
func FindNearestCommand(a Application, name string) *Command { commands := map[string]*Command{} for _, c := range a.GetCommands() { if !c.isSection { commands[c.Name()] = c } } if c, ok := commands[name]; ok { return c } // Search for unique prefix. withPrefix := []*Command{} for n, c := range comman...
go
func FindNearestCommand(a Application, name string) *Command { commands := map[string]*Command{} for _, c := range a.GetCommands() { if !c.isSection { commands[c.Name()] = c } } if c, ok := commands[name]; ok { return c } // Search for unique prefix. withPrefix := []*Command{} for n, c := range comman...
[ "func", "FindNearestCommand", "(", "a", "Application", ",", "name", "string", ")", "*", "Command", "{", "commands", ":=", "map", "[", "string", "]", "*", "Command", "{", "}", "\n", "for", "_", ",", "c", ":=", "range", "a", ".", "GetCommands", "(", ")...
// FindNearestCommand heuristically finds a Command the user wanted to type but // failed to type correctly.
[ "FindNearestCommand", "heuristically", "finds", "a", "Command", "the", "user", "wanted", "to", "type", "but", "failed", "to", "type", "correctly", "." ]
967e945be48bc4df686f64d0ff2aac67e9d1b6ec
https://github.com/maruel/subcommands/blob/967e945be48bc4df686f64d0ff2aac67e9d1b6ec/subcommands.go#L269-L326
147,364
maruel/subcommands
subcommands.go
Run
func Run(a Application, args []string) int { var helpUsed bool // Process general flags first, mainly for -help. flag.Usage = func() { usage(a.GetErr(), a, false) helpUsed = true } // Do not parse during unit tests because flag.commandLine.errorHandling == ExitOnError. :( // It is safer to use a base class ...
go
func Run(a Application, args []string) int { var helpUsed bool // Process general flags first, mainly for -help. flag.Usage = func() { usage(a.GetErr(), a, false) helpUsed = true } // Do not parse during unit tests because flag.commandLine.errorHandling == ExitOnError. :( // It is safer to use a base class ...
[ "func", "Run", "(", "a", "Application", ",", "args", "[", "]", "string", ")", "int", "{", "var", "helpUsed", "bool", "\n\n", "// Process general flags first, mainly for -help.", "flag", ".", "Usage", "=", "func", "(", ")", "{", "usage", "(", "a", ".", "Get...
// Run runs the application, scheduling the subcommand. This is the main entry // point of the library.
[ "Run", "runs", "the", "application", "scheduling", "the", "subcommand", ".", "This", "is", "the", "main", "entry", "point", "of", "the", "library", "." ]
967e945be48bc4df686f64d0ff2aac67e9d1b6ec
https://github.com/maruel/subcommands/blob/967e945be48bc4df686f64d0ff2aac67e9d1b6ec/subcommands.go#L330-L378
147,365
laincloud/deployd
engine/engine.go
operatings
func operatings(store storage.Store) []string { operatingPrefixKey := kLainDeploydRootKey + "/" + kLainPgOpingKey results := make([]string, 0) if keys, err := store.KeysByPrefix(operatingPrefixKey); err != nil { log.Warnf("[Store] Failed to fetch operating pod groups %s, %s", operatingPrefixKey, err) } else { f...
go
func operatings(store storage.Store) []string { operatingPrefixKey := kLainDeploydRootKey + "/" + kLainPgOpingKey results := make([]string, 0) if keys, err := store.KeysByPrefix(operatingPrefixKey); err != nil { log.Warnf("[Store] Failed to fetch operating pod groups %s, %s", operatingPrefixKey, err) } else { f...
[ "func", "operatings", "(", "store", "storage", ".", "Store", ")", "[", "]", "string", "{", "operatingPrefixKey", ":=", "kLainDeploydRootKey", "+", "\"", "\"", "+", "kLainPgOpingKey", "\n", "results", ":=", "make", "(", "[", "]", "string", ",", "0", ")", ...
// fetch all operating pgs' name
[ "fetch", "all", "operating", "pgs", "name" ]
e9d8307061a03612d4e9e91de682ec3a14dabdf0
https://github.com/laincloud/deployd/blob/e9d8307061a03612d4e9e91de682ec3a14dabdf0/engine/engine.go#L667-L678
147,366
laincloud/deployd
utils/util/util.go
ParseContainerName
func ParseContainerName(containerName string) (string, int, int, int, error) { p := regex.MustCompile(`(.*)\.v([0-9]+)-i([0-9]+)-d([0-9]+)`) g := p.Match(containerName) if g == nil { return "", 0, 0, 0, ErrContainerMatchFailed } version, err := strconv.Atoi(g.Group(2)) if err != nil { return "", 0, 0, 0, ErrC...
go
func ParseContainerName(containerName string) (string, int, int, int, error) { p := regex.MustCompile(`(.*)\.v([0-9]+)-i([0-9]+)-d([0-9]+)`) g := p.Match(containerName) if g == nil { return "", 0, 0, 0, ErrContainerMatchFailed } version, err := strconv.Atoi(g.Group(2)) if err != nil { return "", 0, 0, 0, ErrC...
[ "func", "ParseContainerName", "(", "containerName", "string", ")", "(", "string", ",", "int", ",", "int", ",", "int", ",", "error", ")", "{", "p", ":=", "regex", ".", "MustCompile", "(", "`(.*)\\.v([0-9]+)-i([0-9]+)-d([0-9]+)`", ")", "\n", "g", ":=", "p", ...
// pgname, version, instance, driftcount
[ "pgname", "version", "instance", "driftcount" ]
e9d8307061a03612d4e9e91de682ec3a14dabdf0
https://github.com/laincloud/deployd/blob/e9d8307061a03612d4e9e91de682ec3a14dabdf0/utils/util/util.go#L32-L51
147,367
laincloud/deployd
engine/node.go
refreshPodsByNode
func (ev *RuntimeEagleView) refreshPodsByNode(c cluster.Cluster, nodes []string) ([]RuntimeEaglePod, error) { totalContainers := 0 start := time.Now() defer func() { log.Infof("<RuntimeEagleView> pods by node %v refreshed, #containers=%d, duration=%s", nodes, totalContainers, time.Now().Sub(start)) }() nodeFi...
go
func (ev *RuntimeEagleView) refreshPodsByNode(c cluster.Cluster, nodes []string) ([]RuntimeEaglePod, error) { totalContainers := 0 start := time.Now() defer func() { log.Infof("<RuntimeEagleView> pods by node %v refreshed, #containers=%d, duration=%s", nodes, totalContainers, time.Now().Sub(start)) }() nodeFi...
[ "func", "(", "ev", "*", "RuntimeEagleView", ")", "refreshPodsByNode", "(", "c", "cluster", ".", "Cluster", ",", "nodes", "[", "]", "string", ")", "(", "[", "]", "RuntimeEaglePod", ",", "error", ")", "{", "totalContainers", ":=", "0", "\n", "start", ":=",...
// Fetch all containers in target nodes
[ "Fetch", "all", "containers", "in", "target", "nodes" ]
e9d8307061a03612d4e9e91de682ec3a14dabdf0
https://github.com/laincloud/deployd/blob/e9d8307061a03612d4e9e91de682ec3a14dabdf0/engine/node.go#L37-L58
147,368
lestrrat-go/pdebug
debug_on.go
IPrintf
func IPrintf(f string, args ...interface{}) legacyg { if !Trace { return emptylegacyg } DefaultCtx.Printf(f, args...) g := legacyg{ guard: DefaultCtx.Indent(), start: time.Now(), } return g }
go
func IPrintf(f string, args ...interface{}) legacyg { if !Trace { return emptylegacyg } DefaultCtx.Printf(f, args...) g := legacyg{ guard: DefaultCtx.Indent(), start: time.Now(), } return g }
[ "func", "IPrintf", "(", "f", "string", ",", "args", "...", "interface", "{", "}", ")", "legacyg", "{", "if", "!", "Trace", "{", "return", "emptylegacyg", "\n", "}", "\n\n", "DefaultCtx", ".", "Printf", "(", "f", ",", "args", "...", ")", "\n", "g", ...
// IPrintf indents and then prints debug messages. Execute the callback // to undo the indent
[ "IPrintf", "indents", "and", "then", "prints", "debug", "messages", ".", "Execute", "the", "callback", "to", "undo", "the", "indent" ]
39f9a71bcabe9432cbdfe4d3d33f41988acd2ce6
https://github.com/lestrrat-go/pdebug/blob/39f9a71bcabe9432cbdfe4d3d33f41988acd2ce6/debug_on.go#L144-L155
147,369
tylerb/is
is.go
New
func New(tb testing.TB) *Is { if tb == nil { log.Fatalln("You must provide a testing object.") } return &Is{TB: tb, strict: true} }
go
func New(tb testing.TB) *Is { if tb == nil { log.Fatalln("You must provide a testing object.") } return &Is{TB: tb, strict: true} }
[ "func", "New", "(", "tb", "testing", ".", "TB", ")", "*", "Is", "{", "if", "tb", "==", "nil", "{", "log", ".", "Fatalln", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "&", "Is", "{", "TB", ":", "tb", ",", "strict", ":", "true", "}", "\n...
// New creates a new instance of the Is object and stores a reference to the // provided testing object.
[ "New", "creates", "a", "new", "instance", "of", "the", "Is", "object", "and", "stores", "a", "reference", "to", "the", "provided", "testing", "object", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L33-L38
147,370
tylerb/is
is.go
Msg
func (is *Is) Msg(format string, args ...interface{}) *Is { return &Is{ TB: is.TB, strict: is.strict, failFormat: format, failArgs: args, } }
go
func (is *Is) Msg(format string, args ...interface{}) *Is { return &Is{ TB: is.TB, strict: is.strict, failFormat: format, failArgs: args, } }
[ "func", "(", "is", "*", "Is", ")", "Msg", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "*", "Is", "{", "return", "&", "Is", "{", "TB", ":", "is", ".", "TB", ",", "strict", ":", "is", ".", "strict", ",", "failFormat",...
// Msg defines a message to print in the event of a failure. This allows you // to print out additional information about a failure if it happens.
[ "Msg", "defines", "a", "message", "to", "print", "in", "the", "event", "of", "a", "failure", ".", "This", "allows", "you", "to", "print", "out", "additional", "information", "about", "a", "failure", "if", "it", "happens", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L61-L68
147,371
tylerb/is
is.go
Lax
func (is *Is) Lax() *Is { return &Is{ TB: is.TB, strict: false, failFormat: is.failFormat, failArgs: is.failArgs, } }
go
func (is *Is) Lax() *Is { return &Is{ TB: is.TB, strict: false, failFormat: is.failFormat, failArgs: is.failArgs, } }
[ "func", "(", "is", "*", "Is", ")", "Lax", "(", ")", "*", "Is", "{", "return", "&", "Is", "{", "TB", ":", "is", ".", "TB", ",", "strict", ":", "false", ",", "failFormat", ":", "is", ".", "failFormat", ",", "failArgs", ":", "is", ".", "failArgs",...
// Lax returns a copy of this instance of Is which does not abort the test if // a failure occurs. Use this to run a set of tests and see all the failures // at once.
[ "Lax", "returns", "a", "copy", "of", "this", "instance", "of", "Is", "which", "does", "not", "abort", "the", "test", "if", "a", "failure", "occurs", ".", "Use", "this", "to", "run", "a", "set", "of", "tests", "and", "see", "all", "the", "failures", "...
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L96-L103
147,372
tylerb/is
is.go
Strict
func (is *Is) Strict() *Is { return &Is{ TB: is.TB, strict: true, failFormat: is.failFormat, failArgs: is.failArgs, } }
go
func (is *Is) Strict() *Is { return &Is{ TB: is.TB, strict: true, failFormat: is.failFormat, failArgs: is.failArgs, } }
[ "func", "(", "is", "*", "Is", ")", "Strict", "(", ")", "*", "Is", "{", "return", "&", "Is", "{", "TB", ":", "is", ".", "TB", ",", "strict", ":", "true", ",", "failFormat", ":", "is", ".", "failFormat", ",", "failArgs", ":", "is", ".", "failArgs...
// Strict returns a copy of this instance of Is which aborts the test if a // failure occurs. This is the default behavior, thus this method has no // effect unless it is used to reverse a previous call to Lax.
[ "Strict", "returns", "a", "copy", "of", "this", "instance", "of", "Is", "which", "aborts", "the", "test", "if", "a", "failure", "occurs", ".", "This", "is", "the", "default", "behavior", "thus", "this", "method", "has", "no", "effect", "unless", "it", "i...
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L108-L115
147,373
tylerb/is
is.go
Err
func (is *Is) Err(e error) { is.TB.Helper() if isNil(e) { fail(is, "expected error") } }
go
func (is *Is) Err(e error) { is.TB.Helper() if isNil(e) { fail(is, "expected error") } }
[ "func", "(", "is", "*", "Is", ")", "Err", "(", "e", "error", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "if", "isNil", "(", "e", ")", "{", "fail", "(", "is", ",", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// Err checks the provided error object to determine if an error is present.
[ "Err", "checks", "the", "provided", "error", "object", "to", "determine", "if", "an", "error", "is", "present", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L194-L199
147,374
tylerb/is
is.go
Nil
func (is *Is) Nil(o interface{}) { is.TB.Helper() if !isNil(o) { fail(is, "expected object '%s' to be nil, but got: %v", objectTypeName(o), o) } }
go
func (is *Is) Nil(o interface{}) { is.TB.Helper() if !isNil(o) { fail(is, "expected object '%s' to be nil, but got: %v", objectTypeName(o), o) } }
[ "func", "(", "is", "*", "Is", ")", "Nil", "(", "o", "interface", "{", "}", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "if", "!", "isNil", "(", "o", ")", "{", "fail", "(", "is", ",", "\"", "\"", ",", "objectTypeName", "(", "o"...
// Nil checks the provided object to determine if it is nil.
[ "Nil", "checks", "the", "provided", "object", "to", "determine", "if", "it", "is", "nil", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L211-L216
147,375
tylerb/is
is.go
True
func (is *Is) True(b bool) { is.TB.Helper() if !b { fail(is, "expected boolean to be true") } }
go
func (is *Is) True(b bool) { is.TB.Helper() if !b { fail(is, "expected boolean to be true") } }
[ "func", "(", "is", "*", "Is", ")", "True", "(", "b", "bool", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "if", "!", "b", "{", "fail", "(", "is", ",", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// True checks the provided boolean to determine if it is true.
[ "True", "checks", "the", "provided", "boolean", "to", "determine", "if", "it", "is", "true", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L227-L232
147,376
tylerb/is
is.go
False
func (is *Is) False(b bool) { is.TB.Helper() if b { fail(is, "expected boolean to be false") } }
go
func (is *Is) False(b bool) { is.TB.Helper() if b { fail(is, "expected boolean to be false") } }
[ "func", "(", "is", "*", "Is", ")", "False", "(", "b", "bool", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "if", "b", "{", "fail", "(", "is", ",", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// False checks the provided boolean to determine if is false.
[ "False", "checks", "the", "provided", "boolean", "to", "determine", "if", "is", "false", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L235-L240
147,377
tylerb/is
is.go
Zero
func (is *Is) Zero(o interface{}) { is.TB.Helper() if !isZero(o) { fail(is, "expected object '%s' to be zero value, but it was: %v", objectTypeName(o), o) } }
go
func (is *Is) Zero(o interface{}) { is.TB.Helper() if !isZero(o) { fail(is, "expected object '%s' to be zero value, but it was: %v", objectTypeName(o), o) } }
[ "func", "(", "is", "*", "Is", ")", "Zero", "(", "o", "interface", "{", "}", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "if", "!", "isZero", "(", "o", ")", "{", "fail", "(", "is", ",", "\"", "\"", ",", "objectTypeName", "(", "...
// Zero checks the provided object to determine if it is the zero value // for the type of that object. The zero value is the same as what the object // would contain when initialized but not assigned. // // This method, for example, would be used to determine if a string is empty, // an array is empty or a map is empt...
[ "Zero", "checks", "the", "provided", "object", "to", "determine", "if", "it", "is", "the", "zero", "value", "for", "the", "type", "of", "that", "object", ".", "The", "zero", "value", "is", "the", "same", "as", "what", "the", "object", "would", "contain",...
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L252-L257
147,378
tylerb/is
is.go
Len
func (is *Is) Len(o interface{}, l int) { is.TB.Helper() t := reflect.TypeOf(o) if o == nil || (t.Kind() != reflect.Array && t.Kind() != reflect.Slice && t.Kind() != reflect.Map) { fail(is, "expected object '%s' to be of length '%d', but the object is not one of array, slice or map", objectTypeName(o), l) ...
go
func (is *Is) Len(o interface{}, l int) { is.TB.Helper() t := reflect.TypeOf(o) if o == nil || (t.Kind() != reflect.Array && t.Kind() != reflect.Slice && t.Kind() != reflect.Map) { fail(is, "expected object '%s' to be of length '%d', but the object is not one of array, slice or map", objectTypeName(o), l) ...
[ "func", "(", "is", "*", "Is", ")", "Len", "(", "o", "interface", "{", "}", ",", "l", "int", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "t", ":=", "reflect", ".", "TypeOf", "(", "o", ")", "\n", "if", "o", "==", "nil", "||", ...
// Len checks the provided object to determine if it is the same length as the // provided length argument. // // If the object is not one of type array, slice or map, it will fail.
[ "Len", "checks", "the", "provided", "object", "to", "determine", "if", "it", "is", "the", "same", "length", "as", "the", "provided", "length", "argument", ".", "If", "the", "object", "is", "not", "one", "of", "type", "array", "slice", "or", "map", "it", ...
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L280-L295
147,379
tylerb/is
is.go
ShouldPanic
func (is *Is) ShouldPanic(f func()) { is.TB.Helper() defer func() { r := recover() if r == nil { fail(is, "expected function to panic") } }() f() }
go
func (is *Is) ShouldPanic(f func()) { is.TB.Helper() defer func() { r := recover() if r == nil { fail(is, "expected function to panic") } }() f() }
[ "func", "(", "is", "*", "Is", ")", "ShouldPanic", "(", "f", "func", "(", ")", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "defer", "func", "(", ")", "{", "r", ":=", "recover", "(", ")", "\n", "if", "r", "==", "nil", "{", "fail...
// ShouldPanic expects the provided function to panic. If the function does // not panic, this assertion fails.
[ "ShouldPanic", "expects", "the", "provided", "function", "to", "panic", ".", "If", "the", "function", "does", "not", "panic", "this", "assertion", "fails", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L299-L308
147,380
tylerb/is
is.go
EqualType
func (is *Is) EqualType(expected, actual interface{}) { is.TB.Helper() if reflect.TypeOf(expected) != reflect.TypeOf(actual) { fail(is, "expected objects '%s' to be of the same type as object '%s'", objectTypeName(expected), objectTypeName(actual)) } }
go
func (is *Is) EqualType(expected, actual interface{}) { is.TB.Helper() if reflect.TypeOf(expected) != reflect.TypeOf(actual) { fail(is, "expected objects '%s' to be of the same type as object '%s'", objectTypeName(expected), objectTypeName(actual)) } }
[ "func", "(", "is", "*", "Is", ")", "EqualType", "(", "expected", ",", "actual", "interface", "{", "}", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "if", "reflect", ".", "TypeOf", "(", "expected", ")", "!=", "reflect", ".", "TypeOf", ...
// EqualType checks the type of the two provided objects and // fails if they are not the same.
[ "EqualType", "checks", "the", "type", "of", "the", "two", "provided", "objects", "and", "fails", "if", "they", "are", "not", "the", "same", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L312-L317
147,381
tylerb/is
is.go
WaitForTrue
func (is *Is) WaitForTrue(timeout time.Duration, f func() bool) { is.TB.Helper() after := time.After(timeout) for { select { case <-after: fail(is, "function did not return true within the timeout of %v", timeout) return default: if f() { return } time.Sleep(100 * time.Millisecond) } } }
go
func (is *Is) WaitForTrue(timeout time.Duration, f func() bool) { is.TB.Helper() after := time.After(timeout) for { select { case <-after: fail(is, "function did not return true within the timeout of %v", timeout) return default: if f() { return } time.Sleep(100 * time.Millisecond) } } }
[ "func", "(", "is", "*", "Is", ")", "WaitForTrue", "(", "timeout", "time", ".", "Duration", ",", "f", "func", "(", ")", "bool", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n", "after", ":=", "time", ".", "After", "(", "timeout", ")", "...
// WaitForTrue waits until the provided func returns true. If the timeout is // reached before the function returns true, the test will fail.
[ "WaitForTrue", "waits", "until", "the", "provided", "func", "returns", "true", ".", "If", "the", "timeout", "is", "reached", "before", "the", "function", "returns", "true", "the", "test", "will", "fail", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/is.go#L321-L336
147,382
tylerb/is
workers.go
failDefault
func failDefault(is *Is, format string, args ...interface{}) { is.TB.Helper() failFmt := format if len(is.failFormat) != 0 { failFmt = fmt.Sprintf("%s - %s", format, is.failFormat) args = append(args, is.failArgs...) } if is.strict { is.TB.Fatalf(failFmt, args...) } else { is.TB.Errorf(failFmt, args...) ...
go
func failDefault(is *Is, format string, args ...interface{}) { is.TB.Helper() failFmt := format if len(is.failFormat) != 0 { failFmt = fmt.Sprintf("%s - %s", format, is.failFormat) args = append(args, is.failArgs...) } if is.strict { is.TB.Fatalf(failFmt, args...) } else { is.TB.Errorf(failFmt, args...) ...
[ "func", "failDefault", "(", "is", "*", "Is", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "is", ".", "TB", ".", "Helper", "(", ")", "\n\n", "failFmt", ":=", "format", "\n", "if", "len", "(", "is", ".", "failFormat",...
// failDefault is the default failure function.
[ "failDefault", "is", "the", "default", "failure", "function", "." ]
3f742be80976be6f8876250eb36db785a88dfe33
https://github.com/tylerb/is/blob/3f742be80976be6f8876250eb36db785a88dfe33/workers.go#L98-L111
147,383
relistan/go-director
director.go
Done
func (l *TimedLooper) Done(err error) { if l.DoneChan != nil { l.DoneChan <- err } }
go
func (l *TimedLooper) Done(err error) { if l.DoneChan != nil { l.DoneChan <- err } }
[ "func", "(", "l", "*", "TimedLooper", ")", "Done", "(", "err", "error", ")", "{", "if", "l", ".", "DoneChan", "!=", "nil", "{", "l", ".", "DoneChan", "<-", "err", "\n", "}", "\n", "}" ]
// Signal a dependant routine that we're done with our work
[ "Signal", "a", "dependant", "routine", "that", "we", "re", "done", "with", "our", "work" ]
5f56787d973127a1c878fb5cff31ff100846714c
https://github.com/relistan/go-director/blob/5f56787d973127a1c878fb5cff31ff100846714c/director.go#L66-L70
147,384
relistan/go-director
director.go
Done
func (l *FreeLooper) Done(err error) { if l.DoneChan != nil { l.DoneChan <- err } }
go
func (l *FreeLooper) Done(err error) { if l.DoneChan != nil { l.DoneChan <- err } }
[ "func", "(", "l", "*", "FreeLooper", ")", "Done", "(", "err", "error", ")", "{", "if", "l", ".", "DoneChan", "!=", "nil", "{", "l", ".", "DoneChan", "<-", "err", "\n", "}", "\n", "}" ]
// This is used internally, but can also be used by controlling routines // to signal that a job is completed. The FreeLooper doesn's support its // use outside the internals.
[ "This", "is", "used", "internally", "but", "can", "also", "be", "used", "by", "controlling", "routines", "to", "signal", "that", "a", "job", "is", "completed", ".", "The", "FreeLooper", "doesn", "s", "support", "its", "use", "outside", "the", "internals", ...
5f56787d973127a1c878fb5cff31ff100846714c
https://github.com/relistan/go-director/blob/5f56787d973127a1c878fb5cff31ff100846714c/director.go#L160-L164
147,385
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
Initialize
func (sc *SpriteContainer) Initialize(gl GLer) { simlog.FuncIn() sc.gl = gl GetTouchPeer().AddTouchListener(sc) simlog.FuncOut() }
go
func (sc *SpriteContainer) Initialize(gl GLer) { simlog.FuncIn() sc.gl = gl GetTouchPeer().AddTouchListener(sc) simlog.FuncOut() }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "Initialize", "(", "gl", "GLer", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "sc", ".", "gl", "=", "gl", "\n", "GetTouchPeer", "(", ")", ".", "AddTouchListener", "(", "sc", ")", "\n", "simlog", ...
// Initialize initializes SpriteContainer object. // This must be called to use all SpriteContainer's function in advance.
[ "Initialize", "initializes", "SpriteContainer", "object", ".", "This", "must", "be", "called", "to", "use", "all", "SpriteContainer", "s", "function", "in", "advance", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L70-L75
147,386
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
AddSprite
func (sc *SpriteContainer) AddSprite(s *Sprite, subTex *sprite.SubTex, arrangeCallback func()) error { simlog.FuncIn() var sn *spriteNodePair i, ok := sc.spriteNodePairs.Load(s) if !ok { sn = &spriteNodePair{} } else { sn = i.(*spriteNodePair) if sn.inuse { return fmt.Errorf("this sprite is already added ...
go
func (sc *SpriteContainer) AddSprite(s *Sprite, subTex *sprite.SubTex, arrangeCallback func()) error { simlog.FuncIn() var sn *spriteNodePair i, ok := sc.spriteNodePairs.Load(s) if !ok { sn = &spriteNodePair{} } else { sn = i.(*spriteNodePair) if sn.inuse { return fmt.Errorf("this sprite is already added ...
[ "func", "(", "sc", "*", "SpriteContainer", ")", "AddSprite", "(", "s", "*", "Sprite", ",", "subTex", "*", "sprite", ".", "SubTex", ",", "arrangeCallback", "func", "(", ")", ")", "error", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "var", "sn", "*",...
// AddSprite adds a sprite to SpriteContainer.
[ "AddSprite", "adds", "a", "sprite", "to", "SpriteContainer", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L78-L107
147,387
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
RemoveSprite
func (sc *SpriteContainer) RemoveSprite(remove *Sprite) { simlog.FuncIn() i, ok := sc.spriteNodePairs.Load(remove) if !ok { return } sn := i.(*spriteNodePair) if !sn.inuse { simlog.Debug("already removed.") return } sn.inuse = false sc.gl.RemoveNode(sn.znode) simlog.FuncOut() }
go
func (sc *SpriteContainer) RemoveSprite(remove *Sprite) { simlog.FuncIn() i, ok := sc.spriteNodePairs.Load(remove) if !ok { return } sn := i.(*spriteNodePair) if !sn.inuse { simlog.Debug("already removed.") return } sn.inuse = false sc.gl.RemoveNode(sn.znode) simlog.FuncOut() }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "RemoveSprite", "(", "remove", "*", "Sprite", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "i", ",", "ok", ":=", "sc", ".", "spriteNodePairs", ".", "Load", "(", "remove", ")", "\n", "if", "!", "...
// RemoveSprite removes a specified sprite from SpriteContainer. // Since Unregister of Node is not implemented by gomobile, this function just // marks the specified sprite as "not in use". // The sprite marked as "not in use" will be reused at AddSprite.
[ "RemoveSprite", "removes", "a", "specified", "sprite", "from", "SpriteContainer", ".", "Since", "Unregister", "of", "Node", "is", "not", "implemented", "by", "gomobile", "this", "function", "just", "marks", "the", "specified", "sprite", "as", "not", "in", "use",...
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L113-L127
147,388
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
RemoveSprites
func (sc *SpriteContainer) RemoveSprites() { simlog.FuncIn() sc.spriteNodePairs = sync.Map{} simlog.FuncOut() }
go
func (sc *SpriteContainer) RemoveSprites() { simlog.FuncIn() sc.spriteNodePairs = sync.Map{} simlog.FuncOut() }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "RemoveSprites", "(", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "sc", ".", "spriteNodePairs", "=", "sync", ".", "Map", "{", "}", "\n", "simlog", ".", "FuncOut", "(", ")", "\n", "}" ]
// RemoveSprites removes all registered sprites from SpriteContainer.
[ "RemoveSprites", "removes", "all", "registered", "sprites", "from", "SpriteContainer", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L130-L134
147,389
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
SetZIndex
func (sc *SpriteContainer) SetZIndex(s *Sprite, z int) error { simlog.FuncIn() i, ok := sc.spriteNodePairs.Load(s) if !ok { return fmt.Errorf("specified sprite [%p] not found", s) } sn := i.(*spriteNodePair) if sn.znode.ZIndex != z { sn.znode.ZIndex = z sc.gl.ZIndexDirty() } return nil }
go
func (sc *SpriteContainer) SetZIndex(s *Sprite, z int) error { simlog.FuncIn() i, ok := sc.spriteNodePairs.Load(s) if !ok { return fmt.Errorf("specified sprite [%p] not found", s) } sn := i.(*spriteNodePair) if sn.znode.ZIndex != z { sn.znode.ZIndex = z sc.gl.ZIndexDirty() } return nil }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "SetZIndex", "(", "s", "*", "Sprite", ",", "z", "int", ")", "error", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "i", ",", "ok", ":=", "sc", ".", "spriteNodePairs", ".", "Load", "(", "s", ")", "\n...
// SetZIndex sets specified zindex to specified Sprite
[ "SetZIndex", "sets", "specified", "zindex", "to", "specified", "Sprite" ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L137-L149
147,390
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
GetZIndex
func (sc *SpriteContainer) GetZIndex(s *Sprite) (int, error) { simlog.FuncIn() i, ok := sc.spriteNodePairs.Load(s) if !ok { return 0, fmt.Errorf("specified sprite [%p] not found", s) } sn := i.(*spriteNodePair) return sn.znode.ZIndex, nil }
go
func (sc *SpriteContainer) GetZIndex(s *Sprite) (int, error) { simlog.FuncIn() i, ok := sc.spriteNodePairs.Load(s) if !ok { return 0, fmt.Errorf("specified sprite [%p] not found", s) } sn := i.(*spriteNodePair) return sn.znode.ZIndex, nil }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "GetZIndex", "(", "s", "*", "Sprite", ")", "(", "int", ",", "error", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "i", ",", "ok", ":=", "sc", ".", "spriteNodePairs", ".", "Load", "(", "s", ")"...
// GetZIndex returns specified sprite's zindex
[ "GetZIndex", "returns", "specified", "sprite", "s", "zindex" ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L152-L160
147,391
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
ReplaceTexture
func (sc *SpriteContainer) ReplaceTexture(sprite *Sprite, texture *Texture) { simlog.FuncIn() if i, ok := sc.spriteNodePairs.Load(sprite); ok { node := i.(*spriteNodePair).znode sc.gl.SetSubTex(node, &texture.subTex) } simlog.FuncOut() }
go
func (sc *SpriteContainer) ReplaceTexture(sprite *Sprite, texture *Texture) { simlog.FuncIn() if i, ok := sc.spriteNodePairs.Load(sprite); ok { node := i.(*spriteNodePair).znode sc.gl.SetSubTex(node, &texture.subTex) } simlog.FuncOut() }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "ReplaceTexture", "(", "sprite", "*", "Sprite", ",", "texture", "*", "Texture", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "if", "i", ",", "ok", ":=", "sc", ".", "spriteNodePairs", ".", "Load", ...
// ReplaceTexture replaces sprite's texture to specified one.
[ "ReplaceTexture", "replaces", "sprite", "s", "texture", "to", "specified", "one", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L168-L175
147,392
pankona/gomo-simra
simra/internal/peer/spritecontainer.go
OnTouchBegin
func (sc *SpriteContainer) OnTouchBegin(x, y float32) { sc.emitTouchEvent(x, y, touchBegin) }
go
func (sc *SpriteContainer) OnTouchBegin(x, y float32) { sc.emitTouchEvent(x, y, touchBegin) }
[ "func", "(", "sc", "*", "SpriteContainer", ")", "OnTouchBegin", "(", "x", ",", "y", "float32", ")", "{", "sc", ".", "emitTouchEvent", "(", "x", ",", "y", ",", "touchBegin", ")", "\n", "}" ]
// OnTouchBegin is called when screen is started to touch. // This function calls listener's OnTouchBegin if the touched position is // contained by sprite's rectangle.
[ "OnTouchBegin", "is", "called", "when", "screen", "is", "started", "to", "touch", ".", "This", "function", "calls", "listener", "s", "OnTouchBegin", "if", "the", "touched", "position", "is", "contained", "by", "sprite", "s", "rectangle", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/spritecontainer.go#L226-L228
147,393
pankona/gomo-simra
simra/internal/peer/sprite.go
RemoveAllTouchListener
func (s *Sprite) RemoveAllTouchListener() { simlog.FuncIn() s.touchListeners = nil simlog.FuncOut() }
go
func (s *Sprite) RemoveAllTouchListener() { simlog.FuncIn() s.touchListeners = nil simlog.FuncOut() }
[ "func", "(", "s", "*", "Sprite", ")", "RemoveAllTouchListener", "(", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "s", ".", "touchListeners", "=", "nil", "\n", "simlog", ".", "FuncOut", "(", ")", "\n", "}" ]
// RemoveAllTouchListener removes all registered listeners from sprite.
[ "RemoveAllTouchListener", "removes", "all", "registered", "listeners", "from", "sprite", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/sprite.go#L43-L47
147,394
pankona/gomo-simra
simra/sprite.go
ReplaceTexture
func (sprite *sprite) ReplaceTexture(texture *Texture) { simlog.FuncIn() // retain reference for texture to avoid to be discarded by GC sprite.texture = texture sc := sprite.simra.spritecontainer sc.ReplaceTexture(&sprite.Sprite, texture.texture) simlog.FuncOut() }
go
func (sprite *sprite) ReplaceTexture(texture *Texture) { simlog.FuncIn() // retain reference for texture to avoid to be discarded by GC sprite.texture = texture sc := sprite.simra.spritecontainer sc.ReplaceTexture(&sprite.Sprite, texture.texture) simlog.FuncOut() }
[ "func", "(", "sprite", "*", "sprite", ")", "ReplaceTexture", "(", "texture", "*", "Texture", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "// retain reference for texture to avoid to be discarded by GC", "sprite", ".", "texture", "=", "texture", "\n", "sc", ...
// ReplaceTexture replaces sprite's texture with specified image resource.
[ "ReplaceTexture", "replaces", "sprite", "s", "texture", "with", "specified", "image", "resource", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/sprite.go#L68-L75
147,395
pankona/gomo-simra
simra/sprite.go
AddTouchListener
func (sprite *sprite) AddTouchListener(listener peer.TouchListener) { simlog.FuncIn() sprite.Sprite.AddTouchListener(listener) simlog.FuncOut() }
go
func (sprite *sprite) AddTouchListener(listener peer.TouchListener) { simlog.FuncIn() sprite.Sprite.AddTouchListener(listener) simlog.FuncOut() }
[ "func", "(", "sprite", "*", "sprite", ")", "AddTouchListener", "(", "listener", "peer", ".", "TouchListener", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "sprite", ".", "Sprite", ".", "AddTouchListener", "(", "listener", ")", "\n", "simlog", ".", ...
// AddTouchListener registers a listener for touch event. // Touch event will be notified when "sprite" is touched.
[ "AddTouchListener", "registers", "a", "listener", "for", "touch", "event", ".", "Touch", "event", "will", "be", "notified", "when", "sprite", "is", "touched", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/sprite.go#L79-L83
147,396
pankona/gomo-simra
simra/sprite.go
RemoveAllTouchListener
func (sprite *sprite) RemoveAllTouchListener() { simlog.FuncIn() sprite.Sprite.RemoveAllTouchListener() simlog.FuncOut() }
go
func (sprite *sprite) RemoveAllTouchListener() { simlog.FuncIn() sprite.Sprite.RemoveAllTouchListener() simlog.FuncOut() }
[ "func", "(", "sprite", "*", "sprite", ")", "RemoveAllTouchListener", "(", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "sprite", ".", "Sprite", ".", "RemoveAllTouchListener", "(", ")", "\n", "simlog", ".", "FuncOut", "(", ")", "\n", "}" ]
// RemoveAllTouchListener removes all listeners already registered.
[ "RemoveAllTouchListener", "removes", "all", "listeners", "already", "registered", "." ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/sprite.go#L86-L90
147,397
pankona/gomo-simra
simra/sprite.go
AddAnimationSet
func (sprite *sprite) AddAnimationSet(animationName string, set *AnimationSet) { simlog.FuncIn() sprite.animationSets[animationName] = set simlog.FuncOut() }
go
func (sprite *sprite) AddAnimationSet(animationName string, set *AnimationSet) { simlog.FuncIn() sprite.animationSets[animationName] = set simlog.FuncOut() }
[ "func", "(", "sprite", "*", "sprite", ")", "AddAnimationSet", "(", "animationName", "string", ",", "set", "*", "AnimationSet", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "sprite", ".", "animationSets", "[", "animationName", "]", "=", "set", "\n", ...
// AddAnimationSet adds a specified AnimationSet to sprite
[ "AddAnimationSet", "adds", "a", "specified", "AnimationSet", "to", "sprite" ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/sprite.go#L93-L97
147,398
pankona/gomo-simra
simra/sprite.go
StartAnimation
func (sprite *sprite) StartAnimation(animationName string, shouldLoop bool, animationEndCallback func()) { simlog.FuncIn() if sprite.animationCancel != nil { // animation is already in progress. don't start. // TODO: should exlude control return } ctx := context.Background() ctx, cancel := context.WithCancel...
go
func (sprite *sprite) StartAnimation(animationName string, shouldLoop bool, animationEndCallback func()) { simlog.FuncIn() if sprite.animationCancel != nil { // animation is already in progress. don't start. // TODO: should exlude control return } ctx := context.Background() ctx, cancel := context.WithCancel...
[ "func", "(", "sprite", "*", "sprite", ")", "StartAnimation", "(", "animationName", "string", ",", "shouldLoop", "bool", ",", "animationEndCallback", "func", "(", ")", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "if", "sprite", ".", "animationCancel", ...
// StartAnimation starts animation by specified animation name
[ "StartAnimation", "starts", "animation", "by", "specified", "animation", "name" ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/sprite.go#L100-L112
147,399
pankona/gomo-simra
simra/sprite.go
StopAnimation
func (sprite *sprite) StopAnimation() { simlog.FuncIn() if sprite == nil { return } if sprite.animationCancel != nil { sprite.animationCancel() } simlog.FuncOut() }
go
func (sprite *sprite) StopAnimation() { simlog.FuncIn() if sprite == nil { return } if sprite.animationCancel != nil { sprite.animationCancel() } simlog.FuncOut() }
[ "func", "(", "sprite", "*", "sprite", ")", "StopAnimation", "(", ")", "{", "simlog", ".", "FuncIn", "(", ")", "\n", "if", "sprite", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "sprite", ".", "animationCancel", "!=", "nil", "{", "sprite", "."...
// StopAnimation stops animation
[ "StopAnimation", "stops", "animation" ]
90dc6493157a6a46357be5a14d966d2f032f868e
https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/sprite.go#L141-L151