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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
152,300 | IBM-Cloud/go-cloudant-example | Godeps/_workspace/src/golang.org/x/net/publicsuffix/list.go | EffectiveTLDPlusOne | func EffectiveTLDPlusOne(domain string) (string, error) {
suffix, _ := PublicSuffix(domain)
if len(domain) <= len(suffix) {
return "", fmt.Errorf("publicsuffix: cannot derive eTLD+1 for domain %q", domain)
}
i := len(domain) - len(suffix) - 1
if domain[i] != '.' {
return "", fmt.Errorf("publicsuffix: invalid public suffix %q for domain %q", suffix, domain)
}
return domain[1+strings.LastIndex(domain[:i], "."):], nil
} | go | func EffectiveTLDPlusOne(domain string) (string, error) {
suffix, _ := PublicSuffix(domain)
if len(domain) <= len(suffix) {
return "", fmt.Errorf("publicsuffix: cannot derive eTLD+1 for domain %q", domain)
}
i := len(domain) - len(suffix) - 1
if domain[i] != '.' {
return "", fmt.Errorf("publicsuffix: invalid public suffix %q for domain %q", suffix, domain)
}
return domain[1+strings.LastIndex(domain[:i], "."):], nil
} | [
"func",
"EffectiveTLDPlusOne",
"(",
"domain",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"suffix",
",",
"_",
":=",
"PublicSuffix",
"(",
"domain",
")",
"\n",
"if",
"len",
"(",
"domain",
")",
"<=",
"len",
"(",
"suffix",
")",
"{",
"return",
"... | // EffectiveTLDPlusOne returns the effective top level domain plus one more
// label. For example, the eTLD+1 for "foo.bar.golang.org" is "golang.org". | [
"EffectiveTLDPlusOne",
"returns",
"the",
"effective",
"top",
"level",
"domain",
"plus",
"one",
"more",
"label",
".",
"For",
"example",
"the",
"eTLD",
"+",
"1",
"for",
"foo",
".",
"bar",
".",
"golang",
".",
"org",
"is",
"golang",
".",
"org",
"."
] | 7bc1d9087cbf90cda1083be2517da1f68909d66c | https://github.com/IBM-Cloud/go-cloudant-example/blob/7bc1d9087cbf90cda1083be2517da1f68909d66c/Godeps/_workspace/src/golang.org/x/net/publicsuffix/list.go#L123-L133 |
152,301 | simon-whitehead/relayr | relay.go | Call | func (r *Relay) Call(fn string, args ...interface{}) {
r.exchange.callRelayMethod(r, fn, args...)
} | go | func (r *Relay) Call(fn string, args ...interface{}) {
r.exchange.callRelayMethod(r, fn, args...)
} | [
"func",
"(",
"r",
"*",
"Relay",
")",
"Call",
"(",
"fn",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"r",
".",
"exchange",
".",
"callRelayMethod",
"(",
"r",
",",
"fn",
",",
"args",
"...",
")",
"\n",
"}"
] | // Call will execute a function on another server-side Relay,
// passing along the details of the currently connected client. | [
"Call",
"will",
"execute",
"a",
"function",
"on",
"another",
"server",
"-",
"side",
"Relay",
"passing",
"along",
"the",
"details",
"of",
"the",
"currently",
"connected",
"client",
"."
] | 3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5 | https://github.com/simon-whitehead/relayr/blob/3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5/relay.go#L20-L22 |
152,302 | simon-whitehead/relayr | relay.go | Groups | func (r *Relay) Groups(group string) *GroupOperations {
return &GroupOperations{
group: group,
e: r.exchange,
relay: r,
}
} | go | func (r *Relay) Groups(group string) *GroupOperations {
return &GroupOperations{
group: group,
e: r.exchange,
relay: r,
}
} | [
"func",
"(",
"r",
"*",
"Relay",
")",
"Groups",
"(",
"group",
"string",
")",
"*",
"GroupOperations",
"{",
"return",
"&",
"GroupOperations",
"{",
"group",
":",
"group",
",",
"e",
":",
"r",
".",
"exchange",
",",
"relay",
":",
"r",
",",
"}",
"\n",
"}"
... | // Groups returns a GroupOperations object, which offers helper
// methods for communicating with and grouping clients. | [
"Groups",
"returns",
"a",
"GroupOperations",
"object",
"which",
"offers",
"helper",
"methods",
"for",
"communicating",
"with",
"and",
"grouping",
"clients",
"."
] | 3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5 | https://github.com/simon-whitehead/relayr/blob/3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5/relay.go#L26-L32 |
152,303 | simon-whitehead/relayr | clientOps.go | All | func (c *ClientOperations) All(fn string, args ...interface{}) {
c.e.callGroupMethod(c.relay, "Global", fn, args...)
} | go | func (c *ClientOperations) All(fn string, args ...interface{}) {
c.e.callGroupMethod(c.relay, "Global", fn, args...)
} | [
"func",
"(",
"c",
"*",
"ClientOperations",
")",
"All",
"(",
"fn",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"e",
".",
"callGroupMethod",
"(",
"c",
".",
"relay",
",",
"\"",
"\"",
",",
"fn",
",",
"args",
"...",
")",
... | // All invokes a client side method on all clients for the
// given relay. | [
"All",
"invokes",
"a",
"client",
"side",
"method",
"on",
"all",
"clients",
"for",
"the",
"given",
"relay",
"."
] | 3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5 | https://github.com/simon-whitehead/relayr/blob/3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5/clientOps.go#L12-L14 |
152,304 | simon-whitehead/relayr | clientOps.go | Others | func (c *ClientOperations) Others(fn string, args ...interface{}) {
c.e.callGroupMethodExcept(c.relay, "Global", fn, args...)
} | go | func (c *ClientOperations) Others(fn string, args ...interface{}) {
c.e.callGroupMethodExcept(c.relay, "Global", fn, args...)
} | [
"func",
"(",
"c",
"*",
"ClientOperations",
")",
"Others",
"(",
"fn",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"e",
".",
"callGroupMethodExcept",
"(",
"c",
".",
"relay",
",",
"\"",
"\"",
",",
"fn",
",",
"args",
"...",... | // Others invokes a client side method on all clients except the
// one who calls it. | [
"Others",
"invokes",
"a",
"client",
"side",
"method",
"on",
"all",
"clients",
"except",
"the",
"one",
"who",
"calls",
"it",
"."
] | 3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5 | https://github.com/simon-whitehead/relayr/blob/3e5ef072cb350bd883ee7a74d76ec1b5c84e64f5/clientOps.go#L18-L20 |
152,305 | percona/exporter_shared | basic_auth.go | readBasicAuth | func readBasicAuth() *basicAuth {
var auth basicAuth
httpAuth := os.Getenv("HTTP_AUTH")
switch {
case *authFileF != "":
bytes, err := ioutil.ReadFile(*authFileF)
if err != nil {
log.Fatalf("cannot read auth file %q: %s", *authFileF, err)
}
if err = yaml.Unmarshal(bytes, &auth); err != nil {
log.Fatalf("cannot parse auth file %q: %s", *authFileF, err)
}
case httpAuth != "":
data := strings.SplitN(httpAuth, ":", 2)
if len(data) != 2 || data[0] == "" || data[1] == "" {
log.Fatalf("HTTP_AUTH should be formatted as user:password")
}
auth.Username = data[0]
auth.Password = data[1]
default:
// that's fine, return empty one below
}
return &auth
} | go | func readBasicAuth() *basicAuth {
var auth basicAuth
httpAuth := os.Getenv("HTTP_AUTH")
switch {
case *authFileF != "":
bytes, err := ioutil.ReadFile(*authFileF)
if err != nil {
log.Fatalf("cannot read auth file %q: %s", *authFileF, err)
}
if err = yaml.Unmarshal(bytes, &auth); err != nil {
log.Fatalf("cannot parse auth file %q: %s", *authFileF, err)
}
case httpAuth != "":
data := strings.SplitN(httpAuth, ":", 2)
if len(data) != 2 || data[0] == "" || data[1] == "" {
log.Fatalf("HTTP_AUTH should be formatted as user:password")
}
auth.Username = data[0]
auth.Password = data[1]
default:
// that's fine, return empty one below
}
return &auth
} | [
"func",
"readBasicAuth",
"(",
")",
"*",
"basicAuth",
"{",
"var",
"auth",
"basicAuth",
"\n",
"httpAuth",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"switch",
"{",
"case",
"*",
"authFileF",
"!=",
"\"",
"\"",
":",
"bytes",
",",
"err",
":=",
... | // readBasicAuth returns basicAuth from -web.auth-file file, or HTTP_AUTH environment variable, or empty one. | [
"readBasicAuth",
"returns",
"basicAuth",
"from",
"-",
"web",
".",
"auth",
"-",
"file",
"file",
"or",
"HTTP_AUTH",
"environment",
"variable",
"or",
"empty",
"one",
"."
] | 8986abb41c843706a15d64a3088c1aa39195c295 | https://github.com/percona/exporter_shared/blob/8986abb41c843706a15d64a3088c1aa39195c295/basic_auth.go#L41-L65 |
152,306 | percona/exporter_shared | basic_auth.go | authHandler | func authHandler(handler http.Handler) http.Handler {
auth := readBasicAuth()
if auth.Username != "" && auth.Password != "" {
log.Infoln("HTTP Basic authentication is enabled.")
return &basicAuthHandler{basicAuth: *auth, nextHandler: handler}
}
return handler
} | go | func authHandler(handler http.Handler) http.Handler {
auth := readBasicAuth()
if auth.Username != "" && auth.Password != "" {
log.Infoln("HTTP Basic authentication is enabled.")
return &basicAuthHandler{basicAuth: *auth, nextHandler: handler}
}
return handler
} | [
"func",
"authHandler",
"(",
"handler",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"auth",
":=",
"readBasicAuth",
"(",
")",
"\n",
"if",
"auth",
".",
"Username",
"!=",
"\"",
"\"",
"&&",
"auth",
".",
"Password",
"!=",
"\"",
"\"",
"{",
"lo... | // authHandler wraps provided handler with basic authentication if it is configured. | [
"authHandler",
"wraps",
"provided",
"handler",
"with",
"basic",
"authentication",
"if",
"it",
"is",
"configured",
"."
] | 8986abb41c843706a15d64a3088c1aa39195c295 | https://github.com/percona/exporter_shared/blob/8986abb41c843706a15d64a3088c1aa39195c295/basic_auth.go#L88-L96 |
152,307 | intelsdi-x/snap-plugin-utilities | source/simple.go | New | func New(cmd string, args []string) *simpleSource {
return &simpleSource{command: cmd, args: args}
} | go | func New(cmd string, args []string) *simpleSource {
return &simpleSource{command: cmd, args: args}
} | [
"func",
"New",
"(",
"cmd",
"string",
",",
"args",
"[",
"]",
"string",
")",
"*",
"simpleSource",
"{",
"return",
"&",
"simpleSource",
"{",
"command",
":",
"cmd",
",",
"args",
":",
"args",
"}",
"\n",
"}"
] | // New creates simple source as external program output.
// It takes command name and its arguments as parameters.
// It return pointer to new source object ready to execute. | [
"New",
"creates",
"simple",
"source",
"as",
"external",
"program",
"output",
".",
"It",
"takes",
"command",
"name",
"and",
"its",
"arguments",
"as",
"parameters",
".",
"It",
"return",
"pointer",
"to",
"new",
"source",
"object",
"ready",
"to",
"execute",
"."
... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/source/simple.go#L37-L39 |
152,308 | intelsdi-x/snap-plugin-utilities | source/simple.go | Run | func (ss *simpleSource) Run() error {
out, err := exec.Command(ss.command, ss.args...).Output()
if err != nil {
return err
}
ss.rawData = out
return nil
} | go | func (ss *simpleSource) Run() error {
out, err := exec.Command(ss.command, ss.args...).Output()
if err != nil {
return err
}
ss.rawData = out
return nil
} | [
"func",
"(",
"ss",
"*",
"simpleSource",
")",
"Run",
"(",
")",
"error",
"{",
"out",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"ss",
".",
"command",
",",
"ss",
".",
"args",
"...",
")",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // Run executes source command and gathers its output in internal structure.
// It returns nil in case of success and returns error if command execution failed. | [
"Run",
"executes",
"source",
"command",
"and",
"gathers",
"its",
"output",
"in",
"internal",
"structure",
".",
"It",
"returns",
"nil",
"in",
"case",
"of",
"success",
"and",
"returns",
"error",
"if",
"command",
"execution",
"failed",
"."
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/source/simple.go#L43-L52 |
152,309 | intelsdi-x/snap-plugin-utilities | source/simple.go | OutputMap | func (ss *simpleSource) OutputMap() map[string]interface{} {
var jsonMap map[string]interface{}
if err := json.Unmarshal(ss.rawData, &jsonMap); err != nil {
fmt.Println(err)
return nil
}
return jsonMap
} | go | func (ss *simpleSource) OutputMap() map[string]interface{} {
var jsonMap map[string]interface{}
if err := json.Unmarshal(ss.rawData, &jsonMap); err != nil {
fmt.Println(err)
return nil
}
return jsonMap
} | [
"func",
"(",
"ss",
"*",
"simpleSource",
")",
"OutputMap",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"var",
"jsonMap",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"... | // OutputMap translates json document data from command execution to a map.
// It returns map literals with its values, possibly nested maps and slices | [
"OutputMap",
"translates",
"json",
"document",
"data",
"from",
"command",
"execution",
"to",
"a",
"map",
".",
"It",
"returns",
"map",
"literals",
"with",
"its",
"values",
"possibly",
"nested",
"maps",
"and",
"slices"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/source/simple.go#L61-L68 |
152,310 | intelsdi-x/snap-plugin-utilities | str/set.go | Add | func (set *StringSet) Add(element string) bool {
_, found := set.set[element]
set.set[element] = true
return !found
} | go | func (set *StringSet) Add(element string) bool {
_, found := set.set[element]
set.set[element] = true
return !found
} | [
"func",
"(",
"set",
"*",
"StringSet",
")",
"Add",
"(",
"element",
"string",
")",
"bool",
"{",
"_",
",",
"found",
":=",
"set",
".",
"set",
"[",
"element",
"]",
"\n",
"set",
".",
"set",
"[",
"element",
"]",
"=",
"true",
"\n",
"return",
"!",
"found"... | // Add adds new item to set | [
"Add",
"adds",
"new",
"item",
"to",
"set"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/set.go#L28-L32 |
152,311 | intelsdi-x/snap-plugin-utilities | str/set.go | Delete | func (set *StringSet) Delete(element string) bool {
_, found := set.set[element]
if found {
delete(set.set, element)
}
return found
} | go | func (set *StringSet) Delete(element string) bool {
_, found := set.set[element]
if found {
delete(set.set, element)
}
return found
} | [
"func",
"(",
"set",
"*",
"StringSet",
")",
"Delete",
"(",
"element",
"string",
")",
"bool",
"{",
"_",
",",
"found",
":=",
"set",
".",
"set",
"[",
"element",
"]",
"\n",
"if",
"found",
"{",
"delete",
"(",
"set",
".",
"set",
",",
"element",
")",
"\n... | // Delete removes element from set | [
"Delete",
"removes",
"element",
"from",
"set"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/set.go#L35-L41 |
152,312 | intelsdi-x/snap-plugin-utilities | str/set.go | Elements | func (set *StringSet) Elements() []string {
iter := []string{}
for k := range set.set {
iter = append(iter, k)
}
return iter
} | go | func (set *StringSet) Elements() []string {
iter := []string{}
for k := range set.set {
iter = append(iter, k)
}
return iter
} | [
"func",
"(",
"set",
"*",
"StringSet",
")",
"Elements",
"(",
")",
"[",
"]",
"string",
"{",
"iter",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
":=",
"range",
"set",
".",
"set",
"{",
"iter",
"=",
"append",
"(",
"iter",
",",
"k",
")",
... | // Elements returns list of set elements | [
"Elements",
"returns",
"list",
"of",
"set",
"elements"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/set.go#L44-L50 |
152,313 | intelsdi-x/snap-plugin-utilities | str/strings.go | Contains | func Contains(slice []string, lookup string) bool {
for _, element := range slice {
if element == lookup {
return true
}
}
return false
} | go | func Contains(slice []string, lookup string) bool {
for _, element := range slice {
if element == lookup {
return true
}
}
return false
} | [
"func",
"Contains",
"(",
"slice",
"[",
"]",
"string",
",",
"lookup",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"element",
":=",
"range",
"slice",
"{",
"if",
"element",
"==",
"lookup",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
... | // Contains checks if 'lookup' argument is available in given 'slice'.
// Lookup element must be of type string.
// Returns true if there is at least one such element. | [
"Contains",
"checks",
"if",
"lookup",
"argument",
"is",
"available",
"in",
"given",
"slice",
".",
"Lookup",
"element",
"must",
"be",
"of",
"type",
"string",
".",
"Returns",
"true",
"if",
"there",
"is",
"at",
"least",
"one",
"such",
"element",
"."
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/strings.go#L33-L40 |
152,314 | intelsdi-x/snap-plugin-utilities | str/strings.go | Filter | func Filter(slice []string, handler func(string) bool) []string {
filtered := []string{}
for _, element := range slice {
if handler(element) {
filtered = append(filtered, element)
}
}
return filtered
} | go | func Filter(slice []string, handler func(string) bool) []string {
filtered := []string{}
for _, element := range slice {
if handler(element) {
filtered = append(filtered, element)
}
}
return filtered
} | [
"func",
"Filter",
"(",
"slice",
"[",
"]",
"string",
",",
"handler",
"func",
"(",
"string",
")",
"bool",
")",
"[",
"]",
"string",
"{",
"filtered",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"element",
":=",
"range",
"slice",
"{",
"... | // Filter filters slice to elements which fulfill handler function condition.
// It returns new, filtered slice. | [
"Filter",
"filters",
"slice",
"to",
"elements",
"which",
"fulfill",
"handler",
"function",
"condition",
".",
"It",
"returns",
"new",
"filtered",
"slice",
"."
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/strings.go#L44-L52 |
152,315 | intelsdi-x/snap-plugin-utilities | str/strings.go | Any | func Any(slice []string, handler func(string) bool) bool {
for _, element := range slice {
if handler(element) {
return true
}
}
return false
} | go | func Any(slice []string, handler func(string) bool) bool {
for _, element := range slice {
if handler(element) {
return true
}
}
return false
} | [
"func",
"Any",
"(",
"slice",
"[",
"]",
"string",
",",
"handler",
"func",
"(",
"string",
")",
"bool",
")",
"bool",
"{",
"for",
"_",
",",
"element",
":=",
"range",
"slice",
"{",
"if",
"handler",
"(",
"element",
")",
"{",
"return",
"true",
"\n",
"}",
... | // Any checks if there is at least one element in slice which fulfills handler function condition.
// Returns true if there is at lease one such element. | [
"Any",
"checks",
"if",
"there",
"is",
"at",
"least",
"one",
"element",
"in",
"slice",
"which",
"fulfills",
"handler",
"function",
"condition",
".",
"Returns",
"true",
"if",
"there",
"is",
"at",
"lease",
"one",
"such",
"element",
"."
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/strings.go#L56-L63 |
152,316 | intelsdi-x/snap-plugin-utilities | str/map.go | Keys | func (sm StringMap) Keys() []string {
keys := []string{}
for k := range sm {
keys = append(keys, k)
}
return keys
} | go | func (sm StringMap) Keys() []string {
keys := []string{}
for k := range sm {
keys = append(keys, k)
}
return keys
} | [
"func",
"(",
"sm",
"StringMap",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
":=",
"range",
"sm",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"k",
")",
"\n",
"}",
"\n",
"retur... | // Keys returns slice of map keys | [
"Keys",
"returns",
"slice",
"of",
"map",
"keys"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/map.go#L54-L60 |
152,317 | intelsdi-x/snap-plugin-utilities | str/map.go | HasKey | func (sm StringMap) HasKey(key string) bool {
_, found := sm[key]
return found
} | go | func (sm StringMap) HasKey(key string) bool {
_, found := sm[key]
return found
} | [
"func",
"(",
"sm",
"StringMap",
")",
"HasKey",
"(",
"key",
"string",
")",
"bool",
"{",
"_",
",",
"found",
":=",
"sm",
"[",
"key",
"]",
"\n",
"return",
"found",
"\n",
"}"
] | // HasKey checks if key exists in map | [
"HasKey",
"checks",
"if",
"key",
"exists",
"in",
"map"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/str/map.go#L72-L75 |
152,318 | vulcand/route | router.go | New | func New() Router {
return &router{
mutex: &sync.RWMutex{},
routes: make(map[string]*match),
}
} | go | func New() Router {
return &router{
mutex: &sync.RWMutex{},
routes: make(map[string]*match),
}
} | [
"func",
"New",
"(",
")",
"Router",
"{",
"return",
"&",
"router",
"{",
"mutex",
":",
"&",
"sync",
".",
"RWMutex",
"{",
"}",
",",
"routes",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"match",
")",
",",
"}",
"\n",
"}"
] | // New creates a new Router instance | [
"New",
"creates",
"a",
"new",
"Router",
"instance"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/router.go#L84-L89 |
152,319 | percona/exporter_shared | helpers/metric.go | ReadMetric | func ReadMetric(m prometheus.Metric) *Metric {
pb := &dto.Metric{}
if err := m.Write(pb); err != nil {
panic(err)
}
name, help := getNameAndHelp(m.Desc())
labels := make(prometheus.Labels, len(pb.Label))
for _, v := range pb.Label {
labels[v.GetName()] = v.GetValue()
}
if pb.Gauge != nil {
return &Metric{name, help, labels, dto.MetricType_GAUGE, pb.GetGauge().GetValue()}
}
if pb.Counter != nil {
return &Metric{name, help, labels, dto.MetricType_COUNTER, pb.GetCounter().GetValue()}
}
if pb.Untyped != nil {
return &Metric{name, help, labels, dto.MetricType_UNTYPED, pb.GetUntyped().GetValue()}
}
panic("Unsupported metric type")
} | go | func ReadMetric(m prometheus.Metric) *Metric {
pb := &dto.Metric{}
if err := m.Write(pb); err != nil {
panic(err)
}
name, help := getNameAndHelp(m.Desc())
labels := make(prometheus.Labels, len(pb.Label))
for _, v := range pb.Label {
labels[v.GetName()] = v.GetValue()
}
if pb.Gauge != nil {
return &Metric{name, help, labels, dto.MetricType_GAUGE, pb.GetGauge().GetValue()}
}
if pb.Counter != nil {
return &Metric{name, help, labels, dto.MetricType_COUNTER, pb.GetCounter().GetValue()}
}
if pb.Untyped != nil {
return &Metric{name, help, labels, dto.MetricType_UNTYPED, pb.GetUntyped().GetValue()}
}
panic("Unsupported metric type")
} | [
"func",
"ReadMetric",
"(",
"m",
"prometheus",
".",
"Metric",
")",
"*",
"Metric",
"{",
"pb",
":=",
"&",
"dto",
".",
"Metric",
"{",
"}",
"\n",
"if",
"err",
":=",
"m",
".",
"Write",
"(",
"pb",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err"... | // ReadMetric extracts details from Prometheus metric. | [
"ReadMetric",
"extracts",
"details",
"from",
"Prometheus",
"metric",
"."
] | 8986abb41c843706a15d64a3088c1aa39195c295 | https://github.com/percona/exporter_shared/blob/8986abb41c843706a15d64a3088c1aa39195c295/helpers/metric.go#L50-L71 |
152,320 | intelsdi-x/snap-plugin-utilities | stack/stack.go | Push | func (s *Stack) Push(value interface{}) {
s.top = &Element{value: value, next: s.top}
s.size++
} | go | func (s *Stack) Push(value interface{}) {
s.top = &Element{value: value, next: s.top}
s.size++
} | [
"func",
"(",
"s",
"*",
"Stack",
")",
"Push",
"(",
"value",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"top",
"=",
"&",
"Element",
"{",
"value",
":",
"value",
",",
"next",
":",
"s",
".",
"top",
"}",
"\n",
"s",
".",
"size",
"++",
"\n",
"}"
] | // Push value on top of stack | [
"Push",
"value",
"on",
"top",
"of",
"stack"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/stack/stack.go#L40-L43 |
152,321 | bitrise-io/gows | gows/gows.go | CreateCommand | func CreateCommand(cmdWorkdir string, gopath string, cmdName string, cmdArgs ...string) *exec.Cmd {
cmd := exec.Command(cmdName, cmdArgs...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = cmdWorkdir
//
cmdEnvs := os.Environ()
cmdEnvs = filteredEnvsList(cmdEnvs, "GOPATH")
cmdEnvs = filteredEnvsList(cmdEnvs, "PWD")
cmdEnvs = append(cmdEnvs,
fmt.Sprintf("GOPATH=%s", gopath),
fmt.Sprintf("PWD=%s", cmdWorkdir),
)
cmd.Env = cmdEnvs
return cmd
} | go | func CreateCommand(cmdWorkdir string, gopath string, cmdName string, cmdArgs ...string) *exec.Cmd {
cmd := exec.Command(cmdName, cmdArgs...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = cmdWorkdir
//
cmdEnvs := os.Environ()
cmdEnvs = filteredEnvsList(cmdEnvs, "GOPATH")
cmdEnvs = filteredEnvsList(cmdEnvs, "PWD")
cmdEnvs = append(cmdEnvs,
fmt.Sprintf("GOPATH=%s", gopath),
fmt.Sprintf("PWD=%s", cmdWorkdir),
)
cmd.Env = cmdEnvs
return cmd
} | [
"func",
"CreateCommand",
"(",
"cmdWorkdir",
"string",
",",
"gopath",
"string",
",",
"cmdName",
"string",
",",
"cmdArgs",
"...",
"string",
")",
"*",
"exec",
".",
"Cmd",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"cmdName",
",",
"cmdArgs",
"...",
")",
... | // CreateCommand creates a command, prepared to run
// in the isolated workspace environment. | [
"CreateCommand",
"creates",
"a",
"command",
"prepared",
"to",
"run",
"in",
"the",
"isolated",
"workspace",
"environment",
"."
] | 005d8a8baa6e3c6c76527554bb292061ef7d3af0 | https://github.com/bitrise-io/gows/blob/005d8a8baa6e3c6c76527554bb292061ef7d3af0/gows/gows.go#L88-L105 |
152,322 | karlseguin/bytepool | bytes.go | Write | func (b *Bytes) Write(data []byte) (n int, err error) {
b.bytes, n, err = b.write(data)
return n, err
} | go | func (b *Bytes) Write(data []byte) (n int, err error) {
b.bytes, n, err = b.write(data)
return n, err
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"b",
".",
"bytes",
",",
"n",
",",
"err",
"=",
"b",
".",
"write",
"(",
"data",
")",
"\n",
"return",
"n",
",",
... | // Write the bytes | [
"Write",
"the",
"bytes"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L63-L66 |
152,323 | karlseguin/bytepool | bytes.go | WriteByte | func (b *Bytes) WriteByte(d byte) (err error) {
b.bytes, err = b.writeByte(d)
return err
} | go | func (b *Bytes) WriteByte(d byte) (err error) {
b.bytes, err = b.writeByte(d)
return err
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"WriteByte",
"(",
"d",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"b",
".",
"bytes",
",",
"err",
"=",
"b",
".",
"writeByte",
"(",
"d",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Write a byte | [
"Write",
"a",
"byte"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L69-L72 |
152,324 | karlseguin/bytepool | bytes.go | WriteString | func (b *Bytes) WriteString(str string) (int, error) {
return b.Write([]byte(str))
} | go | func (b *Bytes) WriteString(str string) (int, error) {
return b.Write([]byte(str))
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"WriteString",
"(",
"str",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"b",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"str",
")",
")",
"\n",
"}"
] | // Write a string | [
"Write",
"a",
"string"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L119-L121 |
152,325 | karlseguin/bytepool | bytes.go | ReadFrom | func (b *Bytes) ReadFrom(r io.Reader) (n int64, err error) {
return b.ReadNFrom(0, r)
} | go | func (b *Bytes) ReadFrom(r io.Reader) (n int64, err error) {
return b.ReadNFrom(0, r)
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"ReadFrom",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"return",
"b",
".",
"ReadNFrom",
"(",
"0",
",",
"r",
")",
"\n",
"}"
] | // Read from the io.Reader | [
"Read",
"from",
"the",
"io",
".",
"Reader"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L124-L126 |
152,326 | karlseguin/bytepool | bytes.go | ReadNFrom | func (b *Bytes) ReadNFrom(n int64, r io.Reader) (m int64, err error) {
b.bytes, m, err = b.readNFrom(n, r)
return m, err
} | go | func (b *Bytes) ReadNFrom(n int64, r io.Reader) (m int64, err error) {
b.bytes, m, err = b.readNFrom(n, r)
return m, err
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"ReadNFrom",
"(",
"n",
"int64",
",",
"r",
"io",
".",
"Reader",
")",
"(",
"m",
"int64",
",",
"err",
"error",
")",
"{",
"b",
".",
"bytes",
",",
"m",
",",
"err",
"=",
"b",
".",
"readNFrom",
"(",
"n",
",",
"... | // Read N bytes from the io.Reader | [
"Read",
"N",
"bytes",
"from",
"the",
"io",
".",
"Reader"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L129-L132 |
152,327 | karlseguin/bytepool | bytes.go | Reset | func (b *Bytes) Reset() {
b.fixed.reset()
b.bytes = b.fixed
} | go | func (b *Bytes) Reset() {
b.fixed.reset()
b.bytes = b.fixed
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"Reset",
"(",
")",
"{",
"b",
".",
"fixed",
".",
"reset",
"(",
")",
"\n",
"b",
".",
"bytes",
"=",
"b",
".",
"fixed",
"\n",
"}"
] | // Reset the object without releasing it | [
"Reset",
"the",
"object",
"without",
"releasing",
"it"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L139-L142 |
152,328 | karlseguin/bytepool | bytes.go | Release | func (b *Bytes) Release() {
if b.pool != nil {
b.Reset()
b.pool.list <- b
}
} | go | func (b *Bytes) Release() {
if b.pool != nil {
b.Reset()
b.pool.list <- b
}
} | [
"func",
"(",
"b",
"*",
"Bytes",
")",
"Release",
"(",
")",
"{",
"if",
"b",
".",
"pool",
"!=",
"nil",
"{",
"b",
".",
"Reset",
"(",
")",
"\n",
"b",
".",
"pool",
".",
"list",
"<-",
"b",
"\n",
"}",
"\n",
"}"
] | // Release the item back into the pool | [
"Release",
"the",
"item",
"back",
"into",
"the",
"pool"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/bytes.go#L145-L150 |
152,329 | percona/exporter_shared | helpers/format.go | Format | func Format(metrics []prometheus.Metric) []string {
r := prometheus.NewRegistry()
r.MustRegister(&collector{metrics: metrics})
families, err := r.Gather()
if err != nil {
panic(err)
}
var buf strings.Builder
e := expfmt.NewEncoder(&buf, expfmt.FmtText)
for _, f := range families {
if err = e.Encode(f); err != nil {
panic(err)
}
}
return strings.Split(strings.TrimSpace(buf.String()), "\n")
} | go | func Format(metrics []prometheus.Metric) []string {
r := prometheus.NewRegistry()
r.MustRegister(&collector{metrics: metrics})
families, err := r.Gather()
if err != nil {
panic(err)
}
var buf strings.Builder
e := expfmt.NewEncoder(&buf, expfmt.FmtText)
for _, f := range families {
if err = e.Encode(f); err != nil {
panic(err)
}
}
return strings.Split(strings.TrimSpace(buf.String()), "\n")
} | [
"func",
"Format",
"(",
"metrics",
"[",
"]",
"prometheus",
".",
"Metric",
")",
"[",
"]",
"string",
"{",
"r",
":=",
"prometheus",
".",
"NewRegistry",
"(",
")",
"\n",
"r",
".",
"MustRegister",
"(",
"&",
"collector",
"{",
"metrics",
":",
"metrics",
"}",
... | // Format converts a slice of Prometheus metrics to strings in text exposition format. | [
"Format",
"converts",
"a",
"slice",
"of",
"Prometheus",
"metrics",
"to",
"strings",
"in",
"text",
"exposition",
"format",
"."
] | 8986abb41c843706a15d64a3088c1aa39195c295 | https://github.com/percona/exporter_shared/blob/8986abb41c843706a15d64a3088c1aa39195c295/helpers/format.go#L41-L57 |
152,330 | intelsdi-x/snap-plugin-utilities | source/source.go | Generate | func (s *Source) Generate(out chan interface{}, ech chan error) {
cmd := exec.Command(s.Command, s.Args...)
if s.Pdeathsig != nil {
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: *s.Pdeathsig}
}
reader, err := cmd.StdoutPipe()
if err != nil {
ech <- err
close(ech)
return
}
scanner := bufio.NewScanner(reader)
var done sync.WaitGroup
done.Add(1)
go func() {
for scanner.Scan() {
out <- scanner.Text()
}
close(out)
done.Done()
}()
if err = cmd.Start(); err != nil {
ech <- err
close(ech)
return
}
done.Wait()
status := cmd.Wait()
var waitStatus syscall.WaitStatus
waitStatus = cmd.ProcessState.Sys().(syscall.WaitStatus)
if waitStatus.ExitStatus() > 0 {
ech <- status
close(ech)
return
}
} | go | func (s *Source) Generate(out chan interface{}, ech chan error) {
cmd := exec.Command(s.Command, s.Args...)
if s.Pdeathsig != nil {
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: *s.Pdeathsig}
}
reader, err := cmd.StdoutPipe()
if err != nil {
ech <- err
close(ech)
return
}
scanner := bufio.NewScanner(reader)
var done sync.WaitGroup
done.Add(1)
go func() {
for scanner.Scan() {
out <- scanner.Text()
}
close(out)
done.Done()
}()
if err = cmd.Start(); err != nil {
ech <- err
close(ech)
return
}
done.Wait()
status := cmd.Wait()
var waitStatus syscall.WaitStatus
waitStatus = cmd.ProcessState.Sys().(syscall.WaitStatus)
if waitStatus.ExitStatus() > 0 {
ech <- status
close(ech)
return
}
} | [
"func",
"(",
"s",
"*",
"Source",
")",
"Generate",
"(",
"out",
"chan",
"interface",
"{",
"}",
",",
"ech",
"chan",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"s",
".",
"Command",
",",
"s",
".",
"Args",
"...",
")",
"\n",
"if",
"s... | // Generate implements Sourcer interface on Source object.
// It takes output and error channel as arguments.
// Output channel is used to convey output produced by external command.
// Error channel is used to convey errors produced by external command.
// It checks exit status of command and in case it was different then 0, it sends error. | [
"Generate",
"implements",
"Sourcer",
"interface",
"on",
"Source",
"object",
".",
"It",
"takes",
"output",
"and",
"error",
"channel",
"as",
"arguments",
".",
"Output",
"channel",
"is",
"used",
"to",
"convey",
"output",
"produced",
"by",
"external",
"command",
"... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/source/source.go#L46-L87 |
152,331 | vulcand/route | trie.go | newTrieMatcher | func newTrieMatcher(expression string, mapper requestMapper, result *match) (*trie, error) {
t := &trie{
mapper: mapper,
}
t.root = &trieNode{trie: t}
if len(expression) == 0 {
return nil, fmt.Errorf("Empty URL expression")
}
err := t.root.parseExpression(-1, expression, result)
if err != nil {
return nil, err
}
return t, nil
} | go | func newTrieMatcher(expression string, mapper requestMapper, result *match) (*trie, error) {
t := &trie{
mapper: mapper,
}
t.root = &trieNode{trie: t}
if len(expression) == 0 {
return nil, fmt.Errorf("Empty URL expression")
}
err := t.root.parseExpression(-1, expression, result)
if err != nil {
return nil, err
}
return t, nil
} | [
"func",
"newTrieMatcher",
"(",
"expression",
"string",
",",
"mapper",
"requestMapper",
",",
"result",
"*",
"match",
")",
"(",
"*",
"trie",
",",
"error",
")",
"{",
"t",
":=",
"&",
"trie",
"{",
"mapper",
":",
"mapper",
",",
"}",
"\n",
"t",
".",
"root",... | // Takes the expression with url and the node that corresponds to this expression and returns parsed trie | [
"Takes",
"the",
"expression",
"with",
"url",
"and",
"the",
"node",
"that",
"corresponds",
"to",
"this",
"expression",
"and",
"returns",
"parsed",
"trie"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/trie.go#L51-L64 |
152,332 | vulcand/route | trie.go | canMerge | func (t *trie) canMerge(m matcher) bool {
ot, ok := m.(*trie)
return ok && t.mapper.equivalent(ot.mapper) != nil
} | go | func (t *trie) canMerge(m matcher) bool {
ot, ok := m.(*trie)
return ok && t.mapper.equivalent(ot.mapper) != nil
} | [
"func",
"(",
"t",
"*",
"trie",
")",
"canMerge",
"(",
"m",
"matcher",
")",
"bool",
"{",
"ot",
",",
"ok",
":=",
"m",
".",
"(",
"*",
"trie",
")",
"\n",
"return",
"ok",
"&&",
"t",
".",
"mapper",
".",
"equivalent",
"(",
"ot",
".",
"mapper",
")",
"... | // Tries can merge with other tries | [
"Tries",
"can",
"merge",
"with",
"other",
"tries"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/trie.go#L71-L74 |
152,333 | vulcand/route | trie.go | match | func (p *trie) match(r *http.Request) *match {
if p.root == nil {
return nil
}
return p.root.match(p.mapper.newIter(r))
} | go | func (p *trie) match(r *http.Request) *match {
if p.root == nil {
return nil
}
return p.root.match(p.mapper.newIter(r))
} | [
"func",
"(",
"p",
"*",
"trie",
")",
"match",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"match",
"{",
"if",
"p",
".",
"root",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"p",
".",
"root",
".",
"match",
"(",
"p",
".",
... | // Takes the request and returns the location if the request path matches any of it's paths
// returns nil if none of the requests matches | [
"Takes",
"the",
"request",
"and",
"returns",
"the",
"location",
"if",
"the",
"request",
"path",
"matches",
"any",
"of",
"it",
"s",
"paths",
"returns",
"nil",
"if",
"none",
"of",
"the",
"requests",
"matches"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/trie.go#L98-L103 |
152,334 | intelsdi-x/snap-plugin-utilities | pipeline/pipeline.go | Next | func (p Pipe) Next(proc Processor) Pipe {
outPipe := make(Pipe)
go proc.Run(p, outPipe)
return outPipe
} | go | func (p Pipe) Next(proc Processor) Pipe {
outPipe := make(Pipe)
go proc.Run(p, outPipe)
return outPipe
} | [
"func",
"(",
"p",
"Pipe",
")",
"Next",
"(",
"proc",
"Processor",
")",
"Pipe",
"{",
"outPipe",
":=",
"make",
"(",
"Pipe",
")",
"\n",
"go",
"proc",
".",
"Run",
"(",
"p",
",",
"outPipe",
")",
"\n",
"return",
"outPipe",
"\n",
"}"
] | // Next sets up following pipeline chain element
// It returns last Pipe in Pipeline | [
"Next",
"sets",
"up",
"following",
"pipeline",
"chain",
"element",
"It",
"returns",
"last",
"Pipe",
"in",
"Pipeline"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/pipeline/pipeline.go#L36-L40 |
152,335 | vulcand/route | parse.go | IsValid | func IsValid(expr string) bool {
_, err := parse(expr, &match{})
return err == nil
} | go | func IsValid(expr string) bool {
_, err := parse(expr, &match{})
return err == nil
} | [
"func",
"IsValid",
"(",
"expr",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"parse",
"(",
"expr",
",",
"&",
"match",
"{",
"}",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"
] | // IsValid checks whether expression is valid | [
"IsValid",
"checks",
"whether",
"expression",
"is",
"valid"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/parse.go#L10-L13 |
152,336 | vulcand/route | mux.go | InitHandlers | func (m *Mux) InitHandlers(handlers map[string]interface{}) error {
return m.router.InitRoutes(handlers)
} | go | func (m *Mux) InitHandlers(handlers map[string]interface{}) error {
return m.router.InitRoutes(handlers)
} | [
"func",
"(",
"m",
"*",
"Mux",
")",
"InitHandlers",
"(",
"handlers",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"m",
".",
"router",
".",
"InitRoutes",
"(",
"handlers",
")",
"\n",
"}"
] | // This adds a map of handlers and expressions in a single call. This allows
// init to load many rules on first startup, thus reducing the time it takes to
// create the initial mux. | [
"This",
"adds",
"a",
"map",
"of",
"handlers",
"and",
"expressions",
"in",
"a",
"single",
"call",
".",
"This",
"allows",
"init",
"to",
"load",
"many",
"rules",
"on",
"first",
"startup",
"thus",
"reducing",
"the",
"time",
"it",
"takes",
"to",
"create",
"th... | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/mux.go#L26-L28 |
152,337 | vulcand/route | mux.go | Handle | func (m *Mux) Handle(expr string, handler http.Handler) error {
return m.router.UpsertRoute(expr, handler)
} | go | func (m *Mux) Handle(expr string, handler http.Handler) error {
return m.router.UpsertRoute(expr, handler)
} | [
"func",
"(",
"m",
"*",
"Mux",
")",
"Handle",
"(",
"expr",
"string",
",",
"handler",
"http",
".",
"Handler",
")",
"error",
"{",
"return",
"m",
".",
"router",
".",
"UpsertRoute",
"(",
"expr",
",",
"handler",
")",
"\n",
"}"
] | // Handle adds http handler for route expression | [
"Handle",
"adds",
"http",
"handler",
"for",
"route",
"expression"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/mux.go#L31-L33 |
152,338 | vulcand/route | mux.go | HandleFunc | func (m *Mux) HandleFunc(expr string, handler func(http.ResponseWriter, *http.Request)) error {
return m.Handle(expr, http.HandlerFunc(handler))
} | go | func (m *Mux) HandleFunc(expr string, handler func(http.ResponseWriter, *http.Request)) error {
return m.Handle(expr, http.HandlerFunc(handler))
} | [
"func",
"(",
"m",
"*",
"Mux",
")",
"HandleFunc",
"(",
"expr",
"string",
",",
"handler",
"func",
"(",
"http",
".",
"ResponseWriter",
",",
"*",
"http",
".",
"Request",
")",
")",
"error",
"{",
"return",
"m",
".",
"Handle",
"(",
"expr",
",",
"http",
".... | // Handle adds http handler function for route expression | [
"Handle",
"adds",
"http",
"handler",
"function",
"for",
"route",
"expression"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/mux.go#L36-L38 |
152,339 | vulcand/route | mux.go | ServeHTTP | func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h, err := m.router.Route(r)
if err != nil || h == nil {
m.notFound.ServeHTTP(w, r)
return
}
h.(http.Handler).ServeHTTP(w, r)
} | go | func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h, err := m.router.Route(r)
if err != nil || h == nil {
m.notFound.ServeHTTP(w, r)
return
}
h.(http.Handler).ServeHTTP(w, r)
} | [
"func",
"(",
"m",
"*",
"Mux",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"h",
",",
"err",
":=",
"m",
".",
"router",
".",
"Route",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // ServeHTTP routes the request and passes it to handler | [
"ServeHTTP",
"routes",
"the",
"request",
"and",
"passes",
"it",
"to",
"handler"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/mux.go#L45-L52 |
152,340 | vulcand/route | mux.go | ServeHTTP | func (notFound) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "Not found")
} | go | func (notFound) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "Not found")
} | [
"func",
"(",
"notFound",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"w",
".",
"WriteHeader",
... | // ServeHTTP returns a simple 404 Not found response | [
"ServeHTTP",
"returns",
"a",
"simple",
"404",
"Not",
"found",
"response"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/mux.go#L75-L80 |
152,341 | intelsdi-x/snap-plugin-utilities | config/config.go | getConfigItemValue | func getConfigItemValue(item ctypes.ConfigValue) (interface{}, error) {
var value interface{}
switch item.Type() {
case "string":
value = item.(ctypes.ConfigValueStr).Value
break
case "float":
value = item.(ctypes.ConfigValueFloat).Value
break
case "integer":
value = item.(ctypes.ConfigValueInt).Value
break
case "bool":
value = item.(ctypes.ConfigValueBool).Value
break
default:
return nil, fmt.Errorf("Unsupported type of configuration item, type=%v", item.Type())
}
return value, nil
} | go | func getConfigItemValue(item ctypes.ConfigValue) (interface{}, error) {
var value interface{}
switch item.Type() {
case "string":
value = item.(ctypes.ConfigValueStr).Value
break
case "float":
value = item.(ctypes.ConfigValueFloat).Value
break
case "integer":
value = item.(ctypes.ConfigValueInt).Value
break
case "bool":
value = item.(ctypes.ConfigValueBool).Value
break
default:
return nil, fmt.Errorf("Unsupported type of configuration item, type=%v", item.Type())
}
return value, nil
} | [
"func",
"getConfigItemValue",
"(",
"item",
"ctypes",
".",
"ConfigValue",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"value",
"interface",
"{",
"}",
"\n\n",
"switch",
"item",
".",
"Type",
"(",
")",
"{",
"case",
"\"",
"\"",
":",
"v... | // getConfigItemValue returns value of configuration item | [
"getConfigItemValue",
"returns",
"value",
"of",
"configuration",
"item"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/config/config.go#L30-L56 |
152,342 | vulcand/route | iter.go | next | func (r *charIter) next() (byte, byte, bool) {
// we have reached the last string in the index, end
if r.isEnd() {
return 0, 0, false
}
b := r.seq[r.si][r.i]
sep := r.sep[r.si]
r.i++
// current string index exceeded the last char of the current string
// move to the next string if it's present
if r.i >= len(r.seq[r.si]) && r.si < len(r.seq)-1 {
r.si++
r.i = 0
}
return b, sep, true
} | go | func (r *charIter) next() (byte, byte, bool) {
// we have reached the last string in the index, end
if r.isEnd() {
return 0, 0, false
}
b := r.seq[r.si][r.i]
sep := r.sep[r.si]
r.i++
// current string index exceeded the last char of the current string
// move to the next string if it's present
if r.i >= len(r.seq[r.si]) && r.si < len(r.seq)-1 {
r.si++
r.i = 0
}
return b, sep, true
} | [
"func",
"(",
"r",
"*",
"charIter",
")",
"next",
"(",
")",
"(",
"byte",
",",
"byte",
",",
"bool",
")",
"{",
"// we have reached the last string in the index, end",
"if",
"r",
".",
"isEnd",
"(",
")",
"{",
"return",
"0",
",",
"0",
",",
"false",
"\n",
"}",... | // next returns current byte in the sequence, separator corresponding to that byte, and boolean idicator of whether it's the end of the sequence | [
"next",
"returns",
"current",
"byte",
"in",
"the",
"sequence",
"separator",
"corresponding",
"to",
"that",
"byte",
"and",
"boolean",
"idicator",
"of",
"whether",
"it",
"s",
"the",
"end",
"of",
"the",
"sequence"
] | 58b44163b96852a2198ccdff734112df02184c34 | https://github.com/vulcand/route/blob/58b44163b96852a2198ccdff734112df02184c34/iter.go#L70-L88 |
152,343 | karlseguin/bytepool | pool.go | Checkout | func (p *Pool) Checkout() *Bytes {
select {
case bytes := <-p.list:
return bytes
default:
atomic.AddInt64(&p.depleted, 1)
return NewEndianBytes(p.size, p.enc)
}
} | go | func (p *Pool) Checkout() *Bytes {
select {
case bytes := <-p.list:
return bytes
default:
atomic.AddInt64(&p.depleted, 1)
return NewEndianBytes(p.size, p.enc)
}
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Checkout",
"(",
")",
"*",
"Bytes",
"{",
"select",
"{",
"case",
"bytes",
":=",
"<-",
"p",
".",
"list",
":",
"return",
"bytes",
"\n",
"default",
":",
"atomic",
".",
"AddInt64",
"(",
"&",
"p",
".",
"depleted",
",... | // Get an item from the pool | [
"Get",
"an",
"item",
"from",
"the",
"pool"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/pool.go#L38-L46 |
152,344 | karlseguin/bytepool | pool.go | Stats | func (p *Pool) Stats() map[string]int64 {
p.stats["depleted"] = p.Depleted()
p.stats["expanded"] = p.Expanded()
return p.stats
} | go | func (p *Pool) Stats() map[string]int64 {
p.stats["depleted"] = p.Depleted()
p.stats["expanded"] = p.Expanded()
return p.stats
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Stats",
"(",
")",
"map",
"[",
"string",
"]",
"int64",
"{",
"p",
".",
"stats",
"[",
"\"",
"\"",
"]",
"=",
"p",
".",
"Depleted",
"(",
")",
"\n",
"p",
".",
"stats",
"[",
"\"",
"\"",
"]",
"=",
"p",
".",
"E... | // A map containing the "expanded" and "depleted" count
// Call this resets both counters | [
"A",
"map",
"containing",
"the",
"expanded",
"and",
"depleted",
"count",
"Call",
"this",
"resets",
"both",
"counters"
] | f088ef2719bd222fe8c29e3dcd72e0b8c007ac87 | https://github.com/karlseguin/bytepool/blob/f088ef2719bd222fe8c29e3dcd72e0b8c007ac87/pool.go#L84-L88 |
152,345 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | FromMap | func FromMap(m map[string]interface{}, current string, namespace *[]string) error {
return FromCompositeObject(m, current, namespace,
InspectNilPointers(AlwaysFalse),
InspectEmptyContainers(AlwaysFalse),
ExportJsonFieldNames(AlwaysFalse))
} | go | func FromMap(m map[string]interface{}, current string, namespace *[]string) error {
return FromCompositeObject(m, current, namespace,
InspectNilPointers(AlwaysFalse),
InspectEmptyContainers(AlwaysFalse),
ExportJsonFieldNames(AlwaysFalse))
} | [
"func",
"FromMap",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"current",
"string",
",",
"namespace",
"*",
"[",
"]",
"string",
")",
"error",
"{",
"return",
"FromCompositeObject",
"(",
"m",
",",
"current",
",",
"namespace",
",",
"In... | // FromMap constructs list of namespaces from multilevel map using map keys as namespace entries.
// 'Current' value is prefixed to all namespace elements.
// It returns nil in case of success or error if building namespaces failed. | [
"FromMap",
"constructs",
"list",
"of",
"namespaces",
"from",
"multilevel",
"map",
"using",
"map",
"keys",
"as",
"namespace",
"entries",
".",
"Current",
"value",
"is",
"prefixed",
"to",
"all",
"namespace",
"elements",
".",
"It",
"returns",
"nil",
"in",
"case",
... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L56-L61 |
152,346 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | FromJSON | func FromJSON(data *[]byte, current string, namespace *[]string) error {
var m map[string]interface{}
err := json.Unmarshal(*data, &m)
if err != nil {
return err
}
return FromMap(m, current, namespace)
} | go | func FromJSON(data *[]byte, current string, namespace *[]string) error {
var m map[string]interface{}
err := json.Unmarshal(*data, &m)
if err != nil {
return err
}
return FromMap(m, current, namespace)
} | [
"func",
"FromJSON",
"(",
"data",
"*",
"[",
"]",
"byte",
",",
"current",
"string",
",",
"namespace",
"*",
"[",
"]",
"string",
")",
"error",
"{",
"var",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal... | // FromJSON constructs list of namespaces from json document using json literals as namespace entries.
// 'Current' value is prefixed to all namespace elements.
// It returns nil in case of success or error if building namespaces failed. | [
"FromJSON",
"constructs",
"list",
"of",
"namespaces",
"from",
"json",
"document",
"using",
"json",
"literals",
"as",
"namespace",
"entries",
".",
"Current",
"value",
"is",
"prefixed",
"to",
"all",
"namespace",
"elements",
".",
"It",
"returns",
"nil",
"in",
"ca... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L66-L76 |
152,347 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | FromComposition | func FromComposition(object interface{}, current string, namespace *[]string) error {
return FromCompositeObject(object, current, namespace,
InspectNilPointers(AlwaysFalse),
InspectEmptyContainers(AlwaysFalse),
ExportJsonFieldNames(AlwaysFalse))
} | go | func FromComposition(object interface{}, current string, namespace *[]string) error {
return FromCompositeObject(object, current, namespace,
InspectNilPointers(AlwaysFalse),
InspectEmptyContainers(AlwaysFalse),
ExportJsonFieldNames(AlwaysFalse))
} | [
"func",
"FromComposition",
"(",
"object",
"interface",
"{",
"}",
",",
"current",
"string",
",",
"namespace",
"*",
"[",
"]",
"string",
")",
"error",
"{",
"return",
"FromCompositeObject",
"(",
"object",
",",
"current",
",",
"namespace",
",",
"InspectNilPointers"... | // FromComposition constructs list of namespaces from multilevel struct compositions using field names as namespace entries.
// 'Current' value is prefixed to all namespace elements.
// It returns nil in case of success or error if building namespaces failed. | [
"FromComposition",
"constructs",
"list",
"of",
"namespaces",
"from",
"multilevel",
"struct",
"compositions",
"using",
"field",
"names",
"as",
"namespace",
"entries",
".",
"Current",
"value",
"is",
"prefixed",
"to",
"all",
"namespace",
"elements",
".",
"It",
"retur... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L81-L86 |
152,348 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | FromCompositionTags | func FromCompositionTags(object interface{}, current string, namespace *[]string) error {
return FromCompositeObject(object, current, namespace,
InspectNilPointers(AlwaysFalse),
InspectEmptyContainers(AlwaysFalse))
} | go | func FromCompositionTags(object interface{}, current string, namespace *[]string) error {
return FromCompositeObject(object, current, namespace,
InspectNilPointers(AlwaysFalse),
InspectEmptyContainers(AlwaysFalse))
} | [
"func",
"FromCompositionTags",
"(",
"object",
"interface",
"{",
"}",
",",
"current",
"string",
",",
"namespace",
"*",
"[",
"]",
"string",
")",
"error",
"{",
"return",
"FromCompositeObject",
"(",
"object",
",",
"current",
",",
"namespace",
",",
"InspectNilPoint... | // FromCompositionTags constructs list of namespaces from multilevel struct composition using field tags as namespace entries.
// 'Current' value is prefixed to all namespace elements.
// It returns nil in case of success or error if building namespaces failed. | [
"FromCompositionTags",
"constructs",
"list",
"of",
"namespaces",
"from",
"multilevel",
"struct",
"composition",
"using",
"field",
"tags",
"as",
"namespace",
"entries",
".",
"Current",
"value",
"is",
"prefixed",
"to",
"all",
"namespace",
"elements",
".",
"It",
"ret... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L91-L95 |
152,349 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | GetStructValueByNamespace | func GetStructValueByNamespace(object interface{}, ns []string) interface{} {
// current level of namespace
current := ns[0]
fields, err := reflections.Fields(object)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not return fields for object{%v}\n", object)
return nil
}
for _, field := range fields {
tag, err := reflections.GetFieldTag(object, field, "json")
if err != nil {
fmt.Fprintf(os.Stderr, "Could not find tag for field{%s}\n", field)
return nil
}
// remove omitempty from tag
tag = strings.Split(tag, ",")[0]
if tag == current {
val, err := reflections.GetField(object, field)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not retrieve field{%s}\n", field)
return nil
}
// handling of special cases for slice and map
switch reflect.TypeOf(val).Kind() {
case reflect.Slice:
idx, _ := strconv.Atoi(ns[1])
val := reflect.ValueOf(val)
if val.Index(idx).Kind() == reflect.Struct {
return GetStructValueByNamespace(val.Index(idx).Interface(), ns[2:])
} else {
return val.Index(idx).Interface()
}
case reflect.Map:
key := ns[1]
if vi, ok := val.(map[string]uint64); ok {
return vi[key]
}
val := reflect.ValueOf(val)
kval := reflect.ValueOf(key)
if reflect.TypeOf(val.MapIndex(kval).Interface()).Kind() == reflect.Struct {
return GetStructValueByNamespace(val.MapIndex(kval).Interface(), ns[2:])
}
case reflect.Ptr:
v := reflect.Indirect(reflect.ValueOf(val))
if !v.IsValid() || !v.CanInterface() {
// If reflect can't call Interface() on v, we can't go deeper even if
// len(ns) > 1. Therefore, we should just return nil here.
return nil
}
if len(ns) == 1 {
return v.Interface()
} else {
return GetStructValueByNamespace(v.Interface(), ns[1:])
}
default:
// last ns, return value found
if len(ns) == 1 {
return val
} else {
// or go deeper
return GetStructValueByNamespace(val, ns[1:])
}
}
}
}
return nil
} | go | func GetStructValueByNamespace(object interface{}, ns []string) interface{} {
// current level of namespace
current := ns[0]
fields, err := reflections.Fields(object)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not return fields for object{%v}\n", object)
return nil
}
for _, field := range fields {
tag, err := reflections.GetFieldTag(object, field, "json")
if err != nil {
fmt.Fprintf(os.Stderr, "Could not find tag for field{%s}\n", field)
return nil
}
// remove omitempty from tag
tag = strings.Split(tag, ",")[0]
if tag == current {
val, err := reflections.GetField(object, field)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not retrieve field{%s}\n", field)
return nil
}
// handling of special cases for slice and map
switch reflect.TypeOf(val).Kind() {
case reflect.Slice:
idx, _ := strconv.Atoi(ns[1])
val := reflect.ValueOf(val)
if val.Index(idx).Kind() == reflect.Struct {
return GetStructValueByNamespace(val.Index(idx).Interface(), ns[2:])
} else {
return val.Index(idx).Interface()
}
case reflect.Map:
key := ns[1]
if vi, ok := val.(map[string]uint64); ok {
return vi[key]
}
val := reflect.ValueOf(val)
kval := reflect.ValueOf(key)
if reflect.TypeOf(val.MapIndex(kval).Interface()).Kind() == reflect.Struct {
return GetStructValueByNamespace(val.MapIndex(kval).Interface(), ns[2:])
}
case reflect.Ptr:
v := reflect.Indirect(reflect.ValueOf(val))
if !v.IsValid() || !v.CanInterface() {
// If reflect can't call Interface() on v, we can't go deeper even if
// len(ns) > 1. Therefore, we should just return nil here.
return nil
}
if len(ns) == 1 {
return v.Interface()
} else {
return GetStructValueByNamespace(v.Interface(), ns[1:])
}
default:
// last ns, return value found
if len(ns) == 1 {
return val
} else {
// or go deeper
return GetStructValueByNamespace(val, ns[1:])
}
}
}
}
return nil
} | [
"func",
"GetStructValueByNamespace",
"(",
"object",
"interface",
"{",
"}",
",",
"ns",
"[",
"]",
"string",
")",
"interface",
"{",
"}",
"{",
"// current level of namespace",
"current",
":=",
"ns",
"[",
"0",
"]",
"\n\n",
"fields",
",",
"err",
":=",
"reflections... | // GetStructValueByNamespace returns value stored in struct composition.
// It requires filed tags on each struct field which may be represented as namespace component.
// It iterates over fields recursively, checks tags until it finds leaf value. | [
"GetStructValueByNamespace",
"returns",
"value",
"stored",
"in",
"struct",
"composition",
".",
"It",
"requires",
"filed",
"tags",
"on",
"each",
"struct",
"field",
"which",
"may",
"be",
"represented",
"as",
"namespace",
"component",
".",
"It",
"iterates",
"over",
... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L158-L231 |
152,350 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | ReplaceNotAllowedCharsInNamespacePart | func ReplaceNotAllowedCharsInNamespacePart(ns string) string {
for _, chars := range notAllowedChars {
for _, ch := range chars {
ns = strings.Replace(ns, ch, "_", -1)
ns = strings.Replace(ns, "__", "_", -1)
}
}
ns = strings.Trim(ns, "_")
return ns
} | go | func ReplaceNotAllowedCharsInNamespacePart(ns string) string {
for _, chars := range notAllowedChars {
for _, ch := range chars {
ns = strings.Replace(ns, ch, "_", -1)
ns = strings.Replace(ns, "__", "_", -1)
}
}
ns = strings.Trim(ns, "_")
return ns
} | [
"func",
"ReplaceNotAllowedCharsInNamespacePart",
"(",
"ns",
"string",
")",
"string",
"{",
"for",
"_",
",",
"chars",
":=",
"range",
"notAllowedChars",
"{",
"for",
"_",
",",
"ch",
":=",
"range",
"chars",
"{",
"ns",
"=",
"strings",
".",
"Replace",
"(",
"ns",
... | //ReplaceNotAllowedCharsInNamespacePart replaces not allowed characters in namespace part by '_' | [
"ReplaceNotAllowedCharsInNamespacePart",
"replaces",
"not",
"allowed",
"characters",
"in",
"namespace",
"part",
"by",
"_"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L234-L243 |
152,351 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | ValidateMetricNamespacePart | func ValidateMetricNamespacePart(ns string) error {
for _, chars := range notAllowedChars {
for _, ch := range chars {
if strings.ContainsAny(ns, ch) {
return fmt.Errorf("Namespace contains not allowed chars, namespace part: %s, not allowed char: %s", ns, ch)
}
}
}
return nil
} | go | func ValidateMetricNamespacePart(ns string) error {
for _, chars := range notAllowedChars {
for _, ch := range chars {
if strings.ContainsAny(ns, ch) {
return fmt.Errorf("Namespace contains not allowed chars, namespace part: %s, not allowed char: %s", ns, ch)
}
}
}
return nil
} | [
"func",
"ValidateMetricNamespacePart",
"(",
"ns",
"string",
")",
"error",
"{",
"for",
"_",
",",
"chars",
":=",
"range",
"notAllowedChars",
"{",
"for",
"_",
",",
"ch",
":=",
"range",
"chars",
"{",
"if",
"strings",
".",
"ContainsAny",
"(",
"ns",
",",
"ch",... | //ValidateMetricNamespacePart checks if namespace part contains not allowed characters | [
"ValidateMetricNamespacePart",
"checks",
"if",
"namespace",
"part",
"contains",
"not",
"allowed",
"characters"
] | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L246-L255 |
152,352 | intelsdi-x/snap-plugin-utilities | ns/namespace.go | getJsonFieldName | func getJsonFieldName(object interface{}, fieldName string) (string, error) {
jsonTag, err := reflections.GetFieldTag(object, fieldName, "json")
if err != nil {
return "", err
} else if jsonTag == "" {
return fieldName, nil
}
i := strings.Index(jsonTag, ",")
if i == -1 {
return jsonTag, nil
}
if tag := jsonTag[:i]; tag == "-" {
return "-", nil
} else if tag == "" {
return fieldName, nil
} else {
return tag, nil
}
} | go | func getJsonFieldName(object interface{}, fieldName string) (string, error) {
jsonTag, err := reflections.GetFieldTag(object, fieldName, "json")
if err != nil {
return "", err
} else if jsonTag == "" {
return fieldName, nil
}
i := strings.Index(jsonTag, ",")
if i == -1 {
return jsonTag, nil
}
if tag := jsonTag[:i]; tag == "-" {
return "-", nil
} else if tag == "" {
return fieldName, nil
} else {
return tag, nil
}
} | [
"func",
"getJsonFieldName",
"(",
"object",
"interface",
"{",
"}",
",",
"fieldName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"jsonTag",
",",
"err",
":=",
"reflections",
".",
"GetFieldTag",
"(",
"object",
",",
"fieldName",
",",
"\"",
"\"",
")... | // getJsonFieldName gets an object's field name compatible with json tag on;
// details can be found in docs for pkg json. If json tag is empty, or no
// tag is present then original fieldName will be reported. If json tag hides
// a field, function will return dash "-" as name. | [
"getJsonFieldName",
"gets",
"an",
"object",
"s",
"field",
"name",
"compatible",
"with",
"json",
"tag",
"on",
";",
"details",
"can",
"be",
"found",
"in",
"docs",
"for",
"pkg",
"json",
".",
"If",
"json",
"tag",
"is",
"empty",
"or",
"no",
"tag",
"is",
"pr... | 2a2aa9b0e9175b89c902d7183564e9a12f3467ac | https://github.com/intelsdi-x/snap-plugin-utilities/blob/2a2aa9b0e9175b89c902d7183564e9a12f3467ac/ns/namespace.go#L261-L279 |
152,353 | vektra/neko | neko.go | Run | func (o *Organizer) Run() {
if o.only != nil {
o.runTest(o.only)
return
}
for _, test := range o.tests {
o.runTest(&test)
}
} | go | func (o *Organizer) Run() {
if o.only != nil {
o.runTest(o.only)
return
}
for _, test := range o.tests {
o.runTest(&test)
}
} | [
"func",
"(",
"o",
"*",
"Organizer",
")",
"Run",
"(",
")",
"{",
"if",
"o",
".",
"only",
"!=",
"nil",
"{",
"o",
".",
"runTest",
"(",
"o",
".",
"only",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"test",
":=",
"range",
"o",
".",
"... | // Coordinate running the tests with the setups and mocks | [
"Coordinate",
"running",
"the",
"tests",
"with",
"the",
"setups",
"and",
"mocks"
] | 99acbdf12420f5f41875bff6093d48481f8e206c | https://github.com/vektra/neko/blob/99acbdf12420f5f41875bff6093d48481f8e206c/neko.go#L64-L73 |
152,354 | vektra/neko | neko.go | Meow | func (o *Organizer) Meow() {
o.t.Logf("Meow! Neko is on the case! Running %d tests now!", len(o.tests))
o.Run()
} | go | func (o *Organizer) Meow() {
o.t.Logf("Meow! Neko is on the case! Running %d tests now!", len(o.tests))
o.Run()
} | [
"func",
"(",
"o",
"*",
"Organizer",
")",
"Meow",
"(",
")",
"{",
"o",
".",
"t",
".",
"Logf",
"(",
"\"",
"\"",
",",
"len",
"(",
"o",
".",
"tests",
")",
")",
"\n",
"o",
".",
"Run",
"(",
")",
"\n",
"}"
] | // Have fun with neko! | [
"Have",
"fun",
"with",
"neko!"
] | 99acbdf12420f5f41875bff6093d48481f8e206c | https://github.com/vektra/neko/blob/99acbdf12420f5f41875bff6093d48481f8e206c/neko.go#L108-L111 |
152,355 | bitrise-io/gows | cmd/common.go | runCommand | func runCommand(cmdWorkdir string, wsConfig config.WorkspaceConfigModel, cmdName string, cmdArgs ...string) (int, error) {
log.Debugf("[RunCommand] Command Name: %s", cmdName)
log.Debugf("[RunCommand] Command Args: %#v", cmdArgs)
log.Debugf("[RunCommand] Command Work Dir: %#v", cmdWorkdir)
cmd := gows.CreateCommand(cmdWorkdir, wsConfig.WorkspaceRootPath, cmdName, cmdArgs...)
cmdExitCode := 0
if err := cmd.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
waitStatus, ok := exitError.Sys().(syscall.WaitStatus)
if !ok {
return 0, errors.New("Failed to cast exit status")
}
cmdExitCode = waitStatus.ExitStatus()
}
return cmdExitCode, err
}
return 0, nil
} | go | func runCommand(cmdWorkdir string, wsConfig config.WorkspaceConfigModel, cmdName string, cmdArgs ...string) (int, error) {
log.Debugf("[RunCommand] Command Name: %s", cmdName)
log.Debugf("[RunCommand] Command Args: %#v", cmdArgs)
log.Debugf("[RunCommand] Command Work Dir: %#v", cmdWorkdir)
cmd := gows.CreateCommand(cmdWorkdir, wsConfig.WorkspaceRootPath, cmdName, cmdArgs...)
cmdExitCode := 0
if err := cmd.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
waitStatus, ok := exitError.Sys().(syscall.WaitStatus)
if !ok {
return 0, errors.New("Failed to cast exit status")
}
cmdExitCode = waitStatus.ExitStatus()
}
return cmdExitCode, err
}
return 0, nil
} | [
"func",
"runCommand",
"(",
"cmdWorkdir",
"string",
",",
"wsConfig",
"config",
".",
"WorkspaceConfigModel",
",",
"cmdName",
"string",
",",
"cmdArgs",
"...",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"cm... | // runCommand runs the command with it's arguments
// Returns the exit code of the command and any error occured in the function | [
"runCommand",
"runs",
"the",
"command",
"with",
"it",
"s",
"arguments",
"Returns",
"the",
"exit",
"code",
"of",
"the",
"command",
"and",
"any",
"error",
"occured",
"in",
"the",
"function"
] | 005d8a8baa6e3c6c76527554bb292061ef7d3af0 | https://github.com/bitrise-io/gows/blob/005d8a8baa6e3c6c76527554bb292061ef7d3af0/cmd/common.go#L218-L238 |
152,356 | matryer/filedb | db.go | Dial | func Dial(d string) (*DB, error) {
var err error
var i os.FileInfo
if i, err = os.Stat(d); os.IsNotExist(err) {
return nil, ErrDBNotFound
}
if !i.IsDir() {
return nil, ErrDBNotFound
}
return &DB{path: d, cs: make(map[string]*C)}, nil
} | go | func Dial(d string) (*DB, error) {
var err error
var i os.FileInfo
if i, err = os.Stat(d); os.IsNotExist(err) {
return nil, ErrDBNotFound
}
if !i.IsDir() {
return nil, ErrDBNotFound
}
return &DB{path: d, cs: make(map[string]*C)}, nil
} | [
"func",
"Dial",
"(",
"d",
"string",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"i",
"os",
".",
"FileInfo",
"\n",
"if",
"i",
",",
"err",
"=",
"os",
".",
"Stat",
"(",
"d",
")",
";",
"os",
".",
"IsNotExist",... | // Dial initiates communication with a database. | [
"Dial",
"initiates",
"communication",
"with",
"a",
"database",
"."
] | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L36-L46 |
152,357 | matryer/filedb | db.go | ColNames | func (db *DB) ColNames() ([]string, error) {
files, err := ioutil.ReadDir(db.path)
if err != nil {
return nil, err
}
var names []string
for _, file := range files {
if strings.ToLower(path.Ext(file.Name())) == Ext {
names = append(names, file.Name()[0:len(file.Name())-len(Ext)])
}
}
return names, nil
} | go | func (db *DB) ColNames() ([]string, error) {
files, err := ioutil.ReadDir(db.path)
if err != nil {
return nil, err
}
var names []string
for _, file := range files {
if strings.ToLower(path.Ext(file.Name())) == Ext {
names = append(names, file.Name()[0:len(file.Name())-len(Ext)])
}
}
return names, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"ColNames",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"db",
".",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // ColNames gets a list of all collections in the
// database. | [
"ColNames",
"gets",
"a",
"list",
"of",
"all",
"collections",
"in",
"the",
"database",
"."
] | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L50-L62 |
152,358 | matryer/filedb | db.go | C | func (db *DB) C(name string) (*C, error) {
if c, ok := db.cs[name]; ok {
return c, nil
}
c := &C{db: db, path: filepath.Join(db.path, fmt.Sprintf(CNameFormat, name))}
db.cs[name] = c
return c, nil
} | go | func (db *DB) C(name string) (*C, error) {
if c, ok := db.cs[name]; ok {
return c, nil
}
c := &C{db: db, path: filepath.Join(db.path, fmt.Sprintf(CNameFormat, name))}
db.cs[name] = c
return c, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"C",
"(",
"name",
"string",
")",
"(",
"*",
"C",
",",
"error",
")",
"{",
"if",
"c",
",",
"ok",
":=",
"db",
".",
"cs",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"c",
",",
"nil",
"\n",
"}",
"\n",
"c",
"... | // C refers to a collection of JSON objects. | [
"C",
"refers",
"to",
"a",
"collection",
"of",
"JSON",
"objects",
"."
] | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L73-L80 |
152,359 | matryer/filedb | db.go | Drop | func (c *C) Drop() error {
c.m.Lock()
defer c.m.Unlock()
c.close()
if err := os.Remove(c.path); err != nil {
// ignore not exist errors - they're fine
if !os.IsNotExist(err) {
return err
}
}
return nil
} | go | func (c *C) Drop() error {
c.m.Lock()
defer c.m.Unlock()
c.close()
if err := os.Remove(c.path); err != nil {
// ignore not exist errors - they're fine
if !os.IsNotExist(err) {
return err
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"C",
")",
"Drop",
"(",
")",
"error",
"{",
"c",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"close",
"(",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"Remove",... | // Drop drops the collection. | [
"Drop",
"drops",
"the",
"collection",
"."
] | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L118-L129 |
152,360 | matryer/filedb | db.go | Insert | func (c *C) Insert(o []byte) error {
c.m.Lock()
defer c.m.Unlock()
f, err := c.file()
if err != nil {
return err
}
f.Seek(0, os.SEEK_END)
f.Write(o)
f.WriteString(fmt.Sprintln())
return nil
} | go | func (c *C) Insert(o []byte) error {
c.m.Lock()
defer c.m.Unlock()
f, err := c.file()
if err != nil {
return err
}
f.Seek(0, os.SEEK_END)
f.Write(o)
f.WriteString(fmt.Sprintln())
return nil
} | [
"func",
"(",
"c",
"*",
"C",
")",
"Insert",
"(",
"o",
"[",
"]",
"byte",
")",
"error",
"{",
"c",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"f",
",",
"err",
":=",
"c",
".",
"file",
"(",
"... | // Insert adds a new object to the collection. | [
"Insert",
"adds",
"a",
"new",
"object",
"to",
"the",
"collection",
"."
] | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L132-L143 |
152,361 | matryer/filedb | db.go | InsertJSON | func (c *C) InsertJSON(obj interface{}) error {
b, err := json.Marshal(obj)
if err != nil {
return err
}
return c.Insert(b)
} | go | func (c *C) InsertJSON(obj interface{}) error {
b, err := json.Marshal(obj)
if err != nil {
return err
}
return c.Insert(b)
} | [
"func",
"(",
"c",
"*",
"C",
")",
"InsertJSON",
"(",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return"... | // InsertJSON inserts a JSON encoded version of the specified
// object. | [
"InsertJSON",
"inserts",
"a",
"JSON",
"encoded",
"version",
"of",
"the",
"specified",
"object",
"."
] | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L147-L153 |
152,362 | matryer/filedb | db.go | RemoveEach | func (c *C) RemoveEach(fn func(int, []byte) (bool, bool)) error {
return c.SelectEach(func(i int, data []byte) (bool, []byte, bool) {
remove, stop := fn(i, data)
return !remove, data, stop
})
} | go | func (c *C) RemoveEach(fn func(int, []byte) (bool, bool)) error {
return c.SelectEach(func(i int, data []byte) (bool, []byte, bool) {
remove, stop := fn(i, data)
return !remove, data, stop
})
} | [
"func",
"(",
"c",
"*",
"C",
")",
"RemoveEach",
"(",
"fn",
"func",
"(",
"int",
",",
"[",
"]",
"byte",
")",
"(",
"bool",
",",
"bool",
")",
")",
"error",
"{",
"return",
"c",
".",
"SelectEach",
"(",
"func",
"(",
"i",
"int",
",",
"data",
"[",
"]",... | // RemoveEach calls fn for each record in the collection, removing any
// for which fn returns true.
// If stop is returned, processing ceases after the current record has
// been processed. | [
"RemoveEach",
"calls",
"fn",
"for",
"each",
"record",
"in",
"the",
"collection",
"removing",
"any",
"for",
"which",
"fn",
"returns",
"true",
".",
"If",
"stop",
"is",
"returned",
"processing",
"ceases",
"after",
"the",
"current",
"record",
"has",
"been",
"pro... | 3641db67a8c989375ff081fe797ca170a2c54bb5 | https://github.com/matryer/filedb/blob/3641db67a8c989375ff081fe797ca170a2c54bb5/db.go#L240-L245 |
152,363 | farmergreg/rfsnotify | rfsnotify.go | AddRecursive | func (m *RWatcher) AddRecursive(name string) error {
if m.isClosed {
return errors.New("rfsnotify instance already closed")
}
if err := m.watchRecursive(name, false); err != nil {
return err
}
return nil
} | go | func (m *RWatcher) AddRecursive(name string) error {
if m.isClosed {
return errors.New("rfsnotify instance already closed")
}
if err := m.watchRecursive(name, false); err != nil {
return err
}
return nil
} | [
"func",
"(",
"m",
"*",
"RWatcher",
")",
"AddRecursive",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"m",
".",
"isClosed",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"m",
".",
"watchRecursive",... | // AddRecursive starts watching the named directory and all sub-directories. | [
"AddRecursive",
"starts",
"watching",
"the",
"named",
"directory",
"and",
"all",
"sub",
"-",
"directories",
"."
] | 94bf32bab0afb5f7d8b1af410fd89118eae02de2 | https://github.com/farmergreg/rfsnotify/blob/94bf32bab0afb5f7d8b1af410fd89118eae02de2/rfsnotify.go#L49-L57 |
152,364 | farmergreg/rfsnotify | rfsnotify.go | RemoveRecursive | func (m *RWatcher) RemoveRecursive(name string) error {
if err := m.watchRecursive(name, true); err != nil {
return err
}
return nil
} | go | func (m *RWatcher) RemoveRecursive(name string) error {
if err := m.watchRecursive(name, true); err != nil {
return err
}
return nil
} | [
"func",
"(",
"m",
"*",
"RWatcher",
")",
"RemoveRecursive",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"watchRecursive",
"(",
"name",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"retu... | // RemoveRecursive stops watching the named directory and all sub-directories. | [
"RemoveRecursive",
"stops",
"watching",
"the",
"named",
"directory",
"and",
"all",
"sub",
"-",
"directories",
"."
] | 94bf32bab0afb5f7d8b1af410fd89118eae02de2 | https://github.com/farmergreg/rfsnotify/blob/94bf32bab0afb5f7d8b1af410fd89118eae02de2/rfsnotify.go#L65-L70 |
152,365 | farmergreg/rfsnotify | rfsnotify.go | watchRecursive | func (m *RWatcher) watchRecursive(path string, unWatch bool) error {
err := filepath.Walk(path, func(walkPath string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if fi.IsDir() {
if unWatch {
if err = m.fsnotify.Remove(walkPath); err != nil {
return err
}
} else {
if err = m.fsnotify.Add(walkPath); err != nil {
return err
}
}
}
return nil
})
return err
} | go | func (m *RWatcher) watchRecursive(path string, unWatch bool) error {
err := filepath.Walk(path, func(walkPath string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if fi.IsDir() {
if unWatch {
if err = m.fsnotify.Remove(walkPath); err != nil {
return err
}
} else {
if err = m.fsnotify.Add(walkPath); err != nil {
return err
}
}
}
return nil
})
return err
} | [
"func",
"(",
"m",
"*",
"RWatcher",
")",
"watchRecursive",
"(",
"path",
"string",
",",
"unWatch",
"bool",
")",
"error",
"{",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"path",
",",
"func",
"(",
"walkPath",
"string",
",",
"fi",
"os",
".",
"FileInfo",
"... | // watchRecursive adds all directories under the given one to the watch list.
// this is probably a very racey process. What if a file is added to a folder before we get the watch added? | [
"watchRecursive",
"adds",
"all",
"directories",
"under",
"the",
"given",
"one",
"to",
"the",
"watch",
"list",
".",
"this",
"is",
"probably",
"a",
"very",
"racey",
"process",
".",
"What",
"if",
"a",
"file",
"is",
"added",
"to",
"a",
"folder",
"before",
"w... | 94bf32bab0afb5f7d8b1af410fd89118eae02de2 | https://github.com/farmergreg/rfsnotify/blob/94bf32bab0afb5f7d8b1af410fd89118eae02de2/rfsnotify.go#L114-L133 |
152,366 | bobbytables/slacker | rtm_events.go | Message | func (e RTMEvent) Message() (*RTMMessage, error) {
var msg RTMMessage
if err := json.Unmarshal(e.RawMessage, &msg); err != nil {
return nil, err
}
return &msg, nil
} | go | func (e RTMEvent) Message() (*RTMMessage, error) {
var msg RTMMessage
if err := json.Unmarshal(e.RawMessage, &msg); err != nil {
return nil, err
}
return &msg, nil
} | [
"func",
"(",
"e",
"RTMEvent",
")",
"Message",
"(",
")",
"(",
"*",
"RTMMessage",
",",
"error",
")",
"{",
"var",
"msg",
"RTMMessage",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"e",
".",
"RawMessage",
",",
"&",
"msg",
")",
";",
"err",
... | // Message converts an event to an RTMMessage. If the event type is not
// "message", it returns an error | [
"Message",
"converts",
"an",
"event",
"to",
"an",
"RTMMessage",
".",
"If",
"the",
"event",
"type",
"is",
"not",
"message",
"it",
"returns",
"an",
"error"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_events.go#L19-L26 |
152,367 | bobbytables/slacker | api_channels.go | ChannelsList | func (c *APIClient) ChannelsList() ([]*Channel, error) {
dest := ChannelsList{}
if err := c.slackMethodAndParse("channels.list", &dest); err != nil {
return nil, err
}
return dest.Channels, nil
} | go | func (c *APIClient) ChannelsList() ([]*Channel, error) {
dest := ChannelsList{}
if err := c.slackMethodAndParse("channels.list", &dest); err != nil {
return nil, err
}
return dest.Channels, nil
} | [
"func",
"(",
"c",
"*",
"APIClient",
")",
"ChannelsList",
"(",
")",
"(",
"[",
"]",
"*",
"Channel",
",",
"error",
")",
"{",
"dest",
":=",
"ChannelsList",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"slackMethodAndParse",
"(",
"\"",
"\"",
",",
"&",
... | // ChannelsList returns a list of Channels from Slack | [
"ChannelsList",
"returns",
"a",
"list",
"of",
"Channels",
"from",
"Slack"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/api_channels.go#L41-L48 |
152,368 | bobbytables/slacker | api_users.go | UsersList | func (c *APIClient) UsersList() ([]*User, error) {
dest := UsersList{}
if err := c.slackMethodAndParse("users.list", &dest); err != nil {
return nil, err
}
return dest.Users, nil
} | go | func (c *APIClient) UsersList() ([]*User, error) {
dest := UsersList{}
if err := c.slackMethodAndParse("users.list", &dest); err != nil {
return nil, err
}
return dest.Users, nil
} | [
"func",
"(",
"c",
"*",
"APIClient",
")",
"UsersList",
"(",
")",
"(",
"[",
"]",
"*",
"User",
",",
"error",
")",
"{",
"dest",
":=",
"UsersList",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"slackMethodAndParse",
"(",
"\"",
"\"",
",",
"&",
"dest",
... | // UsersList returns all users in the team | [
"UsersList",
"returns",
"all",
"users",
"in",
"the",
"team"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/api_users.go#L44-L51 |
152,369 | vburenin/nsync | namedmutex.go | Lock | func (nm *NamedMutex) Lock(name string) {
nm.localMutex.Lock()
mc, ok := nm.mutexMap[name]
if !ok {
mc = make(chan struct{}, 1)
nm.mutexMap[name] = mc
}
nm.localMutex.Unlock()
mc <- struct{}{}
} | go | func (nm *NamedMutex) Lock(name string) {
nm.localMutex.Lock()
mc, ok := nm.mutexMap[name]
if !ok {
mc = make(chan struct{}, 1)
nm.mutexMap[name] = mc
}
nm.localMutex.Unlock()
mc <- struct{}{}
} | [
"func",
"(",
"nm",
"*",
"NamedMutex",
")",
"Lock",
"(",
"name",
"string",
")",
"{",
"nm",
".",
"localMutex",
".",
"Lock",
"(",
")",
"\n",
"mc",
",",
"ok",
":=",
"nm",
".",
"mutexMap",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"mc",
"=",
"... | // Lock acquires the lock. On the first lock attempt
// a new channel is automatically created. | [
"Lock",
"acquires",
"the",
"lock",
".",
"On",
"the",
"first",
"lock",
"attempt",
"a",
"new",
"channel",
"is",
"automatically",
"created",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedmutex.go#L29-L38 |
152,370 | vburenin/nsync | namedmutex.go | TryLock | func (nm *NamedMutex) TryLock(name string) bool {
nm.localMutex.Lock()
mc, ok := nm.mutexMap[name]
if !ok {
mc = make(chan struct{}, 1)
nm.mutexMap[name] = mc
}
nm.localMutex.Unlock()
select {
case mc <- struct{}{}:
return true
default:
return false
}
} | go | func (nm *NamedMutex) TryLock(name string) bool {
nm.localMutex.Lock()
mc, ok := nm.mutexMap[name]
if !ok {
mc = make(chan struct{}, 1)
nm.mutexMap[name] = mc
}
nm.localMutex.Unlock()
select {
case mc <- struct{}{}:
return true
default:
return false
}
} | [
"func",
"(",
"nm",
"*",
"NamedMutex",
")",
"TryLock",
"(",
"name",
"string",
")",
"bool",
"{",
"nm",
".",
"localMutex",
".",
"Lock",
"(",
")",
"\n",
"mc",
",",
"ok",
":=",
"nm",
".",
"mutexMap",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"mc... | // TryLock tries to acquires the lock returning true on success.
// On the first lock attempt a new channel is automatically created. | [
"TryLock",
"tries",
"to",
"acquires",
"the",
"lock",
"returning",
"true",
"on",
"success",
".",
"On",
"the",
"first",
"lock",
"attempt",
"a",
"new",
"channel",
"is",
"automatically",
"created",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedmutex.go#L42-L56 |
152,371 | vburenin/nsync | namedmutex.go | TryLockTimeout | func (nm *NamedMutex) TryLockTimeout(name string, timeout time.Duration) bool {
nm.localMutex.Lock()
mc, ok := nm.mutexMap[name]
if !ok {
mc = make(chan struct{}, 1)
nm.mutexMap[name] = mc
}
nm.localMutex.Unlock()
select {
case mc <- struct{}{}:
return true
case <-time.After(timeout):
return false
}
} | go | func (nm *NamedMutex) TryLockTimeout(name string, timeout time.Duration) bool {
nm.localMutex.Lock()
mc, ok := nm.mutexMap[name]
if !ok {
mc = make(chan struct{}, 1)
nm.mutexMap[name] = mc
}
nm.localMutex.Unlock()
select {
case mc <- struct{}{}:
return true
case <-time.After(timeout):
return false
}
} | [
"func",
"(",
"nm",
"*",
"NamedMutex",
")",
"TryLockTimeout",
"(",
"name",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"bool",
"{",
"nm",
".",
"localMutex",
".",
"Lock",
"(",
")",
"\n",
"mc",
",",
"ok",
":=",
"nm",
".",
"mutexMap",
"[",
... | // TryLockTimeout tries to acquires the lock returning true on success.
// Attempt to acquire the lock will timeout after the caller defined interval.
// On the first lock attempt a new channel is automatically created. | [
"TryLockTimeout",
"tries",
"to",
"acquires",
"the",
"lock",
"returning",
"true",
"on",
"success",
".",
"Attempt",
"to",
"acquire",
"the",
"lock",
"will",
"timeout",
"after",
"the",
"caller",
"defined",
"interval",
".",
"On",
"the",
"first",
"lock",
"attempt",
... | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedmutex.go#L61-L75 |
152,372 | vburenin/nsync | namedmutex.go | Unlock | func (nm *NamedMutex) Unlock(name string) {
nm.localMutex.Lock()
defer nm.localMutex.Unlock()
mc := nm.mutexMap[name]
if len(mc) == 0 {
panic("No named mutex acquired: " + name)
}
<-mc
} | go | func (nm *NamedMutex) Unlock(name string) {
nm.localMutex.Lock()
defer nm.localMutex.Unlock()
mc := nm.mutexMap[name]
if len(mc) == 0 {
panic("No named mutex acquired: " + name)
}
<-mc
} | [
"func",
"(",
"nm",
"*",
"NamedMutex",
")",
"Unlock",
"(",
"name",
"string",
")",
"{",
"nm",
".",
"localMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"nm",
".",
"localMutex",
".",
"Unlock",
"(",
")",
"\n",
"mc",
":=",
"nm",
".",
"mutexMap",
"[",
"... | // Unlock releases the lock. If lock hasn't been acquired
// function will panic. | [
"Unlock",
"releases",
"the",
"lock",
".",
"If",
"lock",
"hasn",
"t",
"been",
"acquired",
"function",
"will",
"panic",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedmutex.go#L79-L87 |
152,373 | vburenin/nsync | namedoncemutex.go | Lock | func (om *OnceMutex) Lock() bool {
om.mu.Lock()
if om.used {
om.mu.Unlock()
return false
}
return true
} | go | func (om *OnceMutex) Lock() bool {
om.mu.Lock()
if om.used {
om.mu.Unlock()
return false
}
return true
} | [
"func",
"(",
"om",
"*",
"OnceMutex",
")",
"Lock",
"(",
")",
"bool",
"{",
"om",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"om",
".",
"used",
"{",
"om",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"return",... | // Lock tries to acquire lock. | [
"Lock",
"tries",
"to",
"acquire",
"lock",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedoncemutex.go#L20-L27 |
152,374 | vburenin/nsync | namedoncemutex.go | Lock | func (nom *NamedOnceMutex) Lock(useMutexKey interface{}) bool {
nom.mutex.Lock()
m, ok := nom.lockMap[useMutexKey]
if ok {
nom.mutex.Unlock()
return m.Lock()
}
m = &OnceMutex{}
m.Lock()
nom.lockMap[useMutexKey] = m
nom.mutex.Unlock()
return true
} | go | func (nom *NamedOnceMutex) Lock(useMutexKey interface{}) bool {
nom.mutex.Lock()
m, ok := nom.lockMap[useMutexKey]
if ok {
nom.mutex.Unlock()
return m.Lock()
}
m = &OnceMutex{}
m.Lock()
nom.lockMap[useMutexKey] = m
nom.mutex.Unlock()
return true
} | [
"func",
"(",
"nom",
"*",
"NamedOnceMutex",
")",
"Lock",
"(",
"useMutexKey",
"interface",
"{",
"}",
")",
"bool",
"{",
"nom",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"m",
",",
"ok",
":=",
"nom",
".",
"lockMap",
"[",
"useMutexKey",
"]",
"\n",
"if",... | // Lock try to acquire a lock for provided id. If attempt is successful, true is returned
// If lock is already acquired by something else it will block until mutex is unlocked returning false. | [
"Lock",
"try",
"to",
"acquire",
"a",
"lock",
"for",
"provided",
"id",
".",
"If",
"attempt",
"is",
"successful",
"true",
"is",
"returned",
"If",
"lock",
"is",
"already",
"acquired",
"by",
"something",
"else",
"it",
"will",
"block",
"until",
"mutex",
"is",
... | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedoncemutex.go#L56-L69 |
152,375 | vburenin/nsync | namedoncemutex.go | Unlock | func (nom *NamedOnceMutex) Unlock(useMutexKey interface{}) {
nom.mutex.Lock()
m, ok := nom.lockMap[useMutexKey]
if ok {
delete(nom.lockMap, useMutexKey)
nom.mutex.Unlock()
m.Unlock()
} else {
nom.mutex.Unlock()
}
} | go | func (nom *NamedOnceMutex) Unlock(useMutexKey interface{}) {
nom.mutex.Lock()
m, ok := nom.lockMap[useMutexKey]
if ok {
delete(nom.lockMap, useMutexKey)
nom.mutex.Unlock()
m.Unlock()
} else {
nom.mutex.Unlock()
}
} | [
"func",
"(",
"nom",
"*",
"NamedOnceMutex",
")",
"Unlock",
"(",
"useMutexKey",
"interface",
"{",
"}",
")",
"{",
"nom",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"m",
",",
"ok",
":=",
"nom",
".",
"lockMap",
"[",
"useMutexKey",
"]",
"\n",
"if",
"ok",... | // Unlock unlocks the locked mutex. Used mutex will be discarded. | [
"Unlock",
"unlocks",
"the",
"locked",
"mutex",
".",
"Used",
"mutex",
"will",
"be",
"discarded",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/namedoncemutex.go#L72-L82 |
152,376 | bobbytables/slacker | slacker.go | NewAPIClient | func NewAPIClient(token string, url string) *APIClient {
if url == "" {
url = DefaultAPIURL
}
return &APIClient{
client: http.DefaultClient,
token: token,
SlackURL: url,
}
} | go | func NewAPIClient(token string, url string) *APIClient {
if url == "" {
url = DefaultAPIURL
}
return &APIClient{
client: http.DefaultClient,
token: token,
SlackURL: url,
}
} | [
"func",
"NewAPIClient",
"(",
"token",
"string",
",",
"url",
"string",
")",
"*",
"APIClient",
"{",
"if",
"url",
"==",
"\"",
"\"",
"{",
"url",
"=",
"DefaultAPIURL",
"\n",
"}",
"\n\n",
"return",
"&",
"APIClient",
"{",
"client",
":",
"http",
".",
"DefaultC... | // NewAPIClient returns a new APIClient with a token set. | [
"NewAPIClient",
"returns",
"a",
"new",
"APIClient",
"with",
"a",
"token",
"set",
"."
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/slacker.go#L20-L30 |
152,377 | bobbytables/slacker | slacker.go | RunMethod | func (c *APIClient) RunMethod(name string) ([]byte, error) {
resp, err := c.slackMethod(name)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
} | go | func (c *APIClient) RunMethod(name string) ([]byte, error) {
resp, err := c.slackMethod(name)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
} | [
"func",
"(",
"c",
"*",
"APIClient",
")",
"RunMethod",
"(",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"slackMethod",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // RunMethod runs an RPC method and returns the response body as a byte slice | [
"RunMethod",
"runs",
"an",
"RPC",
"method",
"and",
"returns",
"the",
"response",
"body",
"as",
"a",
"byte",
"slice"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/slacker.go#L33-L41 |
152,378 | vburenin/nsync | cwaitgroup.go | Do | func (cwg *ControlWaitGroup) Do(userFunc func()) bool {
cwg.wg.Add(1)
cwg.mu.Lock()
cwg.waiting++
cwg.mu.Unlock()
cwg.sem.Acquire()
cwg.mu.Lock()
cwg.waiting--
if cwg.abort {
cwg.sem.Release()
cwg.wg.Done()
cwg.mu.Unlock()
return false
}
cwg.mu.Unlock()
go func() {
defer cwg.wg.Done()
defer cwg.sem.Release()
userFunc()
}()
return true
} | go | func (cwg *ControlWaitGroup) Do(userFunc func()) bool {
cwg.wg.Add(1)
cwg.mu.Lock()
cwg.waiting++
cwg.mu.Unlock()
cwg.sem.Acquire()
cwg.mu.Lock()
cwg.waiting--
if cwg.abort {
cwg.sem.Release()
cwg.wg.Done()
cwg.mu.Unlock()
return false
}
cwg.mu.Unlock()
go func() {
defer cwg.wg.Done()
defer cwg.sem.Release()
userFunc()
}()
return true
} | [
"func",
"(",
"cwg",
"*",
"ControlWaitGroup",
")",
"Do",
"(",
"userFunc",
"func",
"(",
")",
")",
"bool",
"{",
"cwg",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n\n",
"cwg",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"cwg",
".",
"waiting",
"++",
"\n",
... | // Do runs user defined function with no interface.
// all parameters passed to the required call should be provided
// withing a function closure. | [
"Do",
"runs",
"user",
"defined",
"function",
"with",
"no",
"interface",
".",
"all",
"parameters",
"passed",
"to",
"the",
"required",
"call",
"should",
"be",
"provided",
"withing",
"a",
"function",
"closure",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/cwaitgroup.go#L29-L55 |
152,379 | vburenin/nsync | cwaitgroup.go | Abort | func (cwg *ControlWaitGroup) Abort() {
cwg.mu.Lock()
cwg.abort = true
cwg.mu.Unlock()
} | go | func (cwg *ControlWaitGroup) Abort() {
cwg.mu.Lock()
cwg.abort = true
cwg.mu.Unlock()
} | [
"func",
"(",
"cwg",
"*",
"ControlWaitGroup",
")",
"Abort",
"(",
")",
"{",
"cwg",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"cwg",
".",
"abort",
"=",
"true",
"\n",
"cwg",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Abort interrupts execution of any pending task that is blocked by semaphore. | [
"Abort",
"interrupts",
"execution",
"of",
"any",
"pending",
"task",
"that",
"is",
"blocked",
"by",
"semaphore",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/cwaitgroup.go#L58-L62 |
152,380 | vburenin/nsync | cwaitgroup.go | Waiting | func (cwg *ControlWaitGroup) Waiting() int {
cwg.mu.Lock()
w := cwg.waiting
cwg.mu.Unlock()
return w
} | go | func (cwg *ControlWaitGroup) Waiting() int {
cwg.mu.Lock()
w := cwg.waiting
cwg.mu.Unlock()
return w
} | [
"func",
"(",
"cwg",
"*",
"ControlWaitGroup",
")",
"Waiting",
"(",
")",
"int",
"{",
"cwg",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"w",
":=",
"cwg",
".",
"waiting",
"\n",
"cwg",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"w",
"\n",
"}"
... | // Waiting is a number of the currently scheduled, but not running goroutines. This value is highly
// dynamic so it only make sense to use it for logging purposes. | [
"Waiting",
"is",
"a",
"number",
"of",
"the",
"currently",
"scheduled",
"but",
"not",
"running",
"goroutines",
".",
"This",
"value",
"is",
"highly",
"dynamic",
"so",
"it",
"only",
"make",
"sense",
"to",
"use",
"it",
"for",
"logging",
"purposes",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/cwaitgroup.go#L72-L77 |
152,381 | bobbytables/slacker | rtm_broker.go | NewRTMBroker | func NewRTMBroker(s *RTMStartResult) *RTMBroker {
broker := &RTMBroker{
url: s.URL,
}
return broker
} | go | func NewRTMBroker(s *RTMStartResult) *RTMBroker {
broker := &RTMBroker{
url: s.URL,
}
return broker
} | [
"func",
"NewRTMBroker",
"(",
"s",
"*",
"RTMStartResult",
")",
"*",
"RTMBroker",
"{",
"broker",
":=",
"&",
"RTMBroker",
"{",
"url",
":",
"s",
".",
"URL",
",",
"}",
"\n\n",
"return",
"broker",
"\n",
"}"
] | // NewRTMBroker returns a connected broker to Slack from a rtm.start result | [
"NewRTMBroker",
"returns",
"a",
"connected",
"broker",
"to",
"Slack",
"from",
"a",
"rtm",
".",
"start",
"result"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_broker.go#L27-L33 |
152,382 | bobbytables/slacker | rtm_broker.go | Connect | func (b *RTMBroker) Connect() error {
conn, _, err := websocket.DefaultDialer.Dial(b.url, nil)
if err != nil {
return err
}
b.conn = conn
b.incoming = make(chan []byte, 0)
b.events = make(chan RTMEvent, 0)
go b.startRecv()
go b.handleEvents()
return nil
} | go | func (b *RTMBroker) Connect() error {
conn, _, err := websocket.DefaultDialer.Dial(b.url, nil)
if err != nil {
return err
}
b.conn = conn
b.incoming = make(chan []byte, 0)
b.events = make(chan RTMEvent, 0)
go b.startRecv()
go b.handleEvents()
return nil
} | [
"func",
"(",
"b",
"*",
"RTMBroker",
")",
"Connect",
"(",
")",
"error",
"{",
"conn",
",",
"_",
",",
"err",
":=",
"websocket",
".",
"DefaultDialer",
".",
"Dial",
"(",
"b",
".",
"url",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Connect connects to the RTM Websocket | [
"Connect",
"connects",
"to",
"the",
"RTM",
"Websocket"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_broker.go#L36-L50 |
152,383 | bobbytables/slacker | rtm_broker.go | Close | func (b *RTMBroker) Close() error {
b.closed = true
return b.conn.Close()
} | go | func (b *RTMBroker) Close() error {
b.closed = true
return b.conn.Close()
} | [
"func",
"(",
"b",
"*",
"RTMBroker",
")",
"Close",
"(",
")",
"error",
"{",
"b",
".",
"closed",
"=",
"true",
"\n",
"return",
"b",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close Closes the connection to Slack RTM | [
"Close",
"Closes",
"the",
"connection",
"to",
"Slack",
"RTM"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_broker.go#L53-L56 |
152,384 | bobbytables/slacker | rtm_broker.go | Publish | func (b *RTMBroker) Publish(e Publishable) error {
d, err := e.Publishable()
if err != nil {
return err
}
return b.conn.WriteMessage(websocket.TextMessage, d)
} | go | func (b *RTMBroker) Publish(e Publishable) error {
d, err := e.Publishable()
if err != nil {
return err
}
return b.conn.WriteMessage(websocket.TextMessage, d)
} | [
"func",
"(",
"b",
"*",
"RTMBroker",
")",
"Publish",
"(",
"e",
"Publishable",
")",
"error",
"{",
"d",
",",
"err",
":=",
"e",
".",
"Publishable",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"b",
".",... | // Publish pushes an event to the RTM Websocket | [
"Publish",
"pushes",
"an",
"event",
"to",
"the",
"RTM",
"Websocket"
] | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_broker.go#L65-L72 |
152,385 | codahale/chacha20poly1305 | chacha20poly1305.go | New | func New(key []byte) (cipher.AEAD, error) {
if len(key) != KeySize {
return nil, ErrInvalidKey
}
k := new(chacha20Key)
for i, v := range key {
k[i] = v
}
return k, nil
} | go | func New(key []byte) (cipher.AEAD, error) {
if len(key) != KeySize {
return nil, ErrInvalidKey
}
k := new(chacha20Key)
for i, v := range key {
k[i] = v
}
return k, nil
} | [
"func",
"New",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"cipher",
".",
"AEAD",
",",
"error",
")",
"{",
"if",
"len",
"(",
"key",
")",
"!=",
"KeySize",
"{",
"return",
"nil",
",",
"ErrInvalidKey",
"\n",
"}",
"\n\n",
"k",
":=",
"new",
"(",
"chacha20Ke... | // New creates a new AEAD instance using the given key. The key must be exactly
// 256 bits long. | [
"New",
"creates",
"a",
"new",
"AEAD",
"instance",
"using",
"the",
"given",
"key",
".",
"The",
"key",
"must",
"be",
"exactly",
"256",
"bits",
"long",
"."
] | f8a5c48301822c3d7dd26d78e68ea2968db0ab20 | https://github.com/codahale/chacha20poly1305/blob/f8a5c48301822c3d7dd26d78e68ea2968db0ab20/chacha20poly1305.go#L62-L73 |
152,386 | codahale/chacha20poly1305 | chacha20poly1305.go | initialize | func (k *chacha20Key) initialize(nonce []byte) (cipher.Stream, [32]byte) {
c, err := chacha20.New(k[0:], nonce)
if err != nil {
panic(err) // basically impossible
}
subkey := make([]byte, 64)
c.XORKeyStream(subkey, subkey)
var key [32]byte
for i := 0; i < 32; i++ {
key[i] = subkey[i]
}
return c, key
} | go | func (k *chacha20Key) initialize(nonce []byte) (cipher.Stream, [32]byte) {
c, err := chacha20.New(k[0:], nonce)
if err != nil {
panic(err) // basically impossible
}
subkey := make([]byte, 64)
c.XORKeyStream(subkey, subkey)
var key [32]byte
for i := 0; i < 32; i++ {
key[i] = subkey[i]
}
return c, key
} | [
"func",
"(",
"k",
"*",
"chacha20Key",
")",
"initialize",
"(",
"nonce",
"[",
"]",
"byte",
")",
"(",
"cipher",
".",
"Stream",
",",
"[",
"32",
"]",
"byte",
")",
"{",
"c",
",",
"err",
":=",
"chacha20",
".",
"New",
"(",
"k",
"[",
"0",
":",
"]",
",... | // Converts the given key and nonce into 64 bytes of ChaCha20 key stream, the
// first 32 of which are used as the Poly1305 key. | [
"Converts",
"the",
"given",
"key",
"and",
"nonce",
"into",
"64",
"bytes",
"of",
"ChaCha20",
"key",
"stream",
"the",
"first",
"32",
"of",
"which",
"are",
"used",
"as",
"the",
"Poly1305",
"key",
"."
] | f8a5c48301822c3d7dd26d78e68ea2968db0ab20 | https://github.com/codahale/chacha20poly1305/blob/f8a5c48301822c3d7dd26d78e68ea2968db0ab20/chacha20poly1305.go#L124-L139 |
152,387 | jyap808/go-poloniex | client.go | NewClient | func NewClient(apiKey, apiSecret string) (c *client) {
return &client{apiKey, apiSecret, &http.Client{}, time.Tick(reqInterval), 30 * time.Second, false}
} | go | func NewClient(apiKey, apiSecret string) (c *client) {
return &client{apiKey, apiSecret, &http.Client{}, time.Tick(reqInterval), 30 * time.Second, false}
} | [
"func",
"NewClient",
"(",
"apiKey",
",",
"apiSecret",
"string",
")",
"(",
"c",
"*",
"client",
")",
"{",
"return",
"&",
"client",
"{",
"apiKey",
",",
"apiSecret",
",",
"&",
"http",
".",
"Client",
"{",
"}",
",",
"time",
".",
"Tick",
"(",
"reqInterval",... | // NewClient return a new Poloniex HTTP client | [
"NewClient",
"return",
"a",
"new",
"Poloniex",
"HTTP",
"client"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/client.go#L34-L36 |
152,388 | jyap808/go-poloniex | client.go | NewClientWithCustomTimeout | func NewClientWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) (c *client) {
return &client{apiKey, apiSecret, &http.Client{}, time.Tick(reqInterval), timeout, false}
} | go | func NewClientWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) (c *client) {
return &client{apiKey, apiSecret, &http.Client{}, time.Tick(reqInterval), timeout, false}
} | [
"func",
"NewClientWithCustomTimeout",
"(",
"apiKey",
",",
"apiSecret",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"c",
"*",
"client",
")",
"{",
"return",
"&",
"client",
"{",
"apiKey",
",",
"apiSecret",
",",
"&",
"http",
".",
"Client",
"... | // NewClientWithCustomTimeout returns a new Poloniex HTTP client with custom timeout | [
"NewClientWithCustomTimeout",
"returns",
"a",
"new",
"Poloniex",
"HTTP",
"client",
"with",
"custom",
"timeout"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/client.go#L39-L41 |
152,389 | jyap808/go-poloniex | client.go | do | func (c *client) do(method, resource string, payload map[string]string, authNeeded bool) (response []byte, err error) {
respCh := make(chan []byte)
errCh := make(chan error)
<-c.throttle
go c.makeReq(method, resource, payload, authNeeded, respCh, errCh)
response = <-respCh
err = <-errCh
return
} | go | func (c *client) do(method, resource string, payload map[string]string, authNeeded bool) (response []byte, err error) {
respCh := make(chan []byte)
errCh := make(chan error)
<-c.throttle
go c.makeReq(method, resource, payload, authNeeded, respCh, errCh)
response = <-respCh
err = <-errCh
return
} | [
"func",
"(",
"c",
"*",
"client",
")",
"do",
"(",
"method",
",",
"resource",
"string",
",",
"payload",
"map",
"[",
"string",
"]",
"string",
",",
"authNeeded",
"bool",
")",
"(",
"response",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"respCh",
"... | // do prepare and process HTTP request to Poloniex API | [
"do",
"prepare",
"and",
"process",
"HTTP",
"request",
"to",
"Poloniex",
"API"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/client.go#L171-L179 |
152,390 | jyap808/go-poloniex | client.go | doCommand | func (c *client) doCommand(command string, payload map[string]string) (response []byte, err error) {
if payload == nil {
payload = make(map[string]string)
}
payload["command"] = command
payload["nonce"] = strconv.FormatInt(time.Now().UnixNano(), 10)
return c.do("POST", "tradingApi", payload, true)
} | go | func (c *client) doCommand(command string, payload map[string]string) (response []byte, err error) {
if payload == nil {
payload = make(map[string]string)
}
payload["command"] = command
payload["nonce"] = strconv.FormatInt(time.Now().UnixNano(), 10)
return c.do("POST", "tradingApi", payload, true)
} | [
"func",
"(",
"c",
"*",
"client",
")",
"doCommand",
"(",
"command",
"string",
",",
"payload",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"response",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"payload",
"==",
"nil",
"{",
"payload",
"... | // doCommand prepares an authorized command-request for Poloniex's tradingApi | [
"doCommand",
"prepares",
"an",
"authorized",
"command",
"-",
"request",
"for",
"Poloniex",
"s",
"tradingApi"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/client.go#L182-L191 |
152,391 | jyap808/go-poloniex | poloniex.go | New | func New(apiKey, apiSecret string) *Poloniex {
client := NewClient(apiKey, apiSecret)
return &Poloniex{client}
} | go | func New(apiKey, apiSecret string) *Poloniex {
client := NewClient(apiKey, apiSecret)
return &Poloniex{client}
} | [
"func",
"New",
"(",
"apiKey",
",",
"apiSecret",
"string",
")",
"*",
"Poloniex",
"{",
"client",
":=",
"NewClient",
"(",
"apiKey",
",",
"apiSecret",
")",
"\n",
"return",
"&",
"Poloniex",
"{",
"client",
"}",
"\n",
"}"
] | // New returns an instantiated poloniex struct | [
"New",
"returns",
"an",
"instantiated",
"poloniex",
"struct"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/poloniex.go#L18-L21 |
152,392 | jyap808/go-poloniex | poloniex.go | GetTickers | func (b *Poloniex) GetTickers() (tickers map[string]Ticker, err error) {
r, err := b.client.do("GET", "public?command=returnTicker", nil, false)
if err != nil {
return
}
if err = json.Unmarshal(r, &tickers); err != nil {
return
}
return
} | go | func (b *Poloniex) GetTickers() (tickers map[string]Ticker, err error) {
r, err := b.client.do("GET", "public?command=returnTicker", nil, false)
if err != nil {
return
}
if err = json.Unmarshal(r, &tickers); err != nil {
return
}
return
} | [
"func",
"(",
"b",
"*",
"Poloniex",
")",
"GetTickers",
"(",
")",
"(",
"tickers",
"map",
"[",
"string",
"]",
"Ticker",
",",
"err",
"error",
")",
"{",
"r",
",",
"err",
":=",
"b",
".",
"client",
".",
"do",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"... | // GetTickers is used to get the ticker for all markets | [
"GetTickers",
"is",
"used",
"to",
"get",
"the",
"ticker",
"for",
"all",
"markets"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/poloniex.go#L40-L49 |
152,393 | jyap808/go-poloniex | poloniex.go | GetVolumes | func (b *Poloniex) GetVolumes() (vc VolumeCollection, err error) {
r, err := b.client.do("GET", "public?command=return24hVolume", nil, false)
if err != nil {
return
}
if err = json.Unmarshal(r, &vc); err != nil {
return
}
return
} | go | func (b *Poloniex) GetVolumes() (vc VolumeCollection, err error) {
r, err := b.client.do("GET", "public?command=return24hVolume", nil, false)
if err != nil {
return
}
if err = json.Unmarshal(r, &vc); err != nil {
return
}
return
} | [
"func",
"(",
"b",
"*",
"Poloniex",
")",
"GetVolumes",
"(",
")",
"(",
"vc",
"VolumeCollection",
",",
"err",
"error",
")",
"{",
"r",
",",
"err",
":=",
"b",
".",
"client",
".",
"do",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
")",... | // GetVolumes is used to get the volume for all markets | [
"GetVolumes",
"is",
"used",
"to",
"get",
"the",
"volume",
"for",
"all",
"markets"
] | 50b163cd72c2230ab6f107a0c024f53d488c4ec0 | https://github.com/jyap808/go-poloniex/blob/50b163cd72c2230ab6f107a0c024f53d488c4ec0/poloniex.go#L52-L61 |
152,394 | vburenin/nsync | trymutex.go | TryLockTimeout | func (tm TryMutex) TryLockTimeout(timeout time.Duration) bool {
select {
case tm.c <- struct{}{}:
return true
case <-time.After(timeout):
return false
}
} | go | func (tm TryMutex) TryLockTimeout(timeout time.Duration) bool {
select {
case tm.c <- struct{}{}:
return true
case <-time.After(timeout):
return false
}
} | [
"func",
"(",
"tm",
"TryMutex",
")",
"TryLockTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"bool",
"{",
"select",
"{",
"case",
"tm",
".",
"c",
"<-",
"struct",
"{",
"}",
"{",
"}",
":",
"return",
"true",
"\n",
"case",
"<-",
"time",
".",
"Aft... | // TryLockTimeout tries to acquires the lock returning true on success.
// Attempt to acquire the lock will timeout after the caller defined interval. | [
"TryLockTimeout",
"tries",
"to",
"acquires",
"the",
"lock",
"returning",
"true",
"on",
"success",
".",
"Attempt",
"to",
"acquire",
"the",
"lock",
"will",
"timeout",
"after",
"the",
"caller",
"defined",
"interval",
"."
] | 9a75d1c80410815ac45d65fc01ccabac9c98dd4a | https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/trymutex.go#L35-L42 |
152,395 | coccyx/go-s2s | s2s/s2s.go | encodeString | func encodeString(tosend string, buf *bytes.Buffer) {
l := uint32(len(tosend) + 1)
binary.Write(buf, binary.BigEndian, l)
binary.Write(buf, binary.BigEndian, []byte(tosend))
binary.Write(buf, binary.BigEndian, []byte{0})
} | go | func encodeString(tosend string, buf *bytes.Buffer) {
l := uint32(len(tosend) + 1)
binary.Write(buf, binary.BigEndian, l)
binary.Write(buf, binary.BigEndian, []byte(tosend))
binary.Write(buf, binary.BigEndian, []byte{0})
} | [
"func",
"encodeString",
"(",
"tosend",
"string",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"l",
":=",
"uint32",
"(",
"len",
"(",
"tosend",
")",
"+",
"1",
")",
"\n",
"binary",
".",
"Write",
"(",
"buf",
",",
"binary",
".",
"BigEndian",
",",
... | // encodeString encodes a string to be sent across the wire to Splunk
// Wire protocol has an unsigned integer of the length of the string followed
// by a null terminated string. | [
"encodeString",
"encodes",
"a",
"string",
"to",
"be",
"sent",
"across",
"the",
"wire",
"to",
"Splunk",
"Wire",
"protocol",
"has",
"an",
"unsigned",
"integer",
"of",
"the",
"length",
"of",
"the",
"string",
"followed",
"by",
"a",
"null",
"terminated",
"string"... | bdc39b6946f56bdce124941d05a64fad5e7aa9b7 | https://github.com/coccyx/go-s2s/blob/bdc39b6946f56bdce124941d05a64fad5e7aa9b7/s2s/s2s.go#L196-L201 |
152,396 | coccyx/go-s2s | s2s/s2s.go | EncodeEvent | func EncodeEvent(line map[string]string) []byte {
buf := bp.Get().(*bytes.Buffer)
defer bp.Put(buf)
buf.Reset()
binary.Write(buf, binary.BigEndian, uint32(0)) // Message Size
binary.Write(buf, binary.BigEndian, uint32(0)) // Map Count
// These fields should be present in every event
_time := line["_time"]
host := line["host"]
source := line["source"]
sourcetype := line["sourcetype"]
index := line["index"]
// These are optional
channel, hasChannel := line["_channel"]
conf, hasConf := line["_conf"]
_, hasLineBreaker := line["_linebreaker"]
_, hasDone := line["_done"]
var indexFields string
// Check time for subseconds
if strings.ContainsRune(_time, '.') {
timeparts := strings.Split(_time, ".")
_time = timeparts[0]
indexFields += "_subsecond::" + timeparts[1] + " "
}
for k, v := range line {
switch k {
case "source", "sourcetype", "host", "index", "_raw", "_time", "_channel", "_conf", "_linebreaker", "_done":
break
default:
indexFields += k + "::" + v + " "
}
}
maps := 7
encodeKeyValue("_raw", line["_raw"], buf)
if len(indexFields) > 0 {
indexFields = strings.TrimRight(indexFields, " ")
encodeKeyValue("_meta", indexFields, buf)
maps++
}
if hasDone {
encodeKeyValue("_done", "_done", buf)
maps++
}
if hasLineBreaker {
encodeKeyValue("_linebreaker", "_linebreaker", buf)
maps++
}
encodeKeyValue("_hpn", "_hpn", buf)
encodeKeyValue("_time", _time, buf)
if hasConf {
encodeKeyValue("_conf", conf, buf)
maps++
}
encodeKeyValue("MetaData:Source", "source::"+source, buf)
encodeKeyValue("MetaData:Host", "host::"+host, buf)
encodeKeyValue("MetaData:Sourcetype", "sourcetype::"+sourcetype, buf)
if hasChannel {
encodeKeyValue("_channel", channel, buf)
maps++
}
encodeKeyValue("_MetaData:Index", index, buf)
binary.Write(buf, binary.BigEndian, uint32(0)) // Null terminate raw
encodeString("_raw", buf) // Raw trailer
ret := buf.Bytes()
binary.BigEndian.PutUint32(ret, uint32(len(ret)-4)) // Don't include null terminator in message size
binary.BigEndian.PutUint32(ret[4:], uint32(maps)) // Include extra map for _done key and one for _raw
return ret
} | go | func EncodeEvent(line map[string]string) []byte {
buf := bp.Get().(*bytes.Buffer)
defer bp.Put(buf)
buf.Reset()
binary.Write(buf, binary.BigEndian, uint32(0)) // Message Size
binary.Write(buf, binary.BigEndian, uint32(0)) // Map Count
// These fields should be present in every event
_time := line["_time"]
host := line["host"]
source := line["source"]
sourcetype := line["sourcetype"]
index := line["index"]
// These are optional
channel, hasChannel := line["_channel"]
conf, hasConf := line["_conf"]
_, hasLineBreaker := line["_linebreaker"]
_, hasDone := line["_done"]
var indexFields string
// Check time for subseconds
if strings.ContainsRune(_time, '.') {
timeparts := strings.Split(_time, ".")
_time = timeparts[0]
indexFields += "_subsecond::" + timeparts[1] + " "
}
for k, v := range line {
switch k {
case "source", "sourcetype", "host", "index", "_raw", "_time", "_channel", "_conf", "_linebreaker", "_done":
break
default:
indexFields += k + "::" + v + " "
}
}
maps := 7
encodeKeyValue("_raw", line["_raw"], buf)
if len(indexFields) > 0 {
indexFields = strings.TrimRight(indexFields, " ")
encodeKeyValue("_meta", indexFields, buf)
maps++
}
if hasDone {
encodeKeyValue("_done", "_done", buf)
maps++
}
if hasLineBreaker {
encodeKeyValue("_linebreaker", "_linebreaker", buf)
maps++
}
encodeKeyValue("_hpn", "_hpn", buf)
encodeKeyValue("_time", _time, buf)
if hasConf {
encodeKeyValue("_conf", conf, buf)
maps++
}
encodeKeyValue("MetaData:Source", "source::"+source, buf)
encodeKeyValue("MetaData:Host", "host::"+host, buf)
encodeKeyValue("MetaData:Sourcetype", "sourcetype::"+sourcetype, buf)
if hasChannel {
encodeKeyValue("_channel", channel, buf)
maps++
}
encodeKeyValue("_MetaData:Index", index, buf)
binary.Write(buf, binary.BigEndian, uint32(0)) // Null terminate raw
encodeString("_raw", buf) // Raw trailer
ret := buf.Bytes()
binary.BigEndian.PutUint32(ret, uint32(len(ret)-4)) // Don't include null terminator in message size
binary.BigEndian.PutUint32(ret[4:], uint32(maps)) // Include extra map for _done key and one for _raw
return ret
} | [
"func",
"EncodeEvent",
"(",
"line",
"map",
"[",
"string",
"]",
"string",
")",
"[",
"]",
"byte",
"{",
"buf",
":=",
"bp",
".",
"Get",
"(",
")",
".",
"(",
"*",
"bytes",
".",
"Buffer",
")",
"\n",
"defer",
"bp",
".",
"Put",
"(",
"buf",
")",
"\n",
... | // EncodeEvent encodes a full Splunk event | [
"EncodeEvent",
"encodes",
"a",
"full",
"Splunk",
"event"
] | bdc39b6946f56bdce124941d05a64fad5e7aa9b7 | https://github.com/coccyx/go-s2s/blob/bdc39b6946f56bdce124941d05a64fad5e7aa9b7/s2s/s2s.go#L211-L287 |
152,397 | coccyx/go-s2s | s2s/s2s.go | Copy | func (st *S2S) Copy(r io.Reader) (int64, error) {
if st.closed {
return 0, fmt.Errorf("cannot send on closed connection")
}
if time.Now().Sub(st.lastSendTime) > time.Duration(st.maxIdleTime)*time.Second {
st.reconnect(true)
}
bytes, err := io.Copy(st.buf, r)
if err != nil {
return bytes, err
}
st.lastSendTime = time.Now()
st.reconnect(false)
return bytes, nil
} | go | func (st *S2S) Copy(r io.Reader) (int64, error) {
if st.closed {
return 0, fmt.Errorf("cannot send on closed connection")
}
if time.Now().Sub(st.lastSendTime) > time.Duration(st.maxIdleTime)*time.Second {
st.reconnect(true)
}
bytes, err := io.Copy(st.buf, r)
if err != nil {
return bytes, err
}
st.lastSendTime = time.Now()
st.reconnect(false)
return bytes, nil
} | [
"func",
"(",
"st",
"*",
"S2S",
")",
"Copy",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"int64",
",",
"error",
")",
"{",
"if",
"st",
".",
"closed",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"ti... | // Copy takes a io.Reader and copies it to Splunk, needs to be encoded by EncodeEvent | [
"Copy",
"takes",
"a",
"io",
".",
"Reader",
"and",
"copies",
"it",
"to",
"Splunk",
"needs",
"to",
"be",
"encoded",
"by",
"EncodeEvent"
] | bdc39b6946f56bdce124941d05a64fad5e7aa9b7 | https://github.com/coccyx/go-s2s/blob/bdc39b6946f56bdce124941d05a64fad5e7aa9b7/s2s/s2s.go#L296-L312 |
152,398 | coccyx/go-s2s | s2s/s2s.go | Close | func (st *S2S) Close() error {
if !st.closed {
err := st.close()
if err != nil {
return err
}
st.closed = true
}
return nil
} | go | func (st *S2S) Close() error {
if !st.closed {
err := st.close()
if err != nil {
return err
}
st.closed = true
}
return nil
} | [
"func",
"(",
"st",
"*",
"S2S",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"!",
"st",
".",
"closed",
"{",
"err",
":=",
"st",
".",
"close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"st",
".",
"closed",
... | // Close disconnects from Splunk | [
"Close",
"disconnects",
"from",
"Splunk"
] | bdc39b6946f56bdce124941d05a64fad5e7aa9b7 | https://github.com/coccyx/go-s2s/blob/bdc39b6946f56bdce124941d05a64fad5e7aa9b7/s2s/s2s.go#L315-L324 |
152,399 | bobbytables/slacker | cmd/slacker/main.go | main | func main() {
app := cli.NewApp()
app.Usage = "runs methods against the Slack API and returns the result"
app.Author = "Bobby Tables <me@bobbytables.io>"
app.Name = "slacker"
app.Commands = []cli.Command{slackMethod()}
app.Run(os.Args)
} | go | func main() {
app := cli.NewApp()
app.Usage = "runs methods against the Slack API and returns the result"
app.Author = "Bobby Tables <me@bobbytables.io>"
app.Name = "slacker"
app.Commands = []cli.Command{slackMethod()}
app.Run(os.Args)
} | [
"func",
"main",
"(",
")",
"{",
"app",
":=",
"cli",
".",
"NewApp",
"(",
")",
"\n",
"app",
".",
"Usage",
"=",
"\"",
"\"",
"\n",
"app",
".",
"Author",
"=",
"\"",
"\"",
"\n",
"app",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"app",
".",
"Commands",
"=",... | // This command line tool is mostly used to just see if you're wired up
// correctly. If you're making contributions this is a good tool to modify
// to do smoke testing. | [
"This",
"command",
"line",
"tool",
"is",
"mostly",
"used",
"to",
"just",
"see",
"if",
"you",
"re",
"wired",
"up",
"correctly",
".",
"If",
"you",
"re",
"making",
"contributions",
"this",
"is",
"a",
"good",
"tool",
"to",
"modify",
"to",
"do",
"smoke",
"t... | 0a05912e400e9aacca7296855ba9fb874cdf34c5 | https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/cmd/slacker/main.go#L14-L22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.