id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
149,500 | vbatts/go-mtree | walk.go | keywordEntries | func keywordEntries(keywords []Keyword) []Entry {
// Convert all of the keywords to zero-value keyvals.
return []Entry{
{
Type: CommentType,
Raw: fmt.Sprintf("#%16s%s", "keywords: ", strings.Join(FromKeywords(keywords), ",")),
},
}
} | go | func keywordEntries(keywords []Keyword) []Entry {
// Convert all of the keywords to zero-value keyvals.
return []Entry{
{
Type: CommentType,
Raw: fmt.Sprintf("#%16s%s", "keywords: ", strings.Join(FromKeywords(keywords), ",")),
},
}
} | [
"func",
"keywordEntries",
"(",
"keywords",
"[",
"]",
"Keyword",
")",
"[",
"]",
"Entry",
"{",
"// Convert all of the keywords to zero-value keyvals.",
"return",
"[",
"]",
"Entry",
"{",
"{",
"Type",
":",
"CommentType",
",",
"Raw",
":",
"fmt",
".",
"Sprintf",
"("... | // keywordEntries returns a slice of entries including a comment of the
// keywords requested when generating this manifest. | [
"keywordEntries",
"returns",
"a",
"slice",
"of",
"entries",
"including",
"a",
"comment",
"of",
"the",
"keywords",
"requested",
"when",
"generating",
"this",
"manifest",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/walk.go#L377-L385 |
149,501 | vbatts/go-mtree | pkg/govis/unvis.go | Peek | func (p *unvisParser) Peek() (rune, error) {
if p.idx >= len(p.tokens) {
return unicode.ReplacementChar, fmt.Errorf("tried to read past end of token list")
}
return p.tokens[p.idx], nil
} | go | func (p *unvisParser) Peek() (rune, error) {
if p.idx >= len(p.tokens) {
return unicode.ReplacementChar, fmt.Errorf("tried to read past end of token list")
}
return p.tokens[p.idx], nil
} | [
"func",
"(",
"p",
"*",
"unvisParser",
")",
"Peek",
"(",
")",
"(",
"rune",
",",
"error",
")",
"{",
"if",
"p",
".",
"idx",
">=",
"len",
"(",
"p",
".",
"tokens",
")",
"{",
"return",
"unicode",
".",
"ReplacementChar",
",",
"fmt",
".",
"Errorf",
"(",
... | // Peek gets the current token. | [
"Peek",
"gets",
"the",
"current",
"token",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/pkg/govis/unvis.go#L39-L44 |
149,502 | vbatts/go-mtree | keywords.go | Suffix | func (k Keyword) Suffix() string {
if strings.Contains(string(k), ".") {
return strings.SplitN(string(k), ".", 2)[1]
}
return string(k)
} | go | func (k Keyword) Suffix() string {
if strings.Contains(string(k), ".") {
return strings.SplitN(string(k), ".", 2)[1]
}
return string(k)
} | [
"func",
"(",
"k",
"Keyword",
")",
"Suffix",
"(",
")",
"string",
"{",
"if",
"strings",
".",
"Contains",
"(",
"string",
"(",
"k",
")",
",",
"\"",
"\"",
")",
"{",
"return",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"k",
")",
",",
"\"",
"\"",
"... | // Suffix is the portion of the keyword after a first ".".
// This is an option feature.
//
// Primarly for the xattr use-case, where the keyword `xattr.security.selinux` would have a Suffix of `security.selinux`. | [
"Suffix",
"is",
"the",
"portion",
"of",
"the",
"keyword",
"after",
"a",
"first",
".",
".",
"This",
"is",
"an",
"option",
"feature",
".",
"Primarly",
"for",
"the",
"xattr",
"use",
"-",
"case",
"where",
"the",
"keyword",
"xattr",
".",
"security",
".",
"s... | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L33-L38 |
149,503 | vbatts/go-mtree | keywords.go | InKeywordSlice | func InKeywordSlice(a Keyword, list []Keyword) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
} | go | func InKeywordSlice(a Keyword, list []Keyword) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
} | [
"func",
"InKeywordSlice",
"(",
"a",
"Keyword",
",",
"list",
"[",
"]",
"Keyword",
")",
"bool",
"{",
"for",
"_",
",",
"b",
":=",
"range",
"list",
"{",
"if",
"b",
"==",
"a",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",... | // InKeywordSlice checks for the presence of `a` in `list` | [
"InKeywordSlice",
"checks",
"for",
"the",
"presence",
"of",
"a",
"in",
"list"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L57-L64 |
149,504 | vbatts/go-mtree | keywords.go | ToKeywords | func ToKeywords(list []string) []Keyword {
ret := make([]Keyword, len(list))
for i := range list {
ret[i] = Keyword(list[i])
}
return ret
} | go | func ToKeywords(list []string) []Keyword {
ret := make([]Keyword, len(list))
for i := range list {
ret[i] = Keyword(list[i])
}
return ret
} | [
"func",
"ToKeywords",
"(",
"list",
"[",
"]",
"string",
")",
"[",
"]",
"Keyword",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"Keyword",
",",
"len",
"(",
"list",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"list",
"{",
"ret",
"[",
"i",
"]",
"=",
"... | // ToKeywords makes a list of Keyword from a list of string | [
"ToKeywords",
"makes",
"a",
"list",
"of",
"Keyword",
"from",
"a",
"list",
"of",
"string"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L75-L81 |
149,505 | vbatts/go-mtree | keywords.go | FromKeywords | func FromKeywords(list []Keyword) []string {
ret := make([]string, len(list))
for i := range list {
ret[i] = string(list[i])
}
return ret
} | go | func FromKeywords(list []Keyword) []string {
ret := make([]string, len(list))
for i := range list {
ret[i] = string(list[i])
}
return ret
} | [
"func",
"FromKeywords",
"(",
"list",
"[",
"]",
"Keyword",
")",
"[",
"]",
"string",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"list",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"list",
"{",
"ret",
"[",
"i",
"]",
"=",
... | // FromKeywords makes a list of string from a list of Keyword | [
"FromKeywords",
"makes",
"a",
"list",
"of",
"string",
"from",
"a",
"list",
"of",
"Keyword"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L84-L90 |
149,506 | vbatts/go-mtree | keywords.go | KeyValToString | func KeyValToString(list []KeyVal) []string {
ret := make([]string, len(list))
for i := range list {
ret[i] = string(list[i])
}
return ret
} | go | func KeyValToString(list []KeyVal) []string {
ret := make([]string, len(list))
for i := range list {
ret[i] = string(list[i])
}
return ret
} | [
"func",
"KeyValToString",
"(",
"list",
"[",
"]",
"KeyVal",
")",
"[",
"]",
"string",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"list",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"list",
"{",
"ret",
"[",
"i",
"]",
"=",
... | // KeyValToString constructs a list of string from the list of KeyVal | [
"KeyValToString",
"constructs",
"a",
"list",
"of",
"string",
"from",
"the",
"list",
"of",
"KeyVal"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L93-L99 |
149,507 | vbatts/go-mtree | keywords.go | StringToKeyVals | func StringToKeyVals(list []string) []KeyVal {
ret := make([]KeyVal, len(list))
for i := range list {
ret[i] = KeyVal(list[i])
}
return ret
} | go | func StringToKeyVals(list []string) []KeyVal {
ret := make([]KeyVal, len(list))
for i := range list {
ret[i] = KeyVal(list[i])
}
return ret
} | [
"func",
"StringToKeyVals",
"(",
"list",
"[",
"]",
"string",
")",
"[",
"]",
"KeyVal",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"KeyVal",
",",
"len",
"(",
"list",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"list",
"{",
"ret",
"[",
"i",
"]",
"=",
... | // StringToKeyVals constructs a list of KeyVal from the list of strings, like "keyword=value" | [
"StringToKeyVals",
"constructs",
"a",
"list",
"of",
"KeyVal",
"from",
"the",
"list",
"of",
"strings",
"like",
"keyword",
"=",
"value"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L102-L108 |
149,508 | vbatts/go-mtree | keywords.go | Keyword | func (kv KeyVal) Keyword() Keyword {
if !strings.Contains(string(kv), "=") {
return Keyword("")
}
return Keyword(strings.SplitN(strings.TrimSpace(string(kv)), "=", 2)[0])
} | go | func (kv KeyVal) Keyword() Keyword {
if !strings.Contains(string(kv), "=") {
return Keyword("")
}
return Keyword(strings.SplitN(strings.TrimSpace(string(kv)), "=", 2)[0])
} | [
"func",
"(",
"kv",
"KeyVal",
")",
"Keyword",
"(",
")",
"Keyword",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"string",
"(",
"kv",
")",
",",
"\"",
"\"",
")",
"{",
"return",
"Keyword",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"Keyword... | // Keyword is the mapping to the available keywords | [
"Keyword",
"is",
"the",
"mapping",
"to",
"the",
"available",
"keywords"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L114-L119 |
149,509 | vbatts/go-mtree | keywords.go | NewValue | func (kv KeyVal) NewValue(newval string) KeyVal {
return KeyVal(fmt.Sprintf("%s=%s", kv.Keyword(), newval))
} | go | func (kv KeyVal) NewValue(newval string) KeyVal {
return KeyVal(fmt.Sprintf("%s=%s", kv.Keyword(), newval))
} | [
"func",
"(",
"kv",
"KeyVal",
")",
"NewValue",
"(",
"newval",
"string",
")",
"KeyVal",
"{",
"return",
"KeyVal",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"kv",
".",
"Keyword",
"(",
")",
",",
"newval",
")",
")",
"\n",
"}"
] | // NewValue returns a new KeyVal with the newval | [
"NewValue",
"returns",
"a",
"new",
"KeyVal",
"with",
"the",
"newval"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L130-L132 |
149,510 | vbatts/go-mtree | keywords.go | Equal | func (kv KeyVal) Equal(b KeyVal) bool {
// TODO: Implement handling of tar_mtime.
return kv.Keyword() == b.Keyword() && kv.Value() == b.Value()
} | go | func (kv KeyVal) Equal(b KeyVal) bool {
// TODO: Implement handling of tar_mtime.
return kv.Keyword() == b.Keyword() && kv.Value() == b.Value()
} | [
"func",
"(",
"kv",
"KeyVal",
")",
"Equal",
"(",
"b",
"KeyVal",
")",
"bool",
"{",
"// TODO: Implement handling of tar_mtime.",
"return",
"kv",
".",
"Keyword",
"(",
")",
"==",
"b",
".",
"Keyword",
"(",
")",
"&&",
"kv",
".",
"Value",
"(",
")",
"==",
"b",
... | // Equal returns whether two KeyVal are equivalent. This takes
// care of certain odd cases such as tar_mtime, and should be used over
// using == comparisons directly unless you really know what you're
// doing. | [
"Equal",
"returns",
"whether",
"two",
"KeyVal",
"are",
"equivalent",
".",
"This",
"takes",
"care",
"of",
"certain",
"odd",
"cases",
"such",
"as",
"tar_mtime",
"and",
"should",
"be",
"used",
"over",
"using",
"==",
"comparisons",
"directly",
"unless",
"you",
"... | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L138-L141 |
149,511 | vbatts/go-mtree | keywords.go | Has | func Has(keyvals []KeyVal, keyword string) []KeyVal {
return HasKeyword(keyvals, Keyword(keyword))
} | go | func Has(keyvals []KeyVal, keyword string) []KeyVal {
return HasKeyword(keyvals, Keyword(keyword))
} | [
"func",
"Has",
"(",
"keyvals",
"[",
"]",
"KeyVal",
",",
"keyword",
"string",
")",
"[",
"]",
"KeyVal",
"{",
"return",
"HasKeyword",
"(",
"keyvals",
",",
"Keyword",
"(",
"keyword",
")",
")",
"\n",
"}"
] | // Has the "keyword" present in the list of KeyVal, and returns the
// corresponding KeyVal, else an empty string. | [
"Has",
"the",
"keyword",
"present",
"in",
"the",
"list",
"of",
"KeyVal",
"and",
"returns",
"the",
"corresponding",
"KeyVal",
"else",
"an",
"empty",
"string",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L185-L187 |
149,512 | vbatts/go-mtree | keywords.go | HasKeyword | func HasKeyword(keyvals []KeyVal, keyword Keyword) []KeyVal {
kvs := []KeyVal{}
for i := range keyvals {
if keyvals[i].Keyword().Prefix() == keyword.Prefix() {
kvs = append(kvs, keyvals[i])
}
}
return kvs
} | go | func HasKeyword(keyvals []KeyVal, keyword Keyword) []KeyVal {
kvs := []KeyVal{}
for i := range keyvals {
if keyvals[i].Keyword().Prefix() == keyword.Prefix() {
kvs = append(kvs, keyvals[i])
}
}
return kvs
} | [
"func",
"HasKeyword",
"(",
"keyvals",
"[",
"]",
"KeyVal",
",",
"keyword",
"Keyword",
")",
"[",
"]",
"KeyVal",
"{",
"kvs",
":=",
"[",
"]",
"KeyVal",
"{",
"}",
"\n",
"for",
"i",
":=",
"range",
"keyvals",
"{",
"if",
"keyvals",
"[",
"i",
"]",
".",
"K... | // HasKeyword the "keyword" present in the list of KeyVal, and returns the
// corresponding KeyVal, else an empty string.
// This match is done on the Prefix of the keyword only. | [
"HasKeyword",
"the",
"keyword",
"present",
"in",
"the",
"list",
"of",
"KeyVal",
"and",
"returns",
"the",
"corresponding",
"KeyVal",
"else",
"an",
"empty",
"string",
".",
"This",
"match",
"is",
"done",
"on",
"the",
"Prefix",
"of",
"the",
"keyword",
"only",
... | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L192-L200 |
149,513 | vbatts/go-mtree | keywords.go | MergeSet | func MergeSet(setKeyVals, entryKeyVals []string) []KeyVal {
retList := StringToKeyVals(setKeyVals)
eKVs := StringToKeyVals(entryKeyVals)
return MergeKeyValSet(retList, eKVs)
} | go | func MergeSet(setKeyVals, entryKeyVals []string) []KeyVal {
retList := StringToKeyVals(setKeyVals)
eKVs := StringToKeyVals(entryKeyVals)
return MergeKeyValSet(retList, eKVs)
} | [
"func",
"MergeSet",
"(",
"setKeyVals",
",",
"entryKeyVals",
"[",
"]",
"string",
")",
"[",
"]",
"KeyVal",
"{",
"retList",
":=",
"StringToKeyVals",
"(",
"setKeyVals",
")",
"\n",
"eKVs",
":=",
"StringToKeyVals",
"(",
"entryKeyVals",
")",
"\n",
"return",
"MergeK... | // MergeSet takes the current setKeyVals, and then applies the entryKeyVals
// such that the entry's values win. The union is returned. | [
"MergeSet",
"takes",
"the",
"current",
"setKeyVals",
"and",
"then",
"applies",
"the",
"entryKeyVals",
"such",
"that",
"the",
"entry",
"s",
"values",
"win",
".",
"The",
"union",
"is",
"returned",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L204-L208 |
149,514 | vbatts/go-mtree | keywords.go | MergeKeyValSet | func MergeKeyValSet(setKeyVals, entryKeyVals []KeyVal) []KeyVal {
retList := keyValCopy(setKeyVals)
seenKeywords := []Keyword{}
for i := range retList {
word := retList[i].Keyword()
for _, kv := range HasKeyword(entryKeyVals, word) {
// match on the keyword prefix and suffix here
if kv.Keyword() == word {
... | go | func MergeKeyValSet(setKeyVals, entryKeyVals []KeyVal) []KeyVal {
retList := keyValCopy(setKeyVals)
seenKeywords := []Keyword{}
for i := range retList {
word := retList[i].Keyword()
for _, kv := range HasKeyword(entryKeyVals, word) {
// match on the keyword prefix and suffix here
if kv.Keyword() == word {
... | [
"func",
"MergeKeyValSet",
"(",
"setKeyVals",
",",
"entryKeyVals",
"[",
"]",
"KeyVal",
")",
"[",
"]",
"KeyVal",
"{",
"retList",
":=",
"keyValCopy",
"(",
"setKeyVals",
")",
"\n",
"seenKeywords",
":=",
"[",
"]",
"Keyword",
"{",
"}",
"\n",
"for",
"i",
":=",
... | // MergeKeyValSet does a merge of the two sets of KeyVal, and the KeyVal of
// entryKeyVals win when there is a duplicate Keyword. | [
"MergeKeyValSet",
"does",
"a",
"merge",
"of",
"the",
"two",
"sets",
"of",
"KeyVal",
"and",
"the",
"KeyVal",
"of",
"entryKeyVals",
"win",
"when",
"there",
"is",
"a",
"duplicate",
"Keyword",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L212-L231 |
149,515 | vbatts/go-mtree | keywords.go | KeywordSynonym | func KeywordSynonym(name string) Keyword {
var retname string
switch name {
case "md5":
retname = "md5digest"
case "rmd160":
retname = "ripemd160digest"
case "rmd160digest":
retname = "ripemd160digest"
case "sha1":
retname = "sha1digest"
case "sha256":
retname = "sha256digest"
case "sha384":
retname... | go | func KeywordSynonym(name string) Keyword {
var retname string
switch name {
case "md5":
retname = "md5digest"
case "rmd160":
retname = "ripemd160digest"
case "rmd160digest":
retname = "ripemd160digest"
case "sha1":
retname = "sha1digest"
case "sha256":
retname = "sha256digest"
case "sha384":
retname... | [
"func",
"KeywordSynonym",
"(",
"name",
"string",
")",
"Keyword",
"{",
"var",
"retname",
"string",
"\n",
"switch",
"name",
"{",
"case",
"\"",
"\"",
":",
"retname",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"retname",
"=",
"\"",
"\"",
"\n",
"case... | // KeywordSynonym returns the canonical name for keywords that have synonyms,
// and just returns the name provided if there is no synonym. In this way it
// ought to be safe to wrap any keyword name. | [
"KeywordSynonym",
"returns",
"the",
"canonical",
"name",
"for",
"keywords",
"that",
"have",
"synonyms",
"and",
"just",
"returns",
"the",
"name",
"provided",
"if",
"there",
"is",
"no",
"synonym",
".",
"In",
"this",
"way",
"it",
"ought",
"to",
"be",
"safe",
... | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/keywords.go#L302-L327 |
149,516 | vbatts/go-mtree | updatefuncs.go | tartimeUpdateKeywordFunc | func tartimeUpdateKeywordFunc(path string, kv KeyVal) (os.FileInfo, error) {
info, err := os.Lstat(path)
if err != nil {
return nil, err
}
v := strings.SplitN(kv.Value(), ".", 2)
if len(v) != 2 {
return nil, fmt.Errorf("expected a number like 1469104727.000000000")
}
sec, err := strconv.ParseInt(v[0], 10, 6... | go | func tartimeUpdateKeywordFunc(path string, kv KeyVal) (os.FileInfo, error) {
info, err := os.Lstat(path)
if err != nil {
return nil, err
}
v := strings.SplitN(kv.Value(), ".", 2)
if len(v) != 2 {
return nil, fmt.Errorf("expected a number like 1469104727.000000000")
}
sec, err := strconv.ParseInt(v[0], 10, 6... | [
"func",
"tartimeUpdateKeywordFunc",
"(",
"path",
"string",
",",
"kv",
"KeyVal",
")",
"(",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"os",
".",
"Lstat",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // since tar_time will only be second level precision, then when restoring the
// filepath from a tar_time, then compare the seconds first and only Chtimes if
// the seconds value is different. | [
"since",
"tar_time",
"will",
"only",
"be",
"second",
"level",
"precision",
"then",
"when",
"restoring",
"the",
"filepath",
"from",
"a",
"tar_time",
"then",
"compare",
"the",
"seconds",
"first",
"and",
"only",
"Chtimes",
"if",
"the",
"seconds",
"value",
"is",
... | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/updatefuncs.go#L104-L142 |
149,517 | vbatts/go-mtree | cmd/gomtree/main.go | isDirEntry | func isDirEntry(e mtree.Entry) bool {
for _, kw := range e.Keywords {
kv := mtree.KeyVal(kw)
if kv.Keyword() == "type" {
return kv.Value() == "dir"
}
}
// Shouldn't be reached.
return false
} | go | func isDirEntry(e mtree.Entry) bool {
for _, kw := range e.Keywords {
kv := mtree.KeyVal(kw)
if kv.Keyword() == "type" {
return kv.Value() == "dir"
}
}
// Shouldn't be reached.
return false
} | [
"func",
"isDirEntry",
"(",
"e",
"mtree",
".",
"Entry",
")",
"bool",
"{",
"for",
"_",
",",
"kw",
":=",
"range",
"e",
".",
"Keywords",
"{",
"kv",
":=",
"mtree",
".",
"KeyVal",
"(",
"kw",
")",
"\n",
"if",
"kv",
".",
"Keyword",
"(",
")",
"==",
"\""... | // isDirEntry returns wheter an mtree.Entry describes a directory. | [
"isDirEntry",
"returns",
"wheter",
"an",
"mtree",
".",
"Entry",
"describes",
"a",
"directory",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/cmd/gomtree/main.go#L382-L391 |
149,518 | vbatts/go-mtree | cmd/gomtree/main.go | isTarSpec | func isTarSpec(spec *mtree.DirectoryHierarchy) bool {
// Find a directory and check whether it's missing size=...
// NOTE: This will definitely break if someone drops the size=... keyword.
for _, e := range spec.Entries {
if !isDirEntry(e) {
continue
}
for _, kw := range e.Keywords {
kv := mtree.KeyVal(... | go | func isTarSpec(spec *mtree.DirectoryHierarchy) bool {
// Find a directory and check whether it's missing size=...
// NOTE: This will definitely break if someone drops the size=... keyword.
for _, e := range spec.Entries {
if !isDirEntry(e) {
continue
}
for _, kw := range e.Keywords {
kv := mtree.KeyVal(... | [
"func",
"isTarSpec",
"(",
"spec",
"*",
"mtree",
".",
"DirectoryHierarchy",
")",
"bool",
"{",
"// Find a directory and check whether it's missing size=...",
"// NOTE: This will definitely break if someone drops the size=... keyword.",
"for",
"_",
",",
"e",
":=",
"range",
"spec",... | // isTarSpec returns whether the spec provided came from the tar generator.
// This takes advantage of an unsolveable problem in tar generation. | [
"isTarSpec",
"returns",
"whether",
"the",
"spec",
"provided",
"came",
"from",
"the",
"tar",
"generator",
".",
"This",
"takes",
"advantage",
"of",
"an",
"unsolveable",
"problem",
"in",
"tar",
"generation",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/cmd/gomtree/main.go#L444-L463 |
149,519 | vbatts/go-mtree | hierarchy.go | WriteTo | func (dh DirectoryHierarchy) WriteTo(w io.Writer) (n int64, err error) {
sort.Sort(byPos(dh.Entries))
var sum int64
for _, e := range dh.Entries {
str := e.String()
i, err := io.WriteString(w, str+"\n")
if err != nil {
return sum, err
}
sum += int64(i)
}
return sum, nil
} | go | func (dh DirectoryHierarchy) WriteTo(w io.Writer) (n int64, err error) {
sort.Sort(byPos(dh.Entries))
var sum int64
for _, e := range dh.Entries {
str := e.String()
i, err := io.WriteString(w, str+"\n")
if err != nil {
return sum, err
}
sum += int64(i)
}
return sum, nil
} | [
"func",
"(",
"dh",
"DirectoryHierarchy",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"sort",
".",
"Sort",
"(",
"byPos",
"(",
"dh",
".",
"Entries",
")",
")",
"\n",
"var",
"sum",
"int64",
"\... | // WriteTo simplifies the output of the resulting hierarchy spec | [
"WriteTo",
"simplifies",
"the",
"output",
"of",
"the",
"resulting",
"hierarchy",
"spec"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/hierarchy.go#L15-L27 |
149,520 | vbatts/go-mtree | hierarchy.go | UsedKeywords | func (dh DirectoryHierarchy) UsedKeywords() []Keyword {
usedkeywords := []Keyword{}
for _, e := range dh.Entries {
switch e.Type {
case FullType, RelativeType, SpecialType:
if e.Type != SpecialType || e.Name == "/set" {
kvs := e.Keywords
for _, kv := range kvs {
kw := KeyVal(kv).Keyword().Prefix()... | go | func (dh DirectoryHierarchy) UsedKeywords() []Keyword {
usedkeywords := []Keyword{}
for _, e := range dh.Entries {
switch e.Type {
case FullType, RelativeType, SpecialType:
if e.Type != SpecialType || e.Name == "/set" {
kvs := e.Keywords
for _, kv := range kvs {
kw := KeyVal(kv).Keyword().Prefix()... | [
"func",
"(",
"dh",
"DirectoryHierarchy",
")",
"UsedKeywords",
"(",
")",
"[",
"]",
"Keyword",
"{",
"usedkeywords",
":=",
"[",
"]",
"Keyword",
"{",
"}",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"dh",
".",
"Entries",
"{",
"switch",
"e",
".",
"Type",
... | // UsedKeywords collects and returns all the keywords used in a
// a DirectoryHierarchy | [
"UsedKeywords",
"collects",
"and",
"returns",
"all",
"the",
"keywords",
"used",
"in",
"a",
"a",
"DirectoryHierarchy"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/hierarchy.go#L31-L48 |
149,521 | vbatts/go-mtree | tar.go | NewTarStreamer | func NewTarStreamer(r io.Reader, excludes []ExcludeFunc, keywords []Keyword) Streamer {
pR, pW := io.Pipe()
ts := &tarStream{
pipeReader: pR,
pipeWriter: pW,
creator: dhCreator{DH: &DirectoryHierarchy{}},
teeReader: io.TeeReader(r, pW),
tarReader: tar.NewReader(pR),
keywords: keywords,
hardlinks:... | go | func NewTarStreamer(r io.Reader, excludes []ExcludeFunc, keywords []Keyword) Streamer {
pR, pW := io.Pipe()
ts := &tarStream{
pipeReader: pR,
pipeWriter: pW,
creator: dhCreator{DH: &DirectoryHierarchy{}},
teeReader: io.TeeReader(r, pW),
tarReader: tar.NewReader(pR),
keywords: keywords,
hardlinks:... | [
"func",
"NewTarStreamer",
"(",
"r",
"io",
".",
"Reader",
",",
"excludes",
"[",
"]",
"ExcludeFunc",
",",
"keywords",
"[",
"]",
"Keyword",
")",
"Streamer",
"{",
"pR",
",",
"pW",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"ts",
":=",
"&",
"tarStream",
"... | // NewTarStreamer streams a tar archive and creates a file hierarchy based off
// of the tar metadata headers | [
"NewTarStreamer",
"streams",
"a",
"tar",
"archive",
"and",
"creates",
"a",
"file",
"hierarchy",
"based",
"off",
"of",
"the",
"tar",
"metadata",
"headers"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/tar.go#L30-L45 |
149,522 | vbatts/go-mtree | tar.go | resolveHardlinks | func resolveHardlinks(root *Entry, hardlinks map[string][]string, countlinks bool) {
originals := make(map[string]*Entry)
for base, links := range hardlinks {
var basefile *Entry
if seen, ok := originals[base]; !ok {
basefile = root.Find(base)
if basefile == nil {
logrus.Printf("%s does not exist in thi... | go | func resolveHardlinks(root *Entry, hardlinks map[string][]string, countlinks bool) {
originals := make(map[string]*Entry)
for base, links := range hardlinks {
var basefile *Entry
if seen, ok := originals[base]; !ok {
basefile = root.Find(base)
if basefile == nil {
logrus.Printf("%s does not exist in thi... | [
"func",
"resolveHardlinks",
"(",
"root",
"*",
"Entry",
",",
"hardlinks",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"countlinks",
"bool",
")",
"{",
"originals",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Entry",
")",
"\n",
"for",
"b... | // resolveHardlinks goes through an Entry tree, and finds the Entry's associated
// with hardlinks and fills them in with the actual data from the base file. | [
"resolveHardlinks",
"goes",
"through",
"an",
"Entry",
"tree",
"and",
"finds",
"the",
"Entry",
"s",
"associated",
"with",
"hardlinks",
"and",
"fills",
"them",
"in",
"with",
"the",
"actual",
"data",
"from",
"the",
"base",
"file",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/tar.go#L381-L410 |
149,523 | vbatts/go-mtree | tar.go | filter | func filter(root *Entry, p func(*Entry) bool) []Entry {
if root != nil {
var validEntrys []Entry
if len(root.Children) > 0 || root.Prev != nil {
for _, c := range root.Children {
// filter the sub-directory
if c.Prev != nil {
validEntrys = append(validEntrys, filter(c, p)...)
}
if p(c) {
... | go | func filter(root *Entry, p func(*Entry) bool) []Entry {
if root != nil {
var validEntrys []Entry
if len(root.Children) > 0 || root.Prev != nil {
for _, c := range root.Children {
// filter the sub-directory
if c.Prev != nil {
validEntrys = append(validEntrys, filter(c, p)...)
}
if p(c) {
... | [
"func",
"filter",
"(",
"root",
"*",
"Entry",
",",
"p",
"func",
"(",
"*",
"Entry",
")",
"bool",
")",
"[",
"]",
"Entry",
"{",
"if",
"root",
"!=",
"nil",
"{",
"var",
"validEntrys",
"[",
"]",
"Entry",
"\n",
"if",
"len",
"(",
"root",
".",
"Children",
... | // filter takes in a pointer to an Entry, and returns a slice of Entry's that
// satisfy the predicate p | [
"filter",
"takes",
"in",
"a",
"pointer",
"to",
"an",
"Entry",
"and",
"returns",
"a",
"slice",
"of",
"Entry",
"s",
"that",
"satisfy",
"the",
"predicate",
"p"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/tar.go#L414-L435 |
149,524 | vbatts/go-mtree | tar.go | Hierarchy | func (ts *tarStream) Hierarchy() (*DirectoryHierarchy, error) {
if ts.err != nil && ts.err != io.EOF {
return nil, ts.err
}
if ts.root == nil {
return nil, fmt.Errorf("root Entry not found, nothing to flatten")
}
resolveHardlinks(ts.root, ts.hardlinks, InKeywordSlice(Keyword("nlink"), ts.keywords))
flatten(ts... | go | func (ts *tarStream) Hierarchy() (*DirectoryHierarchy, error) {
if ts.err != nil && ts.err != io.EOF {
return nil, ts.err
}
if ts.root == nil {
return nil, fmt.Errorf("root Entry not found, nothing to flatten")
}
resolveHardlinks(ts.root, ts.hardlinks, InKeywordSlice(Keyword("nlink"), ts.keywords))
flatten(ts... | [
"func",
"(",
"ts",
"*",
"tarStream",
")",
"Hierarchy",
"(",
")",
"(",
"*",
"DirectoryHierarchy",
",",
"error",
")",
"{",
"if",
"ts",
".",
"err",
"!=",
"nil",
"&&",
"ts",
".",
"err",
"!=",
"io",
".",
"EOF",
"{",
"return",
"nil",
",",
"ts",
".",
... | // Hierarchy returns the DirectoryHierarchy of the archive. It flattens the
// Entry tree before returning the DirectoryHierarchy | [
"Hierarchy",
"returns",
"the",
"DirectoryHierarchy",
"of",
"the",
"archive",
".",
"It",
"flattens",
"the",
"Entry",
"tree",
"before",
"returning",
"the",
"DirectoryHierarchy"
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/tar.go#L451-L461 |
149,525 | vbatts/go-mtree | fseval.go | Open | func (fs DefaultFsEval) Open(path string) (*os.File, error) {
return os.Open(path)
} | go | func (fs DefaultFsEval) Open(path string) (*os.File, error) {
return os.Open(path)
} | [
"func",
"(",
"fs",
"DefaultFsEval",
")",
"Open",
"(",
"path",
"string",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"return",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"}"
] | // Open must have the same semantics as os.Open. | [
"Open",
"must",
"have",
"the",
"same",
"semantics",
"as",
"os",
".",
"Open",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/fseval.go#L30-L32 |
149,526 | vbatts/go-mtree | fseval.go | Lstat | func (fs DefaultFsEval) Lstat(path string) (os.FileInfo, error) {
return os.Lstat(path)
} | go | func (fs DefaultFsEval) Lstat(path string) (os.FileInfo, error) {
return os.Lstat(path)
} | [
"func",
"(",
"fs",
"DefaultFsEval",
")",
"Lstat",
"(",
"path",
"string",
")",
"(",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"return",
"os",
".",
"Lstat",
"(",
"path",
")",
"\n",
"}"
] | // Lstat must have the same semantics as os.Lstat. | [
"Lstat",
"must",
"have",
"the",
"same",
"semantics",
"as",
"os",
".",
"Lstat",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/fseval.go#L35-L37 |
149,527 | vbatts/go-mtree | pkg/govis/vis.go | ishttp | func ishttp(ch rune) bool {
// RFC1808 does not really consider characters outside of ASCII, so just to
// be safe always treat characters outside the ASCII character set as "not
// HTTP".
if ch > unicode.MaxASCII {
return false
}
return unicode.IsDigit(ch) || unicode.IsLetter(ch) ||
// Safe characters.
ch... | go | func ishttp(ch rune) bool {
// RFC1808 does not really consider characters outside of ASCII, so just to
// be safe always treat characters outside the ASCII character set as "not
// HTTP".
if ch > unicode.MaxASCII {
return false
}
return unicode.IsDigit(ch) || unicode.IsLetter(ch) ||
// Safe characters.
ch... | [
"func",
"ishttp",
"(",
"ch",
"rune",
")",
"bool",
"{",
"// RFC1808 does not really consider characters outside of ASCII, so just to",
"// be safe always treat characters outside the ASCII character set as \"not",
"// HTTP\".",
"if",
"ch",
">",
"unicode",
".",
"MaxASCII",
"{",
"re... | // ishttp is defined by RFC 1808. | [
"ishttp",
"is",
"defined",
"by",
"RFC",
"1808",
"."
] | 8b6de6073c1a0c205934283ceefc5396b96a071e | https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/pkg/govis/vis.go#L34-L48 |
149,528 | tg/gosortmap | sortmap.go | Top | func (r Items) Top(n int) Items {
if n > len(r) {
n = len(r)
}
return r[:n]
} | go | func (r Items) Top(n int) Items {
if n > len(r) {
n = len(r)
}
return r[:n]
} | [
"func",
"(",
"r",
"Items",
")",
"Top",
"(",
"n",
"int",
")",
"Items",
"{",
"if",
"n",
">",
"len",
"(",
"r",
")",
"{",
"n",
"=",
"len",
"(",
"r",
")",
"\n",
"}",
"\n",
"return",
"r",
"[",
":",
"n",
"]",
"\n",
"}"
] | // Top returns slice of up to n leading elements | [
"Top",
"returns",
"slice",
"of",
"up",
"to",
"n",
"leading",
"elements"
] | 4b9ddc7c3a61652b569b7cc4368bbcde539392ce | https://github.com/tg/gosortmap/blob/4b9ddc7c3a61652b569b7cc4368bbcde539392ce/sortmap.go#L55-L60 |
149,529 | tg/gosortmap | sortmap.go | ByFunc | func ByFunc(m interface{}, c Less) Items {
fm := newFlatMap(m, c)
sort.Sort(fm)
return fm.items
} | go | func ByFunc(m interface{}, c Less) Items {
fm := newFlatMap(m, c)
sort.Sort(fm)
return fm.items
} | [
"func",
"ByFunc",
"(",
"m",
"interface",
"{",
"}",
",",
"c",
"Less",
")",
"Items",
"{",
"fm",
":=",
"newFlatMap",
"(",
"m",
",",
"c",
")",
"\n",
"sort",
".",
"Sort",
"(",
"fm",
")",
"\n",
"return",
"fm",
".",
"items",
"\n",
"}"
] | // ByFunc sorts map using a provided comparator | [
"ByFunc",
"sorts",
"map",
"using",
"a",
"provided",
"comparator"
] | 4b9ddc7c3a61652b569b7cc4368bbcde539392ce | https://github.com/tg/gosortmap/blob/4b9ddc7c3a61652b569b7cc4368bbcde539392ce/sortmap.go#L63-L67 |
149,530 | tg/gosortmap | sortmap.go | ByKey | func ByKey(m interface{}) Items {
ls := getLess(reflect.ValueOf(m).Type().Key())
return ByFunc(m, func(x, y Item) bool { return ls(x.Key, y.Key) })
} | go | func ByKey(m interface{}) Items {
ls := getLess(reflect.ValueOf(m).Type().Key())
return ByFunc(m, func(x, y Item) bool { return ls(x.Key, y.Key) })
} | [
"func",
"ByKey",
"(",
"m",
"interface",
"{",
"}",
")",
"Items",
"{",
"ls",
":=",
"getLess",
"(",
"reflect",
".",
"ValueOf",
"(",
"m",
")",
".",
"Type",
"(",
")",
".",
"Key",
"(",
")",
")",
"\n",
"return",
"ByFunc",
"(",
"m",
",",
"func",
"(",
... | // ByKey sorts map by keys in the ascending order | [
"ByKey",
"sorts",
"map",
"by",
"keys",
"in",
"the",
"ascending",
"order"
] | 4b9ddc7c3a61652b569b7cc4368bbcde539392ce | https://github.com/tg/gosortmap/blob/4b9ddc7c3a61652b569b7cc4368bbcde539392ce/sortmap.go#L70-L73 |
149,531 | tg/gosortmap | sortmap.go | ByValue | func ByValue(m interface{}) Items {
ls := getLess(reflect.ValueOf(m).Type().Elem())
return ByFunc(m, func(x, y Item) bool { return ls(x.Value, y.Value) })
} | go | func ByValue(m interface{}) Items {
ls := getLess(reflect.ValueOf(m).Type().Elem())
return ByFunc(m, func(x, y Item) bool { return ls(x.Value, y.Value) })
} | [
"func",
"ByValue",
"(",
"m",
"interface",
"{",
"}",
")",
"Items",
"{",
"ls",
":=",
"getLess",
"(",
"reflect",
".",
"ValueOf",
"(",
"m",
")",
".",
"Type",
"(",
")",
".",
"Elem",
"(",
")",
")",
"\n",
"return",
"ByFunc",
"(",
"m",
",",
"func",
"("... | // ByValue sorts map by values in the ascending order | [
"ByValue",
"sorts",
"map",
"by",
"values",
"in",
"the",
"ascending",
"order"
] | 4b9ddc7c3a61652b569b7cc4368bbcde539392ce | https://github.com/tg/gosortmap/blob/4b9ddc7c3a61652b569b7cc4368bbcde539392ce/sortmap.go#L82-L85 |
149,532 | AlekSi/zabbix | base.go | Call | func (api *API) Call(method string, params interface{}) (response Response, err error) {
b, err := api.callBytes(method, params)
if err == nil {
err = json.Unmarshal(b, &response)
}
return
} | go | func (api *API) Call(method string, params interface{}) (response Response, err error) {
b, err := api.callBytes(method, params)
if err == nil {
err = json.Unmarshal(b, &response)
}
return
} | [
"func",
"(",
"api",
"*",
"API",
")",
"Call",
"(",
"method",
"string",
",",
"params",
"interface",
"{",
"}",
")",
"(",
"response",
"Response",
",",
"err",
"error",
")",
"{",
"b",
",",
"err",
":=",
"api",
".",
"callBytes",
"(",
"method",
",",
"params... | // Calls specified API method. Uses api.Auth if not empty.
// err is something network or marshaling related. Caller should inspect response.Error to get API error. | [
"Calls",
"specified",
"API",
"method",
".",
"Uses",
"api",
".",
"Auth",
"if",
"not",
"empty",
".",
"err",
"is",
"something",
"network",
"or",
"marshaling",
"related",
".",
"Caller",
"should",
"inspect",
"response",
".",
"Error",
"to",
"get",
"API",
"error"... | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/base.go#L115-L121 |
149,533 | AlekSi/zabbix | base.go | Login | func (api *API) Login(user, password string) (auth string, err error) {
params := map[string]string{"user": user, "password": password}
response, err := api.CallWithError("user.login", params)
if err != nil {
return
}
auth = response.Result.(string)
api.Auth = auth
return
} | go | func (api *API) Login(user, password string) (auth string, err error) {
params := map[string]string{"user": user, "password": password}
response, err := api.CallWithError("user.login", params)
if err != nil {
return
}
auth = response.Result.(string)
api.Auth = auth
return
} | [
"func",
"(",
"api",
"*",
"API",
")",
"Login",
"(",
"user",
",",
"password",
"string",
")",
"(",
"auth",
"string",
",",
"err",
"error",
")",
"{",
"params",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"user",
",",
"\"",
"\"",
... | // Calls "user.login" API method and fills api.Auth field.
// This method modifies API structure and should not be called concurrently with other methods. | [
"Calls",
"user",
".",
"login",
"API",
"method",
"and",
"fills",
"api",
".",
"Auth",
"field",
".",
"This",
"method",
"modifies",
"API",
"structure",
"and",
"should",
"not",
"be",
"called",
"concurrently",
"with",
"other",
"methods",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/base.go#L134-L144 |
149,534 | AlekSi/zabbix | base.go | Version | func (api *API) Version() (v string, err error) {
// temporary remove auth for this method to succeed
// https://www.zabbix.com/documentation/2.2/manual/appendix/api/apiinfo/version
auth := api.Auth
api.Auth = ""
response, err := api.CallWithError("APIInfo.version", Params{})
api.Auth = auth
// despite what doc... | go | func (api *API) Version() (v string, err error) {
// temporary remove auth for this method to succeed
// https://www.zabbix.com/documentation/2.2/manual/appendix/api/apiinfo/version
auth := api.Auth
api.Auth = ""
response, err := api.CallWithError("APIInfo.version", Params{})
api.Auth = auth
// despite what doc... | [
"func",
"(",
"api",
"*",
"API",
")",
"Version",
"(",
")",
"(",
"v",
"string",
",",
"err",
"error",
")",
"{",
"// temporary remove auth for this method to succeed",
"// https://www.zabbix.com/documentation/2.2/manual/appendix/api/apiinfo/version",
"auth",
":=",
"api",
".",... | // Calls "APIInfo.version" API method.
// This method temporary modifies API structure and should not be called concurrently with other methods. | [
"Calls",
"APIInfo",
".",
"version",
"API",
"method",
".",
"This",
"method",
"temporary",
"modifies",
"API",
"structure",
"and",
"should",
"not",
"be",
"called",
"concurrently",
"with",
"other",
"methods",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/base.go#L148-L166 |
149,535 | AlekSi/zabbix | host_group.go | HostGroupGetById | func (api *API) HostGroupGetById(id string) (res *HostGroup, err error) {
groups, err := api.HostGroupsGet(Params{"groupids": id})
if err != nil {
return
}
if len(groups) == 1 {
res = &groups[0]
} else {
e := ExpectedOneResult(len(groups))
err = &e
}
return
} | go | func (api *API) HostGroupGetById(id string) (res *HostGroup, err error) {
groups, err := api.HostGroupsGet(Params{"groupids": id})
if err != nil {
return
}
if len(groups) == 1 {
res = &groups[0]
} else {
e := ExpectedOneResult(len(groups))
err = &e
}
return
} | [
"func",
"(",
"api",
"*",
"API",
")",
"HostGroupGetById",
"(",
"id",
"string",
")",
"(",
"res",
"*",
"HostGroup",
",",
"err",
"error",
")",
"{",
"groups",
",",
"err",
":=",
"api",
".",
"HostGroupsGet",
"(",
"Params",
"{",
"\"",
"\"",
":",
"id",
"}",... | // Gets host group by Id only if there is exactly 1 matching host group. | [
"Gets",
"host",
"group",
"by",
"Id",
"only",
"if",
"there",
"is",
"exactly",
"1",
"matching",
"host",
"group",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/host_group.go#L46-L59 |
149,536 | AlekSi/zabbix | item.go | ByKey | func (items Items) ByKey() (res map[string]Item) {
res = make(map[string]Item, len(items))
for _, i := range items {
_, present := res[i.Key]
if present {
panic(fmt.Errorf("Duplicate key %s", i.Key))
}
res[i.Key] = i
}
return
} | go | func (items Items) ByKey() (res map[string]Item) {
res = make(map[string]Item, len(items))
for _, i := range items {
_, present := res[i.Key]
if present {
panic(fmt.Errorf("Duplicate key %s", i.Key))
}
res[i.Key] = i
}
return
} | [
"func",
"(",
"items",
"Items",
")",
"ByKey",
"(",
")",
"(",
"res",
"map",
"[",
"string",
"]",
"Item",
")",
"{",
"res",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"Item",
",",
"len",
"(",
"items",
")",
")",
"\n",
"for",
"_",
",",
"i",
":=",
... | // Converts slice to map by key. Panics if there are duplicate keys. | [
"Converts",
"slice",
"to",
"map",
"by",
"key",
".",
"Panics",
"if",
"there",
"are",
"duplicate",
"keys",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/item.go#L74-L84 |
149,537 | AlekSi/zabbix | item.go | ItemsGetByApplicationId | func (api *API) ItemsGetByApplicationId(id string) (res Items, err error) {
return api.ItemsGet(Params{"applicationids": id})
} | go | func (api *API) ItemsGetByApplicationId(id string) (res Items, err error) {
return api.ItemsGet(Params{"applicationids": id})
} | [
"func",
"(",
"api",
"*",
"API",
")",
"ItemsGetByApplicationId",
"(",
"id",
"string",
")",
"(",
"res",
"Items",
",",
"err",
"error",
")",
"{",
"return",
"api",
".",
"ItemsGet",
"(",
"Params",
"{",
"\"",
"\"",
":",
"id",
"}",
")",
"\n",
"}"
] | // Gets items by application Id. | [
"Gets",
"items",
"by",
"application",
"Id",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/item.go#L101-L103 |
149,538 | AlekSi/zabbix | application.go | ApplicationGetById | func (api *API) ApplicationGetById(id string) (res *Application, err error) {
apps, err := api.ApplicationsGet(Params{"applicationids": id})
if err != nil {
return
}
if len(apps) == 1 {
res = &apps[0]
} else {
e := ExpectedOneResult(len(apps))
err = &e
}
return
} | go | func (api *API) ApplicationGetById(id string) (res *Application, err error) {
apps, err := api.ApplicationsGet(Params{"applicationids": id})
if err != nil {
return
}
if len(apps) == 1 {
res = &apps[0]
} else {
e := ExpectedOneResult(len(apps))
err = &e
}
return
} | [
"func",
"(",
"api",
"*",
"API",
")",
"ApplicationGetById",
"(",
"id",
"string",
")",
"(",
"res",
"*",
"Application",
",",
"err",
"error",
")",
"{",
"apps",
",",
"err",
":=",
"api",
".",
"ApplicationsGet",
"(",
"Params",
"{",
"\"",
"\"",
":",
"id",
... | // Gets application by Id only if there is exactly 1 matching application. | [
"Gets",
"application",
"by",
"Id",
"only",
"if",
"there",
"is",
"exactly",
"1",
"matching",
"application",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/application.go#L32-L45 |
149,539 | AlekSi/zabbix | application.go | ApplicationGetByHostIdAndName | func (api *API) ApplicationGetByHostIdAndName(hostId, name string) (res *Application, err error) {
apps, err := api.ApplicationsGet(Params{"hostids": hostId, "filter": map[string]string{"name": name}})
if err != nil {
return
}
if len(apps) == 1 {
res = &apps[0]
} else {
e := ExpectedOneResult(len(apps))
e... | go | func (api *API) ApplicationGetByHostIdAndName(hostId, name string) (res *Application, err error) {
apps, err := api.ApplicationsGet(Params{"hostids": hostId, "filter": map[string]string{"name": name}})
if err != nil {
return
}
if len(apps) == 1 {
res = &apps[0]
} else {
e := ExpectedOneResult(len(apps))
e... | [
"func",
"(",
"api",
"*",
"API",
")",
"ApplicationGetByHostIdAndName",
"(",
"hostId",
",",
"name",
"string",
")",
"(",
"res",
"*",
"Application",
",",
"err",
"error",
")",
"{",
"apps",
",",
"err",
":=",
"api",
".",
"ApplicationsGet",
"(",
"Params",
"{",
... | // Gets application by host Id and name only if there is exactly 1 matching application. | [
"Gets",
"application",
"by",
"host",
"Id",
"and",
"name",
"only",
"if",
"there",
"is",
"exactly",
"1",
"matching",
"application",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/application.go#L48-L61 |
149,540 | AlekSi/zabbix | host.go | HostsGetByHostGroupIds | func (api *API) HostsGetByHostGroupIds(ids []string) (res Hosts, err error) {
return api.HostsGet(Params{"groupids": ids})
} | go | func (api *API) HostsGetByHostGroupIds(ids []string) (res Hosts, err error) {
return api.HostsGet(Params{"groupids": ids})
} | [
"func",
"(",
"api",
"*",
"API",
")",
"HostsGetByHostGroupIds",
"(",
"ids",
"[",
"]",
"string",
")",
"(",
"res",
"Hosts",
",",
"err",
"error",
")",
"{",
"return",
"api",
".",
"HostsGet",
"(",
"Params",
"{",
"\"",
"\"",
":",
"ids",
"}",
")",
"\n",
... | // Gets hosts by host group Ids. | [
"Gets",
"hosts",
"by",
"host",
"group",
"Ids",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/host.go#L51-L53 |
149,541 | AlekSi/zabbix | host.go | HostsGetByHostGroups | func (api *API) HostsGetByHostGroups(hostGroups HostGroups) (res Hosts, err error) {
ids := make([]string, len(hostGroups))
for i, id := range hostGroups {
ids[i] = id.GroupId
}
return api.HostsGetByHostGroupIds(ids)
} | go | func (api *API) HostsGetByHostGroups(hostGroups HostGroups) (res Hosts, err error) {
ids := make([]string, len(hostGroups))
for i, id := range hostGroups {
ids[i] = id.GroupId
}
return api.HostsGetByHostGroupIds(ids)
} | [
"func",
"(",
"api",
"*",
"API",
")",
"HostsGetByHostGroups",
"(",
"hostGroups",
"HostGroups",
")",
"(",
"res",
"Hosts",
",",
"err",
"error",
")",
"{",
"ids",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"hostGroups",
")",
")",
"\n",
"for",... | // Gets hosts by host groups. | [
"Gets",
"hosts",
"by",
"host",
"groups",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/host.go#L56-L62 |
149,542 | AlekSi/zabbix | host.go | HostGetById | func (api *API) HostGetById(id string) (res *Host, err error) {
hosts, err := api.HostsGet(Params{"hostids": id})
if err != nil {
return
}
if len(hosts) == 1 {
res = &hosts[0]
} else {
e := ExpectedOneResult(len(hosts))
err = &e
}
return
} | go | func (api *API) HostGetById(id string) (res *Host, err error) {
hosts, err := api.HostsGet(Params{"hostids": id})
if err != nil {
return
}
if len(hosts) == 1 {
res = &hosts[0]
} else {
e := ExpectedOneResult(len(hosts))
err = &e
}
return
} | [
"func",
"(",
"api",
"*",
"API",
")",
"HostGetById",
"(",
"id",
"string",
")",
"(",
"res",
"*",
"Host",
",",
"err",
"error",
")",
"{",
"hosts",
",",
"err",
":=",
"api",
".",
"HostsGet",
"(",
"Params",
"{",
"\"",
"\"",
":",
"id",
"}",
")",
"\n",
... | // Gets host by Id only if there is exactly 1 matching host. | [
"Gets",
"host",
"by",
"Id",
"only",
"if",
"there",
"is",
"exactly",
"1",
"matching",
"host",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/host.go#L65-L78 |
149,543 | AlekSi/zabbix | host.go | HostGetByHost | func (api *API) HostGetByHost(host string) (res *Host, err error) {
hosts, err := api.HostsGet(Params{"filter": map[string]string{"host": host}})
if err != nil {
return
}
if len(hosts) == 1 {
res = &hosts[0]
} else {
e := ExpectedOneResult(len(hosts))
err = &e
}
return
} | go | func (api *API) HostGetByHost(host string) (res *Host, err error) {
hosts, err := api.HostsGet(Params{"filter": map[string]string{"host": host}})
if err != nil {
return
}
if len(hosts) == 1 {
res = &hosts[0]
} else {
e := ExpectedOneResult(len(hosts))
err = &e
}
return
} | [
"func",
"(",
"api",
"*",
"API",
")",
"HostGetByHost",
"(",
"host",
"string",
")",
"(",
"res",
"*",
"Host",
",",
"err",
"error",
")",
"{",
"hosts",
",",
"err",
":=",
"api",
".",
"HostsGet",
"(",
"Params",
"{",
"\"",
"\"",
":",
"map",
"[",
"string"... | // Gets host by Host only if there is exactly 1 matching host. | [
"Gets",
"host",
"by",
"Host",
"only",
"if",
"there",
"is",
"exactly",
"1",
"matching",
"host",
"."
] | 332cdfbc6302d68be9d50bd7423f1fc9fcfe21de | https://github.com/AlekSi/zabbix/blob/332cdfbc6302d68be9d50bd7423f1fc9fcfe21de/host.go#L81-L94 |
149,544 | cathalgarvey/fmtless | encoding/xml/xml.go | ungetc | func (d *Decoder) ungetc(b byte) {
if b == '\n' {
d.line--
}
d.nextByte = int(b)
d.offset--
} | go | func (d *Decoder) ungetc(b byte) {
if b == '\n' {
d.line--
}
d.nextByte = int(b)
d.offset--
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"ungetc",
"(",
"b",
"byte",
")",
"{",
"if",
"b",
"==",
"'\\n'",
"{",
"d",
".",
"line",
"--",
"\n",
"}",
"\n",
"d",
".",
"nextByte",
"=",
"int",
"(",
"b",
")",
"\n",
"d",
".",
"offset",
"--",
"\n",
"}"
... | // Unread a single byte. | [
"Unread",
"a",
"single",
"byte",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/encoding/xml/xml.go#L917-L923 |
149,545 | cathalgarvey/fmtless | encoding/xml/xml.go | EscapeText | func EscapeText(w io.Writer, s []byte) error {
return escapeText(w, s, true)
} | go | func EscapeText(w io.Writer, s []byte) error {
return escapeText(w, s, true)
} | [
"func",
"EscapeText",
"(",
"w",
"io",
".",
"Writer",
",",
"s",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"escapeText",
"(",
"w",
",",
"s",
",",
"true",
")",
"\n",
"}"
] | // EscapeText writes to w the properly escaped XML equivalent
// of the plain text data s. | [
"EscapeText",
"writes",
"to",
"w",
"the",
"properly",
"escaped",
"XML",
"equivalent",
"of",
"the",
"plain",
"text",
"data",
"s",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/encoding/xml/xml.go#L1853-L1855 |
149,546 | cathalgarvey/fmtless | encoding/xml/xml.go | emitCDATA | func emitCDATA(w io.Writer, s []byte) error {
if len(s) == 0 {
return nil
}
if _, err := w.Write(cdataStart); err != nil {
return err
}
for {
i := bytes.Index(s, cdataEnd)
if i >= 0 && i+len(cdataEnd) <= len(s) {
// Found a nested CDATA directive end.
if _, err := w.Write(s[:i]); err != nil {
ret... | go | func emitCDATA(w io.Writer, s []byte) error {
if len(s) == 0 {
return nil
}
if _, err := w.Write(cdataStart); err != nil {
return err
}
for {
i := bytes.Index(s, cdataEnd)
if i >= 0 && i+len(cdataEnd) <= len(s) {
// Found a nested CDATA directive end.
if _, err := w.Write(s[:i]); err != nil {
ret... | [
"func",
"emitCDATA",
"(",
"w",
"io",
".",
"Writer",
",",
"s",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"cdataStart"... | // emitCDATA writes to w the CDATA-wrapped plain text data s.
// It escapes CDATA directives nested in s. | [
"emitCDATA",
"writes",
"to",
"w",
"the",
"CDATA",
"-",
"wrapped",
"plain",
"text",
"data",
"s",
".",
"It",
"escapes",
"CDATA",
"directives",
"nested",
"in",
"s",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/encoding/xml/xml.go#L1961-L1991 |
149,547 | cathalgarvey/fmtless | encoding/xml/xml.go | procInst | func procInst(param, s string) string {
// TODO: this parsing is somewhat lame and not exact.
// It works for all actual cases, though.
param = param + "="
idx := strings.Index(s, param)
if idx == -1 {
return ""
}
v := s[idx+len(param):]
if v == "" {
return ""
}
if v[0] != '\'' && v[0] != '"' {
return "... | go | func procInst(param, s string) string {
// TODO: this parsing is somewhat lame and not exact.
// It works for all actual cases, though.
param = param + "="
idx := strings.Index(s, param)
if idx == -1 {
return ""
}
v := s[idx+len(param):]
if v == "" {
return ""
}
if v[0] != '\'' && v[0] != '"' {
return "... | [
"func",
"procInst",
"(",
"param",
",",
"s",
"string",
")",
"string",
"{",
"// TODO: this parsing is somewhat lame and not exact.",
"// It works for all actual cases, though.",
"param",
"=",
"param",
"+",
"\"",
"\"",
"\n",
"idx",
":=",
"strings",
".",
"Index",
"(",
"... | // procInst parses the `param="..."` or `param='...'`
// value out of the provided string, returning "" if not found. | [
"procInst",
"parses",
"the",
"param",
"=",
"...",
"or",
"param",
"=",
"...",
"value",
"out",
"of",
"the",
"provided",
"string",
"returning",
"if",
"not",
"found",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/encoding/xml/xml.go#L1995-L2015 |
149,548 | cathalgarvey/fmtless | fmtshim.go | Printf | func Printf(format string, a ...interface{}) (n int, err error) {
out := Sprintf(format, a...)
print(out)
return len([]byte(out)), nil
} | go | func Printf(format string, a ...interface{}) (n int, err error) {
out := Sprintf(format, a...)
print(out)
return len([]byte(out)), nil
} | [
"func",
"Printf",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"out",
":=",
"Sprintf",
"(",
"format",
",",
"a",
"...",
")",
"\n",
"print",
"(",
"out",
")",
"\n",
"return",
... | // Printf prints a format string filled with the given values. | [
"Printf",
"prints",
"a",
"format",
"string",
"filled",
"with",
"the",
"given",
"values",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/fmtshim.go#L16-L20 |
149,549 | cathalgarvey/fmtless | fmtshim.go | Println | func Println(a ...interface{}) (n int, err error) {
out := Sprint(a...)
println(out)
return len([]byte(out)), nil
} | go | func Println(a ...interface{}) (n int, err error) {
out := Sprint(a...)
println(out)
return len([]byte(out)), nil
} | [
"func",
"Println",
"(",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"out",
":=",
"Sprint",
"(",
"a",
"...",
")",
"\n",
"println",
"(",
"out",
")",
"\n",
"return",
"len",
"(",
"[",
"]",
"byte",
"(",
... | // Println formats using the default formats for its
// operands and writes to standard output. Spaces are
// always added between operands and a newline is appended.
// It returns the number of bytes written and any write
// error encountered. | [
"Println",
"formats",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"and",
"writes",
"to",
"standard",
"output",
".",
"Spaces",
"are",
"always",
"added",
"between",
"operands",
"and",
"a",
"newline",
"is",
"appended",
".",
"It",
"returns",
... | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/fmtshim.go#L27-L31 |
149,550 | cathalgarvey/fmtless | fmtshim.go | Print | func Print(a ...interface{}) (n int, err error) {
out := Sprint(a...)
print(out)
return len([]byte(out)), nil
} | go | func Print(a ...interface{}) (n int, err error) {
out := Sprint(a...)
print(out)
return len([]byte(out)), nil
} | [
"func",
"Print",
"(",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"out",
":=",
"Sprint",
"(",
"a",
"...",
")",
"\n",
"print",
"(",
"out",
")",
"\n",
"return",
"len",
"(",
"[",
"]",
"byte",
"(",
"out... | // Print formats using the default formats for its
// operands and writes to standard output. Spaces
// are added between operands when neither is a string.
// It returns the number of bytes written and any
// write error encountered. | [
"Print",
"formats",
"using",
"the",
"default",
"formats",
"for",
"its",
"operands",
"and",
"writes",
"to",
"standard",
"output",
".",
"Spaces",
"are",
"added",
"between",
"operands",
"when",
"neither",
"is",
"a",
"string",
".",
"It",
"returns",
"the",
"numbe... | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/fmtshim.go#L38-L42 |
149,551 | cathalgarvey/fmtless | fmtshim.go | Sprintf | func Sprintf(fmts string, args ...interface{}) string {
var bits []string
fmlist := splitFmtSpecs(fmts)
for idx, sm := range fmlist {
var i interface{}
i = nil
if idx < len(args) {
i = args[idx]
}
bits = append(bits, sm.render(i))
}
return strings.Join(bits, "")
} | go | func Sprintf(fmts string, args ...interface{}) string {
var bits []string
fmlist := splitFmtSpecs(fmts)
for idx, sm := range fmlist {
var i interface{}
i = nil
if idx < len(args) {
i = args[idx]
}
bits = append(bits, sm.render(i))
}
return strings.Join(bits, "")
} | [
"func",
"Sprintf",
"(",
"fmts",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"string",
"{",
"var",
"bits",
"[",
"]",
"string",
"\n",
"fmlist",
":=",
"splitFmtSpecs",
"(",
"fmts",
")",
"\n",
"for",
"idx",
",",
"sm",
":=",
"range",
"fmlist... | // Sprintf is a fmtless alternative to fmt.Sprintf that supports some of
// the most common subset of fmt usage. | [
"Sprintf",
"is",
"a",
"fmtless",
"alternative",
"to",
"fmt",
".",
"Sprintf",
"that",
"supports",
"some",
"of",
"the",
"most",
"common",
"subset",
"of",
"fmt",
"usage",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/fmtshim.go#L56-L68 |
149,552 | cathalgarvey/fmtless | net/url/url.go | Password | func (u *Userinfo) Password() (string, bool) {
if u.passwordSet {
return u.password, true
}
return "", false
} | go | func (u *Userinfo) Password() (string, bool) {
if u.passwordSet {
return u.password, true
}
return "", false
} | [
"func",
"(",
"u",
"*",
"Userinfo",
")",
"Password",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"u",
".",
"passwordSet",
"{",
"return",
"u",
".",
"password",
",",
"true",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}"
] | // Password returns the password in case it is set, and whether it is set. | [
"Password",
"returns",
"the",
"password",
"in",
"case",
"it",
"is",
"set",
"and",
"whether",
"it",
"is",
"set",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L354-L359 |
149,553 | cathalgarvey/fmtless | net/url/url.go | parse | func parse(rawurl string, viaRequest bool) (url *URL, err error) {
var rest string
if rawurl == "" && viaRequest {
err = errors.New("empty url")
goto Error
}
url = new(URL)
if rawurl == "*" {
url.Path = "*"
return
}
// Split off possible leading "http:", "mailto:", etc.
// Cannot contain escaped char... | go | func parse(rawurl string, viaRequest bool) (url *URL, err error) {
var rest string
if rawurl == "" && viaRequest {
err = errors.New("empty url")
goto Error
}
url = new(URL)
if rawurl == "*" {
url.Path = "*"
return
}
// Split off possible leading "http:", "mailto:", etc.
// Cannot contain escaped char... | [
"func",
"parse",
"(",
"rawurl",
"string",
",",
"viaRequest",
"bool",
")",
"(",
"url",
"*",
"URL",
",",
"err",
"error",
")",
"{",
"var",
"rest",
"string",
"\n\n",
"if",
"rawurl",
"==",
"\"",
"\"",
"&&",
"viaRequest",
"{",
"err",
"=",
"errors",
".",
... | // parse parses a URL from a string in one of two contexts. If
// viaRequest is true, the URL is assumed to have arrived via an HTTP request,
// in which case only absolute URLs or path-absolute relative URLs are allowed.
// If viaRequest is false, all forms of relative URLs are allowed. | [
"parse",
"parses",
"a",
"URL",
"from",
"a",
"string",
"in",
"one",
"of",
"two",
"contexts",
".",
"If",
"viaRequest",
"is",
"true",
"the",
"URL",
"is",
"assumed",
"to",
"have",
"arrived",
"via",
"an",
"HTTP",
"request",
"in",
"which",
"case",
"only",
"a... | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L442-L499 |
149,554 | cathalgarvey/fmtless | net/url/url.go | EscapedPath | func (u *URL) EscapedPath() string {
if u.RawPath != "" && validEncodedPath(u.RawPath) {
p, err := unescape(u.RawPath, encodePath)
if err == nil && p == u.Path {
return u.RawPath
}
}
if u.Path == "*" {
return "*" // don't escape (Issue 11202)
}
return escape(u.Path, encodePath)
} | go | func (u *URL) EscapedPath() string {
if u.RawPath != "" && validEncodedPath(u.RawPath) {
p, err := unescape(u.RawPath, encodePath)
if err == nil && p == u.Path {
return u.RawPath
}
}
if u.Path == "*" {
return "*" // don't escape (Issue 11202)
}
return escape(u.Path, encodePath)
} | [
"func",
"(",
"u",
"*",
"URL",
")",
"EscapedPath",
"(",
")",
"string",
"{",
"if",
"u",
".",
"RawPath",
"!=",
"\"",
"\"",
"&&",
"validEncodedPath",
"(",
"u",
".",
"RawPath",
")",
"{",
"p",
",",
"err",
":=",
"unescape",
"(",
"u",
".",
"RawPath",
","... | // EscapedPath returns the escaped form of u.Path.
// In general there are multiple possible escaped forms of any path.
// EscapedPath returns u.RawPath when it is a valid escaping of u.Path.
// Otherwise EscapedPath ignores u.RawPath and computes an escaped
// form on its own.
// The String and RequestURI methods use ... | [
"EscapedPath",
"returns",
"the",
"escaped",
"form",
"of",
"u",
".",
"Path",
".",
"In",
"general",
"there",
"are",
"multiple",
"possible",
"escaped",
"forms",
"of",
"any",
"path",
".",
"EscapedPath",
"returns",
"u",
".",
"RawPath",
"when",
"it",
"is",
"a",
... | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L588-L599 |
149,555 | cathalgarvey/fmtless | net/url/url.go | resolvePath | func resolvePath(base, ref string) string {
var full string
if ref == "" {
full = base
} else if ref[0] != '/' {
i := strings.LastIndex(base, "/")
full = base[:i+1] + ref
} else {
full = ref
}
if full == "" {
return ""
}
var dst []string
src := strings.Split(full, "/")
for _, elem := range src {
s... | go | func resolvePath(base, ref string) string {
var full string
if ref == "" {
full = base
} else if ref[0] != '/' {
i := strings.LastIndex(base, "/")
full = base[:i+1] + ref
} else {
full = ref
}
if full == "" {
return ""
}
var dst []string
src := strings.Split(full, "/")
for _, elem := range src {
s... | [
"func",
"resolvePath",
"(",
"base",
",",
"ref",
"string",
")",
"string",
"{",
"var",
"full",
"string",
"\n",
"if",
"ref",
"==",
"\"",
"\"",
"{",
"full",
"=",
"base",
"\n",
"}",
"else",
"if",
"ref",
"[",
"0",
"]",
"!=",
"'/'",
"{",
"i",
":=",
"s... | // resolvePath applies special path segments from refs and applies
// them to base, per RFC 3986. | [
"resolvePath",
"applies",
"special",
"path",
"segments",
"from",
"refs",
"and",
"applies",
"them",
"to",
"base",
"per",
"RFC",
"3986",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L810-L842 |
149,556 | cathalgarvey/fmtless | net/url/url.go | Parse | func (u *URL) Parse(ref string) (*URL, error) {
refurl, err := Parse(ref)
if err != nil {
return nil, err
}
return u.ResolveReference(refurl), nil
} | go | func (u *URL) Parse(ref string) (*URL, error) {
refurl, err := Parse(ref)
if err != nil {
return nil, err
}
return u.ResolveReference(refurl), nil
} | [
"func",
"(",
"u",
"*",
"URL",
")",
"Parse",
"(",
"ref",
"string",
")",
"(",
"*",
"URL",
",",
"error",
")",
"{",
"refurl",
",",
"err",
":=",
"Parse",
"(",
"ref",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",... | // Parse parses a URL in the context of the receiver. The provided URL
// may be relative or absolute. Parse returns nil, err on parse
// failure, otherwise its return value is the same as ResolveReference. | [
"Parse",
"parses",
"a",
"URL",
"in",
"the",
"context",
"of",
"the",
"receiver",
".",
"The",
"provided",
"URL",
"may",
"be",
"relative",
"or",
"absolute",
".",
"Parse",
"returns",
"nil",
"err",
"on",
"parse",
"failure",
"otherwise",
"its",
"return",
"value"... | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L852-L858 |
149,557 | cathalgarvey/fmtless | net/url/url.go | ResolveReference | func (u *URL) ResolveReference(ref *URL) *URL {
url := *ref
if ref.Scheme == "" {
url.Scheme = u.Scheme
}
if ref.Scheme != "" || ref.Host != "" || ref.User != nil {
// The "absoluteURI" or "net_path" cases.
url.Path = resolvePath(ref.Path, "")
return &url
}
if ref.Opaque != "" {
url.User = nil
url.Hos... | go | func (u *URL) ResolveReference(ref *URL) *URL {
url := *ref
if ref.Scheme == "" {
url.Scheme = u.Scheme
}
if ref.Scheme != "" || ref.Host != "" || ref.User != nil {
// The "absoluteURI" or "net_path" cases.
url.Path = resolvePath(ref.Path, "")
return &url
}
if ref.Opaque != "" {
url.User = nil
url.Hos... | [
"func",
"(",
"u",
"*",
"URL",
")",
"ResolveReference",
"(",
"ref",
"*",
"URL",
")",
"*",
"URL",
"{",
"url",
":=",
"*",
"ref",
"\n",
"if",
"ref",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"url",
".",
"Scheme",
"=",
"u",
".",
"Scheme",
"\n",
"}",
"... | // ResolveReference resolves a URI reference to an absolute URI from
// an absolute base URI, per RFC 3986 Section 5.2. The URI reference
// may be relative or absolute. ResolveReference always returns a new
// URL instance, even if the returned URL is identical to either the
// base or reference. If ref is an absolu... | [
"ResolveReference",
"resolves",
"a",
"URI",
"reference",
"to",
"an",
"absolute",
"URI",
"from",
"an",
"absolute",
"base",
"URI",
"per",
"RFC",
"3986",
"Section",
"5",
".",
"2",
".",
"The",
"URI",
"reference",
"may",
"be",
"relative",
"or",
"absolute",
".",... | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L866-L895 |
149,558 | cathalgarvey/fmtless | net/url/url.go | Query | func (u *URL) Query() Values {
v, _ := ParseQuery(u.RawQuery)
return v
} | go | func (u *URL) Query() Values {
v, _ := ParseQuery(u.RawQuery)
return v
} | [
"func",
"(",
"u",
"*",
"URL",
")",
"Query",
"(",
")",
"Values",
"{",
"v",
",",
"_",
":=",
"ParseQuery",
"(",
"u",
".",
"RawQuery",
")",
"\n",
"return",
"v",
"\n",
"}"
] | // Query parses RawQuery and returns the corresponding values. | [
"Query",
"parses",
"RawQuery",
"and",
"returns",
"the",
"corresponding",
"values",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L898-L901 |
149,559 | cathalgarvey/fmtless | net/url/url.go | RequestURI | func (u *URL) RequestURI() string {
result := u.Opaque
if result == "" {
result = u.EscapedPath()
if result == "" {
result = "/"
}
} else {
if strings.HasPrefix(result, "//") {
result = u.Scheme + ":" + result
}
}
if u.RawQuery != "" {
result += "?" + u.RawQuery
}
return result
} | go | func (u *URL) RequestURI() string {
result := u.Opaque
if result == "" {
result = u.EscapedPath()
if result == "" {
result = "/"
}
} else {
if strings.HasPrefix(result, "//") {
result = u.Scheme + ":" + result
}
}
if u.RawQuery != "" {
result += "?" + u.RawQuery
}
return result
} | [
"func",
"(",
"u",
"*",
"URL",
")",
"RequestURI",
"(",
")",
"string",
"{",
"result",
":=",
"u",
".",
"Opaque",
"\n",
"if",
"result",
"==",
"\"",
"\"",
"{",
"result",
"=",
"u",
".",
"EscapedPath",
"(",
")",
"\n",
"if",
"result",
"==",
"\"",
"\"",
... | // RequestURI returns the encoded path?query or opaque?query
// string that would be used in an HTTP request for u. | [
"RequestURI",
"returns",
"the",
"encoded",
"path?query",
"or",
"opaque?query",
"string",
"that",
"would",
"be",
"used",
"in",
"an",
"HTTP",
"request",
"for",
"u",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/net/url/url.go#L905-L921 |
149,560 | cathalgarvey/fmtless | encoding/xml/marshal.go | isValidDirective | func isValidDirective(dir Directive) bool {
var (
depth int
inquote uint8
incomment bool
)
for i, c := range dir {
switch {
case incomment:
if c == '>' {
if n := 1 + i - len(endComment); n >= 0 && bytes.Equal(dir[n:i+1], endComment) {
incomment = false
}
}
// Just ignore anythin... | go | func isValidDirective(dir Directive) bool {
var (
depth int
inquote uint8
incomment bool
)
for i, c := range dir {
switch {
case incomment:
if c == '>' {
if n := 1 + i - len(endComment); n >= 0 && bytes.Equal(dir[n:i+1], endComment) {
incomment = false
}
}
// Just ignore anythin... | [
"func",
"isValidDirective",
"(",
"dir",
"Directive",
")",
"bool",
"{",
"var",
"(",
"depth",
"int",
"\n",
"inquote",
"uint8",
"\n",
"incomment",
"bool",
"\n",
")",
"\n",
"for",
"i",
",",
"c",
":=",
"range",
"dir",
"{",
"switch",
"{",
"case",
"incomment"... | // isValidDirective reports whether dir is a valid directive text,
// meaning angle brackets are matched, ignoring comments and strings. | [
"isValidDirective",
"reports",
"whether",
"dir",
"is",
"a",
"valid",
"directive",
"text",
"meaning",
"angle",
"brackets",
"are",
"matched",
"ignoring",
"comments",
"and",
"strings",
"."
] | 5077ea9388910b75830078d274e1addafb53711f | https://github.com/cathalgarvey/fmtless/blob/5077ea9388910b75830078d274e1addafb53711f/encoding/xml/marshal.go#L254-L290 |
149,561 | lytics/datemath | datemath.go | Eval | func Eval(expression string) (time.Time, error) {
return EvalAnchor(time.Now(), expression)
} | go | func Eval(expression string) (time.Time, error) {
return EvalAnchor(time.Now(), expression)
} | [
"func",
"Eval",
"(",
"expression",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"return",
"EvalAnchor",
"(",
"time",
".",
"Now",
"(",
")",
",",
"expression",
")",
"\n",
"}"
] | // Eval evaluates a duration relative to now and returns the time or an error. | [
"Eval",
"evaluates",
"a",
"duration",
"relative",
"to",
"now",
"and",
"returns",
"the",
"time",
"or",
"an",
"error",
"."
] | 3ada1c10b5debaa3a4e0d34a42060429de7cdf96 | https://github.com/lytics/datemath/blob/3ada1c10b5debaa3a4e0d34a42060429de7cdf96/datemath.go#L19-L21 |
149,562 | lytics/datemath | datemath.go | EvalAnchor | func EvalAnchor(anchor time.Time, expression string) (time.Time, error) {
if len(expression) < 3 {
return zero, fmt.Errorf("Expression too short: %s", expression)
}
if strings.HasPrefix(expression, "now") {
expression = expression[3:]
}
if expression == "" {
return time.Now(), nil
}
numStr, unit := expr... | go | func EvalAnchor(anchor time.Time, expression string) (time.Time, error) {
if len(expression) < 3 {
return zero, fmt.Errorf("Expression too short: %s", expression)
}
if strings.HasPrefix(expression, "now") {
expression = expression[3:]
}
if expression == "" {
return time.Now(), nil
}
numStr, unit := expr... | [
"func",
"EvalAnchor",
"(",
"anchor",
"time",
".",
"Time",
",",
"expression",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"if",
"len",
"(",
"expression",
")",
"<",
"3",
"{",
"return",
"zero",
",",
"fmt",
".",
"Errorf",
"(",
"\""... | // evalAnchor evaluates a date expression relative to an anchor time. | [
"evalAnchor",
"evaluates",
"a",
"date",
"expression",
"relative",
"to",
"an",
"anchor",
"time",
"."
] | 3ada1c10b5debaa3a4e0d34a42060429de7cdf96 | https://github.com/lytics/datemath/blob/3ada1c10b5debaa3a4e0d34a42060429de7cdf96/datemath.go#L24-L62 |
149,563 | peter-edge/proto-go | server/protoserver.go | GetServeEnv | func GetServeEnv() (ServeEnv, error) {
var serveEnv ServeEnv
if err := env.Populate(&serveEnv); err != nil {
return ServeEnv{}, err
}
return serveEnv, nil
} | go | func GetServeEnv() (ServeEnv, error) {
var serveEnv ServeEnv
if err := env.Populate(&serveEnv); err != nil {
return ServeEnv{}, err
}
return serveEnv, nil
} | [
"func",
"GetServeEnv",
"(",
")",
"(",
"ServeEnv",
",",
"error",
")",
"{",
"var",
"serveEnv",
"ServeEnv",
"\n",
"if",
"err",
":=",
"env",
".",
"Populate",
"(",
"&",
"serveEnv",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ServeEnv",
"{",
"}",
",",
... | // GetServeEnv gets a ServeEnv using environment variables. | [
"GetServeEnv",
"gets",
"a",
"ServeEnv",
"using",
"environment",
"variables",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/server/protoserver.go#L37-L43 |
149,564 | peter-edge/proto-go | server/protoserver.go | GetAndServe | func GetAndServe(
registerFunc func(*grpc.Server),
options ServeOptions,
) error {
serveEnv, err := GetServeEnv()
if err != nil {
return err
}
return Serve(
registerFunc,
options,
serveEnv,
)
} | go | func GetAndServe(
registerFunc func(*grpc.Server),
options ServeOptions,
) error {
serveEnv, err := GetServeEnv()
if err != nil {
return err
}
return Serve(
registerFunc,
options,
serveEnv,
)
} | [
"func",
"GetAndServe",
"(",
"registerFunc",
"func",
"(",
"*",
"grpc",
".",
"Server",
")",
",",
"options",
"ServeOptions",
",",
")",
"error",
"{",
"serveEnv",
",",
"err",
":=",
"GetServeEnv",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err... | // GetAndServe is GetServeEnv with Serve. | [
"GetAndServe",
"is",
"GetServeEnv",
"with",
"Serve",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/server/protoserver.go#L51-L64 |
149,565 | peter-edge/proto-go | server/protoserver.go | Serve | func Serve(
registerFunc func(*grpc.Server),
options ServeOptions,
serveEnv ServeEnv,
) (retErr error) {
defer func(start time.Time) { logServerFinished(start, retErr) }(time.Now())
if registerFunc == nil {
return ErrMustSpecifyRegisterFunc
}
if serveEnv.GRPCPort == 0 {
serveEnv.GRPCPort = 7070
}
grpcServe... | go | func Serve(
registerFunc func(*grpc.Server),
options ServeOptions,
serveEnv ServeEnv,
) (retErr error) {
defer func(start time.Time) { logServerFinished(start, retErr) }(time.Now())
if registerFunc == nil {
return ErrMustSpecifyRegisterFunc
}
if serveEnv.GRPCPort == 0 {
serveEnv.GRPCPort = 7070
}
grpcServe... | [
"func",
"Serve",
"(",
"registerFunc",
"func",
"(",
"*",
"grpc",
".",
"Server",
")",
",",
"options",
"ServeOptions",
",",
"serveEnv",
"ServeEnv",
",",
")",
"(",
"retErr",
"error",
")",
"{",
"defer",
"func",
"(",
"start",
"time",
".",
"Time",
")",
"{",
... | // Serve serves stuff. | [
"Serve",
"serves",
"stuff",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/server/protoserver.go#L67-L99 |
149,566 | peter-edge/proto-go | server/protoserver.go | GetAndServeWithHTTP | func GetAndServeWithHTTP(
registerFunc func(*grpc.Server),
httpRegisterFunc func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error,
options ServeWithHTTPOptions,
) error {
serveEnv, err := GetServeEnv()
if err != nil {
return err
}
handlerEnv, err := pkghttp.GetHandlerEnv()
if err != nil {
return ... | go | func GetAndServeWithHTTP(
registerFunc func(*grpc.Server),
httpRegisterFunc func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error,
options ServeWithHTTPOptions,
) error {
serveEnv, err := GetServeEnv()
if err != nil {
return err
}
handlerEnv, err := pkghttp.GetHandlerEnv()
if err != nil {
return ... | [
"func",
"GetAndServeWithHTTP",
"(",
"registerFunc",
"func",
"(",
"*",
"grpc",
".",
"Server",
")",
",",
"httpRegisterFunc",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"runtime",
".",
"ServeMux",
",",
"*",
"grpc",
".",
"ClientConn",
")",
"error",
",",... | // GetAndServeWithHTTP is GetServeEnv and GetHandlerEnv with ServeWithHTTP. | [
"GetAndServeWithHTTP",
"is",
"GetServeEnv",
"and",
"GetHandlerEnv",
"with",
"ServeWithHTTP",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/server/protoserver.go#L108-L128 |
149,567 | peter-edge/proto-go | stream/protostream.go | WriteToStreamingBytesServer | func WriteToStreamingBytesServer(reader io.Reader, streamingBytesServer StreamingBytesServer) error {
_, err := bufio.NewReader(reader).WriteTo(NewStreamingBytesWriter(streamingBytesServer))
return err
} | go | func WriteToStreamingBytesServer(reader io.Reader, streamingBytesServer StreamingBytesServer) error {
_, err := bufio.NewReader(reader).WriteTo(NewStreamingBytesWriter(streamingBytesServer))
return err
} | [
"func",
"WriteToStreamingBytesServer",
"(",
"reader",
"io",
".",
"Reader",
",",
"streamingBytesServer",
"StreamingBytesServer",
")",
"error",
"{",
"_",
",",
"err",
":=",
"bufio",
".",
"NewReader",
"(",
"reader",
")",
".",
"WriteTo",
"(",
"NewStreamingBytesWriter",... | // WriteToStreamingBytesServer writes the data from the io.Reader to the StreamingBytesServer. | [
"WriteToStreamingBytesServer",
"writes",
"the",
"data",
"from",
"the",
"io",
".",
"Reader",
"to",
"the",
"StreamingBytesServer",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/stream/protostream.go#L67-L70 |
149,568 | peter-edge/proto-go | stream/protostream.go | WriteFromStreamingBytesClient | func WriteFromStreamingBytesClient(streamingBytesClient StreamingBytesClient, writer io.Writer) error {
return NewStreamingBytesClientHandler(
func(bytesValue *wrappers.BytesValue) error {
_, err := writer.Write(bytesValue.Value)
return err
},
).Handle(streamingBytesClient)
} | go | func WriteFromStreamingBytesClient(streamingBytesClient StreamingBytesClient, writer io.Writer) error {
return NewStreamingBytesClientHandler(
func(bytesValue *wrappers.BytesValue) error {
_, err := writer.Write(bytesValue.Value)
return err
},
).Handle(streamingBytesClient)
} | [
"func",
"WriteFromStreamingBytesClient",
"(",
"streamingBytesClient",
"StreamingBytesClient",
",",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"NewStreamingBytesClientHandler",
"(",
"func",
"(",
"bytesValue",
"*",
"wrappers",
".",
"BytesValue",
")",
"e... | // WriteFromStreamingBytesClient writes from the StreamingBytesClient to the io.Writer. | [
"WriteFromStreamingBytesClient",
"writes",
"from",
"the",
"StreamingBytesClient",
"to",
"the",
"io",
".",
"Writer",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/stream/protostream.go#L78-L85 |
149,569 | peter-edge/proto-go | rpclog/protorpclog.go | Log | func Log(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration) {
if err != nil {
Error(serviceName, methodName, request, response, err, duration)
} else {
Info(serviceName, methodName, request, response, err, duration)
}
} | go | func Log(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration) {
if err != nil {
Error(serviceName, methodName, request, response, err, duration)
} else {
Info(serviceName, methodName, request, response, err, duration)
}
} | [
"func",
"Log",
"(",
"serviceName",
"string",
",",
"methodName",
"string",
",",
"request",
"proto",
".",
"Message",
",",
"response",
"proto",
".",
"Message",
",",
"err",
"error",
",",
"duration",
"time",
".",
"Duration",
")",
"{",
"if",
"err",
"!=",
"nil"... | // Log logs an RPC call at the info level if no error, or at the error level if error. | [
"Log",
"logs",
"an",
"RPC",
"call",
"at",
"the",
"info",
"level",
"if",
"no",
"error",
"or",
"at",
"the",
"error",
"level",
"if",
"error",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/rpclog/protorpclog.go#L54-L60 |
149,570 | peter-edge/proto-go | rpclog/protorpclog.go | Debug | func Debug(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration) {
protolion.Debug(event(serviceName, methodName, request, response, err, duration))
} | go | func Debug(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration) {
protolion.Debug(event(serviceName, methodName, request, response, err, duration))
} | [
"func",
"Debug",
"(",
"serviceName",
"string",
",",
"methodName",
"string",
",",
"request",
"proto",
".",
"Message",
",",
"response",
"proto",
".",
"Message",
",",
"err",
"error",
",",
"duration",
"time",
".",
"Duration",
")",
"{",
"protolion",
".",
"Debug... | // Debug logs an RPC call at the debug level. | [
"Debug",
"logs",
"an",
"RPC",
"call",
"at",
"the",
"debug",
"level",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/rpclog/protorpclog.go#L63-L65 |
149,571 | peter-edge/proto-go | time/prototime.go | TimeToTimestamp | func TimeToTimestamp(t time.Time) *timestamp.Timestamp {
return ×tamp.Timestamp{
Seconds: t.UnixNano() / int64(time.Second),
Nanos: int32(t.UnixNano() % int64(time.Second)),
}
} | go | func TimeToTimestamp(t time.Time) *timestamp.Timestamp {
return ×tamp.Timestamp{
Seconds: t.UnixNano() / int64(time.Second),
Nanos: int32(t.UnixNano() % int64(time.Second)),
}
} | [
"func",
"TimeToTimestamp",
"(",
"t",
"time",
".",
"Time",
")",
"*",
"timestamp",
".",
"Timestamp",
"{",
"return",
"&",
"timestamp",
".",
"Timestamp",
"{",
"Seconds",
":",
"t",
".",
"UnixNano",
"(",
")",
"/",
"int64",
"(",
"time",
".",
"Second",
")",
... | // TimeToTimestamp converts a go Time to a protobuf Timestamp. | [
"TimeToTimestamp",
"converts",
"a",
"go",
"Time",
"to",
"a",
"protobuf",
"Timestamp",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/time/prototime.go#L13-L18 |
149,572 | peter-edge/proto-go | time/prototime.go | TimestampToTime | func TimestampToTime(timestamp *timestamp.Timestamp) time.Time {
if timestamp == nil {
return time.Unix(0, 0).UTC()
}
return time.Unix(
timestamp.Seconds,
int64(timestamp.Nanos),
).UTC()
} | go | func TimestampToTime(timestamp *timestamp.Timestamp) time.Time {
if timestamp == nil {
return time.Unix(0, 0).UTC()
}
return time.Unix(
timestamp.Seconds,
int64(timestamp.Nanos),
).UTC()
} | [
"func",
"TimestampToTime",
"(",
"timestamp",
"*",
"timestamp",
".",
"Timestamp",
")",
"time",
".",
"Time",
"{",
"if",
"timestamp",
"==",
"nil",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"0",
")",
".",
"UTC",
"(",
")",
"\n",
"}",
"\n",
"ret... | // TimestampToTime converts a protobuf Timestamp to a go Time. | [
"TimestampToTime",
"converts",
"a",
"protobuf",
"Timestamp",
"to",
"a",
"go",
"Time",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/time/prototime.go#L21-L29 |
149,573 | peter-edge/proto-go | time/prototime.go | TimestampLess | func TimestampLess(i *timestamp.Timestamp, j *timestamp.Timestamp) bool {
if j == nil {
return false
}
if i == nil {
return true
}
if i.Seconds < j.Seconds {
return true
}
if i.Seconds > j.Seconds {
return false
}
return i.Nanos < j.Nanos
} | go | func TimestampLess(i *timestamp.Timestamp, j *timestamp.Timestamp) bool {
if j == nil {
return false
}
if i == nil {
return true
}
if i.Seconds < j.Seconds {
return true
}
if i.Seconds > j.Seconds {
return false
}
return i.Nanos < j.Nanos
} | [
"func",
"TimestampLess",
"(",
"i",
"*",
"timestamp",
".",
"Timestamp",
",",
"j",
"*",
"timestamp",
".",
"Timestamp",
")",
"bool",
"{",
"if",
"j",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"i",
"==",
"nil",
"{",
"return",
"true",
"... | // TimestampLess returns true if i is before j. | [
"TimestampLess",
"returns",
"true",
"if",
"i",
"is",
"before",
"j",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/time/prototime.go#L32-L46 |
149,574 | kylemcc/twitter-text-go | validate/validate.go | UrlIsValid | func UrlIsValid(url string, requireProtocol bool, allowUnicode bool) bool {
if url == "" {
return false
}
match := validateUrlUnencodedRe.FindStringSubmatchIndex(url)
if match == nil || url[match[0]:match[1]] != url {
return false
}
if requireProtocol {
schemeStart := match[validateUrlUnencodedGroupScheme... | go | func UrlIsValid(url string, requireProtocol bool, allowUnicode bool) bool {
if url == "" {
return false
}
match := validateUrlUnencodedRe.FindStringSubmatchIndex(url)
if match == nil || url[match[0]:match[1]] != url {
return false
}
if requireProtocol {
schemeStart := match[validateUrlUnencodedGroupScheme... | [
"func",
"UrlIsValid",
"(",
"url",
"string",
",",
"requireProtocol",
"bool",
",",
"allowUnicode",
"bool",
")",
"bool",
"{",
"if",
"url",
"==",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"match",
":=",
"validateUrlUnencodedRe",
".",
"FindStringSubm... | // Returns true if the given text represents a valid URL | [
"Returns",
"true",
"if",
"the",
"given",
"text",
"represents",
"a",
"valid",
"URL"
] | 7f582f6736ec1777a4725aaae652edfd2c28470a | https://github.com/kylemcc/twitter-text-go/blob/7f582f6736ec1777a4725aaae652edfd2c28470a/validate/validate.go#L138-L183 |
149,575 | peter-edge/proto-go | http/protohttp.go | GetRequestMetadata | func (c *BasicAuth) GetRequestMetadata(ctx context.Context, uris ...string) (map[string]string, error) {
return map[string]string{
"Authorization": c.GetAuthorization(),
}, nil
} | go | func (c *BasicAuth) GetRequestMetadata(ctx context.Context, uris ...string) (map[string]string, error) {
return map[string]string{
"Authorization": c.GetAuthorization(),
}, nil
} | [
"func",
"(",
"c",
"*",
"BasicAuth",
")",
"GetRequestMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"uris",
"...",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"map",
"[",
"string",
"]",
"string",
... | // GetRequestMetadata gets the request metadata for gRPC. | [
"GetRequestMetadata",
"gets",
"the",
"request",
"metadata",
"for",
"gRPC",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/http/protohttp.go#L22-L26 |
149,576 | peter-edge/proto-go | http/protohttp.go | GetAuthorization | func (c *BasicAuth) GetAuthorization() string {
return fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", c.Username, c.Password))))
} | go | func (c *BasicAuth) GetAuthorization() string {
return fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", c.Username, c.Password))))
} | [
"func",
"(",
"c",
"*",
"BasicAuth",
")",
"GetAuthorization",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
... | // GetAuthorization gets the request authorization. | [
"GetAuthorization",
"gets",
"the",
"request",
"authorization",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/http/protohttp.go#L35-L37 |
149,577 | peter-edge/proto-go | http/protohttp.go | NewContext | func (c *BasicAuth) NewContext(ctx context.Context) context.Context {
return metadata.NewOutgoingContext(ctx, metadata.Pairs("Authorization", c.GetAuthorization()))
} | go | func (c *BasicAuth) NewContext(ctx context.Context) context.Context {
return metadata.NewOutgoingContext(ctx, metadata.Pairs("Authorization", c.GetAuthorization()))
} | [
"func",
"(",
"c",
"*",
"BasicAuth",
")",
"NewContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"return",
"metadata",
".",
"NewOutgoingContext",
"(",
"ctx",
",",
"metadata",
".",
"Pairs",
"(",
"\"",
"\"",
",",
"c",
".... | // NewContext returns a new context.Context with the basic auth attached. | [
"NewContext",
"returns",
"a",
"new",
"context",
".",
"Context",
"with",
"the",
"basic",
"auth",
"attached",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/http/protohttp.go#L40-L42 |
149,578 | peter-edge/proto-go | http/protohttp.go | BasicAuthFromContext | func BasicAuthFromContext(ctx context.Context) (*BasicAuth, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, nil
}
authorization, ok := md["Authorization"]
if !ok {
authorization, ok = md["authorization"]
if !ok {
return nil, nil
}
}
if len(authorization) != 1 {
return nil, ... | go | func BasicAuthFromContext(ctx context.Context) (*BasicAuth, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, nil
}
authorization, ok := md["Authorization"]
if !ok {
authorization, ok = md["authorization"]
if !ok {
return nil, nil
}
}
if len(authorization) != 1 {
return nil, ... | [
"func",
"BasicAuthFromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"BasicAuth",
",",
"error",
")",
"{",
"md",
",",
"ok",
":=",
"metadata",
".",
"FromIncomingContext",
"(",
"ctx",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",... | // BasicAuthFromContext gets the basic auth from the specified context.Context.
//
// If no basic auth is present, BasicAuthFromContext returns nil. | [
"BasicAuthFromContext",
"gets",
"the",
"basic",
"auth",
"from",
"the",
"specified",
"context",
".",
"Context",
".",
"If",
"no",
"basic",
"auth",
"is",
"present",
"BasicAuthFromContext",
"returns",
"nil",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/http/protohttp.go#L47-L77 |
149,579 | cespare/cp | cp.go | CopyAllOverwrite | func CopyAllOverwrite(dst, src string) error {
return filepath.Walk(src, makeWalkFn(dst, src, flagOverwrite))
} | go | func CopyAllOverwrite(dst, src string) error {
return filepath.Walk(src, makeWalkFn(dst, src, flagOverwrite))
} | [
"func",
"CopyAllOverwrite",
"(",
"dst",
",",
"src",
"string",
")",
"error",
"{",
"return",
"filepath",
".",
"Walk",
"(",
"src",
",",
"makeWalkFn",
"(",
"dst",
",",
"src",
",",
"flagOverwrite",
")",
")",
"\n",
"}"
] | // CopyAllOverwrite is like CopyAll except that it recursively overwrites
// any existing directories or files. | [
"CopyAllOverwrite",
"is",
"like",
"CopyAll",
"except",
"that",
"it",
"recursively",
"overwrites",
"any",
"existing",
"directories",
"or",
"files",
"."
] | db1407d84ae423533fe1d25510c1c4c4d831f0fc | https://github.com/cespare/cp/blob/db1407d84ae423533fe1d25510c1c4c4d831f0fc/cp.go#L76-L78 |
149,580 | abhishekkr/gol | golservice/service.go | Start | func Start(toRun Funk) {
flag.Parse()
if PersistPID(*DaemonPIDFile) {
LogDaemon("Started daemon.")
toRun()
LogDaemon("Daemon finished task.")
} else {
LogDaemon("Daemon seem to already run. Start failed.")
}
} | go | func Start(toRun Funk) {
flag.Parse()
if PersistPID(*DaemonPIDFile) {
LogDaemon("Started daemon.")
toRun()
LogDaemon("Daemon finished task.")
} else {
LogDaemon("Daemon seem to already run. Start failed.")
}
} | [
"func",
"Start",
"(",
"toRun",
"Funk",
")",
"{",
"flag",
".",
"Parse",
"(",
")",
"\n",
"if",
"PersistPID",
"(",
"*",
"DaemonPIDFile",
")",
"{",
"LogDaemon",
"(",
"\"",
"\"",
")",
"\n",
"toRun",
"(",
")",
"\n",
"LogDaemon",
"(",
"\"",
"\"",
")",
"... | // start for passed Funk typed method call | [
"start",
"for",
"passed",
"Funk",
"typed",
"method",
"call"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/golservice/service.go#L43-L52 |
149,581 | abhishekkr/gol | golservice/service.go | Stop | func Stop() {
flag.Parse()
var status string
if KillPID(*DaemonPIDFile) {
status = "Status: Stopped."
} else {
status = fmt.Sprintf("Failed to stop. Status: %s", StatusPID(*DaemonPIDFile))
}
LogDaemon(status)
} | go | func Stop() {
flag.Parse()
var status string
if KillPID(*DaemonPIDFile) {
status = "Status: Stopped."
} else {
status = fmt.Sprintf("Failed to stop. Status: %s", StatusPID(*DaemonPIDFile))
}
LogDaemon(status)
} | [
"func",
"Stop",
"(",
")",
"{",
"flag",
".",
"Parse",
"(",
")",
"\n\n",
"var",
"status",
"string",
"\n",
"if",
"KillPID",
"(",
"*",
"DaemonPIDFile",
")",
"{",
"status",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"status",
"=",
"fmt",
".",
"Sprintf",
... | // stop for the given process name's stored pid | [
"stop",
"for",
"the",
"given",
"process",
"name",
"s",
"stored",
"pid"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/golservice/service.go#L55-L66 |
149,582 | abhishekkr/gol | goltime/from_time_points.go | secondFragments | func secondFragments(second string) (sec, milliSec, microSec, nanoSec, picoSec int) {
fragments := strings.Split(second, ".")
if len(fragments) > 0 {
sec, _ = strconv.Atoi(fragments[0])
}
if len(fragments) > 1 {
milliSec, _ = strconv.Atoi(fragments[1])
}
if len(fragments) > 2 {
microSec, _ = strconv.Atoi(f... | go | func secondFragments(second string) (sec, milliSec, microSec, nanoSec, picoSec int) {
fragments := strings.Split(second, ".")
if len(fragments) > 0 {
sec, _ = strconv.Atoi(fragments[0])
}
if len(fragments) > 1 {
milliSec, _ = strconv.Atoi(fragments[1])
}
if len(fragments) > 2 {
microSec, _ = strconv.Atoi(f... | [
"func",
"secondFragments",
"(",
"second",
"string",
")",
"(",
"sec",
",",
"milliSec",
",",
"microSec",
",",
"nanoSec",
",",
"picoSec",
"int",
")",
"{",
"fragments",
":=",
"strings",
".",
"Split",
"(",
"second",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"len"... | // getting value for second fragments from second value | [
"getting",
"value",
"for",
"second",
"fragments",
"from",
"second",
"value"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/goltime/from_time_points.go#L16-L35 |
149,583 | abhishekkr/gol | goltime/from_time_points.go | Time | func (timestamp *Timestamp) Time() time.Time {
return time.Date(timestamp.Year, time.Month(timestamp.Month), timestamp.Day,
timestamp.Hour, timestamp.Min, timestamp.Sec, timestamp.NanoSec, time.UTC)
} | go | func (timestamp *Timestamp) Time() time.Time {
return time.Date(timestamp.Year, time.Month(timestamp.Month), timestamp.Day,
timestamp.Hour, timestamp.Min, timestamp.Sec, timestamp.NanoSec, time.UTC)
} | [
"func",
"(",
"timestamp",
"*",
"Timestamp",
")",
"Time",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Date",
"(",
"timestamp",
".",
"Year",
",",
"time",
".",
"Month",
"(",
"timestamp",
".",
"Month",
")",
",",
"timestamp",
".",
"Day",
... | // create time.Time from a Timestamp struct | [
"create",
"time",
".",
"Time",
"from",
"a",
"Timestamp",
"struct"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/goltime/from_time_points.go#L72-L75 |
149,584 | abhishekkr/gol | goltime/from_time_points.go | TimestampNow | func TimestampNow() Timestamp {
var year, day, hour, min, sec int
var month time.Month
year, month, day = time.Now().Date()
hour, min, sec = time.Now().Clock()
return Timestamp{
Year: year,
Month: int(month),
Day: day,
Hour: hour,
Min: min,
Sec: sec,
MilliSec: 0,
MicroSec:... | go | func TimestampNow() Timestamp {
var year, day, hour, min, sec int
var month time.Month
year, month, day = time.Now().Date()
hour, min, sec = time.Now().Clock()
return Timestamp{
Year: year,
Month: int(month),
Day: day,
Hour: hour,
Min: min,
Sec: sec,
MilliSec: 0,
MicroSec:... | [
"func",
"TimestampNow",
"(",
")",
"Timestamp",
"{",
"var",
"year",
",",
"day",
",",
"hour",
",",
"min",
",",
"sec",
"int",
"\n",
"var",
"month",
"time",
".",
"Month",
"\n",
"year",
",",
"month",
",",
"day",
"=",
"time",
".",
"Now",
"(",
")",
".",... | // create Timestamp struct from time.Now | [
"create",
"Timestamp",
"struct",
"from",
"time",
".",
"Now"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/goltime/from_time_points.go#L78-L95 |
149,585 | nanobox-io/nanobox-golang-stylish | stylish.go | Nest | func Nest(level int, msg string) (rtn string) {
for index, line := range strings.Split(msg, "\n") {
// skip the last new line at the end of the message
// because we add the new line in on each Sprintf
if index == len(strings.Split(msg, "\n"))-1 && line == "" {
continue
}
rtn += fmt.Sprintf("%s%s\n", Gene... | go | func Nest(level int, msg string) (rtn string) {
for index, line := range strings.Split(msg, "\n") {
// skip the last new line at the end of the message
// because we add the new line in on each Sprintf
if index == len(strings.Split(msg, "\n"))-1 && line == "" {
continue
}
rtn += fmt.Sprintf("%s%s\n", Gene... | [
"func",
"Nest",
"(",
"level",
"int",
",",
"msg",
"string",
")",
"(",
"rtn",
"string",
")",
"{",
"for",
"index",
",",
"line",
":=",
"range",
"strings",
".",
"Split",
"(",
"msg",
",",
"\"",
"\\n",
"\"",
")",
"{",
"// skip the last new line at the end of th... | // Nest is a generic nesting function that
// will generate the appropariate prefix based
// on the nest level | [
"Nest",
"is",
"a",
"generic",
"nesting",
"function",
"that",
"will",
"generate",
"the",
"appropariate",
"prefix",
"based",
"on",
"the",
"nest",
"level"
] | f30190544d5d47500c15735beedcfadeaf145a27 | https://github.com/nanobox-io/nanobox-golang-stylish/blob/f30190544d5d47500c15735beedcfadeaf145a27/stylish.go#L20-L30 |
149,586 | nanobox-io/nanobox-golang-stylish | stylish.go | GenerateNestedPrefix | func GenerateNestedPrefix(level int) string {
prefix := ""
for i := 0; i < level; i++ {
prefix += " "
}
return prefix
} | go | func GenerateNestedPrefix(level int) string {
prefix := ""
for i := 0; i < level; i++ {
prefix += " "
}
return prefix
} | [
"func",
"GenerateNestedPrefix",
"(",
"level",
"int",
")",
"string",
"{",
"prefix",
":=",
"\"",
"\"",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"level",
";",
"i",
"++",
"{",
"prefix",
"+=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"prefix",
"\n"... | // GenerateNestedPrefix will generate a prefix string of spaces to match the
// specified depth level | [
"GenerateNestedPrefix",
"will",
"generate",
"a",
"prefix",
"string",
"of",
"spaces",
"to",
"match",
"the",
"specified",
"depth",
"level"
] | f30190544d5d47500c15735beedcfadeaf145a27 | https://github.com/nanobox-io/nanobox-golang-stylish/blob/f30190544d5d47500c15735beedcfadeaf145a27/stylish.go#L176-L184 |
149,587 | abhishekkr/gol | gollog/log.go | Start | func (l Log) Start() {
for {
msg := <-(l.Thread)
fmt.Printf("[%s] %s", l.Level, msg)
}
} | go | func (l Log) Start() {
for {
msg := <-(l.Thread)
fmt.Printf("[%s] %s", l.Level, msg)
}
} | [
"func",
"(",
"l",
"Log",
")",
"Start",
"(",
")",
"{",
"for",
"{",
"msg",
":=",
"<-",
"(",
"l",
".",
"Thread",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"l",
".",
"Level",
",",
"msg",
")",
"\n",
"}",
"\n",
"}"
] | // start Log Action | [
"start",
"Log",
"Action"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/gollog/log.go#L35-L40 |
149,588 | abhishekkr/gol | gollog/log.go | LogIt | func LogIt(fyl *os.File, lyn string) {
lyn = fmt.Sprintf("%s\n", lyn)
n, err := io.WriteString(fyl, lyn)
if err != nil {
fmt.Println(n, err)
}
} | go | func LogIt(fyl *os.File, lyn string) {
lyn = fmt.Sprintf("%s\n", lyn)
n, err := io.WriteString(fyl, lyn)
if err != nil {
fmt.Println(n, err)
}
} | [
"func",
"LogIt",
"(",
"fyl",
"*",
"os",
".",
"File",
",",
"lyn",
"string",
")",
"{",
"lyn",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"lyn",
")",
"\n",
"n",
",",
"err",
":=",
"io",
".",
"WriteString",
"(",
"fyl",
",",
"lyn",
")... | // just write to given file handle | [
"just",
"write",
"to",
"given",
"file",
"handle"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/gollog/log.go#L58-L64 |
149,589 | abhishekkr/gol | gollog/log.go | LogOnce | func LogOnce(logfile string, msg string) {
logr := OpenLogFile(logfile)
defer logr.Close()
LogIt(logr, msg)
} | go | func LogOnce(logfile string, msg string) {
logr := OpenLogFile(logfile)
defer logr.Close()
LogIt(logr, msg)
} | [
"func",
"LogOnce",
"(",
"logfile",
"string",
",",
"msg",
"string",
")",
"{",
"logr",
":=",
"OpenLogFile",
"(",
"logfile",
")",
"\n",
"defer",
"logr",
".",
"Close",
"(",
")",
"\n",
"LogIt",
"(",
"logr",
",",
"msg",
")",
"\n",
"}"
] | // Open, Log, Close | [
"Open",
"Log",
"Close"
] | d04ee3dc97da79ffdd80bf5601d767df44b9301d | https://github.com/abhishekkr/gol/blob/d04ee3dc97da79ffdd80bf5601d767df44b9301d/gollog/log.go#L67-L71 |
149,590 | peter-edge/proto-go | date/protodate.go | NewDate | func NewDate(month int32, day int32, year int32) *google_type.Date {
return &google_type.Date{
Month: month,
Day: day,
Year: year,
}
} | go | func NewDate(month int32, day int32, year int32) *google_type.Date {
return &google_type.Date{
Month: month,
Day: day,
Year: year,
}
} | [
"func",
"NewDate",
"(",
"month",
"int32",
",",
"day",
"int32",
",",
"year",
"int32",
")",
"*",
"google_type",
".",
"Date",
"{",
"return",
"&",
"google_type",
".",
"Date",
"{",
"Month",
":",
"month",
",",
"Day",
":",
"day",
",",
"Year",
":",
"year",
... | // NewDate is a convienence function to create a new Date. | [
"NewDate",
"is",
"a",
"convienence",
"function",
"to",
"create",
"a",
"new",
"Date",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L18-L24 |
149,591 | peter-edge/proto-go | date/protodate.go | TimeToDate | func TimeToDate(t time.Time) *google_type.Date {
return NewDate(int32(t.Month()), int32(t.Day()), int32(t.Year()))
} | go | func TimeToDate(t time.Time) *google_type.Date {
return NewDate(int32(t.Month()), int32(t.Day()), int32(t.Year()))
} | [
"func",
"TimeToDate",
"(",
"t",
"time",
".",
"Time",
")",
"*",
"google_type",
".",
"Date",
"{",
"return",
"NewDate",
"(",
"int32",
"(",
"t",
".",
"Month",
"(",
")",
")",
",",
"int32",
"(",
"t",
".",
"Day",
"(",
")",
")",
",",
"int32",
"(",
"t",... | // TimeToDate converts a golang Time to a Date. | [
"TimeToDate",
"converts",
"a",
"golang",
"Time",
"to",
"a",
"Date",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L32-L34 |
149,592 | peter-edge/proto-go | date/protodate.go | DateToTime | func DateToTime(d *google_type.Date) time.Time {
if d == nil {
return time.Unix(0, 0).UTC()
}
return time.Date(int(d.Year), time.Month(d.Month), int(d.Day), 0, 0, 0, 0, time.UTC)
} | go | func DateToTime(d *google_type.Date) time.Time {
if d == nil {
return time.Unix(0, 0).UTC()
}
return time.Date(int(d.Year), time.Month(d.Month), int(d.Day), 0, 0, 0, 0, time.UTC)
} | [
"func",
"DateToTime",
"(",
"d",
"*",
"google_type",
".",
"Date",
")",
"time",
".",
"Time",
"{",
"if",
"d",
"==",
"nil",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"0",
")",
".",
"UTC",
"(",
")",
"\n",
"}",
"\n",
"return",
"time",
".",
... | // DateToTime converts a Date to a golang Time. | [
"DateToTime",
"converts",
"a",
"Date",
"to",
"a",
"golang",
"Time",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L37-L42 |
149,593 | peter-edge/proto-go | date/protodate.go | DateLess | func DateLess(i *google_type.Date, j *google_type.Date) bool {
if j == nil {
return false
}
if i == nil {
return true
}
if i.Year < j.Year {
return true
}
if i.Year > j.Year {
return false
}
if i.Month < j.Month {
return true
}
if i.Month > j.Month {
return false
}
return i.Day < j.Day
} | go | func DateLess(i *google_type.Date, j *google_type.Date) bool {
if j == nil {
return false
}
if i == nil {
return true
}
if i.Year < j.Year {
return true
}
if i.Year > j.Year {
return false
}
if i.Month < j.Month {
return true
}
if i.Month > j.Month {
return false
}
return i.Day < j.Day
} | [
"func",
"DateLess",
"(",
"i",
"*",
"google_type",
".",
"Date",
",",
"j",
"*",
"google_type",
".",
"Date",
")",
"bool",
"{",
"if",
"j",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"i",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",... | // DateLess returns true if i is before j. | [
"DateLess",
"returns",
"true",
"if",
"i",
"is",
"before",
"j",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L45-L65 |
149,594 | peter-edge/proto-go | date/protodate.go | DateInRange | func DateInRange(d *google_type.Date, start *google_type.Date, end *google_type.Date) bool {
if start == nil && end == nil {
return true
}
if start == nil {
return DateLess(d, end) || DateEqual(d, end)
}
if end == nil {
return DateLess(start, d) || DateEqual(start, d)
}
return DateEqual(d, start) || DateEq... | go | func DateInRange(d *google_type.Date, start *google_type.Date, end *google_type.Date) bool {
if start == nil && end == nil {
return true
}
if start == nil {
return DateLess(d, end) || DateEqual(d, end)
}
if end == nil {
return DateLess(start, d) || DateEqual(start, d)
}
return DateEqual(d, start) || DateEq... | [
"func",
"DateInRange",
"(",
"d",
"*",
"google_type",
".",
"Date",
",",
"start",
"*",
"google_type",
".",
"Date",
",",
"end",
"*",
"google_type",
".",
"Date",
")",
"bool",
"{",
"if",
"start",
"==",
"nil",
"&&",
"end",
"==",
"nil",
"{",
"return",
"true... | // DateInRange returns whether d is within start to end, inclusive.
// The given date is expected to not be nil.
// If start is nil, it checks whether d is less than or equal to end.
// If end is nil it checks whether d is greater than or equal to end.
// If start and end are nil, it returns true. | [
"DateInRange",
"returns",
"whether",
"d",
"is",
"within",
"start",
"to",
"end",
"inclusive",
".",
"The",
"given",
"date",
"is",
"expected",
"to",
"not",
"be",
"nil",
".",
"If",
"start",
"is",
"nil",
"it",
"checks",
"whether",
"d",
"is",
"less",
"than",
... | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L72-L83 |
149,595 | peter-edge/proto-go | date/protodate.go | DateEqual | func DateEqual(i *google_type.Date, j *google_type.Date) bool {
return ((i == nil) == (j == nil)) && ((i == nil) || (*i == *j))
} | go | func DateEqual(i *google_type.Date, j *google_type.Date) bool {
return ((i == nil) == (j == nil)) && ((i == nil) || (*i == *j))
} | [
"func",
"DateEqual",
"(",
"i",
"*",
"google_type",
".",
"Date",
",",
"j",
"*",
"google_type",
".",
"Date",
")",
"bool",
"{",
"return",
"(",
"(",
"i",
"==",
"nil",
")",
"==",
"(",
"j",
"==",
"nil",
")",
")",
"&&",
"(",
"(",
"i",
"==",
"nil",
"... | // DateEqual returns true if i equals j. | [
"DateEqual",
"returns",
"true",
"if",
"i",
"equals",
"j",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L86-L88 |
149,596 | peter-edge/proto-go | date/protodate.go | NewFakeDater | func NewFakeDater(month int32, day int32, year int32) FakeDater {
return newFakeDater(month, day, year)
} | go | func NewFakeDater(month int32, day int32, year int32) FakeDater {
return newFakeDater(month, day, year)
} | [
"func",
"NewFakeDater",
"(",
"month",
"int32",
",",
"day",
"int32",
",",
"year",
"int32",
")",
"FakeDater",
"{",
"return",
"newFakeDater",
"(",
"month",
",",
"day",
",",
"year",
")",
"\n",
"}"
] | // NewFakeDater returns a new FakeDater with the initial date. | [
"NewFakeDater",
"returns",
"a",
"new",
"FakeDater",
"with",
"the",
"initial",
"date",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/date/protodate.go#L102-L104 |
149,597 | peter-edge/proto-go | version/protoversion.go | VersionString | func (v *Version) VersionString() string {
return fmt.Sprintf("%d.%d.%d%s", v.Major, v.Minor, v.Micro, v.Additional)
} | go | func (v *Version) VersionString() string {
return fmt.Sprintf("%d.%d.%d%s", v.Major, v.Minor, v.Micro, v.Additional)
} | [
"func",
"(",
"v",
"*",
"Version",
")",
"VersionString",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"Major",
",",
"v",
".",
"Minor",
",",
"v",
".",
"Micro",
",",
"v",
".",
"Additional",
")",
"\n",
"... | // VersionString returns a string representation of the Version. | [
"VersionString",
"returns",
"a",
"string",
"representation",
"of",
"the",
"Version",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/version/protoversion.go#L30-L32 |
149,598 | peter-edge/proto-go | client/protoclient.go | NewVersionCommand | func NewVersionCommand(clientVersion *protoversion.Version, clientConnFunc func() (*grpc.ClientConn, error)) *cobra.Command {
return &cobra.Command{
Use: "version",
Long: "Print the version.",
Run: pkgcobra.RunFixedArgs(0, func(args []string) error {
clientConn, err := clientConnFunc()
if err != nil {
... | go | func NewVersionCommand(clientVersion *protoversion.Version, clientConnFunc func() (*grpc.ClientConn, error)) *cobra.Command {
return &cobra.Command{
Use: "version",
Long: "Print the version.",
Run: pkgcobra.RunFixedArgs(0, func(args []string) error {
clientConn, err := clientConnFunc()
if err != nil {
... | [
"func",
"NewVersionCommand",
"(",
"clientVersion",
"*",
"protoversion",
".",
"Version",
",",
"clientConnFunc",
"func",
"(",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
")",
"*",
"cobra",
".",
"Command",
"{",
"return",
"&",
"cobra",
".",
... | // NewVersionCommand creates a new command to print the version of the client and server. | [
"NewVersionCommand",
"creates",
"a",
"new",
"command",
"to",
"print",
"the",
"version",
"of",
"the",
"client",
"and",
"server",
"."
] | 671bc5dde355c10447e5f4c6d05cf9dcf69be068 | https://github.com/peter-edge/proto-go/blob/671bc5dde355c10447e5f4c6d05cf9dcf69be068/client/protoclient.go#L14-L31 |
149,599 | xyproto/cookie | cookie.go | SecureCookie | func SecureCookie(req *http.Request, name string, cookieSecret string) (string, bool) {
for _, cookie := range req.Cookies() {
if cookie.Name != name {
continue
}
parts := strings.SplitN(cookie.Value, "|", 3)
// fix potential out of range error
if len(parts) != 3 {
return "", false
}
val := part... | go | func SecureCookie(req *http.Request, name string, cookieSecret string) (string, bool) {
for _, cookie := range req.Cookies() {
if cookie.Name != name {
continue
}
parts := strings.SplitN(cookie.Value, "|", 3)
// fix potential out of range error
if len(parts) != 3 {
return "", false
}
val := part... | [
"func",
"SecureCookie",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"name",
"string",
",",
"cookieSecret",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"for",
"_",
",",
"cookie",
":=",
"range",
"req",
".",
"Cookies",
"(",
")",
"{",
"if",
... | // SecureCookie retrieves a secure cookie from a HTTP request | [
"SecureCookie",
"retrieves",
"a",
"secure",
"cookie",
"from",
"a",
"HTTP",
"request"
] | f4de411f45ff7eb4e4b9310f783951c35cf01711 | https://github.com/xyproto/cookie/blob/f4de411f45ff7eb4e4b9310f783951c35cf01711/cookie.go#L28-L61 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.