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
partition
stringclasses
1 value
gpmgo/gopm
modules/goconfig/conf.go
Bool
func (c *ConfigFile) Bool(section, key string) (bool, error) { value, err := c.GetValue(section, key) if err != nil { return false, err } return strconv.ParseBool(value) }
go
func (c *ConfigFile) Bool(section, key string) (bool, error) { value, err := c.GetValue(section, key) if err != nil { return false, err } return strconv.ParseBool(value) }
[ "func", "(", "c", "*", "ConfigFile", ")", "Bool", "(", "section", ",", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "value", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ")", "\n", "if", "err", "!=", "nil", ...
// Bool returns bool type value.
[ "Bool", "returns", "bool", "type", "value", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L212-L218
train
gpmgo/gopm
modules/goconfig/conf.go
Float64
func (c *ConfigFile) Float64(section, key string) (float64, error) { value, err := c.GetValue(section, key) if err != nil { return 0.0, err } return strconv.ParseFloat(value, 64) }
go
func (c *ConfigFile) Float64(section, key string) (float64, error) { value, err := c.GetValue(section, key) if err != nil { return 0.0, err } return strconv.ParseFloat(value, 64) }
[ "func", "(", "c", "*", "ConfigFile", ")", "Float64", "(", "section", ",", "key", "string", ")", "(", "float64", ",", "error", ")", "{", "value", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ")", "\n", "if", "err", "!=", "ni...
// Float64 returns float64 type value.
[ "Float64", "returns", "float64", "type", "value", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L221-L227
train
gpmgo/gopm
modules/goconfig/conf.go
Int64
func (c *ConfigFile) Int64(section, key string) (int64, error) { value, err := c.GetValue(section, key) if err != nil { return 0, err } return strconv.ParseInt(value, 10, 64) }
go
func (c *ConfigFile) Int64(section, key string) (int64, error) { value, err := c.GetValue(section, key) if err != nil { return 0, err } return strconv.ParseInt(value, 10, 64) }
[ "func", "(", "c", "*", "ConfigFile", ")", "Int64", "(", "section", ",", "key", "string", ")", "(", "int64", ",", "error", ")", "{", "value", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ")", "\n", "if", "err", "!=", "nil", ...
// Int64 returns int64 type value.
[ "Int64", "returns", "int64", "type", "value", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L239-L245
train
gpmgo/gopm
modules/goconfig/conf.go
MustValue
func (c *ConfigFile) MustValue(section, key string, defaultVal ...string) string { val, err := c.GetValue(section, key) if len(defaultVal) > 0 && (err != nil || len(val) == 0) { return defaultVal[0] } return val }
go
func (c *ConfigFile) MustValue(section, key string, defaultVal ...string) string { val, err := c.GetValue(section, key) if len(defaultVal) > 0 && (err != nil || len(val) == 0) { return defaultVal[0] } return val }
[ "func", "(", "c", "*", "ConfigFile", ")", "MustValue", "(", "section", ",", "key", "string", ",", "defaultVal", "...", "string", ")", "string", "{", "val", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ")", "\n", "if", "len", ...
// MustValue always returns value without error. // It returns empty string if error occurs, or the default value if given.
[ "MustValue", "always", "returns", "value", "without", "error", ".", "It", "returns", "empty", "string", "if", "error", "occurs", "or", "the", "default", "value", "if", "given", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L249-L255
train
gpmgo/gopm
modules/goconfig/conf.go
MustValueSet
func (c *ConfigFile) MustValueSet(section, key string, defaultVal ...string) (string, bool) { val, err := c.GetValue(section, key) if len(defaultVal) > 0 && (err != nil || len(val) == 0) { c.SetValue(section, key, defaultVal[0]) return defaultVal[0], true } return val, false }
go
func (c *ConfigFile) MustValueSet(section, key string, defaultVal ...string) (string, bool) { val, err := c.GetValue(section, key) if len(defaultVal) > 0 && (err != nil || len(val) == 0) { c.SetValue(section, key, defaultVal[0]) return defaultVal[0], true } return val, false }
[ "func", "(", "c", "*", "ConfigFile", ")", "MustValueSet", "(", "section", ",", "key", "string", ",", "defaultVal", "...", "string", ")", "(", "string", ",", "bool", ")", "{", "val", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ...
// MustValue always returns value without error, // It returns empty string if error occurs, or the default value if given, // and a bool value indicates whether default value is returned.
[ "MustValue", "always", "returns", "value", "without", "error", "It", "returns", "empty", "string", "if", "error", "occurs", "or", "the", "default", "value", "if", "given", "and", "a", "bool", "value", "indicates", "whether", "default", "value", "is", "returned...
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L260-L267
train
gpmgo/gopm
modules/goconfig/conf.go
MustValueRange
func (c *ConfigFile) MustValueRange(section, key, defaultVal string, candidates []string) string { val, err := c.GetValue(section, key) if err != nil || len(val) == 0 { return defaultVal } for _, cand := range candidates { if val == cand { return val } } return defaultVal }
go
func (c *ConfigFile) MustValueRange(section, key, defaultVal string, candidates []string) string { val, err := c.GetValue(section, key) if err != nil || len(val) == 0 { return defaultVal } for _, cand := range candidates { if val == cand { return val } } return defaultVal }
[ "func", "(", "c", "*", "ConfigFile", ")", "MustValueRange", "(", "section", ",", "key", ",", "defaultVal", "string", ",", "candidates", "[", "]", "string", ")", "string", "{", "val", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ...
// MustValueRange always returns value without error, // it returns default value if error occurs or doesn't fit into range.
[ "MustValueRange", "always", "returns", "value", "without", "error", "it", "returns", "default", "value", "if", "error", "occurs", "or", "doesn", "t", "fit", "into", "range", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L271-L283
train
gpmgo/gopm
modules/goconfig/conf.go
MustValueArray
func (c *ConfigFile) MustValueArray(section, key, delim string) []string { val, err := c.GetValue(section, key) if err != nil || len(val) == 0 { return []string{} } vals := strings.Split(val, delim) for i := range vals { vals[i] = strings.TrimSpace(vals[i]) } return vals }
go
func (c *ConfigFile) MustValueArray(section, key, delim string) []string { val, err := c.GetValue(section, key) if err != nil || len(val) == 0 { return []string{} } vals := strings.Split(val, delim) for i := range vals { vals[i] = strings.TrimSpace(vals[i]) } return vals }
[ "func", "(", "c", "*", "ConfigFile", ")", "MustValueArray", "(", "section", ",", "key", ",", "delim", "string", ")", "[", "]", "string", "{", "val", ",", "err", ":=", "c", ".", "GetValue", "(", "section", ",", "key", ")", "\n", "if", "err", "!=", ...
// MustValueArray always returns value array without error, // it returns empty array if error occurs, split by delimiter otherwise.
[ "MustValueArray", "always", "returns", "value", "array", "without", "error", "it", "returns", "empty", "array", "if", "error", "occurs", "split", "by", "delimiter", "otherwise", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L287-L298
train
gpmgo/gopm
modules/goconfig/conf.go
GetSectionList
func (c *ConfigFile) GetSectionList() []string { list := make([]string, len(c.sectionList)) copy(list, c.sectionList) return list }
go
func (c *ConfigFile) GetSectionList() []string { list := make([]string, len(c.sectionList)) copy(list, c.sectionList) return list }
[ "func", "(", "c", "*", "ConfigFile", ")", "GetSectionList", "(", ")", "[", "]", "string", "{", "list", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "c", ".", "sectionList", ")", ")", "\n", "copy", "(", "list", ",", "c", ".", "sectionLi...
// GetSectionList returns the list of all sections // in the same order in the file.
[ "GetSectionList", "returns", "the", "list", "of", "all", "sections", "in", "the", "same", "order", "in", "the", "file", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L342-L346
train
gpmgo/gopm
modules/goconfig/conf.go
GetKeyList
func (c *ConfigFile) GetKeyList(section string) []string { // Blank section name represents DEFAULT section. if len(section) == 0 { section = DEFAULT_SECTION } // Check if section exists. if _, ok := c.data[section]; !ok { return nil } // Non-default section has a blank key as section keeper. offset := 1 ...
go
func (c *ConfigFile) GetKeyList(section string) []string { // Blank section name represents DEFAULT section. if len(section) == 0 { section = DEFAULT_SECTION } // Check if section exists. if _, ok := c.data[section]; !ok { return nil } // Non-default section has a blank key as section keeper. offset := 1 ...
[ "func", "(", "c", "*", "ConfigFile", ")", "GetKeyList", "(", "section", "string", ")", "[", "]", "string", "{", "// Blank section name represents DEFAULT section.", "if", "len", "(", "section", ")", "==", "0", "{", "section", "=", "DEFAULT_SECTION", "\n", "}",...
// GetKeyList returns the list of all keys in give section // in the same order in the file. // It returns nil if given section does not exist.
[ "GetKeyList", "returns", "the", "list", "of", "all", "keys", "in", "give", "section", "in", "the", "same", "order", "in", "the", "file", ".", "It", "returns", "nil", "if", "given", "section", "does", "not", "exist", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L351-L371
train
gpmgo/gopm
modules/goconfig/conf.go
DeleteSection
func (c *ConfigFile) DeleteSection(section string) bool { // Blank section name represents DEFAULT section. if len(section) == 0 { section = DEFAULT_SECTION } // Check if section exists. if _, ok := c.data[section]; !ok { return false } delete(c.data, section) // Remove comments of section. c.SetSectionC...
go
func (c *ConfigFile) DeleteSection(section string) bool { // Blank section name represents DEFAULT section. if len(section) == 0 { section = DEFAULT_SECTION } // Check if section exists. if _, ok := c.data[section]; !ok { return false } delete(c.data, section) // Remove comments of section. c.SetSectionC...
[ "func", "(", "c", "*", "ConfigFile", ")", "DeleteSection", "(", "section", "string", ")", "bool", "{", "// Blank section name represents DEFAULT section.", "if", "len", "(", "section", ")", "==", "0", "{", "section", "=", "DEFAULT_SECTION", "\n", "}", "\n\n", ...
// DeleteSection deletes the entire section by given name. // It returns true if the section was deleted, and false if the section didn't exist.
[ "DeleteSection", "deletes", "the", "entire", "section", "by", "given", "name", ".", "It", "returns", "true", "if", "the", "section", "was", "deleted", "and", "false", "if", "the", "section", "didn", "t", "exist", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L375-L400
train
gpmgo/gopm
modules/goconfig/conf.go
GetSection
func (c *ConfigFile) GetSection(section string) (map[string]string, error) { // Blank section name represents DEFAULT section. if len(section) == 0 { section = DEFAULT_SECTION } // Check if section exists. if _, ok := c.data[section]; !ok { // Section does not exist. return nil, getError{ErrSectionNotFound,...
go
func (c *ConfigFile) GetSection(section string) (map[string]string, error) { // Blank section name represents DEFAULT section. if len(section) == 0 { section = DEFAULT_SECTION } // Check if section exists. if _, ok := c.data[section]; !ok { // Section does not exist. return nil, getError{ErrSectionNotFound,...
[ "func", "(", "c", "*", "ConfigFile", ")", "GetSection", "(", "section", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "// Blank section name represents DEFAULT section.", "if", "len", "(", "section", ")", "==", "0", "{", ...
// GetSection returns key-value pairs in given section. // It section does not exist, returns nil and error.
[ "GetSection", "returns", "key", "-", "value", "pairs", "in", "given", "section", ".", "It", "section", "does", "not", "exist", "returns", "nil", "and", "error", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/conf.go#L404-L422
train
gpmgo/gopm
modules/doc/struct.go
IsFixed
func (pkg *Pkg) IsFixed() bool { if pkg.Type == BRANCH || len(pkg.Value) == 0 { return false } return true }
go
func (pkg *Pkg) IsFixed() bool { if pkg.Type == BRANCH || len(pkg.Value) == 0 { return false } return true }
[ "func", "(", "pkg", "*", "Pkg", ")", "IsFixed", "(", ")", "bool", "{", "if", "pkg", ".", "Type", "==", "BRANCH", "||", "len", "(", "pkg", ".", "Value", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// If the package is fixed and no need to updated. // For commit, tag and local, it's fixed.
[ "If", "the", "package", "is", "fixed", "and", "no", "need", "to", "updated", ".", "For", "commit", "tag", "and", "local", "it", "s", "fixed", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/struct.go#L88-L93
train
gpmgo/gopm
modules/doc/struct.go
NewNode
func NewNode( importPath string, tp RevisionType, val string, isGetDeps bool) *Node { n := &Node{ Pkg: Pkg{ ImportPath: importPath, RootPath: GetRootPath(importPath), Type: tp, Value: val, }, DownloadURL: importPath, IsGetDeps: isGetDeps, } n.InstallPath = path.Join(setting.Ins...
go
func NewNode( importPath string, tp RevisionType, val string, isGetDeps bool) *Node { n := &Node{ Pkg: Pkg{ ImportPath: importPath, RootPath: GetRootPath(importPath), Type: tp, Value: val, }, DownloadURL: importPath, IsGetDeps: isGetDeps, } n.InstallPath = path.Join(setting.Ins...
[ "func", "NewNode", "(", "importPath", "string", ",", "tp", "RevisionType", ",", "val", "string", ",", "isGetDeps", "bool", ")", "*", "Node", "{", "n", ":=", "&", "Node", "{", "Pkg", ":", "Pkg", "{", "ImportPath", ":", "importPath", ",", "RootPath", ":"...
// NewNode initializes and returns a new Node representation.
[ "NewNode", "initializes", "and", "returns", "a", "new", "Node", "representation", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/struct.go#L126-L144
train
gpmgo/gopm
modules/doc/struct.go
UpdateByVcs
func (n *Node) UpdateByVcs(vcs string) error { switch vcs { case "git": branch, stderr, err := base.ExecCmdDir(n.InstallGopath, "git", "rev-parse", "--abbrev-ref", "HEAD") if err != nil { log.Error("", "Error occurs when 'git rev-parse --abbrev-ref HEAD'") log.Error("", "\t"+stderr) return errors.New(...
go
func (n *Node) UpdateByVcs(vcs string) error { switch vcs { case "git": branch, stderr, err := base.ExecCmdDir(n.InstallGopath, "git", "rev-parse", "--abbrev-ref", "HEAD") if err != nil { log.Error("", "Error occurs when 'git rev-parse --abbrev-ref HEAD'") log.Error("", "\t"+stderr) return errors.New(...
[ "func", "(", "n", "*", "Node", ")", "UpdateByVcs", "(", "vcs", "string", ")", "error", "{", "switch", "vcs", "{", "case", "\"", "\"", ":", "branch", ",", "stderr", ",", "err", ":=", "base", ".", "ExecCmdDir", "(", "n", ".", "InstallGopath", ",", "\...
// If vcs has been detected, use corresponding command to update package.
[ "If", "vcs", "has", "been", "detected", "use", "corresponding", "command", "to", "update", "package", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/struct.go#L190-L235
train
gpmgo/gopm
modules/doc/struct.go
Download
func (n *Node) Download(ctx *cli.Context) ([]string, error) { for _, s := range services { if !strings.HasPrefix(n.DownloadURL, s.prefix) { continue } m := s.pattern.FindStringSubmatch(n.DownloadURL) if m == nil { if s.prefix != "" { return nil, errors.New("Cannot match package service prefix by giv...
go
func (n *Node) Download(ctx *cli.Context) ([]string, error) { for _, s := range services { if !strings.HasPrefix(n.DownloadURL, s.prefix) { continue } m := s.pattern.FindStringSubmatch(n.DownloadURL) if m == nil { if s.prefix != "" { return nil, errors.New("Cannot match package service prefix by giv...
[ "func", "(", "n", "*", "Node", ")", "Download", "(", "ctx", "*", "cli", ".", "Context", ")", "(", "[", "]", "string", ",", "error", ")", "{", "for", "_", ",", "s", ":=", "range", "services", "{", "if", "!", "strings", ".", "HasPrefix", "(", "n"...
// Download downloads remote package without version control.
[ "Download", "downloads", "remote", "package", "without", "version", "control", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/struct.go#L358-L388
train
gpmgo/gopm
modules/doc/utils.go
ParseTarget
func ParseTarget(target string) string { if len(target) > 0 { return target } for _, gopath := range base.GetGOPATHs() { if strings.HasPrefix(setting.WorkDir, gopath) { target = strings.TrimPrefix(setting.WorkDir, path.Join(gopath, "src")+"/") log.Info("Guess import path: %s", target) return target }...
go
func ParseTarget(target string) string { if len(target) > 0 { return target } for _, gopath := range base.GetGOPATHs() { if strings.HasPrefix(setting.WorkDir, gopath) { target = strings.TrimPrefix(setting.WorkDir, path.Join(gopath, "src")+"/") log.Info("Guess import path: %s", target) return target }...
[ "func", "ParseTarget", "(", "target", "string", ")", "string", "{", "if", "len", "(", "target", ")", ">", "0", "{", "return", "target", "\n", "}", "\n\n", "for", "_", ",", "gopath", ":=", "range", "base", ".", "GetGOPATHs", "(", ")", "{", "if", "st...
// ParseTarget guesses import path of current package if target is empty, // otherwise simply returns the value it gets.
[ "ParseTarget", "guesses", "import", "path", "of", "current", "package", "if", "target", "is", "empty", "otherwise", "simply", "returns", "the", "value", "it", "gets", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/utils.go#L33-L46
train
gpmgo/gopm
modules/doc/utils.go
GetRootPath
func GetRootPath(name string) string { for prefix, num := range setting.RootPathPairs { if strings.HasPrefix(name, prefix) { return joinPath(name, num) } } if strings.HasPrefix(name, "gopkg.in") { m := gopkgPathPattern.FindStringSubmatch(strings.TrimPrefix(name, "gopkg.in")) if m == nil { return name ...
go
func GetRootPath(name string) string { for prefix, num := range setting.RootPathPairs { if strings.HasPrefix(name, prefix) { return joinPath(name, num) } } if strings.HasPrefix(name, "gopkg.in") { m := gopkgPathPattern.FindStringSubmatch(strings.TrimPrefix(name, "gopkg.in")) if m == nil { return name ...
[ "func", "GetRootPath", "(", "name", "string", ")", "string", "{", "for", "prefix", ",", "num", ":=", "range", "setting", ".", "RootPathPairs", "{", "if", "strings", ".", "HasPrefix", "(", "name", ",", "prefix", ")", "{", "return", "joinPath", "(", "name"...
// GetRootPath returns project root path.
[ "GetRootPath", "returns", "project", "root", "path", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/utils.go#L59-L76
train
gpmgo/gopm
modules/doc/utils.go
ListImports
func ListImports(importPath, rootPath, vendorPath, srcPath, tags string, isTest bool) ([]string, error) { oldGOPATH := os.Getenv("GOPATH") sep := ":" if runtime.GOOS == "windows" { sep = ";" } ctxt := build.Default ctxt.BuildTags = strings.Split(tags, " ") ctxt.GOPATH = vendorPath + sep + oldGOPATH if settin...
go
func ListImports(importPath, rootPath, vendorPath, srcPath, tags string, isTest bool) ([]string, error) { oldGOPATH := os.Getenv("GOPATH") sep := ":" if runtime.GOOS == "windows" { sep = ";" } ctxt := build.Default ctxt.BuildTags = strings.Split(tags, " ") ctxt.GOPATH = vendorPath + sep + oldGOPATH if settin...
[ "func", "ListImports", "(", "importPath", ",", "rootPath", ",", "vendorPath", ",", "srcPath", ",", "tags", "string", ",", "isTest", "bool", ")", "(", "[", "]", "string", ",", "error", ")", "{", "oldGOPATH", ":=", "os", ".", "Getenv", "(", "\"", "\"", ...
// ListImports checks and returns a list of imports of given import path and options.
[ "ListImports", "checks", "and", "returns", "a", "list", "of", "imports", "of", "given", "import", "path", "and", "options", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/utils.go#L256-L303
train
gpmgo/gopm
modules/doc/utils.go
GetVcsName
func GetVcsName(dirPath string) string { switch { case base.IsExist(path.Join(dirPath, ".git")): return "git" case base.IsExist(path.Join(dirPath, ".hg")): return "hg" case base.IsExist(path.Join(dirPath, ".svn")): return "svn" } return "" }
go
func GetVcsName(dirPath string) string { switch { case base.IsExist(path.Join(dirPath, ".git")): return "git" case base.IsExist(path.Join(dirPath, ".hg")): return "hg" case base.IsExist(path.Join(dirPath, ".svn")): return "svn" } return "" }
[ "func", "GetVcsName", "(", "dirPath", "string", ")", "string", "{", "switch", "{", "case", "base", ".", "IsExist", "(", "path", ".", "Join", "(", "dirPath", ",", "\"", "\"", ")", ")", ":", "return", "\"", "\"", "\n", "case", "base", ".", "IsExist", ...
// GetVcsName checks whether dirPath has .git .hg .svn else return ""
[ "GetVcsName", "checks", "whether", "dirPath", "has", ".", "git", ".", "hg", ".", "svn", "else", "return" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/doc/utils.go#L306-L316
train
gpmgo/gopm
cmd/list.go
getDepList
func getDepList(ctx *cli.Context, target, pkgPath, vendor string) ([]string, error) { vendorSrc := path.Join(vendor, "src") rootPath := doc.GetRootPath(target) // If work directory is not in GOPATH, then need to setup a vendor path. if !setting.HasGOPATHSetting || !strings.HasPrefix(pkgPath, setting.InstallGopath) ...
go
func getDepList(ctx *cli.Context, target, pkgPath, vendor string) ([]string, error) { vendorSrc := path.Join(vendor, "src") rootPath := doc.GetRootPath(target) // If work directory is not in GOPATH, then need to setup a vendor path. if !setting.HasGOPATHSetting || !strings.HasPrefix(pkgPath, setting.InstallGopath) ...
[ "func", "getDepList", "(", "ctx", "*", "cli", ".", "Context", ",", "target", ",", "pkgPath", ",", "vendor", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "vendorSrc", ":=", "path", ".", "Join", "(", "vendor", ",", "\"", "\"", ")",...
// getDepList gets list of dependencies in root path format and nature order.
[ "getDepList", "gets", "list", "of", "dependencies", "in", "root", "path", "format", "and", "nature", "order", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/cmd/list.go#L57-L88
train
gpmgo/gopm
modules/cli/command.go
HasName
func (c Command) HasName(name string) bool { return c.Name == name || c.ShortName == name }
go
func (c Command) HasName(name string) bool { return c.Name == name || c.ShortName == name }
[ "func", "(", "c", "Command", ")", "HasName", "(", "name", "string", ")", "bool", "{", "return", "c", ".", "Name", "==", "name", "||", "c", ".", "ShortName", "==", "name", "\n", "}" ]
// Returns true if Command.Name or Command.ShortName matches given name
[ "Returns", "true", "if", "Command", ".", "Name", "or", "Command", ".", "ShortName", "matches", "given", "name" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/command.go#L106-L108
train
gpmgo/gopm
modules/cae/cae.go
IsEntry
func IsEntry(name string, entries []string) bool { for _, e := range entries { if e == name { return true } } return false }
go
func IsEntry(name string, entries []string) bool { for _, e := range entries { if e == name { return true } } return false }
[ "func", "IsEntry", "(", "name", "string", ",", "entries", "[", "]", "string", ")", "bool", "{", "for", "_", ",", "e", ":=", "range", "entries", "{", "if", "e", "==", "name", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\...
// IsEntry returns true if name equals to any string in given slice.
[ "IsEntry", "returns", "true", "if", "name", "equals", "to", "any", "string", "in", "given", "slice", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/cae.go#L45-L52
train
gpmgo/gopm
modules/cli/help.go
DefaultAppComplete
func DefaultAppComplete(c *Context) { for _, command := range c.App.Commands { fmt.Println(command.Name) if command.ShortName != "" { fmt.Println(command.ShortName) } } }
go
func DefaultAppComplete(c *Context) { for _, command := range c.App.Commands { fmt.Println(command.Name) if command.ShortName != "" { fmt.Println(command.ShortName) } } }
[ "func", "DefaultAppComplete", "(", "c", "*", "Context", ")", "{", "for", "_", ",", "command", ":=", "range", "c", ".", "App", ".", "Commands", "{", "fmt", ".", "Println", "(", "command", ".", "Name", ")", "\n", "if", "command", ".", "ShortName", "!="...
// Prints the list of subcommands as the default app completion method
[ "Prints", "the", "list", "of", "subcommands", "as", "the", "default", "app", "completion", "method" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/help.go#L107-L114
train
gpmgo/gopm
modules/cli/help.go
ShowCommandHelp
func ShowCommandHelp(c *Context, command string) { for _, c := range c.App.Commands { if c.HasName(command) { HelpPrinter(CommandHelpTemplate, c) return } } if c.App.CommandNotFound != nil { c.App.CommandNotFound(c, command) } else { fmt.Printf("No help topic for '%v'\n", command) } }
go
func ShowCommandHelp(c *Context, command string) { for _, c := range c.App.Commands { if c.HasName(command) { HelpPrinter(CommandHelpTemplate, c) return } } if c.App.CommandNotFound != nil { c.App.CommandNotFound(c, command) } else { fmt.Printf("No help topic for '%v'\n", command) } }
[ "func", "ShowCommandHelp", "(", "c", "*", "Context", ",", "command", "string", ")", "{", "for", "_", ",", "c", ":=", "range", "c", ".", "App", ".", "Commands", "{", "if", "c", ".", "HasName", "(", "command", ")", "{", "HelpPrinter", "(", "CommandHelp...
// Prints help for the given command
[ "Prints", "help", "for", "the", "given", "command" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/help.go#L117-L130
train
gpmgo/gopm
modules/cae/zip/zip.go
List
func (z *ZipArchive) List(prefixes ...string) []string { isHasPrefix := len(prefixes) > 0 names := make([]string, 0, z.NumFiles) for _, f := range z.files { if isHasPrefix && !cae.HasPrefix(f.Name, prefixes) { continue } names = append(names, f.Name) } return names }
go
func (z *ZipArchive) List(prefixes ...string) []string { isHasPrefix := len(prefixes) > 0 names := make([]string, 0, z.NumFiles) for _, f := range z.files { if isHasPrefix && !cae.HasPrefix(f.Name, prefixes) { continue } names = append(names, f.Name) } return names }
[ "func", "(", "z", "*", "ZipArchive", ")", "List", "(", "prefixes", "...", "string", ")", "[", "]", "string", "{", "isHasPrefix", ":=", "len", "(", "prefixes", ")", ">", "0", "\n", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "z"...
// List returns a string slice of files' name in ZipArchive. // Specify prefixes will be used as filters.
[ "List", "returns", "a", "string", "slice", "of", "files", "name", "in", "ZipArchive", ".", "Specify", "prefixes", "will", "be", "used", "as", "filters", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/zip.go#L96-L106
train
gpmgo/gopm
modules/cae/zip/zip.go
AddEmptyDir
func (z *ZipArchive) AddEmptyDir(dirPath string) bool { if !strings.HasSuffix(dirPath, "/") { dirPath += "/" } for _, f := range z.files { if dirPath == f.Name { return false } } dirPath = strings.TrimSuffix(dirPath, "/") if strings.Contains(dirPath, "/") { // Auto add all upper level directories. ...
go
func (z *ZipArchive) AddEmptyDir(dirPath string) bool { if !strings.HasSuffix(dirPath, "/") { dirPath += "/" } for _, f := range z.files { if dirPath == f.Name { return false } } dirPath = strings.TrimSuffix(dirPath, "/") if strings.Contains(dirPath, "/") { // Auto add all upper level directories. ...
[ "func", "(", "z", "*", "ZipArchive", ")", "AddEmptyDir", "(", "dirPath", "string", ")", "bool", "{", "if", "!", "strings", ".", "HasSuffix", "(", "dirPath", ",", "\"", "\"", ")", "{", "dirPath", "+=", "\"", "\"", "\n", "}", "\n\n", "for", "_", ",",...
// AddEmptyDir adds a raw directory entry to ZipArchive, // it returns false if same directory enry already existed.
[ "AddEmptyDir", "adds", "a", "raw", "directory", "entry", "to", "ZipArchive", "it", "returns", "false", "if", "same", "directory", "enry", "already", "existed", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/zip.go#L110-L134
train
gpmgo/gopm
modules/cae/zip/zip.go
AddFile
func (z *ZipArchive) AddFile(fileName, absPath string) error { if cae.IsFilter(absPath) { return nil } f, err := os.Open(absPath) if err != nil { return err } defer f.Close() fi, err := f.Stat() if err != nil { return err } file := new(File) file.FileHeader, err = zip.FileInfoHeader(fi) if err != n...
go
func (z *ZipArchive) AddFile(fileName, absPath string) error { if cae.IsFilter(absPath) { return nil } f, err := os.Open(absPath) if err != nil { return err } defer f.Close() fi, err := f.Stat() if err != nil { return err } file := new(File) file.FileHeader, err = zip.FileInfoHeader(fi) if err != n...
[ "func", "(", "z", "*", "ZipArchive", ")", "AddFile", "(", "fileName", ",", "absPath", "string", ")", "error", "{", "if", "cae", ".", "IsFilter", "(", "absPath", ")", "{", "return", "nil", "\n", "}", "\n\n", "f", ",", "err", ":=", "os", ".", "Open",...
// AddFile adds a file entry to ZipArchive.
[ "AddFile", "adds", "a", "file", "entry", "to", "ZipArchive", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/zip.go#L174-L214
train
gpmgo/gopm
modules/cli/context.go
NewContext
func NewContext(app *App, set *flag.FlagSet, globalSet *flag.FlagSet) *Context { return &Context{App: app, flagSet: set, globalSet: globalSet} }
go
func NewContext(app *App, set *flag.FlagSet, globalSet *flag.FlagSet) *Context { return &Context{App: app, flagSet: set, globalSet: globalSet} }
[ "func", "NewContext", "(", "app", "*", "App", ",", "set", "*", "flag", ".", "FlagSet", ",", "globalSet", "*", "flag", ".", "FlagSet", ")", "*", "Context", "{", "return", "&", "Context", "{", "App", ":", "app", ",", "flagSet", ":", "set", ",", "glob...
// Creates a new context. For use in when invoking an App or Command action.
[ "Creates", "a", "new", "context", ".", "For", "use", "in", "when", "invoking", "an", "App", "or", "Command", "action", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L24-L26
train
gpmgo/gopm
modules/cli/context.go
GlobalInt
func (c *Context) GlobalInt(name string) int { return lookupInt(name, c.globalSet) }
go
func (c *Context) GlobalInt(name string) int { return lookupInt(name, c.globalSet) }
[ "func", "(", "c", "*", "Context", ")", "GlobalInt", "(", "name", "string", ")", "int", "{", "return", "lookupInt", "(", "name", ",", "c", ".", "globalSet", ")", "\n", "}" ]
// Looks up the value of a global int flag, returns 0 if no int flag exists
[ "Looks", "up", "the", "value", "of", "a", "global", "int", "flag", "returns", "0", "if", "no", "int", "flag", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L74-L76
train
gpmgo/gopm
modules/cli/context.go
GlobalDuration
func (c *Context) GlobalDuration(name string) time.Duration { return lookupDuration(name, c.globalSet) }
go
func (c *Context) GlobalDuration(name string) time.Duration { return lookupDuration(name, c.globalSet) }
[ "func", "(", "c", "*", "Context", ")", "GlobalDuration", "(", "name", "string", ")", "time", ".", "Duration", "{", "return", "lookupDuration", "(", "name", ",", "c", ".", "globalSet", ")", "\n", "}" ]
// Looks up the value of a global time.Duration flag, returns 0 if no time.Duration flag exists
[ "Looks", "up", "the", "value", "of", "a", "global", "time", ".", "Duration", "flag", "returns", "0", "if", "no", "time", ".", "Duration", "flag", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L79-L81
train
gpmgo/gopm
modules/cli/context.go
GlobalBool
func (c *Context) GlobalBool(name string) bool { return lookupBool(name, c.globalSet) }
go
func (c *Context) GlobalBool(name string) bool { return lookupBool(name, c.globalSet) }
[ "func", "(", "c", "*", "Context", ")", "GlobalBool", "(", "name", "string", ")", "bool", "{", "return", "lookupBool", "(", "name", ",", "c", ".", "globalSet", ")", "\n", "}" ]
// Looks up the value of a global bool flag, returns false if no bool flag exists
[ "Looks", "up", "the", "value", "of", "a", "global", "bool", "flag", "returns", "false", "if", "no", "bool", "flag", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L84-L86
train
gpmgo/gopm
modules/cli/context.go
GlobalString
func (c *Context) GlobalString(name string) string { return lookupString(name, c.globalSet) }
go
func (c *Context) GlobalString(name string) string { return lookupString(name, c.globalSet) }
[ "func", "(", "c", "*", "Context", ")", "GlobalString", "(", "name", "string", ")", "string", "{", "return", "lookupString", "(", "name", ",", "c", ".", "globalSet", ")", "\n", "}" ]
// Looks up the value of a global string flag, returns "" if no string flag exists
[ "Looks", "up", "the", "value", "of", "a", "global", "string", "flag", "returns", "if", "no", "string", "flag", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L89-L91
train
gpmgo/gopm
modules/cli/context.go
GlobalStringSlice
func (c *Context) GlobalStringSlice(name string) []string { return lookupStringSlice(name, c.globalSet) }
go
func (c *Context) GlobalStringSlice(name string) []string { return lookupStringSlice(name, c.globalSet) }
[ "func", "(", "c", "*", "Context", ")", "GlobalStringSlice", "(", "name", "string", ")", "[", "]", "string", "{", "return", "lookupStringSlice", "(", "name", ",", "c", ".", "globalSet", ")", "\n", "}" ]
// Looks up the value of a global string slice flag, returns nil if no string slice flag exists
[ "Looks", "up", "the", "value", "of", "a", "global", "string", "slice", "flag", "returns", "nil", "if", "no", "string", "slice", "flag", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L94-L96
train
gpmgo/gopm
modules/cli/context.go
GlobalIntSlice
func (c *Context) GlobalIntSlice(name string) []int { return lookupIntSlice(name, c.globalSet) }
go
func (c *Context) GlobalIntSlice(name string) []int { return lookupIntSlice(name, c.globalSet) }
[ "func", "(", "c", "*", "Context", ")", "GlobalIntSlice", "(", "name", "string", ")", "[", "]", "int", "{", "return", "lookupIntSlice", "(", "name", ",", "c", ".", "globalSet", ")", "\n", "}" ]
// Looks up the value of a global int slice flag, returns nil if no int slice flag exists
[ "Looks", "up", "the", "value", "of", "a", "global", "int", "slice", "flag", "returns", "nil", "if", "no", "int", "slice", "flag", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L99-L101
train
gpmgo/gopm
modules/cli/context.go
IsSet
func (c *Context) IsSet(name string) bool { if c.setFlags == nil { c.setFlags = make(map[string]bool) c.flagSet.Visit(func(f *flag.Flag) { c.setFlags[f.Name] = true }) } return c.setFlags[name] == true }
go
func (c *Context) IsSet(name string) bool { if c.setFlags == nil { c.setFlags = make(map[string]bool) c.flagSet.Visit(func(f *flag.Flag) { c.setFlags[f.Name] = true }) } return c.setFlags[name] == true }
[ "func", "(", "c", "*", "Context", ")", "IsSet", "(", "name", "string", ")", "bool", "{", "if", "c", ".", "setFlags", "==", "nil", "{", "c", ".", "setFlags", "=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "c", ".", "flagSet", "....
// Determines if the flag was actually set exists
[ "Determines", "if", "the", "flag", "was", "actually", "set", "exists" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/context.go#L109-L117
train
gpmgo/gopm
cmd/get.go
downloadPackage
func downloadPackage(ctx *cli.Context, n *doc.Node) (*doc.Node, []string, error) { // fmt.Println(n.VerString()) log.Info("Downloading package: %s", n.VerString()) downloadCache.Set(n.VerString()) vendor := base.GetTempDir() defer os.RemoveAll(vendor) var ( err error imports []string srcPath string ...
go
func downloadPackage(ctx *cli.Context, n *doc.Node) (*doc.Node, []string, error) { // fmt.Println(n.VerString()) log.Info("Downloading package: %s", n.VerString()) downloadCache.Set(n.VerString()) vendor := base.GetTempDir() defer os.RemoveAll(vendor) var ( err error imports []string srcPath string ...
[ "func", "downloadPackage", "(", "ctx", "*", "cli", ".", "Context", ",", "n", "*", "doc", ".", "Node", ")", "(", "*", "doc", ".", "Node", ",", "[", "]", "string", ",", "error", ")", "{", "// fmt.Println(n.VerString())", "log", ".", "Info", "(", "\"", ...
// downloadPackage downloads package either use version control tools or not.
[ "downloadPackage", "downloads", "package", "either", "use", "version", "control", "tools", "or", "not", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/cmd/get.go#L71-L118
train
gpmgo/gopm
modules/goconfig/write.go
SaveConfigFile
func SaveConfigFile(c *ConfigFile, filename string) (err error) { // Write configuration file by filename. var f *os.File if f, err = os.Create(filename); err != nil { return err } equalSign := "=" if PrettyFormat { equalSign = " = " } buf := bytes.NewBuffer(nil) for _, section := range c.sectionList { ...
go
func SaveConfigFile(c *ConfigFile, filename string) (err error) { // Write configuration file by filename. var f *os.File if f, err = os.Create(filename); err != nil { return err } equalSign := "=" if PrettyFormat { equalSign = " = " } buf := bytes.NewBuffer(nil) for _, section := range c.sectionList { ...
[ "func", "SaveConfigFile", "(", "c", "*", "ConfigFile", ",", "filename", "string", ")", "(", "err", "error", ")", "{", "// Write configuration file by filename.", "var", "f", "*", "os", ".", "File", "\n", "if", "f", ",", "err", "=", "os", ".", "Create", "...
// SaveConfigFile writes configuration file to local file system
[ "SaveConfigFile", "writes", "configuration", "file", "to", "local", "file", "system" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/write.go#L27-L108
train
gpmgo/gopm
modules/setting/setting.go
LoadGopmfile
func LoadGopmfile(fileName string) (*goconfig.ConfigFile, error) { if !base.IsFile(fileName) { return goconfig.LoadFromData([]byte("")) } gf, err := goconfig.LoadConfigFile(fileName) if err != nil { return nil, fmt.Errorf("Fail to load gopmfile: %v", err) } return gf, nil }
go
func LoadGopmfile(fileName string) (*goconfig.ConfigFile, error) { if !base.IsFile(fileName) { return goconfig.LoadFromData([]byte("")) } gf, err := goconfig.LoadConfigFile(fileName) if err != nil { return nil, fmt.Errorf("Fail to load gopmfile: %v", err) } return gf, nil }
[ "func", "LoadGopmfile", "(", "fileName", "string", ")", "(", "*", "goconfig", ".", "ConfigFile", ",", "error", ")", "{", "if", "!", "base", ".", "IsFile", "(", "fileName", ")", "{", "return", "goconfig", ".", "LoadFromData", "(", "[", "]", "byte", "(",...
// LoadGopmfile loads and returns given gopmfile.
[ "LoadGopmfile", "loads", "and", "returns", "given", "gopmfile", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L92-L102
train
gpmgo/gopm
modules/setting/setting.go
SaveGopmfile
func SaveGopmfile(gf *goconfig.ConfigFile, fileName string) error { if err := goconfig.SaveConfigFile(gf, fileName); err != nil { return fmt.Errorf("Fail to save gopmfile: %v", err) } return nil }
go
func SaveGopmfile(gf *goconfig.ConfigFile, fileName string) error { if err := goconfig.SaveConfigFile(gf, fileName); err != nil { return fmt.Errorf("Fail to save gopmfile: %v", err) } return nil }
[ "func", "SaveGopmfile", "(", "gf", "*", "goconfig", ".", "ConfigFile", ",", "fileName", "string", ")", "error", "{", "if", "err", ":=", "goconfig", ".", "SaveConfigFile", "(", "gf", ",", "fileName", ")", ";", "err", "!=", "nil", "{", "return", "fmt", "...
// SaveGopmfile saves gopmfile to given path.
[ "SaveGopmfile", "saves", "gopmfile", "to", "given", "path", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L105-L110
train
gpmgo/gopm
modules/setting/setting.go
LoadConfig
func LoadConfig() (err error) { if !base.IsExist(ConfigFile) { os.MkdirAll(path.Dir(ConfigFile), os.ModePerm) if _, err = os.Create(ConfigFile); err != nil { return fmt.Errorf("fail to create config file: %v", err) } } Cfg, err = goconfig.LoadConfigFile(ConfigFile) if err != nil { return fmt.Errorf("fai...
go
func LoadConfig() (err error) { if !base.IsExist(ConfigFile) { os.MkdirAll(path.Dir(ConfigFile), os.ModePerm) if _, err = os.Create(ConfigFile); err != nil { return fmt.Errorf("fail to create config file: %v", err) } } Cfg, err = goconfig.LoadConfigFile(ConfigFile) if err != nil { return fmt.Errorf("fai...
[ "func", "LoadConfig", "(", ")", "(", "err", "error", ")", "{", "if", "!", "base", ".", "IsExist", "(", "ConfigFile", ")", "{", "os", ".", "MkdirAll", "(", "path", ".", "Dir", "(", "ConfigFile", ")", ",", "os", ".", "ModePerm", ")", "\n", "if", "_...
// LoadConfig loads gopm global configuration.
[ "LoadConfig", "loads", "gopm", "global", "configuration", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L113-L128
train
gpmgo/gopm
modules/setting/setting.go
SetConfigValue
func SetConfigValue(section, key, val string) error { Cfg.SetValue(section, key, val) if err := goconfig.SaveConfigFile(Cfg, ConfigFile); err != nil { return fmt.Errorf("fail to set config value(%s:%s=%s): %v", section, key, val, err) } return nil }
go
func SetConfigValue(section, key, val string) error { Cfg.SetValue(section, key, val) if err := goconfig.SaveConfigFile(Cfg, ConfigFile); err != nil { return fmt.Errorf("fail to set config value(%s:%s=%s): %v", section, key, val, err) } return nil }
[ "func", "SetConfigValue", "(", "section", ",", "key", ",", "val", "string", ")", "error", "{", "Cfg", ".", "SetValue", "(", "section", ",", "key", ",", "val", ")", "\n", "if", "err", ":=", "goconfig", ".", "SaveConfigFile", "(", "Cfg", ",", "ConfigFile...
// SetConfigValue sets and saves gopm configuration.
[ "SetConfigValue", "sets", "and", "saves", "gopm", "configuration", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L131-L137
train
gpmgo/gopm
modules/setting/setting.go
DeleteConfigOption
func DeleteConfigOption(section, key string) error { Cfg.DeleteKey(section, key) if err := goconfig.SaveConfigFile(Cfg, ConfigFile); err != nil { return fmt.Errorf("fail to delete config key(%s:%s): %v", section, key, err) } return nil }
go
func DeleteConfigOption(section, key string) error { Cfg.DeleteKey(section, key) if err := goconfig.SaveConfigFile(Cfg, ConfigFile); err != nil { return fmt.Errorf("fail to delete config key(%s:%s): %v", section, key, err) } return nil }
[ "func", "DeleteConfigOption", "(", "section", ",", "key", "string", ")", "error", "{", "Cfg", ".", "DeleteKey", "(", "section", ",", "key", ")", "\n", "if", "err", ":=", "goconfig", ".", "SaveConfigFile", "(", "Cfg", ",", "ConfigFile", ")", ";", "err", ...
// DeleteConfigOption deletes and saves gopm configuration.
[ "DeleteConfigOption", "deletes", "and", "saves", "gopm", "configuration", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L140-L146
train
gpmgo/gopm
modules/setting/setting.go
LoadPkgNameList
func LoadPkgNameList() error { if !base.IsFile(PkgNameListFile) { return nil } data, err := ioutil.ReadFile(PkgNameListFile) if err != nil { return fmt.Errorf("fail to load package name list: %v", err) } pkgs := strings.Split(string(data), "\n") for i, line := range pkgs { infos := strings.Split(line, "=...
go
func LoadPkgNameList() error { if !base.IsFile(PkgNameListFile) { return nil } data, err := ioutil.ReadFile(PkgNameListFile) if err != nil { return fmt.Errorf("fail to load package name list: %v", err) } pkgs := strings.Split(string(data), "\n") for i, line := range pkgs { infos := strings.Split(line, "=...
[ "func", "LoadPkgNameList", "(", ")", "error", "{", "if", "!", "base", ".", "IsFile", "(", "PkgNameListFile", ")", "{", "return", "nil", "\n", "}", "\n\n", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "PkgNameListFile", ")", "\n", "if", "er...
// LoadPkgNameList loads package name pairs.
[ "LoadPkgNameList", "loads", "package", "name", "pairs", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L149-L172
train
gpmgo/gopm
modules/setting/setting.go
GetPkgFullPath
func GetPkgFullPath(short string) (string, error) { name, ok := PackageNameList[short] if !ok { return "", fmt.Errorf("no match package import path with given short name: %s", short) } return name, nil }
go
func GetPkgFullPath(short string) (string, error) { name, ok := PackageNameList[short] if !ok { return "", fmt.Errorf("no match package import path with given short name: %s", short) } return name, nil }
[ "func", "GetPkgFullPath", "(", "short", "string", ")", "(", "string", ",", "error", ")", "{", "name", ",", "ok", ":=", "PackageNameList", "[", "short", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"...
// GetPkgFullPath attmpts to get full path by given package short name.
[ "GetPkgFullPath", "attmpts", "to", "get", "full", "path", "by", "given", "package", "short", "name", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/setting/setting.go#L175-L181
train
gpmgo/gopm
cmd/run.go
validPkgInfo
func validPkgInfo(info string) (doc.RevisionType, string, error) { if len(info) == 0 { return doc.BRANCH, "", nil } infos := strings.Split(info, ":") if len(infos) == 2 { tp := doc.RevisionType(infos[0]) val := infos[1] switch tp { case doc.BRANCH, doc.COMMIT, doc.TAG: default: return "", "", fmt.E...
go
func validPkgInfo(info string) (doc.RevisionType, string, error) { if len(info) == 0 { return doc.BRANCH, "", nil } infos := strings.Split(info, ":") if len(infos) == 2 { tp := doc.RevisionType(infos[0]) val := infos[1] switch tp { case doc.BRANCH, doc.COMMIT, doc.TAG: default: return "", "", fmt.E...
[ "func", "validPkgInfo", "(", "info", "string", ")", "(", "doc", ".", "RevisionType", ",", "string", ",", "error", ")", "{", "if", "len", "(", "info", ")", "==", "0", "{", "return", "doc", ".", "BRANCH", ",", "\"", "\"", ",", "nil", "\n", "}", "\n...
// validPkgInfo checks if the information of the package is valid.
[ "validPkgInfo", "checks", "if", "the", "information", "of", "the", "package", "is", "valid", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/cmd/run.go#L56-L74
train
gpmgo/gopm
modules/cli/app.go
NewApp
func NewApp() *App { return &App{ Name: os.Args[0], Usage: "A new cli application", Version: "0.0.0", BashComplete: DefaultAppComplete, Action: helpCommand.Action, Compiled: compileTime(), } }
go
func NewApp() *App { return &App{ Name: os.Args[0], Usage: "A new cli application", Version: "0.0.0", BashComplete: DefaultAppComplete, Action: helpCommand.Action, Compiled: compileTime(), } }
[ "func", "NewApp", "(", ")", "*", "App", "{", "return", "&", "App", "{", "Name", ":", "os", ".", "Args", "[", "0", "]", ",", "Usage", ":", "\"", "\"", ",", "Version", ":", "\"", "\"", ",", "BashComplete", ":", "DefaultAppComplete", ",", "Action", ...
// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
[ "Creates", "a", "new", "cli", "Application", "with", "some", "reasonable", "defaults", "for", "Name", "Usage", "Version", "and", "Action", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/app.go#L55-L64
train
gpmgo/gopm
modules/cli/app.go
RunAndExitOnError
func (a *App) RunAndExitOnError() { if err := a.Run(os.Args); err != nil { os.Stderr.WriteString(fmt.Sprintln(err)) os.Exit(1) } }
go
func (a *App) RunAndExitOnError() { if err := a.Run(os.Args); err != nil { os.Stderr.WriteString(fmt.Sprintln(err)) os.Exit(1) } }
[ "func", "(", "a", "*", "App", ")", "RunAndExitOnError", "(", ")", "{", "if", "err", ":=", "a", ".", "Run", "(", "os", ".", "Args", ")", ";", "err", "!=", "nil", "{", "os", ".", "Stderr", ".", "WriteString", "(", "fmt", ".", "Sprintln", "(", "er...
// Another entry point to the cli app, takes care of passing arguments and error handling
[ "Another", "entry", "point", "to", "the", "cli", "app", "takes", "care", "of", "passing", "arguments", "and", "error", "handling" ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cli/app.go#L135-L140
train
gpmgo/gopm
cmd/cmd.go
setup
func setup(ctx *cli.Context) (err error) { setting.Debug = ctx.GlobalBool("debug") log.NonColor = ctx.GlobalBool("noterm") log.Verbose = ctx.Bool("verbose") log.Info("App Version: %s", ctx.App.Version) setting.HomeDir, err = base.HomeDir() if err != nil { return fmt.Errorf("Fail to get home directory: %v", er...
go
func setup(ctx *cli.Context) (err error) { setting.Debug = ctx.GlobalBool("debug") log.NonColor = ctx.GlobalBool("noterm") log.Verbose = ctx.Bool("verbose") log.Info("App Version: %s", ctx.App.Version) setting.HomeDir, err = base.HomeDir() if err != nil { return fmt.Errorf("Fail to get home directory: %v", er...
[ "func", "setup", "(", "ctx", "*", "cli", ".", "Context", ")", "(", "err", "error", ")", "{", "setting", ".", "Debug", "=", "ctx", ".", "GlobalBool", "(", "\"", "\"", ")", "\n", "log", ".", "NonColor", "=", "ctx", ".", "GlobalBool", "(", "\"", "\"...
// setup initializes and checks common environment variables.
[ "setup", "initializes", "and", "checks", "common", "environment", "variables", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/cmd/cmd.go#L35-L124
train
gpmgo/gopm
cmd/cmd.go
isSubpackage
func isSubpackage(rootPath, target string) bool { return strings.HasSuffix(setting.WorkDir, rootPath) || strings.HasPrefix(rootPath, target) }
go
func isSubpackage(rootPath, target string) bool { return strings.HasSuffix(setting.WorkDir, rootPath) || strings.HasPrefix(rootPath, target) }
[ "func", "isSubpackage", "(", "rootPath", ",", "target", "string", ")", "bool", "{", "return", "strings", ".", "HasSuffix", "(", "setting", ".", "WorkDir", ",", "rootPath", ")", "||", "strings", ".", "HasPrefix", "(", "rootPath", ",", "target", ")", "\n", ...
// isSubpackage returns true if given package belongs to current project.
[ "isSubpackage", "returns", "true", "if", "given", "package", "belongs", "to", "current", "project", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/cmd/cmd.go#L180-L183
train
gpmgo/gopm
modules/goconfig/read.go
LoadConfigFile
func LoadConfigFile(fileName string, moreFiles ...string) (c *ConfigFile, err error) { // Append files' name together. fileNames := make([]string, 1, len(moreFiles)+1) fileNames[0] = fileName if len(moreFiles) > 0 { fileNames = append(fileNames, moreFiles...) } c = newConfigFile(fileNames) for _, name := ran...
go
func LoadConfigFile(fileName string, moreFiles ...string) (c *ConfigFile, err error) { // Append files' name together. fileNames := make([]string, 1, len(moreFiles)+1) fileNames[0] = fileName if len(moreFiles) > 0 { fileNames = append(fileNames, moreFiles...) } c = newConfigFile(fileNames) for _, name := ran...
[ "func", "LoadConfigFile", "(", "fileName", "string", ",", "moreFiles", "...", "string", ")", "(", "c", "*", "ConfigFile", ",", "err", "error", ")", "{", "// Append files' name together.", "fileNames", ":=", "make", "(", "[", "]", "string", ",", "1", ",", "...
// LoadConfigFile reads a file and returns a new configuration representation. // This representation can be queried with GetValue.
[ "LoadConfigFile", "reads", "a", "file", "and", "returns", "a", "new", "configuration", "representation", ".", "This", "representation", "can", "be", "queried", "with", "GetValue", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/read.go#L196-L213
train
gpmgo/gopm
modules/goconfig/read.go
Reload
func (c *ConfigFile) Reload() (err error) { var cfg *ConfigFile if len(c.fileNames) == 1 { cfg, err = LoadConfigFile(c.fileNames[0]) } else { cfg, err = LoadConfigFile(c.fileNames[0], c.fileNames[1:]...) } if err == nil { *c = *cfg } return err }
go
func (c *ConfigFile) Reload() (err error) { var cfg *ConfigFile if len(c.fileNames) == 1 { cfg, err = LoadConfigFile(c.fileNames[0]) } else { cfg, err = LoadConfigFile(c.fileNames[0], c.fileNames[1:]...) } if err == nil { *c = *cfg } return err }
[ "func", "(", "c", "*", "ConfigFile", ")", "Reload", "(", ")", "(", "err", "error", ")", "{", "var", "cfg", "*", "ConfigFile", "\n", "if", "len", "(", "c", ".", "fileNames", ")", "==", "1", "{", "cfg", ",", "err", "=", "LoadConfigFile", "(", "c", ...
// Reload reloads configuration file in case it has changes.
[ "Reload", "reloads", "configuration", "file", "in", "case", "it", "has", "changes", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/read.go#L216-L228
train
gpmgo/gopm
modules/goconfig/read.go
AppendFiles
func (c *ConfigFile) AppendFiles(files ...string) error { c.fileNames = append(c.fileNames, files...) return c.Reload() }
go
func (c *ConfigFile) AppendFiles(files ...string) error { c.fileNames = append(c.fileNames, files...) return c.Reload() }
[ "func", "(", "c", "*", "ConfigFile", ")", "AppendFiles", "(", "files", "...", "string", ")", "error", "{", "c", ".", "fileNames", "=", "append", "(", "c", ".", "fileNames", ",", "files", "...", ")", "\n", "return", "c", ".", "Reload", "(", ")", "\n...
// AppendFiles appends more files to ConfigFile and reload automatically.
[ "AppendFiles", "appends", "more", "files", "to", "ConfigFile", "and", "reload", "automatically", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/goconfig/read.go#L231-L234
train
gpmgo/gopm
modules/cae/zip/write.go
extractFile
func (z *ZipArchive) extractFile(f *File) error { if !z.isHasWriter { for _, zf := range z.ReadCloser.File { if f.Name == zf.Name { return extractFile(zf, path.Dir(f.tmpPath)) } } } return cae.Copy(f.tmpPath, f.absPath) }
go
func (z *ZipArchive) extractFile(f *File) error { if !z.isHasWriter { for _, zf := range z.ReadCloser.File { if f.Name == zf.Name { return extractFile(zf, path.Dir(f.tmpPath)) } } } return cae.Copy(f.tmpPath, f.absPath) }
[ "func", "(", "z", "*", "ZipArchive", ")", "extractFile", "(", "f", "*", "File", ")", "error", "{", "if", "!", "z", ".", "isHasWriter", "{", "for", "_", ",", "zf", ":=", "range", "z", ".", "ReadCloser", ".", "File", "{", "if", "f", ".", "Name", ...
// extractFile extracts file from ZipArchive to file system.
[ "extractFile", "extracts", "file", "from", "ZipArchive", "to", "file", "system", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/write.go#L151-L160
train
gpmgo/gopm
modules/cae/zip/write.go
packDir
func packDir(srcPath string, recPath string, zw *zip.Writer, fn cae.HookFunc) error { dir, err := os.Open(srcPath) if err != nil { return err } defer dir.Close() fis, err := dir.Readdir(0) if err != nil { return err } for _, fi := range fis { if cae.IsFilter(fi.Name()) { continue } curPath := srcP...
go
func packDir(srcPath string, recPath string, zw *zip.Writer, fn cae.HookFunc) error { dir, err := os.Open(srcPath) if err != nil { return err } defer dir.Close() fis, err := dir.Readdir(0) if err != nil { return err } for _, fi := range fis { if cae.IsFilter(fi.Name()) { continue } curPath := srcP...
[ "func", "packDir", "(", "srcPath", "string", ",", "recPath", "string", ",", "zw", "*", "zip", ".", "Writer", ",", "fn", "cae", ".", "HookFunc", ")", "error", "{", "dir", ",", "err", ":=", "os", ".", "Open", "(", "srcPath", ")", "\n", "if", "err", ...
// packDir packs a directory and its subdirectories and files // recursively to zip.Writer.
[ "packDir", "packs", "a", "directory", "and", "its", "subdirectories", "and", "files", "recursively", "to", "zip", ".", "Writer", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/write.go#L243-L277
train
gpmgo/gopm
modules/cae/zip/write.go
packToWriter
func packToWriter(srcPath string, w io.Writer, fn func(fullName string, fi os.FileInfo) error, includeDir bool) error { zw := zip.NewWriter(w) defer zw.Close() f, err := os.Open(srcPath) if err != nil { return err } defer f.Close() fi, err := f.Stat() if err != nil { return err } basePath := path.Base(...
go
func packToWriter(srcPath string, w io.Writer, fn func(fullName string, fi os.FileInfo) error, includeDir bool) error { zw := zip.NewWriter(w) defer zw.Close() f, err := os.Open(srcPath) if err != nil { return err } defer f.Close() fi, err := f.Stat() if err != nil { return err } basePath := path.Base(...
[ "func", "packToWriter", "(", "srcPath", "string", ",", "w", "io", ".", "Writer", ",", "fn", "func", "(", "fullName", "string", ",", "fi", "os", ".", "FileInfo", ")", "error", ",", "includeDir", "bool", ")", "error", "{", "zw", ":=", "zip", ".", "NewW...
// packToWriter packs given path object to io.Writer.
[ "packToWriter", "packs", "given", "path", "object", "to", "io", ".", "Writer", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/write.go#L280-L307
train
gpmgo/gopm
modules/cae/zip/write.go
packTo
func packTo(srcPath, destPath string, fn cae.HookFunc, includeDir bool) error { fw, err := os.Create(destPath) if err != nil { return err } defer fw.Close() return packToWriter(srcPath, fw, fn, includeDir) }
go
func packTo(srcPath, destPath string, fn cae.HookFunc, includeDir bool) error { fw, err := os.Create(destPath) if err != nil { return err } defer fw.Close() return packToWriter(srcPath, fw, fn, includeDir) }
[ "func", "packTo", "(", "srcPath", ",", "destPath", "string", ",", "fn", "cae", ".", "HookFunc", ",", "includeDir", "bool", ")", "error", "{", "fw", ",", "err", ":=", "os", ".", "Create", "(", "destPath", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// packTo packs given source path object to target path.
[ "packTo", "packs", "given", "source", "path", "object", "to", "target", "path", "." ]
7edb73a0f439c016ee40b6608bc271c7fc4462e9
https://github.com/gpmgo/gopm/blob/7edb73a0f439c016ee40b6608bc271c7fc4462e9/modules/cae/zip/write.go#L310-L318
train
go-gorp/gorp
gorp.go
maybeExpandNamedQueryAndExec
func maybeExpandNamedQueryAndExec(e SqlExecutor, query string, args ...interface{}) (sql.Result, error) { dbMap := extractDbMap(e) if len(args) == 1 { query, args = maybeExpandNamedQuery(dbMap, query, args) } return exec(e, query, args...) }
go
func maybeExpandNamedQueryAndExec(e SqlExecutor, query string, args ...interface{}) (sql.Result, error) { dbMap := extractDbMap(e) if len(args) == 1 { query, args = maybeExpandNamedQuery(dbMap, query, args) } return exec(e, query, args...) }
[ "func", "maybeExpandNamedQueryAndExec", "(", "e", "SqlExecutor", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "Result", ",", "error", ")", "{", "dbMap", ":=", "extractDbMap", "(", "e", ")", "\n\n", "if", "len",...
// Calls the Exec function on the executor, but attempts to expand any eligible named // query arguments first.
[ "Calls", "the", "Exec", "function", "on", "the", "executor", "but", "attempts", "to", "expand", "any", "eligible", "named", "query", "arguments", "first", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/gorp.go#L166-L174
train
go-gorp/gorp
column.go
SetTransient
func (c *ColumnMap) SetTransient(b bool) *ColumnMap { c.Transient = b return c }
go
func (c *ColumnMap) SetTransient(b bool) *ColumnMap { c.Transient = b return c }
[ "func", "(", "c", "*", "ColumnMap", ")", "SetTransient", "(", "b", "bool", ")", "*", "ColumnMap", "{", "c", ".", "Transient", "=", "b", "\n", "return", "c", "\n", "}" ]
// SetTransient allows you to mark the column as transient. If true // this column will be skipped when SQL statements are generated
[ "SetTransient", "allows", "you", "to", "mark", "the", "column", "as", "transient", ".", "If", "true", "this", "column", "will", "be", "skipped", "when", "SQL", "statements", "are", "generated" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/column.go#L58-L61
train
go-gorp/gorp
column.go
SetUnique
func (c *ColumnMap) SetUnique(b bool) *ColumnMap { c.Unique = b return c }
go
func (c *ColumnMap) SetUnique(b bool) *ColumnMap { c.Unique = b return c }
[ "func", "(", "c", "*", "ColumnMap", ")", "SetUnique", "(", "b", "bool", ")", "*", "ColumnMap", "{", "c", ".", "Unique", "=", "b", "\n", "return", "c", "\n", "}" ]
// SetUnique adds "unique" to the create table statements for this // column, if b is true.
[ "SetUnique", "adds", "unique", "to", "the", "create", "table", "statements", "for", "this", "column", "if", "b", "is", "true", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/column.go#L65-L68
train
go-gorp/gorp
column.go
SetNotNull
func (c *ColumnMap) SetNotNull(nn bool) *ColumnMap { c.isNotNull = nn return c }
go
func (c *ColumnMap) SetNotNull(nn bool) *ColumnMap { c.isNotNull = nn return c }
[ "func", "(", "c", "*", "ColumnMap", ")", "SetNotNull", "(", "nn", "bool", ")", "*", "ColumnMap", "{", "c", ".", "isNotNull", "=", "nn", "\n", "return", "c", "\n", "}" ]
// SetNotNull adds "not null" to the create table statements for this // column, if nn is true.
[ "SetNotNull", "adds", "not", "null", "to", "the", "create", "table", "statements", "for", "this", "column", "if", "nn", "is", "true", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/column.go#L72-L75
train
go-gorp/gorp
table.go
IdxMap
func (t *TableMap) IdxMap(field string) *IndexMap { for _, idx := range t.indexes { if idx.IndexName == field { return idx } } return nil }
go
func (t *TableMap) IdxMap(field string) *IndexMap { for _, idx := range t.indexes { if idx.IndexName == field { return idx } } return nil }
[ "func", "(", "t", "*", "TableMap", ")", "IdxMap", "(", "field", "string", ")", "*", "IndexMap", "{", "for", "_", ",", "idx", ":=", "range", "t", ".", "indexes", "{", "if", "idx", ".", "IndexName", "==", "field", "{", "return", "idx", "\n", "}", "...
// IdxMap returns the IndexMap pointer matching the given index name.
[ "IdxMap", "returns", "the", "IndexMap", "pointer", "matching", "the", "given", "index", "name", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/table.go#L130-L137
train
go-gorp/gorp
table.go
SqlForCreate
func (t *TableMap) SqlForCreate(ifNotExists bool) string { s := bytes.Buffer{} dialect := t.dbmap.Dialect if strings.TrimSpace(t.SchemaName) != "" { schemaCreate := "create schema" if ifNotExists { s.WriteString(dialect.IfSchemaNotExists(schemaCreate, t.SchemaName)) } else { s.WriteString(schemaCreate) ...
go
func (t *TableMap) SqlForCreate(ifNotExists bool) string { s := bytes.Buffer{} dialect := t.dbmap.Dialect if strings.TrimSpace(t.SchemaName) != "" { schemaCreate := "create schema" if ifNotExists { s.WriteString(dialect.IfSchemaNotExists(schemaCreate, t.SchemaName)) } else { s.WriteString(schemaCreate) ...
[ "func", "(", "t", "*", "TableMap", ")", "SqlForCreate", "(", "ifNotExists", "bool", ")", "string", "{", "s", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "dialect", ":=", "t", ".", "dbmap", ".", "Dialect", "\n\n", "if", "strings", ".", "TrimSpace", ...
// SqlForCreateTable gets a sequence of SQL commands that will create // the specified table and any associated schema
[ "SqlForCreateTable", "gets", "a", "sequence", "of", "SQL", "commands", "that", "will", "create", "the", "specified", "table", "and", "any", "associated", "schema" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/table.go#L180-L253
train
go-gorp/gorp
dialect_mysql.go
CreateTableSuffix
func (d MySQLDialect) CreateTableSuffix() string { if d.Engine == "" || d.Encoding == "" { msg := "gorp - undefined" if d.Engine == "" { msg += " MySQLDialect.Engine" } if d.Engine == "" && d.Encoding == "" { msg += "," } if d.Encoding == "" { msg += " MySQLDialect.Encoding" } msg += ". Check...
go
func (d MySQLDialect) CreateTableSuffix() string { if d.Engine == "" || d.Encoding == "" { msg := "gorp - undefined" if d.Engine == "" { msg += " MySQLDialect.Engine" } if d.Engine == "" && d.Encoding == "" { msg += "," } if d.Encoding == "" { msg += " MySQLDialect.Encoding" } msg += ". Check...
[ "func", "(", "d", "MySQLDialect", ")", "CreateTableSuffix", "(", ")", "string", "{", "if", "d", ".", "Engine", "==", "\"", "\"", "||", "d", ".", "Encoding", "==", "\"", "\"", "{", "msg", ":=", "\"", "\"", "\n\n", "if", "d", ".", "Engine", "==", "...
// Returns engine=%s charset=%s based on values stored on struct
[ "Returns", "engine", "=", "%s", "charset", "=", "%s", "based", "on", "values", "stored", "on", "struct" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/dialect_mysql.go#L109-L127
train
go-gorp/gorp
db.go
AddTableWithName
func (m *DbMap) AddTableWithName(i interface{}, name string) *TableMap { return m.AddTableWithNameAndSchema(i, "", name) }
go
func (m *DbMap) AddTableWithName(i interface{}, name string) *TableMap { return m.AddTableWithNameAndSchema(i, "", name) }
[ "func", "(", "m", "*", "DbMap", ")", "AddTableWithName", "(", "i", "interface", "{", "}", ",", "name", "string", ")", "*", "TableMap", "{", "return", "m", ".", "AddTableWithNameAndSchema", "(", "i", ",", "\"", "\"", ",", "name", ")", "\n", "}" ]
// AddTableWithName has the same behavior as AddTable, but sets // table.TableName to name.
[ "AddTableWithName", "has", "the", "same", "behavior", "as", "AddTable", "but", "sets", "table", ".", "TableName", "to", "name", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L225-L227
train
go-gorp/gorp
db.go
AddTableWithNameAndSchema
func (m *DbMap) AddTableWithNameAndSchema(i interface{}, schema string, name string) *TableMap { t := reflect.TypeOf(i) if name == "" { name = t.Name() } // check if we have a table for this type already // if so, update the name and return the existing pointer for i := range m.tables { table := m.tables[i] ...
go
func (m *DbMap) AddTableWithNameAndSchema(i interface{}, schema string, name string) *TableMap { t := reflect.TypeOf(i) if name == "" { name = t.Name() } // check if we have a table for this type already // if so, update the name and return the existing pointer for i := range m.tables { table := m.tables[i] ...
[ "func", "(", "m", "*", "DbMap", ")", "AddTableWithNameAndSchema", "(", "i", "interface", "{", "}", ",", "schema", "string", ",", "name", "string", ")", "*", "TableMap", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "i", ")", "\n", "if", "name", "=="...
// AddTableWithNameAndSchema has the same behavior as AddTable, but sets // table.TableName to name.
[ "AddTableWithNameAndSchema", "has", "the", "same", "behavior", "as", "AddTable", "but", "sets", "table", ".", "TableName", "to", "name", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L231-L256
train
go-gorp/gorp
db.go
AddTableDynamic
func (m *DbMap) AddTableDynamic(inp DynamicTable, schema string) *TableMap { val := reflect.ValueOf(inp) elm := val.Elem() t := elm.Type() name := inp.TableName() if name == "" { panic("Missing table name in DynamicTable instance") } // Check if there is another dynamic table with the same name if _, found ...
go
func (m *DbMap) AddTableDynamic(inp DynamicTable, schema string) *TableMap { val := reflect.ValueOf(inp) elm := val.Elem() t := elm.Type() name := inp.TableName() if name == "" { panic("Missing table name in DynamicTable instance") } // Check if there is another dynamic table with the same name if _, found ...
[ "func", "(", "m", "*", "DbMap", ")", "AddTableDynamic", "(", "inp", "DynamicTable", ",", "schema", "string", ")", "*", "TableMap", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "inp", ")", "\n", "elm", ":=", "val", ".", "Elem", "(", ")", "\n", ...
// AddTableDynamic registers the given interface type with gorp. // The table name will be dynamically determined at runtime by // using the GetTableName method on DynamicTable interface
[ "AddTableDynamic", "registers", "the", "given", "interface", "type", "with", "gorp", ".", "The", "table", "name", "will", "be", "dynamically", "determined", "at", "runtime", "by", "using", "the", "GetTableName", "method", "on", "DynamicTable", "interface" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L261-L286
train
go-gorp/gorp
db.go
DropTable
func (m *DbMap) DropTable(table interface{}) error { t := reflect.TypeOf(table) tableName := "" if dyn, ok := table.(DynamicTable); ok { tableName = dyn.TableName() } return m.dropTable(t, tableName, false) }
go
func (m *DbMap) DropTable(table interface{}) error { t := reflect.TypeOf(table) tableName := "" if dyn, ok := table.(DynamicTable); ok { tableName = dyn.TableName() } return m.dropTable(t, tableName, false) }
[ "func", "(", "m", "*", "DbMap", ")", "DropTable", "(", "table", "interface", "{", "}", ")", "error", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "table", ")", "\n\n", "tableName", ":=", "\"", "\"", "\n", "if", "dyn", ",", "ok", ":=", "table", ...
// DropTable drops an individual table. // Returns an error when the table does not exist.
[ "DropTable", "drops", "an", "individual", "table", ".", "Returns", "an", "error", "when", "the", "table", "does", "not", "exist", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L463-L472
train
go-gorp/gorp
db.go
DropTableIfExists
func (m *DbMap) DropTableIfExists(table interface{}) error { t := reflect.TypeOf(table) tableName := "" if dyn, ok := table.(DynamicTable); ok { tableName = dyn.TableName() } return m.dropTable(t, tableName, true) }
go
func (m *DbMap) DropTableIfExists(table interface{}) error { t := reflect.TypeOf(table) tableName := "" if dyn, ok := table.(DynamicTable); ok { tableName = dyn.TableName() } return m.dropTable(t, tableName, true) }
[ "func", "(", "m", "*", "DbMap", ")", "DropTableIfExists", "(", "table", "interface", "{", "}", ")", "error", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "table", ")", "\n\n", "tableName", ":=", "\"", "\"", "\n", "if", "dyn", ",", "ok", ":=", "ta...
// DropTableIfExists drops an individual table when the table exists.
[ "DropTableIfExists", "drops", "an", "individual", "table", "when", "the", "table", "exists", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L475-L484
train
go-gorp/gorp
db.go
dropTables
func (m *DbMap) dropTables(addIfExists bool) (err error) { for _, table := range m.tables { err = m.dropTableImpl(table, addIfExists) if err != nil { return err } } for _, table := range m.dynamicTableMap() { err = m.dropTableImpl(table, addIfExists) if err != nil { return err } } return err }
go
func (m *DbMap) dropTables(addIfExists bool) (err error) { for _, table := range m.tables { err = m.dropTableImpl(table, addIfExists) if err != nil { return err } } for _, table := range m.dynamicTableMap() { err = m.dropTableImpl(table, addIfExists) if err != nil { return err } } return err }
[ "func", "(", "m", "*", "DbMap", ")", "dropTables", "(", "addIfExists", "bool", ")", "(", "err", "error", ")", "{", "for", "_", ",", "table", ":=", "range", "m", ".", "tables", "{", "err", "=", "m", ".", "dropTableImpl", "(", "table", ",", "addIfExi...
// Goes through all the registered tables, dropping them one by one. // If an error is encountered, then it is returned and the rest of // the tables are not dropped.
[ "Goes", "through", "all", "the", "registered", "tables", "dropping", "them", "one", "by", "one", ".", "If", "an", "error", "is", "encountered", "then", "it", "is", "returned", "and", "the", "rest", "of", "the", "tables", "are", "not", "dropped", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L501-L517
train
go-gorp/gorp
db.go
dropTable
func (m *DbMap) dropTable(t reflect.Type, name string, addIfExists bool) error { table := tableOrNil(m, t, name) if table == nil { return fmt.Errorf("table %s was not registered", table.TableName) } return m.dropTableImpl(table, addIfExists) }
go
func (m *DbMap) dropTable(t reflect.Type, name string, addIfExists bool) error { table := tableOrNil(m, t, name) if table == nil { return fmt.Errorf("table %s was not registered", table.TableName) } return m.dropTableImpl(table, addIfExists) }
[ "func", "(", "m", "*", "DbMap", ")", "dropTable", "(", "t", "reflect", ".", "Type", ",", "name", "string", ",", "addIfExists", "bool", ")", "error", "{", "table", ":=", "tableOrNil", "(", "m", ",", "t", ",", "name", ")", "\n", "if", "table", "==", ...
// Implementation of dropping a single table.
[ "Implementation", "of", "dropping", "a", "single", "table", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L520-L527
train
go-gorp/gorp
db.go
SelectInt
func (m *DbMap) SelectInt(query string, args ...interface{}) (int64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectInt(m, query, args...) }
go
func (m *DbMap) SelectInt(query string, args ...interface{}) (int64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectInt(m, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectInt", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int64", ",", "error", ")", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", "query", ",", "args",...
// SelectInt is a convenience wrapper around the gorp.SelectInt function
[ "SelectInt", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectInt", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L681-L687
train
go-gorp/gorp
db.go
SelectNullInt
func (m *DbMap) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullInt(m, query, args...) }
go
func (m *DbMap) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullInt(m, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectNullInt", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "NullInt64", ",", "error", ")", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", "...
// SelectNullInt is a convenience wrapper around the gorp.SelectNullInt function
[ "SelectNullInt", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectNullInt", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L690-L696
train
go-gorp/gorp
db.go
SelectFloat
func (m *DbMap) SelectFloat(query string, args ...interface{}) (float64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectFloat(m, query, args...) }
go
func (m *DbMap) SelectFloat(query string, args ...interface{}) (float64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectFloat(m, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectFloat", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "float64", ",", "error", ")", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", "query", ",", "ar...
// SelectFloat is a convenience wrapper around the gorp.SelectFloat function
[ "SelectFloat", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectFloat", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L699-L705
train
go-gorp/gorp
db.go
SelectNullFloat
func (m *DbMap) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullFloat(m, query, args...) }
go
func (m *DbMap) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullFloat(m, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectNullFloat", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "NullFloat64", ",", "error", ")", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&",...
// SelectNullFloat is a convenience wrapper around the gorp.SelectNullFloat function
[ "SelectNullFloat", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectNullFloat", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L708-L714
train
go-gorp/gorp
db.go
SelectStr
func (m *DbMap) SelectStr(query string, args ...interface{}) (string, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectStr(m, query, args...) }
go
func (m *DbMap) SelectStr(query string, args ...interface{}) (string, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectStr(m, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectStr", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", "query", ",", "args"...
// SelectStr is a convenience wrapper around the gorp.SelectStr function
[ "SelectStr", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectStr", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L717-L723
train
go-gorp/gorp
db.go
SelectNullStr
func (m *DbMap) SelectNullStr(query string, args ...interface{}) (sql.NullString, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullStr(m, query, args...) }
go
func (m *DbMap) SelectNullStr(query string, args ...interface{}) (sql.NullString, error) { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullStr(m, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectNullStr", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "NullString", ",", "error", ")", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", ...
// SelectNullStr is a convenience wrapper around the gorp.SelectNullStr function
[ "SelectNullStr", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectNullStr", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L726-L732
train
go-gorp/gorp
db.go
SelectOne
func (m *DbMap) SelectOne(holder interface{}, query string, args ...interface{}) error { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectOne(m, m, holder, query, args...) }
go
func (m *DbMap) SelectOne(holder interface{}, query string, args ...interface{}) error { if m.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectOne(m, m, holder, query, args...) }
[ "func", "(", "m", "*", "DbMap", ")", "SelectOne", "(", "holder", "interface", "{", "}", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "if", "m", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", "query", ...
// SelectOne is a convenience wrapper around the gorp.SelectOne function
[ "SelectOne", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectOne", "function" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L735-L741
train
go-gorp/gorp
db.go
Begin
func (m *DbMap) Begin() (*Transaction, error) { if m.logger != nil { now := time.Now() defer m.trace(now, "begin;") } tx, err := begin(m) if err != nil { return nil, err } return &Transaction{ dbmap: m, tx: tx, closed: false, }, nil }
go
func (m *DbMap) Begin() (*Transaction, error) { if m.logger != nil { now := time.Now() defer m.trace(now, "begin;") } tx, err := begin(m) if err != nil { return nil, err } return &Transaction{ dbmap: m, tx: tx, closed: false, }, nil }
[ "func", "(", "m", "*", "DbMap", ")", "Begin", "(", ")", "(", "*", "Transaction", ",", "error", ")", "{", "if", "m", ".", "logger", "!=", "nil", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "defer", "m", ".", "trace", "(", "now", ",",...
// Begin starts a gorp Transaction
[ "Begin", "starts", "a", "gorp", "Transaction" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/db.go#L744-L758
train
go-gorp/gorp
index.go
SetUnique
func (idx *IndexMap) SetUnique(b bool) *IndexMap { idx.Unique = b return idx }
go
func (idx *IndexMap) SetUnique(b bool) *IndexMap { idx.Unique = b return idx }
[ "func", "(", "idx", "*", "IndexMap", ")", "SetUnique", "(", "b", "bool", ")", "*", "IndexMap", "{", "idx", ".", "Unique", "=", "b", "\n", "return", "idx", "\n", "}" ]
// SetUnique adds "unique" to the create index statements for this // index, if b is true.
[ "SetUnique", "adds", "unique", "to", "the", "create", "index", "statements", "for", "this", "index", "if", "b", "is", "true", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/index.go#L47-L50
train
go-gorp/gorp
index.go
SetIndexType
func (idx *IndexMap) SetIndexType(indtype string) *IndexMap { idx.IndexType = indtype return idx }
go
func (idx *IndexMap) SetIndexType(indtype string) *IndexMap { idx.IndexType = indtype return idx }
[ "func", "(", "idx", "*", "IndexMap", ")", "SetIndexType", "(", "indtype", "string", ")", "*", "IndexMap", "{", "idx", ".", "IndexType", "=", "indtype", "\n", "return", "idx", "\n", "}" ]
// SetIndexType specifies the index type supported by chousen SQL Dialect
[ "SetIndexType", "specifies", "the", "index", "type", "supported", "by", "chousen", "SQL", "Dialect" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/index.go#L53-L56
train
go-gorp/gorp
dialect_sqlite.go
QuotedTableForQuery
func (d SqliteDialect) QuotedTableForQuery(schema string, table string) string { return d.QuoteField(table) }
go
func (d SqliteDialect) QuotedTableForQuery(schema string, table string) string { return d.QuoteField(table) }
[ "func", "(", "d", "SqliteDialect", ")", "QuotedTableForQuery", "(", "schema", "string", ",", "table", "string", ")", "string", "{", "return", "d", ".", "QuoteField", "(", "table", ")", "\n", "}" ]
// sqlite does not have schemas like PostgreSQL does, so just escape it like normal
[ "sqlite", "does", "not", "have", "schemas", "like", "PostgreSQL", "does", "so", "just", "escape", "it", "like", "normal" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/dialect_sqlite.go#L105-L107
train
go-gorp/gorp
dialect_oracle.go
InsertQueryToTarget
func (d OracleDialect) InsertQueryToTarget(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{}) error { _, err := exec.Exec(insertSql, params...) if err != nil { return err } id, err := exec.SelectInt(idSql) if err != nil { return err } switch target.(type) { case *int64: ...
go
func (d OracleDialect) InsertQueryToTarget(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{}) error { _, err := exec.Exec(insertSql, params...) if err != nil { return err } id, err := exec.SelectInt(idSql) if err != nil { return err } switch target.(type) { case *int64: ...
[ "func", "(", "d", "OracleDialect", ")", "InsertQueryToTarget", "(", "exec", "SqlExecutor", ",", "insertSql", ",", "idSql", "string", ",", "target", "interface", "{", "}", ",", "params", "...", "interface", "{", "}", ")", "error", "{", "_", ",", "err", ":...
// After executing the insert uses the ColMap IdQuery to get the generated id
[ "After", "executing", "the", "insert", "uses", "the", "ColMap", "IdQuery", "to", "get", "the", "generated", "id" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/dialect_oracle.go#L102-L122
train
go-gorp/gorp
transaction.go
SelectInt
func (t *Transaction) SelectInt(query string, args ...interface{}) (int64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectInt(t, query, args...) }
go
func (t *Transaction) SelectInt(query string, args ...interface{}) (int64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectInt(t, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectInt", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int64", ",", "error", ")", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", "...
// SelectInt is a convenience wrapper around the gorp.SelectInt function.
[ "SelectInt", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectInt", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L86-L92
train
go-gorp/gorp
transaction.go
SelectNullInt
func (t *Transaction) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullInt(t, query, args...) }
go
func (t *Transaction) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullInt(t, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectNullInt", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "NullInt64", ",", "error", ")", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandSlice...
// SelectNullInt is a convenience wrapper around the gorp.SelectNullInt function.
[ "SelectNullInt", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectNullInt", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L95-L101
train
go-gorp/gorp
transaction.go
SelectFloat
func (t *Transaction) SelectFloat(query string, args ...interface{}) (float64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectFloat(t, query, args...) }
go
func (t *Transaction) SelectFloat(query string, args ...interface{}) (float64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectFloat(t, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectFloat", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "float64", ",", "error", ")", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&",...
// SelectFloat is a convenience wrapper around the gorp.SelectFloat function.
[ "SelectFloat", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectFloat", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L104-L110
train
go-gorp/gorp
transaction.go
SelectNullFloat
func (t *Transaction) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullFloat(t, query, args...) }
go
func (t *Transaction) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullFloat(t, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectNullFloat", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "NullFloat64", ",", "error", ")", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandS...
// SelectNullFloat is a convenience wrapper around the gorp.SelectNullFloat function.
[ "SelectNullFloat", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectNullFloat", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L113-L119
train
go-gorp/gorp
transaction.go
SelectStr
func (t *Transaction) SelectStr(query string, args ...interface{}) (string, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectStr(t, query, args...) }
go
func (t *Transaction) SelectStr(query string, args ...interface{}) (string, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectStr(t, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectStr", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandSliceArgs", "(", "&", ...
// SelectStr is a convenience wrapper around the gorp.SelectStr function.
[ "SelectStr", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectStr", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L122-L128
train
go-gorp/gorp
transaction.go
SelectNullStr
func (t *Transaction) SelectNullStr(query string, args ...interface{}) (sql.NullString, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullStr(t, query, args...) }
go
func (t *Transaction) SelectNullStr(query string, args ...interface{}) (sql.NullString, error) { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectNullStr(t, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectNullStr", "(", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "sql", ".", "NullString", ",", "error", ")", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandSlic...
// SelectNullStr is a convenience wrapper around the gorp.SelectNullStr function.
[ "SelectNullStr", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectNullStr", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L131-L137
train
go-gorp/gorp
transaction.go
SelectOne
func (t *Transaction) SelectOne(holder interface{}, query string, args ...interface{}) error { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectOne(t.dbmap, t, holder, query, args...) }
go
func (t *Transaction) SelectOne(holder interface{}, query string, args ...interface{}) error { if t.dbmap.ExpandSliceArgs { expandSliceArgs(&query, args...) } return SelectOne(t.dbmap, t, holder, query, args...) }
[ "func", "(", "t", "*", "Transaction", ")", "SelectOne", "(", "holder", "interface", "{", "}", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "if", "t", ".", "dbmap", ".", "ExpandSliceArgs", "{", "expandSliceArgs", ...
// SelectOne is a convenience wrapper around the gorp.SelectOne function.
[ "SelectOne", "is", "a", "convenience", "wrapper", "around", "the", "gorp", ".", "SelectOne", "function", "." ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L140-L146
train
go-gorp/gorp
transaction.go
Savepoint
func (t *Transaction) Savepoint(name string) error { query := "savepoint " + t.dbmap.Dialect.QuoteField(name) if t.dbmap.logger != nil { now := time.Now() defer t.dbmap.trace(now, query, nil) } _, err := exec(t, query) return err }
go
func (t *Transaction) Savepoint(name string) error { query := "savepoint " + t.dbmap.Dialect.QuoteField(name) if t.dbmap.logger != nil { now := time.Now() defer t.dbmap.trace(now, query, nil) } _, err := exec(t, query) return err }
[ "func", "(", "t", "*", "Transaction", ")", "Savepoint", "(", "name", "string", ")", "error", "{", "query", ":=", "\"", "\"", "+", "t", ".", "dbmap", ".", "Dialect", ".", "QuoteField", "(", "name", ")", "\n", "if", "t", ".", "dbmap", ".", "logger", ...
// Savepoint creates a savepoint with the given name. The name is interpolated // directly into the SQL SAVEPOINT statement, so you must sanitize it if it is // derived from user input.
[ "Savepoint", "creates", "a", "savepoint", "with", "the", "given", "name", ".", "The", "name", "is", "interpolated", "directly", "into", "the", "SQL", "SAVEPOINT", "statement", "so", "you", "must", "sanitize", "it", "if", "it", "is", "derived", "from", "user"...
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/transaction.go#L179-L187
train
go-gorp/gorp
lockerror.go
Error
func (e OptimisticLockError) Error() string { if e.RowExists { return fmt.Sprintf("gorp: OptimisticLockError table=%s keys=%v out of date version=%d", e.TableName, e.Keys, e.LocalVersion) } return fmt.Sprintf("gorp: OptimisticLockError no row found for table=%s keys=%v", e.TableName, e.Keys) }
go
func (e OptimisticLockError) Error() string { if e.RowExists { return fmt.Sprintf("gorp: OptimisticLockError table=%s keys=%v out of date version=%d", e.TableName, e.Keys, e.LocalVersion) } return fmt.Sprintf("gorp: OptimisticLockError no row found for table=%s keys=%v", e.TableName, e.Keys) }
[ "func", "(", "e", "OptimisticLockError", ")", "Error", "(", ")", "string", "{", "if", "e", ".", "RowExists", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "TableName", ",", "e", ".", "Keys", ",", "e", ".", "LocalVersion", ")...
// Error returns a description of the cause of the lock error
[ "Error", "returns", "a", "description", "of", "the", "cause", "of", "the", "lock", "error" ]
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/lockerror.go#L41-L47
train
go-gorp/gorp
select.go
SelectInt
func SelectInt(e SqlExecutor, query string, args ...interface{}) (int64, error) { var h int64 err := selectVal(e, &h, query, args...) if err != nil && err != sql.ErrNoRows { return 0, err } return h, nil }
go
func SelectInt(e SqlExecutor, query string, args ...interface{}) (int64, error) { var h int64 err := selectVal(e, &h, query, args...) if err != nil && err != sql.ErrNoRows { return 0, err } return h, nil }
[ "func", "SelectInt", "(", "e", "SqlExecutor", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int64", ",", "error", ")", "{", "var", "h", "int64", "\n", "err", ":=", "selectVal", "(", "e", ",", "&", "h", ",", "query", ...
// SelectInt executes the given query, which should be a SELECT statement for a single // integer column, and returns the value of the first row returned. If no rows are // found, zero is returned.
[ "SelectInt", "executes", "the", "given", "query", "which", "should", "be", "a", "SELECT", "statement", "for", "a", "single", "integer", "column", "and", "returns", "the", "value", "of", "the", "first", "row", "returned", ".", "If", "no", "rows", "are", "fo...
f3677d4a0a8838c846ed41bf41927f2c8713bd60
https://github.com/go-gorp/gorp/blob/f3677d4a0a8838c846ed41bf41927f2c8713bd60/select.go#L23-L30
train
hashicorp/go-version
constraint.go
NewConstraint
func NewConstraint(v string) (Constraints, error) { vs := strings.Split(v, ",") result := make([]*Constraint, len(vs)) for i, single := range vs { c, err := parseSingle(single) if err != nil { return nil, err } result[i] = c } return Constraints(result), nil }
go
func NewConstraint(v string) (Constraints, error) { vs := strings.Split(v, ",") result := make([]*Constraint, len(vs)) for i, single := range vs { c, err := parseSingle(single) if err != nil { return nil, err } result[i] = c } return Constraints(result), nil }
[ "func", "NewConstraint", "(", "v", "string", ")", "(", "Constraints", ",", "error", ")", "{", "vs", ":=", "strings", ".", "Split", "(", "v", ",", "\"", "\"", ")", "\n", "result", ":=", "make", "(", "[", "]", "*", "Constraint", ",", "len", "(", "v...
// NewConstraint will parse one or more constraints from the given // constraint string. The string must be a comma-separated list of // constraints.
[ "NewConstraint", "will", "parse", "one", "or", "more", "constraints", "from", "the", "given", "constraint", "string", ".", "The", "string", "must", "be", "a", "comma", "-", "separated", "list", "of", "constraints", "." ]
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/constraint.go#L54-L67
train
hashicorp/go-version
constraint.go
Check
func (cs Constraints) Check(v *Version) bool { for _, c := range cs { if !c.Check(v) { return false } } return true }
go
func (cs Constraints) Check(v *Version) bool { for _, c := range cs { if !c.Check(v) { return false } } return true }
[ "func", "(", "cs", "Constraints", ")", "Check", "(", "v", "*", "Version", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "cs", "{", "if", "!", "c", ".", "Check", "(", "v", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "re...
// Check tests if a version satisfies all the constraints.
[ "Check", "tests", "if", "a", "version", "satisfies", "all", "the", "constraints", "." ]
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/constraint.go#L70-L78
train
hashicorp/go-version
constraint.go
String
func (cs Constraints) String() string { csStr := make([]string, len(cs)) for i, c := range cs { csStr[i] = c.String() } return strings.Join(csStr, ",") }
go
func (cs Constraints) String() string { csStr := make([]string, len(cs)) for i, c := range cs { csStr[i] = c.String() } return strings.Join(csStr, ",") }
[ "func", "(", "cs", "Constraints", ")", "String", "(", ")", "string", "{", "csStr", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "cs", ")", ")", "\n", "for", "i", ",", "c", ":=", "range", "cs", "{", "csStr", "[", "i", "]", "=", "c",...
// Returns the string format of the constraints
[ "Returns", "the", "string", "format", "of", "the", "constraints" ]
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/constraint.go#L81-L88
train
hashicorp/go-version
constraint.go
Check
func (c *Constraint) Check(v *Version) bool { return c.f(v, c.check) }
go
func (c *Constraint) Check(v *Version) bool { return c.f(v, c.check) }
[ "func", "(", "c", "*", "Constraint", ")", "Check", "(", "v", "*", "Version", ")", "bool", "{", "return", "c", ".", "f", "(", "v", ",", "c", ".", "check", ")", "\n", "}" ]
// Check tests if a constraint is validated by the given version.
[ "Check", "tests", "if", "a", "constraint", "is", "validated", "by", "the", "given", "version", "." ]
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/constraint.go#L91-L93
train
hashicorp/go-version
version.go
Compare
func (v *Version) Compare(other *Version) int { // A quick, efficient equality check if v.String() == other.String() { return 0 } segmentsSelf := v.Segments64() segmentsOther := other.Segments64() // If the segments are the same, we must compare on prerelease info if reflect.DeepEqual(segmentsSelf, segmentsO...
go
func (v *Version) Compare(other *Version) int { // A quick, efficient equality check if v.String() == other.String() { return 0 } segmentsSelf := v.Segments64() segmentsOther := other.Segments64() // If the segments are the same, we must compare on prerelease info if reflect.DeepEqual(segmentsSelf, segmentsO...
[ "func", "(", "v", "*", "Version", ")", "Compare", "(", "other", "*", "Version", ")", "int", "{", "// A quick, efficient equality check", "if", "v", ".", "String", "(", ")", "==", "other", ".", "String", "(", ")", "{", "return", "0", "\n", "}", "\n\n", ...
// Compare compares this version to another version. This // returns -1, 0, or 1 if this version is smaller, equal, // or larger than the other version, respectively. // // If you want boolean results, use the LessThan, Equal, // GreaterThan, GreaterThanOrEqual or LessThanOrEqual methods.
[ "Compare", "compares", "this", "version", "to", "another", "version", ".", "This", "returns", "-", "1", "0", "or", "1", "if", "this", "version", "is", "smaller", "equal", "or", "larger", "than", "the", "other", "version", "respectively", ".", "If", "you", ...
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/version.go#L116-L183
train
hashicorp/go-version
version.go
Segments
func (v *Version) Segments() []int { segmentSlice := make([]int, len(v.segments)) for i, v := range v.segments { segmentSlice[i] = int(v) } return segmentSlice }
go
func (v *Version) Segments() []int { segmentSlice := make([]int, len(v.segments)) for i, v := range v.segments { segmentSlice[i] = int(v) } return segmentSlice }
[ "func", "(", "v", "*", "Version", ")", "Segments", "(", ")", "[", "]", "int", "{", "segmentSlice", ":=", "make", "(", "[", "]", "int", ",", "len", "(", "v", ".", "segments", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "v", ".", "segm...
// Segments returns the numeric segments of the version as a slice of ints. // // This excludes any metadata or pre-release information. For example, // for a version "1.2.3-beta", segments will return a slice of // 1, 2, 3.
[ "Segments", "returns", "the", "numeric", "segments", "of", "the", "version", "as", "a", "slice", "of", "ints", ".", "This", "excludes", "any", "metadata", "or", "pre", "-", "release", "information", ".", "For", "example", "for", "a", "version", "1", ".", ...
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/version.go#L330-L336
train
hashicorp/go-version
version.go
Segments64
func (v *Version) Segments64() []int64 { result := make([]int64, len(v.segments)) copy(result, v.segments) return result }
go
func (v *Version) Segments64() []int64 { result := make([]int64, len(v.segments)) copy(result, v.segments) return result }
[ "func", "(", "v", "*", "Version", ")", "Segments64", "(", ")", "[", "]", "int64", "{", "result", ":=", "make", "(", "[", "]", "int64", ",", "len", "(", "v", ".", "segments", ")", ")", "\n", "copy", "(", "result", ",", "v", ".", "segments", ")",...
// Segments64 returns the numeric segments of the version as a slice of int64s. // // This excludes any metadata or pre-release information. For example, // for a version "1.2.3-beta", segments will return a slice of // 1, 2, 3.
[ "Segments64", "returns", "the", "numeric", "segments", "of", "the", "version", "as", "a", "slice", "of", "int64s", ".", "This", "excludes", "any", "metadata", "or", "pre", "-", "release", "information", ".", "For", "example", "for", "a", "version", "1", "....
192140e6f3e645d971b134d4e35b5191adb9dfd3
https://github.com/hashicorp/go-version/blob/192140e6f3e645d971b134d4e35b5191adb9dfd3/version.go#L343-L347
train
google/gops
main.go
elapsedTime
func elapsedTime(p *process.Process) (string, error) { crtTime, err := p.CreateTime() if err != nil { return "", err } etime := time.Since(time.Unix(int64(crtTime/1000), 0)) return fmtEtimeDuration(etime), nil }
go
func elapsedTime(p *process.Process) (string, error) { crtTime, err := p.CreateTime() if err != nil { return "", err } etime := time.Since(time.Unix(int64(crtTime/1000), 0)) return fmtEtimeDuration(etime), nil }
[ "func", "elapsedTime", "(", "p", "*", "process", ".", "Process", ")", "(", "string", ",", "error", ")", "{", "crtTime", ",", "err", ":=", "p", ".", "CreateTime", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n...
// elapsedTime shows the elapsed time of the process indicating how long the // process has been running for.
[ "elapsedTime", "shows", "the", "elapsed", "time", "of", "the", "process", "indicating", "how", "long", "the", "process", "has", "been", "running", "for", "." ]
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/main.go#L170-L177
train