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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,300 | NebulousLabs/go-upnp | goupnp/service_client.go | NewServiceClients | func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []error, err error) {
return NewServiceClientsCtx(context.Background(), searchTarget)
} | go | func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []error, err error) {
return NewServiceClientsCtx(context.Background(), searchTarget)
} | [
"func",
"NewServiceClients",
"(",
"searchTarget",
"string",
")",
"(",
"clients",
"[",
"]",
"ServiceClient",
",",
"errors",
"[",
"]",
"error",
",",
"err",
"error",
")",
"{",
"return",
"NewServiceClientsCtx",
"(",
"context",
".",
"Background",
"(",
")",
",",
... | // NewServiceClients is deprecated. Use NewServiceClientsCtx instead. | [
"NewServiceClients",
"is",
"deprecated",
".",
"Use",
"NewServiceClientsCtx",
"instead",
"."
] | b32978b8ccbffe222d6f37a980e795074ac2ba74 | https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/goupnp/service_client.go#L24-L26 |
141,301 | NebulousLabs/go-upnp | goupnp/soap/soap.go | PerformAction | func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAction interface{}, outAction interface{}) error {
requestBytes, err := encodeRequestAction(actionNamespace, actionName, inAction)
if err != nil {
return err
}
response, err := client.HTTPClient.Do(&http.Request{
Method: "POST",
UR... | go | func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAction interface{}, outAction interface{}) error {
requestBytes, err := encodeRequestAction(actionNamespace, actionName, inAction)
if err != nil {
return err
}
response, err := client.HTTPClient.Do(&http.Request{
Method: "POST",
UR... | [
"func",
"(",
"client",
"*",
"SOAPClient",
")",
"PerformAction",
"(",
"actionNamespace",
",",
"actionName",
"string",
",",
"inAction",
"interface",
"{",
"}",
",",
"outAction",
"interface",
"{",
"}",
")",
"error",
"{",
"requestBytes",
",",
"err",
":=",
"encode... | // PerformSOAPAction makes a SOAP request, with the given action.
// inAction and outAction must both be pointers to structs with string fields
// only. | [
"PerformSOAPAction",
"makes",
"a",
"SOAP",
"request",
"with",
"the",
"given",
"action",
".",
"inAction",
"and",
"outAction",
"must",
"both",
"be",
"pointers",
"to",
"structs",
"with",
"string",
"fields",
"only",
"."
] | b32978b8ccbffe222d6f37a980e795074ac2ba74 | https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/goupnp/soap/soap.go#L35-L78 |
141,302 | comail/colog | std_formatter.go | levelHeaders | func (sf *StdFormatter) levelHeaders() LevelMap {
switch {
case sf.NoColors:
return sf.HeaderPlain
case sf.Colors:
return sf.HeaderColor
case sf.colorSupported:
return sf.HeaderColor
}
return sf.HeaderPlain
} | go | func (sf *StdFormatter) levelHeaders() LevelMap {
switch {
case sf.NoColors:
return sf.HeaderPlain
case sf.Colors:
return sf.HeaderColor
case sf.colorSupported:
return sf.HeaderColor
}
return sf.HeaderPlain
} | [
"func",
"(",
"sf",
"*",
"StdFormatter",
")",
"levelHeaders",
"(",
")",
"LevelMap",
"{",
"switch",
"{",
"case",
"sf",
".",
"NoColors",
":",
"return",
"sf",
".",
"HeaderPlain",
"\n",
"case",
"sf",
".",
"Colors",
":",
"return",
"sf",
".",
"HeaderColor",
"... | // levelHeaders returns plain or color level headers
// depending on user preference and output support | [
"levelHeaders",
"returns",
"plain",
"or",
"color",
"level",
"headers",
"depending",
"on",
"user",
"preference",
"and",
"output",
"support"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/std_formatter.go#L78-L88 |
141,303 | comail/colog | std_formatter.go | stdHeader | func (sf *StdFormatter) stdHeader(buf *[]byte, t time.Time, prefix, file string, line int) {
*buf = append(*buf, prefix...)
if sf.Flag&(log.Ldate|log.Ltime|log.Lmicroseconds) != 0 {
if sf.Flag&log.Ldate != 0 {
year, month, day := t.Date()
itoa(buf, year, 4)
*buf = append(*buf, '/')
itoa(buf, int(month),... | go | func (sf *StdFormatter) stdHeader(buf *[]byte, t time.Time, prefix, file string, line int) {
*buf = append(*buf, prefix...)
if sf.Flag&(log.Ldate|log.Ltime|log.Lmicroseconds) != 0 {
if sf.Flag&log.Ldate != 0 {
year, month, day := t.Date()
itoa(buf, year, 4)
*buf = append(*buf, '/')
itoa(buf, int(month),... | [
"func",
"(",
"sf",
"*",
"StdFormatter",
")",
"stdHeader",
"(",
"buf",
"*",
"[",
"]",
"byte",
",",
"t",
"time",
".",
"Time",
",",
"prefix",
",",
"file",
"string",
",",
"line",
"int",
")",
"{",
"*",
"buf",
"=",
"append",
"(",
"*",
"buf",
",",
"pr... | // Adapted replica of log.Logger.formatHeader | [
"Adapted",
"replica",
"of",
"log",
".",
"Logger",
".",
"formatHeader"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/std_formatter.go#L106-L152 |
141,304 | comail/colog | std_formatter.go | getFileLine | func getFileLine(calldepth int) (string, int) {
var file string
var line int
var ok bool
_, file, line, ok = runtime.Caller(calldepth)
if !ok {
file = "???"
line = 0
}
return file, line
} | go | func getFileLine(calldepth int) (string, int) {
var file string
var line int
var ok bool
_, file, line, ok = runtime.Caller(calldepth)
if !ok {
file = "???"
line = 0
}
return file, line
} | [
"func",
"getFileLine",
"(",
"calldepth",
"int",
")",
"(",
"string",
",",
"int",
")",
"{",
"var",
"file",
"string",
"\n",
"var",
"line",
"int",
"\n\n",
"var",
"ok",
"bool",
"\n",
"_",
",",
"file",
",",
"line",
",",
"ok",
"=",
"runtime",
".",
"Caller... | // get file a line where logger was called | [
"get",
"file",
"a",
"line",
"where",
"logger",
"was",
"called"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/std_formatter.go#L194-L207 |
141,305 | comail/colog | std_formatter.go | itoa | func itoa(buf *[]byte, i int, wid int) {
var u = uint(i)
if u == 0 && wid <= 1 {
*buf = append(*buf, '0')
return
}
// Assemble decimal in reverse order.
var b [32]byte
bp := len(b)
for ; u > 0 || wid > 0; u /= 10 {
bp--
wid--
b[bp] = byte(u%10) + '0'
}
*buf = append(*buf, b[bp:]...)
} | go | func itoa(buf *[]byte, i int, wid int) {
var u = uint(i)
if u == 0 && wid <= 1 {
*buf = append(*buf, '0')
return
}
// Assemble decimal in reverse order.
var b [32]byte
bp := len(b)
for ; u > 0 || wid > 0; u /= 10 {
bp--
wid--
b[bp] = byte(u%10) + '0'
}
*buf = append(*buf, b[bp:]...)
} | [
"func",
"itoa",
"(",
"buf",
"*",
"[",
"]",
"byte",
",",
"i",
"int",
",",
"wid",
"int",
")",
"{",
"var",
"u",
"=",
"uint",
"(",
"i",
")",
"\n",
"if",
"u",
"==",
"0",
"&&",
"wid",
"<=",
"1",
"{",
"*",
"buf",
"=",
"append",
"(",
"*",
"buf",
... | // Replica of log.Logger.itoa | [
"Replica",
"of",
"log",
".",
"Logger",
".",
"itoa"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/std_formatter.go#L210-L226 |
141,306 | comail/colog | colog.go | String | func (level Level) String() string {
switch level {
case LTrace:
return "trace"
case LDebug:
return "debug"
case LInfo:
return "info"
case LWarning:
return "warning"
case LError:
return "error"
case LAlert:
return "alert"
}
return "unknown"
} | go | func (level Level) String() string {
switch level {
case LTrace:
return "trace"
case LDebug:
return "debug"
case LInfo:
return "info"
case LWarning:
return "warning"
case LError:
return "error"
case LAlert:
return "alert"
}
return "unknown"
} | [
"func",
"(",
"level",
"Level",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"level",
"{",
"case",
"LTrace",
":",
"return",
"\"",
"\"",
"\n",
"case",
"LDebug",
":",
"return",
"\"",
"\"",
"\n",
"case",
"LInfo",
":",
"return",
"\"",
"\"",
"\n",
"... | // String implements the Stringer interface for levels | [
"String",
"implements",
"the",
"Stringer",
"interface",
"for",
"levels"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L93-L110 |
141,307 | comail/colog | colog.go | Register | func Register() {
// Inherit standard logger flags and prefix if appropriate
if !std.customFmt {
std.formatter.SetFlags(log.Flags())
}
if log.Prefix() != "" && std.prefix == "" {
std.SetPrefix(log.Prefix())
}
// Disable all extras
log.SetPrefix("")
log.SetFlags(0)
// Set CoLog as output
log.SetOutput(s... | go | func Register() {
// Inherit standard logger flags and prefix if appropriate
if !std.customFmt {
std.formatter.SetFlags(log.Flags())
}
if log.Prefix() != "" && std.prefix == "" {
std.SetPrefix(log.Prefix())
}
// Disable all extras
log.SetPrefix("")
log.SetFlags(0)
// Set CoLog as output
log.SetOutput(s... | [
"func",
"Register",
"(",
")",
"{",
"// Inherit standard logger flags and prefix if appropriate",
"if",
"!",
"std",
".",
"customFmt",
"{",
"std",
".",
"formatter",
".",
"SetFlags",
"(",
"log",
".",
"Flags",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"log",
".",
... | // Register sets CoLog as output for the default logger.
// It "hijacks" the standard logger flags and prefix previously set.
// It's not possible to know the output previously set, so the
// default os.Stderr is assumed. | [
"Register",
"sets",
"CoLog",
"as",
"output",
"for",
"the",
"default",
"logger",
".",
"It",
"hijacks",
"the",
"standard",
"logger",
"flags",
"and",
"prefix",
"previously",
"set",
".",
"It",
"s",
"not",
"possible",
"to",
"know",
"the",
"output",
"previously",
... | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L161-L177 |
141,308 | comail/colog | colog.go | AddHook | func (cl *CoLog) AddHook(hook Hook) {
cl.mu.Lock()
defer cl.mu.Unlock()
for _, l := range hook.Levels() {
cl.hooks[l] = append(cl.hooks[l], hook)
}
} | go | func (cl *CoLog) AddHook(hook Hook) {
cl.mu.Lock()
defer cl.mu.Unlock()
for _, l := range hook.Levels() {
cl.hooks[l] = append(cl.hooks[l], hook)
}
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"AddHook",
"(",
"hook",
"Hook",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"l",
":=",
"range",
"hook",
".",
"Levels... | // AddHook adds a hook to be fired on every event with
// matching level being logged. See the hook interface | [
"AddHook",
"adds",
"a",
"hook",
"to",
"be",
"fired",
"on",
"every",
"event",
"with",
"matching",
"level",
"being",
"logged",
".",
"See",
"the",
"hook",
"interface"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L181-L188 |
141,309 | comail/colog | colog.go | SetHost | func (cl *CoLog) SetHost(host string) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.host = host
} | go | func (cl *CoLog) SetHost(host string) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.host = host
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetHost",
"(",
"host",
"string",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"host",
"=",
"host",
"\n",
"}"
] | // SetHost sets the logger hostname assigned to the entries | [
"SetHost",
"sets",
"the",
"logger",
"hostname",
"assigned",
"to",
"the",
"entries"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L191-L196 |
141,310 | comail/colog | colog.go | SetPrefix | func (cl *CoLog) SetPrefix(prefix string) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.prefix = prefix
} | go | func (cl *CoLog) SetPrefix(prefix string) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.prefix = prefix
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetPrefix",
"(",
"prefix",
"string",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"prefix",
"=",
"prefix",
"\n",
"}"
] | // SetPrefix sets the logger output prefix | [
"SetPrefix",
"sets",
"the",
"logger",
"output",
"prefix"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L199-L204 |
141,311 | comail/colog | colog.go | SetMinLevel | func (cl *CoLog) SetMinLevel(l Level) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.minLevel = l
} | go | func (cl *CoLog) SetMinLevel(l Level) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.minLevel = l
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetMinLevel",
"(",
"l",
"Level",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"minLevel",
"=",
"l",
"\n",
"}"
] | // SetMinLevel sets the minimum level that will be actually logged | [
"SetMinLevel",
"sets",
"the",
"minimum",
"level",
"that",
"will",
"be",
"actually",
"logged"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L207-L212 |
141,312 | comail/colog | colog.go | SetDefaultLevel | func (cl *CoLog) SetDefaultLevel(l Level) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.defaultLevel = l
} | go | func (cl *CoLog) SetDefaultLevel(l Level) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.defaultLevel = l
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetDefaultLevel",
"(",
"l",
"Level",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"defaultLevel",
"=",
"l",
"\n",
"}"
] | // SetDefaultLevel sets the level that will be used when no level is detected | [
"SetDefaultLevel",
"sets",
"the",
"level",
"that",
"will",
"be",
"used",
"when",
"no",
"level",
"is",
"detected"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L215-L220 |
141,313 | comail/colog | colog.go | ParseFields | func (cl *CoLog) ParseFields(active bool) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.parseFields = active
} | go | func (cl *CoLog) ParseFields(active bool) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.parseFields = active
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"ParseFields",
"(",
"active",
"bool",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"parseFields",
"=",
"active",
"\n",
"}"
] | // ParseFields activates or deactivates field parsing in the message | [
"ParseFields",
"activates",
"or",
"deactivates",
"field",
"parsing",
"in",
"the",
"message"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L223-L228 |
141,314 | comail/colog | colog.go | SetHeaders | func (cl *CoLog) SetHeaders(headers HeaderMap) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.headers = headers
} | go | func (cl *CoLog) SetHeaders(headers HeaderMap) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.headers = headers
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetHeaders",
"(",
"headers",
"HeaderMap",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"headers",
"=",
"headers",
"\n",
"}"
] | // SetHeaders sets custom headers as the input headers to be search for to determine the level | [
"SetHeaders",
"sets",
"custom",
"headers",
"as",
"the",
"input",
"headers",
"to",
"be",
"search",
"for",
"to",
"determine",
"the",
"level"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L231-L236 |
141,315 | comail/colog | colog.go | AddHeader | func (cl *CoLog) AddHeader(header string, level Level) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.headers[header] = level
} | go | func (cl *CoLog) AddHeader(header string, level Level) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.headers[header] = level
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"AddHeader",
"(",
"header",
"string",
",",
"level",
"Level",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"headers",
"[",
"he... | // AddHeader adds a custom header to the input headers to be search for to determine the level | [
"AddHeader",
"adds",
"a",
"custom",
"header",
"to",
"the",
"input",
"headers",
"to",
"be",
"search",
"for",
"to",
"determine",
"the",
"level"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L239-L244 |
141,316 | comail/colog | colog.go | SetFormatter | func (cl *CoLog) SetFormatter(f Formatter) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.customFmt = true
cl.formatter = f
} | go | func (cl *CoLog) SetFormatter(f Formatter) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.customFmt = true
cl.formatter = f
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetFormatter",
"(",
"f",
"Formatter",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"customFmt",
"=",
"true",
"\n",
"cl",
"."... | // SetFormatter sets the formatter to use | [
"SetFormatter",
"sets",
"the",
"formatter",
"to",
"use"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L247-L253 |
141,317 | comail/colog | colog.go | SetExtractor | func (cl *CoLog) SetExtractor(ex Extractor) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.extractor = ex
} | go | func (cl *CoLog) SetExtractor(ex Extractor) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.extractor = ex
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetExtractor",
"(",
"ex",
"Extractor",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"extractor",
"=",
"ex",
"\n",
"}"
] | // SetExtractor sets the formatter to use | [
"SetExtractor",
"sets",
"the",
"formatter",
"to",
"use"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L256-L261 |
141,318 | comail/colog | colog.go | FixedValue | func (cl *CoLog) FixedValue(key string, value interface{}) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.fixed[key] = value
} | go | func (cl *CoLog) FixedValue(key string, value interface{}) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.fixed[key] = value
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"FixedValue",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"fixed"... | // FixedValue sets a key-value pair that will get automatically
// added to every log entry in this logger | [
"FixedValue",
"sets",
"a",
"key",
"-",
"value",
"pair",
"that",
"will",
"get",
"automatically",
"added",
"to",
"every",
"log",
"entry",
"in",
"this",
"logger"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L265-L270 |
141,319 | comail/colog | colog.go | ClearFixedValues | func (cl *CoLog) ClearFixedValues() {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.fixed = make(Fields)
} | go | func (cl *CoLog) ClearFixedValues() {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.fixed = make(Fields)
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"ClearFixedValues",
"(",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"fixed",
"=",
"make",
"(",
"Fields",
")",
"\n",
"}"
] | // ClearFixedValues removes all previously set fields from the logger | [
"ClearFixedValues",
"removes",
"all",
"previously",
"set",
"fields",
"from",
"the",
"logger"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L273-L278 |
141,320 | comail/colog | colog.go | Flags | func (cl *CoLog) Flags() int {
cl.mu.Lock()
defer cl.mu.Unlock()
if cl.formatter == nil {
return 0
}
return cl.formatter.Flags()
} | go | func (cl *CoLog) Flags() int {
cl.mu.Lock()
defer cl.mu.Unlock()
if cl.formatter == nil {
return 0
}
return cl.formatter.Flags()
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"Flags",
"(",
")",
"int",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"cl",
".",
"formatter",
"==",
"nil",
"{",
"return",
"0",
"\n",
... | // Flags returns the output flags for the formatter if any | [
"Flags",
"returns",
"the",
"output",
"flags",
"for",
"the",
"formatter",
"if",
"any"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L281-L289 |
141,321 | comail/colog | colog.go | SetFlags | func (cl *CoLog) SetFlags(flags int) {
cl.mu.Lock()
defer cl.mu.Unlock()
if cl.formatter == nil {
return
}
cl.formatter.SetFlags(flags)
} | go | func (cl *CoLog) SetFlags(flags int) {
cl.mu.Lock()
defer cl.mu.Unlock()
if cl.formatter == nil {
return
}
cl.formatter.SetFlags(flags)
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetFlags",
"(",
"flags",
"int",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"cl",
".",
"formatter",
"==",
"nil",
"{",
"return",
... | // SetFlags sets the output flags for the formatter if any | [
"SetFlags",
"sets",
"the",
"output",
"flags",
"for",
"the",
"formatter",
"if",
"any"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L292-L300 |
141,322 | comail/colog | colog.go | SetOutput | func (cl *CoLog) SetOutput(w io.Writer) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.out = w
// if we have a color formatter, notify if new output supports color
if _, ok := cl.formatter.(ColorFormatter); ok {
cl.formatter.(ColorFormatter).ColorSupported(cl.colorSupported())
}
} | go | func (cl *CoLog) SetOutput(w io.Writer) {
cl.mu.Lock()
defer cl.mu.Unlock()
cl.out = w
// if we have a color formatter, notify if new output supports color
if _, ok := cl.formatter.(ColorFormatter); ok {
cl.formatter.(ColorFormatter).ColorSupported(cl.colorSupported())
}
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"SetOutput",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"cl",
".",
"out",
"=",
"w",
"\n\n",
"// if we... | // SetOutput is analog to log.SetOutput sets the output destination. | [
"SetOutput",
"is",
"analog",
"to",
"log",
".",
"SetOutput",
"sets",
"the",
"output",
"destination",
"."
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L303-L313 |
141,323 | comail/colog | colog.go | NewLogger | func (cl *CoLog) NewLogger() *log.Logger {
cl.mu.Lock()
defer cl.mu.Unlock()
return log.New(cl, "", 0)
} | go | func (cl *CoLog) NewLogger() *log.Logger {
cl.mu.Lock()
defer cl.mu.Unlock()
return log.New(cl, "", 0)
} | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"NewLogger",
"(",
")",
"*",
"log",
".",
"Logger",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cl",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"log",
".",
"New",
"(",
"cl",
",",... | // NewLogger returns a colog-enabled logger | [
"NewLogger",
"returns",
"a",
"colog",
"-",
"enabled",
"logger"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L316-L321 |
141,324 | comail/colog | colog.go | Write | func (cl *CoLog) Write(p []byte) (n int, err error) {
cl.mu.Lock()
defer func() {
cl.mu.Unlock()
if r := recover(); r != nil {
err = fmt.Errorf("error: colog: recovered panic %v\n", r)
fmt.Fprintln(os.Stderr, err.Error())
}
}()
e := cl.parse(p)
cl.extractFields(e)
cl.fireHooks(e)
if e.Level != unkn... | go | func (cl *CoLog) Write(p []byte) (n int, err error) {
cl.mu.Lock()
defer func() {
cl.mu.Unlock()
if r := recover(); r != nil {
err = fmt.Errorf("error: colog: recovered panic %v\n", r)
fmt.Fprintln(os.Stderr, err.Error())
}
}()
e := cl.parse(p)
cl.extractFields(e)
cl.fireHooks(e)
if e.Level != unkn... | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"cl",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"cl",
".",
"mu",
".",
"Unlock",
... | // Write implements io.Writer interface to that the standard logger uses. | [
"Write",
"implements",
"io",
".",
"Writer",
"interface",
"to",
"that",
"the",
"standard",
"logger",
"uses",
"."
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L324-L364 |
141,325 | comail/colog | colog.go | colorSupported | func (cl *CoLog) colorSupported() bool {
// ColorSupporters can decide themselves
if ce, ok := cl.out.(ColorSupporter); ok {
return ce.ColorSupported()
}
// Windows users need ColorSupporter outputs
if runtime.GOOS == "windows" {
return false
}
// Check for Fd() method
output, ok := cl.out.(interface {
... | go | func (cl *CoLog) colorSupported() bool {
// ColorSupporters can decide themselves
if ce, ok := cl.out.(ColorSupporter); ok {
return ce.ColorSupported()
}
// Windows users need ColorSupporter outputs
if runtime.GOOS == "windows" {
return false
}
// Check for Fd() method
output, ok := cl.out.(interface {
... | [
"func",
"(",
"cl",
"*",
"CoLog",
")",
"colorSupported",
"(",
")",
"bool",
"{",
"// ColorSupporters can decide themselves",
"if",
"ce",
",",
"ok",
":=",
"cl",
".",
"out",
".",
"(",
"ColorSupporter",
")",
";",
"ok",
"{",
"return",
"ce",
".",
"ColorSupported"... | // figure if output supports color | [
"figure",
"if",
"output",
"supports",
"color"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L405-L428 |
141,326 | comail/colog | colog.go | ParseLevel | func ParseLevel(level string) (Level, error) {
if lvl, ok := std.headers[level+": "]; ok {
return lvl, nil
}
return unknown, fmt.Errorf("could not parse level %s", level)
} | go | func ParseLevel(level string) (Level, error) {
if lvl, ok := std.headers[level+": "]; ok {
return lvl, nil
}
return unknown, fmt.Errorf("could not parse level %s", level)
} | [
"func",
"ParseLevel",
"(",
"level",
"string",
")",
"(",
"Level",
",",
"error",
")",
"{",
"if",
"lvl",
",",
"ok",
":=",
"std",
".",
"headers",
"[",
"level",
"+",
"\"",
"\"",
"]",
";",
"ok",
"{",
"return",
"lvl",
",",
"nil",
"\n",
"}",
"\n\n",
"r... | // ParseLevel parses a string into a type Level | [
"ParseLevel",
"parses",
"a",
"string",
"into",
"a",
"type",
"Level"
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/colog.go#L528-L534 |
141,327 | comail/colog | tty_windows.go | isTerminalFunc | func isTerminalFunc(fd int) bool {
var st uint32
r, _, errno := syscall.Syscall(procMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
if errno != 0 {
return false
}
return r != 0
} | go | func isTerminalFunc(fd int) bool {
var st uint32
r, _, errno := syscall.Syscall(procMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
if errno != 0 {
return false
}
return r != 0
} | [
"func",
"isTerminalFunc",
"(",
"fd",
"int",
")",
"bool",
"{",
"var",
"st",
"uint32",
"\n",
"r",
",",
"_",
",",
"errno",
":=",
"syscall",
".",
"Syscall",
"(",
"procMode",
".",
"Addr",
"(",
")",
",",
"2",
",",
"uintptr",
"(",
"fd",
")",
",",
"uintp... | // isTerminalFunc returns true if the given file descriptor is a terminal. | [
"isTerminalFunc",
"returns",
"true",
"if",
"the",
"given",
"file",
"descriptor",
"is",
"a",
"terminal",
"."
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/tty_windows.go#L21-L29 |
141,328 | comail/colog | std_extractor.go | Extract | func (se *StdExtractor) Extract(e *Entry) error {
if se.rxFields == nil {
se.rxFields = regexp.MustCompile(fieldsRegex)
}
matches := se.rxFields.FindAllSubmatch(e.Message, -1)
if matches == nil {
return nil
}
var key, value []byte
captures := make(map[string]interface{})
// Look for positions with: fmt.Pr... | go | func (se *StdExtractor) Extract(e *Entry) error {
if se.rxFields == nil {
se.rxFields = regexp.MustCompile(fieldsRegex)
}
matches := se.rxFields.FindAllSubmatch(e.Message, -1)
if matches == nil {
return nil
}
var key, value []byte
captures := make(map[string]interface{})
// Look for positions with: fmt.Pr... | [
"func",
"(",
"se",
"*",
"StdExtractor",
")",
"Extract",
"(",
"e",
"*",
"Entry",
")",
"error",
"{",
"if",
"se",
".",
"rxFields",
"==",
"nil",
"{",
"se",
".",
"rxFields",
"=",
"regexp",
".",
"MustCompile",
"(",
"fieldsRegex",
")",
"\n",
"}",
"\n",
"m... | // Extract finds key-value pairs in the message and sets them as Fields
// in the entry removing the pairs from the message. | [
"Extract",
"finds",
"key",
"-",
"value",
"pairs",
"in",
"the",
"message",
"and",
"sets",
"them",
"as",
"Fields",
"in",
"the",
"entry",
"removing",
"the",
"pairs",
"from",
"the",
"message",
"."
] | fba8e7b1f46c3607f09760ce3880066e7ff57c5a | https://github.com/comail/colog/blob/fba8e7b1f46c3607f09760ce3880066e7ff57c5a/std_extractor.go#L21-L61 |
141,329 | carbocation/interpose | middleware/basicAuth.go | BasicAuth | func BasicAuth(username string, password string) func(http.Handler) http.Handler {
var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
auth := req.Header.Get("A... | go | func BasicAuth(username string, password string) func(http.Handler) http.Handler {
var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
auth := req.Header.Get("A... | [
"func",
"BasicAuth",
"(",
"username",
"string",
",",
"password",
"string",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"var",
"siteAuth",
"=",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"[",
"]",
"byte",
"("... | // Basic returns a Handler that authenticates via Basic Auth. Writes a http.StatusUnauthorized
// if authentication fails | [
"Basic",
"returns",
"a",
"Handler",
"that",
"authenticates",
"via",
"Basic",
"Auth",
".",
"Writes",
"a",
"http",
".",
"StatusUnauthorized",
"if",
"authentication",
"fails"
] | 723534742ba3bbda66268b735aaa41634468acc6 | https://github.com/carbocation/interpose/blob/723534742ba3bbda66268b735aaa41634468acc6/middleware/basicAuth.go#L19-L31 |
141,330 | carbocation/interpose | middleware/nosurf.go | Nosurf | func Nosurf() func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return nosurf.New(next)
}
} | go | func Nosurf() func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return nosurf.New(next)
}
} | [
"func",
"Nosurf",
"(",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"nosurf",
".",
"New",
"(",
"next",
")",
"\n",
"}",... | // Nosurf is a wrapper for justinas' csrf protection middleware | [
"Nosurf",
"is",
"a",
"wrapper",
"for",
"justinas",
"csrf",
"protection",
"middleware"
] | 723534742ba3bbda66268b735aaa41634468acc6 | https://github.com/carbocation/interpose/blob/723534742ba3bbda66268b735aaa41634468acc6/middleware/nosurf.go#L10-L14 |
141,331 | Azure/azure-pipeline-go | pipeline/error.go | Temporary | func (e ErrorNode) Temporary() bool {
type temporary interface {
Temporary() bool
}
for err := e.cause; err != nil; {
if t, ok := err.(temporary); ok {
return t.Temporary()
}
if cause, ok := err.(causer); ok {
err = cause.Cause()
} else {
err = nil
}
}
return false
} | go | func (e ErrorNode) Temporary() bool {
type temporary interface {
Temporary() bool
}
for err := e.cause; err != nil; {
if t, ok := err.(temporary); ok {
return t.Temporary()
}
if cause, ok := err.(causer); ok {
err = cause.Cause()
} else {
err = nil
}
}
return false
} | [
"func",
"(",
"e",
"ErrorNode",
")",
"Temporary",
"(",
")",
"bool",
"{",
"type",
"temporary",
"interface",
"{",
"Temporary",
"(",
")",
"bool",
"\n",
"}",
"\n\n",
"for",
"err",
":=",
"e",
".",
"cause",
";",
"err",
"!=",
"nil",
";",
"{",
"if",
"t",
... | // Temporary returns true if the error occurred due to a temporary condition. | [
"Temporary",
"returns",
"true",
"if",
"the",
"error",
"occurred",
"due",
"to",
"a",
"temporary",
"condition",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/error.go#L53-L70 |
141,332 | Azure/azure-pipeline-go | pipeline/error.go | Timeout | func (e ErrorNode) Timeout() bool {
type timeout interface {
Timeout() bool
}
for err := e.cause; err != nil; {
if t, ok := err.(timeout); ok {
return t.Timeout()
}
if cause, ok := err.(causer); ok {
err = cause.Cause()
} else {
err = nil
}
}
return false
} | go | func (e ErrorNode) Timeout() bool {
type timeout interface {
Timeout() bool
}
for err := e.cause; err != nil; {
if t, ok := err.(timeout); ok {
return t.Timeout()
}
if cause, ok := err.(causer); ok {
err = cause.Cause()
} else {
err = nil
}
}
return false
} | [
"func",
"(",
"e",
"ErrorNode",
")",
"Timeout",
"(",
")",
"bool",
"{",
"type",
"timeout",
"interface",
"{",
"Timeout",
"(",
")",
"bool",
"\n",
"}",
"\n\n",
"for",
"err",
":=",
"e",
".",
"cause",
";",
"err",
"!=",
"nil",
";",
"{",
"if",
"t",
",",
... | // Timeout returns true if the error occurred due to time expiring. | [
"Timeout",
"returns",
"true",
"if",
"the",
"error",
"occurred",
"due",
"to",
"time",
"expiring",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/error.go#L73-L90 |
141,333 | Azure/azure-pipeline-go | pipeline/error.go | Cause | func Cause(err error) error {
for err != nil {
cause, ok := err.(causer)
if !ok {
break
}
err = cause.Cause()
}
return err
} | go | func Cause(err error) error {
for err != nil {
cause, ok := err.(causer)
if !ok {
break
}
err = cause.Cause()
}
return err
} | [
"func",
"Cause",
"(",
"err",
"error",
")",
"error",
"{",
"for",
"err",
"!=",
"nil",
"{",
"cause",
",",
"ok",
":=",
"err",
".",
"(",
"causer",
")",
"\n",
"if",
"!",
"ok",
"{",
"break",
"\n",
"}",
"\n",
"err",
"=",
"cause",
".",
"Cause",
"(",
"... | // Cause walks all the preceding errors and return the originating error. | [
"Cause",
"walks",
"all",
"the",
"preceding",
"errors",
"and",
"return",
"the",
"originating",
"error",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/error.go#L103-L112 |
141,334 | Azure/azure-pipeline-go | pipeline/progress.go | NewRequestBodyProgress | func NewRequestBodyProgress(requestBody io.ReadSeeker, pr ProgressReceiver) io.ReadSeeker {
if pr == nil {
panic("pr must not be nil")
}
return &requestBodyProgress{requestBody: requestBody, pr: pr}
} | go | func NewRequestBodyProgress(requestBody io.ReadSeeker, pr ProgressReceiver) io.ReadSeeker {
if pr == nil {
panic("pr must not be nil")
}
return &requestBodyProgress{requestBody: requestBody, pr: pr}
} | [
"func",
"NewRequestBodyProgress",
"(",
"requestBody",
"io",
".",
"ReadSeeker",
",",
"pr",
"ProgressReceiver",
")",
"io",
".",
"ReadSeeker",
"{",
"if",
"pr",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"requestBodyProgre... | // NewRequestBodyProgress adds progress reporting to an HTTP request's body stream. | [
"NewRequestBodyProgress",
"adds",
"progress",
"reporting",
"to",
"an",
"HTTP",
"request",
"s",
"body",
"stream",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/progress.go#L19-L24 |
141,335 | Azure/azure-pipeline-go | pipeline/progress.go | Close | func (rbp *requestBodyProgress) Close() error {
if c, ok := rbp.requestBody.(io.Closer); ok {
return c.Close()
}
return nil
} | go | func (rbp *requestBodyProgress) Close() error {
if c, ok := rbp.requestBody.(io.Closer); ok {
return c.Close()
}
return nil
} | [
"func",
"(",
"rbp",
"*",
"requestBodyProgress",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
",",
"ok",
":=",
"rbp",
".",
"requestBody",
".",
"(",
"io",
".",
"Closer",
")",
";",
"ok",
"{",
"return",
"c",
".",
"Close",
"(",
")",
"\n",
"}",
"... | // requestBodyProgress supports Close but the underlying stream may not; if it does, Close will close it. | [
"requestBodyProgress",
"supports",
"Close",
"but",
"the",
"underlying",
"stream",
"may",
"not",
";",
"if",
"it",
"does",
"Close",
"will",
"close",
"it",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/progress.go#L46-L51 |
141,336 | Azure/azure-pipeline-go | pipeline/progress.go | NewResponseBodyProgress | func NewResponseBodyProgress(responseBody io.ReadCloser, pr ProgressReceiver) io.ReadCloser {
if pr == nil {
panic("pr must not be nil")
}
return &responseBodyProgress{responseBody: responseBody, pr: pr, offset: 0}
} | go | func NewResponseBodyProgress(responseBody io.ReadCloser, pr ProgressReceiver) io.ReadCloser {
if pr == nil {
panic("pr must not be nil")
}
return &responseBodyProgress{responseBody: responseBody, pr: pr, offset: 0}
} | [
"func",
"NewResponseBodyProgress",
"(",
"responseBody",
"io",
".",
"ReadCloser",
",",
"pr",
"ProgressReceiver",
")",
"io",
".",
"ReadCloser",
"{",
"if",
"pr",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"responseBodyPro... | // NewResponseBodyProgress adds progress reporting to an HTTP response's body stream. | [
"NewResponseBodyProgress",
"adds",
"progress",
"reporting",
"to",
"an",
"HTTP",
"response",
"s",
"body",
"stream",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/progress.go#L63-L68 |
141,337 | Azure/azure-pipeline-go | pipeline/request.go | NewRequest | func NewRequest(method string, url url.URL, body io.ReadSeeker) (request Request, err error) {
// Note: the url is passed by value so that any pipeline operations that modify it do so on a copy.
// This code to construct an http.Request is copied from http.NewRequest(); we intentionally omitted removeEmptyPort for n... | go | func NewRequest(method string, url url.URL, body io.ReadSeeker) (request Request, err error) {
// Note: the url is passed by value so that any pipeline operations that modify it do so on a copy.
// This code to construct an http.Request is copied from http.NewRequest(); we intentionally omitted removeEmptyPort for n... | [
"func",
"NewRequest",
"(",
"method",
"string",
",",
"url",
"url",
".",
"URL",
",",
"body",
"io",
".",
"ReadSeeker",
")",
"(",
"request",
"Request",
",",
"err",
"error",
")",
"{",
"// Note: the url is passed by value so that any pipeline operations that modify it do so... | // NewRequest initializes a new HTTP request object with any desired options. | [
"NewRequest",
"initializes",
"a",
"new",
"HTTP",
"request",
"object",
"with",
"any",
"desired",
"options",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/request.go#L16-L34 |
141,338 | Azure/azure-pipeline-go | pipeline/request.go | SetBody | func (r Request) SetBody(body io.ReadSeeker) error {
size, err := body.Seek(0, io.SeekEnd)
if err != nil {
return err
}
body.Seek(0, io.SeekStart)
r.ContentLength = size
r.Header["Content-Length"] = []string{strconv.FormatInt(size, 10)}
if size != 0 {
r.Body = &retryableRequestBody{body: body}
r.GetBody ... | go | func (r Request) SetBody(body io.ReadSeeker) error {
size, err := body.Seek(0, io.SeekEnd)
if err != nil {
return err
}
body.Seek(0, io.SeekStart)
r.ContentLength = size
r.Header["Content-Length"] = []string{strconv.FormatInt(size, 10)}
if size != 0 {
r.Body = &retryableRequestBody{body: body}
r.GetBody ... | [
"func",
"(",
"r",
"Request",
")",
"SetBody",
"(",
"body",
"io",
".",
"ReadSeeker",
")",
"error",
"{",
"size",
",",
"err",
":=",
"body",
".",
"Seek",
"(",
"0",
",",
"io",
".",
"SeekEnd",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // SetBody sets the body and content length, assumes body is not nil. | [
"SetBody",
"sets",
"the",
"body",
"and",
"content",
"length",
"assumes",
"body",
"is",
"not",
"nil",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/request.go#L37-L70 |
141,339 | Azure/azure-pipeline-go | pipeline/request.go | RewindBody | func (r Request) RewindBody() error {
if r.Body != nil && r.Body != http.NoBody {
s, ok := r.Body.(io.Seeker)
if !ok {
panic("unexpected request body type (should be io.Seeker)")
}
// Reset the stream back to the beginning
_, err := s.Seek(0, io.SeekStart)
return err
}
return nil
} | go | func (r Request) RewindBody() error {
if r.Body != nil && r.Body != http.NoBody {
s, ok := r.Body.(io.Seeker)
if !ok {
panic("unexpected request body type (should be io.Seeker)")
}
// Reset the stream back to the beginning
_, err := s.Seek(0, io.SeekStart)
return err
}
return nil
} | [
"func",
"(",
"r",
"Request",
")",
"RewindBody",
"(",
")",
"error",
"{",
"if",
"r",
".",
"Body",
"!=",
"nil",
"&&",
"r",
".",
"Body",
"!=",
"http",
".",
"NoBody",
"{",
"s",
",",
"ok",
":=",
"r",
".",
"Body",
".",
"(",
"io",
".",
"Seeker",
")",... | // RewindBody seeks the request's Body stream back to the beginning so it can be resent when retrying an operation. | [
"RewindBody",
"seeks",
"the",
"request",
"s",
"Body",
"stream",
"back",
"to",
"the",
"beginning",
"so",
"it",
"can",
"be",
"resent",
"when",
"retrying",
"an",
"operation",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/request.go#L106-L118 |
141,340 | Azure/azure-pipeline-go | pipeline/core.go | NewPipeline | func NewPipeline(factories []Factory, o Options) Pipeline {
if o.HTTPSender == nil {
o.HTTPSender = newDefaultHTTPClientFactory()
}
if o.Log.Log == nil {
o.Log.Log = func(LogLevel, string) {} // No-op logger
}
return &pipeline{factories: factories, options: o}
} | go | func NewPipeline(factories []Factory, o Options) Pipeline {
if o.HTTPSender == nil {
o.HTTPSender = newDefaultHTTPClientFactory()
}
if o.Log.Log == nil {
o.Log.Log = func(LogLevel, string) {} // No-op logger
}
return &pipeline{factories: factories, options: o}
} | [
"func",
"NewPipeline",
"(",
"factories",
"[",
"]",
"Factory",
",",
"o",
"Options",
")",
"Pipeline",
"{",
"if",
"o",
".",
"HTTPSender",
"==",
"nil",
"{",
"o",
".",
"HTTPSender",
"=",
"newDefaultHTTPClientFactory",
"(",
")",
"\n",
"}",
"\n",
"if",
"o",
"... | // NewPipeline creates a new goroutine-safe Pipeline object from the slice of Factory objects and the specified options. | [
"NewPipeline",
"creates",
"a",
"new",
"goroutine",
"-",
"safe",
"Pipeline",
"object",
"from",
"the",
"slice",
"of",
"Factory",
"objects",
"and",
"the",
"specified",
"options",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/core.go#L113-L121 |
141,341 | Azure/azure-pipeline-go | pipeline/core.go | ShouldLog | func (po *PolicyOptions) ShouldLog(level LogLevel) bool {
if po.pipeline.options.Log.ShouldLog != nil {
return po.pipeline.options.Log.ShouldLog(level)
}
return false
} | go | func (po *PolicyOptions) ShouldLog(level LogLevel) bool {
if po.pipeline.options.Log.ShouldLog != nil {
return po.pipeline.options.Log.ShouldLog(level)
}
return false
} | [
"func",
"(",
"po",
"*",
"PolicyOptions",
")",
"ShouldLog",
"(",
"level",
"LogLevel",
")",
"bool",
"{",
"if",
"po",
".",
"pipeline",
".",
"options",
".",
"Log",
".",
"ShouldLog",
"!=",
"nil",
"{",
"return",
"po",
".",
"pipeline",
".",
"options",
".",
... | // ShouldLog returns true if the specified log level should be logged. | [
"ShouldLog",
"returns",
"true",
"if",
"the",
"specified",
"log",
"level",
"should",
"be",
"logged",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/core.go#L174-L179 |
141,342 | Azure/azure-pipeline-go | pipeline/core.go | Log | func (po *PolicyOptions) Log(level LogLevel, msg string) {
if !po.ShouldLog(level) {
return // Short circuit message formatting if we're not logging it
}
// We are logging it, ensure trailing newline
if len(msg) == 0 || msg[len(msg)-1] != '\n' {
msg += "\n" // Ensure trailing newline
}
po.pipeline.options.Lo... | go | func (po *PolicyOptions) Log(level LogLevel, msg string) {
if !po.ShouldLog(level) {
return // Short circuit message formatting if we're not logging it
}
// We are logging it, ensure trailing newline
if len(msg) == 0 || msg[len(msg)-1] != '\n' {
msg += "\n" // Ensure trailing newline
}
po.pipeline.options.Lo... | [
"func",
"(",
"po",
"*",
"PolicyOptions",
")",
"Log",
"(",
"level",
"LogLevel",
",",
"msg",
"string",
")",
"{",
"if",
"!",
"po",
".",
"ShouldLog",
"(",
"level",
")",
"{",
"return",
"// Short circuit message formatting if we're not logging it",
"\n",
"}",
"\n\n"... | // Log logs a string to the Pipeline's Logger. | [
"Log",
"logs",
"a",
"string",
"to",
"the",
"Pipeline",
"s",
"Logger",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/core.go#L182-L199 |
141,343 | Azure/azure-pipeline-go | pipeline/core.go | newDefaultHTTPClientFactory | func newDefaultHTTPClientFactory() Factory {
return FactoryFunc(func(next Policy, po *PolicyOptions) PolicyFunc {
return func(ctx context.Context, request Request) (Response, error) {
r, err := pipelineHTTPClient.Do(request.WithContext(ctx))
if err != nil {
err = NewError(err, "HTTP request failed")
}
... | go | func newDefaultHTTPClientFactory() Factory {
return FactoryFunc(func(next Policy, po *PolicyOptions) PolicyFunc {
return func(ctx context.Context, request Request) (Response, error) {
r, err := pipelineHTTPClient.Do(request.WithContext(ctx))
if err != nil {
err = NewError(err, "HTTP request failed")
}
... | [
"func",
"newDefaultHTTPClientFactory",
"(",
")",
"Factory",
"{",
"return",
"FactoryFunc",
"(",
"func",
"(",
"next",
"Policy",
",",
"po",
"*",
"PolicyOptions",
")",
"PolicyFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"R... | // newDefaultHTTPClientFactory creates a DefaultHTTPClientPolicyFactory object that sends HTTP requests to a Go's default http.Client. | [
"newDefaultHTTPClientFactory",
"creates",
"a",
"DefaultHTTPClientPolicyFactory",
"object",
"that",
"sends",
"HTTP",
"requests",
"to",
"a",
"Go",
"s",
"default",
"http",
".",
"Client",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/core.go#L229-L239 |
141,344 | Azure/azure-pipeline-go | pipeline/response.go | writeHeader | func writeHeader(b *bytes.Buffer, header map[string][]string) {
if len(header) == 0 {
b.WriteString(" (no headers)\n")
return
}
keys := make([]string, 0, len(header))
// Alphabetize the headers
for k := range header {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
// Redact the v... | go | func writeHeader(b *bytes.Buffer, header map[string][]string) {
if len(header) == 0 {
b.WriteString(" (no headers)\n")
return
}
keys := make([]string, 0, len(header))
// Alphabetize the headers
for k := range header {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
// Redact the v... | [
"func",
"writeHeader",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
",",
"header",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"header",
")",
"==",
"0",
"{",
"b",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"... | // formatHeaders appends an HTTP request's or response's header into a Buffer. | [
"formatHeaders",
"appends",
"an",
"HTTP",
"request",
"s",
"or",
"response",
"s",
"header",
"into",
"a",
"Buffer",
"."
] | 55fedc85a614dcd0e942a66f302ae3efb83d563c | https://github.com/Azure/azure-pipeline-go/blob/55fedc85a614dcd0e942a66f302ae3efb83d563c/pipeline/response.go#L55-L74 |
141,345 | honeycombio/libhoney-go | client.go | NewClient | func NewClient(conf ClientConfig) (*Client, error) {
if conf.SampleRate == 0 {
conf.SampleRate = defaultSampleRate
}
if conf.APIHost == "" {
conf.APIHost = defaultAPIHost
}
if conf.Dataset == "" {
conf.Dataset = defaultDataset
}
c := &Client{
logger: conf.Logger,
}
c.ensureLogger()
if conf.Transmiss... | go | func NewClient(conf ClientConfig) (*Client, error) {
if conf.SampleRate == 0 {
conf.SampleRate = defaultSampleRate
}
if conf.APIHost == "" {
conf.APIHost = defaultAPIHost
}
if conf.Dataset == "" {
conf.Dataset = defaultDataset
}
c := &Client{
logger: conf.Logger,
}
c.ensureLogger()
if conf.Transmiss... | [
"func",
"NewClient",
"(",
"conf",
"ClientConfig",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"conf",
".",
"SampleRate",
"==",
"0",
"{",
"conf",
".",
"SampleRate",
"=",
"defaultSampleRate",
"\n",
"}",
"\n",
"if",
"conf",
".",
"APIHost",
"=="... | // NewClient creates a Client with defaults correctly set | [
"NewClient",
"creates",
"a",
"Client",
"with",
"defaults",
"correctly",
"set"
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L68-L115 |
141,346 | honeycombio/libhoney-go | client.go | TxResponses | func (c *Client) TxResponses() chan transmission.Response {
c.ensureTransmission()
return c.transmission.TxResponses()
} | go | func (c *Client) TxResponses() chan transmission.Response {
c.ensureTransmission()
return c.transmission.TxResponses()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"TxResponses",
"(",
")",
"chan",
"transmission",
".",
"Response",
"{",
"c",
".",
"ensureTransmission",
"(",
")",
"\n",
"return",
"c",
".",
"transmission",
".",
"TxResponses",
"(",
")",
"\n",
"}"
] | // TxResponses returns the channel from which the caller can read the responses
// to sent events. | [
"TxResponses",
"returns",
"the",
"channel",
"from",
"which",
"the",
"caller",
"can",
"read",
"the",
"responses",
"to",
"sent",
"events",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L177-L180 |
141,347 | honeycombio/libhoney-go | client.go | AddField | func (c *Client) AddField(name string, val interface{}) {
c.ensureTransmission()
c.ensureBuilder()
c.builder.AddField(name, val)
} | go | func (c *Client) AddField(name string, val interface{}) {
c.ensureTransmission()
c.ensureBuilder()
c.builder.AddField(name, val)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddField",
"(",
"name",
"string",
",",
"val",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"ensureTransmission",
"(",
")",
"\n",
"c",
".",
"ensureBuilder",
"(",
")",
"\n",
"c",
".",
"builder",
".",
"AddField",
"... | // AddField adds a Field to the Client's scope. This metric will be inherited by
// all builders and events. | [
"AddField",
"adds",
"a",
"Field",
"to",
"the",
"Client",
"s",
"scope",
".",
"This",
"metric",
"will",
"be",
"inherited",
"by",
"all",
"builders",
"and",
"events",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L194-L198 |
141,348 | honeycombio/libhoney-go | client.go | Add | func (c *Client) Add(data interface{}) error {
c.ensureTransmission()
c.ensureBuilder()
return c.builder.Add(data)
} | go | func (c *Client) Add(data interface{}) error {
c.ensureTransmission()
c.ensureBuilder()
return c.builder.Add(data)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Add",
"(",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"c",
".",
"ensureTransmission",
"(",
")",
"\n",
"c",
".",
"ensureBuilder",
"(",
")",
"\n",
"return",
"c",
".",
"builder",
".",
"Add",
"(",
"data",
... | // Add adds its data to the Client's scope. It adds all fields in a struct or
// all keys in a map as individual Fields. These metrics will be inherited by
// all builders and events. | [
"Add",
"adds",
"its",
"data",
"to",
"the",
"Client",
"s",
"scope",
".",
"It",
"adds",
"all",
"fields",
"in",
"a",
"struct",
"or",
"all",
"keys",
"in",
"a",
"map",
"as",
"individual",
"Fields",
".",
"These",
"metrics",
"will",
"be",
"inherited",
"by",
... | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L203-L207 |
141,349 | honeycombio/libhoney-go | client.go | NewEvent | func (c *Client) NewEvent() *Event {
c.ensureTransmission()
c.ensureBuilder()
return c.builder.NewEvent()
} | go | func (c *Client) NewEvent() *Event {
c.ensureTransmission()
c.ensureBuilder()
return c.builder.NewEvent()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewEvent",
"(",
")",
"*",
"Event",
"{",
"c",
".",
"ensureTransmission",
"(",
")",
"\n",
"c",
".",
"ensureBuilder",
"(",
")",
"\n",
"return",
"c",
".",
"builder",
".",
"NewEvent",
"(",
")",
"\n",
"}"
] | // NewEvent creates a new event prepopulated with any Fields present in the
// Client's scope. | [
"NewEvent",
"creates",
"a",
"new",
"event",
"prepopulated",
"with",
"any",
"Fields",
"present",
"in",
"the",
"Client",
"s",
"scope",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L211-L215 |
141,350 | honeycombio/libhoney-go | client.go | NewBuilder | func (c *Client) NewBuilder() *Builder {
c.ensureTransmission()
c.ensureBuilder()
return c.builder.Clone()
} | go | func (c *Client) NewBuilder() *Builder {
c.ensureTransmission()
c.ensureBuilder()
return c.builder.Clone()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewBuilder",
"(",
")",
"*",
"Builder",
"{",
"c",
".",
"ensureTransmission",
"(",
")",
"\n",
"c",
".",
"ensureBuilder",
"(",
")",
"\n",
"return",
"c",
".",
"builder",
".",
"Clone",
"(",
")",
"\n",
"}"
] | // NewBuilder creates a new event builder. The builder inherits any Dynamic or
// Static Fields present in the Client's scope. | [
"NewBuilder",
"creates",
"a",
"new",
"event",
"builder",
".",
"The",
"builder",
"inherits",
"any",
"Dynamic",
"or",
"Static",
"Fields",
"present",
"in",
"the",
"Client",
"s",
"scope",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L219-L223 |
141,351 | honeycombio/libhoney-go | client.go | sendDroppedResponse | func (c *Client) sendDroppedResponse(e *Event, message string) {
c.ensureTransmission()
r := transmission.Response{
Err: errors.New(message),
Metadata: e.Metadata,
}
c.transmission.SendResponse(r)
} | go | func (c *Client) sendDroppedResponse(e *Event, message string) {
c.ensureTransmission()
r := transmission.Response{
Err: errors.New(message),
Metadata: e.Metadata,
}
c.transmission.SendResponse(r)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"sendDroppedResponse",
"(",
"e",
"*",
"Event",
",",
"message",
"string",
")",
"{",
"c",
".",
"ensureTransmission",
"(",
")",
"\n",
"r",
":=",
"transmission",
".",
"Response",
"{",
"Err",
":",
"errors",
".",
"New",
... | // sendResponse sends a dropped event response down the response channel | [
"sendResponse",
"sends",
"a",
"dropped",
"event",
"response",
"down",
"the",
"response",
"channel"
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/client.go#L226-L234 |
141,352 | honeycombio/libhoney-go | logger.go | Printf | func (d *DefaultLogger) Printf(msg string, args ...interface{}) {
// use the same format as the python libhoney:
// '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
// except for go's more friendly rfc3339nano rather than asctime
msg = fmt.Sprintf("%s - %s - %s", "libhoney", "DEBUG", msg)
log.Printf(msg+"\n... | go | func (d *DefaultLogger) Printf(msg string, args ...interface{}) {
// use the same format as the python libhoney:
// '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
// except for go's more friendly rfc3339nano rather than asctime
msg = fmt.Sprintf("%s - %s - %s", "libhoney", "DEBUG", msg)
log.Printf(msg+"\n... | [
"func",
"(",
"d",
"*",
"DefaultLogger",
")",
"Printf",
"(",
"msg",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"// use the same format as the python libhoney:",
"// '%(asctime)s - %(name)s - %(levelname)s - %(message)s')",
"// except for go's more friendly ... | // Printf prints the message to stdout. | [
"Printf",
"prints",
"the",
"message",
"to",
"stdout",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/logger.go#L24-L30 |
141,353 | honeycombio/libhoney-go | transmission/transmission.go | encodeBatch | func (b *batchAgg) encodeBatch(events []*Event) ([]byte, int) {
// track first vs. rest events for commas
first := true
// track how many we successfully encode for later bookkeeping
var numEncoded int
buf := bytes.Buffer{}
buf.WriteByte('[')
bytesTotal := 1
// ok, we've got our array, let's populate it with JS... | go | func (b *batchAgg) encodeBatch(events []*Event) ([]byte, int) {
// track first vs. rest events for commas
first := true
// track how many we successfully encode for later bookkeeping
var numEncoded int
buf := bytes.Buffer{}
buf.WriteByte('[')
bytesTotal := 1
// ok, we've got our array, let's populate it with JS... | [
"func",
"(",
"b",
"*",
"batchAgg",
")",
"encodeBatch",
"(",
"events",
"[",
"]",
"*",
"Event",
")",
"(",
"[",
"]",
"byte",
",",
"int",
")",
"{",
"// track first vs. rest events for commas",
"first",
":=",
"true",
"\n",
"// track how many we successfully encode fo... | // create the JSON for this event list manually so that we can send
// responses down the response queue for any that fail to marshal | [
"create",
"the",
"JSON",
"for",
"this",
"event",
"list",
"manually",
"so",
"that",
"we",
"can",
"send",
"responses",
"down",
"the",
"response",
"queue",
"for",
"any",
"that",
"fail",
"to",
"marshal"
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/transmission/transmission.go#L374-L421 |
141,354 | honeycombio/libhoney-go | transmission/transmission.go | buildReqReader | func buildReqReader(jsonEncoded []byte, useGzip bool) (io.Reader, bool) {
if useGzip {
buf := bytes.Buffer{}
g := gzip.NewWriter(&buf)
if _, err := g.Write(jsonEncoded); err == nil {
if err = g.Close(); err == nil { // flush
return &buf, true
}
}
return bytes.NewReader(jsonEncoded), false
}
retu... | go | func buildReqReader(jsonEncoded []byte, useGzip bool) (io.Reader, bool) {
if useGzip {
buf := bytes.Buffer{}
g := gzip.NewWriter(&buf)
if _, err := g.Write(jsonEncoded); err == nil {
if err = g.Close(); err == nil { // flush
return &buf, true
}
}
return bytes.NewReader(jsonEncoded), false
}
retu... | [
"func",
"buildReqReader",
"(",
"jsonEncoded",
"[",
"]",
"byte",
",",
"useGzip",
"bool",
")",
"(",
"io",
".",
"Reader",
",",
"bool",
")",
"{",
"if",
"useGzip",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"g",
":=",
"gzip",
".",
"NewWri... | // buildReqReader returns an io.Reader and a boolean, indicating whether or not
// the io.Reader is gzip-compressed. | [
"buildReqReader",
"returns",
"an",
"io",
".",
"Reader",
"and",
"a",
"boolean",
"indicating",
"whether",
"or",
"not",
"the",
"io",
".",
"Reader",
"is",
"gzip",
"-",
"compressed",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/transmission/transmission.go#L437-L450 |
141,355 | honeycombio/libhoney-go | transmission/event.go | MarshalJSON | func (e *Event) MarshalJSON() ([]byte, error) {
tPointer := &(e.Timestamp)
if e.Timestamp.IsZero() {
tPointer = nil
}
// don't include sample rate if it's 1; this is the default
sampleRate := e.SampleRate
if sampleRate == 1 {
sampleRate = 0
}
return json.Marshal(struct {
Data marshallableMap `json... | go | func (e *Event) MarshalJSON() ([]byte, error) {
tPointer := &(e.Timestamp)
if e.Timestamp.IsZero() {
tPointer = nil
}
// don't include sample rate if it's 1; this is the default
sampleRate := e.SampleRate
if sampleRate == 1 {
sampleRate = 0
}
return json.Marshal(struct {
Data marshallableMap `json... | [
"func",
"(",
"e",
"*",
"Event",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"tPointer",
":=",
"&",
"(",
"e",
".",
"Timestamp",
")",
"\n",
"if",
"e",
".",
"Timestamp",
".",
"IsZero",
"(",
")",
"{",
"tPointer",
"=... | // Marshaling an Event for batching up to the Honeycomb servers. Omits fields
// that aren't specific to this particular event, and allows for behavior like
// omitempty'ing a zero'ed out time.Time. | [
"Marshaling",
"an",
"Event",
"for",
"batching",
"up",
"to",
"the",
"Honeycomb",
"servers",
".",
"Omits",
"fields",
"that",
"aren",
"t",
"specific",
"to",
"this",
"particular",
"event",
"and",
"allows",
"for",
"behavior",
"like",
"omitempty",
"ing",
"a",
"zer... | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/transmission/event.go#L35-L52 |
141,356 | honeycombio/libhoney-go | libhoney.go | VerifyAPIKey | func VerifyAPIKey(config Config) (team string, err error) {
dc.ensureLogger()
defer func() { dc.logger.Printf("verify write key got back %s with err=%s", team, err) }()
if config.APIKey == "" {
if config.WriteKey == "" {
return team, errors.New("config.APIKey and config.WriteKey are both empty; can't verify emp... | go | func VerifyAPIKey(config Config) (team string, err error) {
dc.ensureLogger()
defer func() { dc.logger.Printf("verify write key got back %s with err=%s", team, err) }()
if config.APIKey == "" {
if config.WriteKey == "" {
return team, errors.New("config.APIKey and config.WriteKey are both empty; can't verify emp... | [
"func",
"VerifyAPIKey",
"(",
"config",
"Config",
")",
"(",
"team",
"string",
",",
"err",
"error",
")",
"{",
"dc",
".",
"ensureLogger",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"dc",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"team",... | // VerifyAPIKey calls out to the Honeycomb API to validate the API key so we can
// exit immediately if desired instead of happily sending events that are all
// rejected. | [
"VerifyAPIKey",
"calls",
"out",
"to",
"the",
"Honeycomb",
"API",
"to",
"validate",
"the",
"API",
"key",
"so",
"we",
"can",
"exit",
"immediately",
"if",
"desired",
"instead",
"of",
"happily",
"sending",
"events",
"that",
"are",
"all",
"rejected",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L282-L325 |
141,357 | honeycombio/libhoney-go | libhoney.go | Responses | func Responses() chan Response {
oneResp.Do(func() {
if transitionResponses == nil {
txResponses := dc.TxResponses()
transitionResponses = make(chan Response, cap(txResponses))
go func() {
for txResp := range txResponses {
resp := Response{}
resp.Response = txResp
transitionResponses <- r... | go | func Responses() chan Response {
oneResp.Do(func() {
if transitionResponses == nil {
txResponses := dc.TxResponses()
transitionResponses = make(chan Response, cap(txResponses))
go func() {
for txResp := range txResponses {
resp := Response{}
resp.Response = txResp
transitionResponses <- r... | [
"func",
"Responses",
"(",
")",
"chan",
"Response",
"{",
"oneResp",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"if",
"transitionResponses",
"==",
"nil",
"{",
"txResponses",
":=",
"dc",
".",
"TxResponses",
"(",
")",
"\n",
"transitionResponses",
"=",
"make",
"(... | // Responses returns the channel from which the caller can read the responses
// to sent events. Responses is deprecated; please use TxResponses instead. | [
"Responses",
"returns",
"the",
"channel",
"from",
"which",
"the",
"caller",
"can",
"read",
"the",
"responses",
"to",
"sent",
"events",
".",
"Responses",
"is",
"deprecated",
";",
"please",
"use",
"TxResponses",
"instead",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L490-L506 |
141,358 | honeycombio/libhoney-go | libhoney.go | AddFunc | func (f *fieldHolder) AddFunc(fn func() (string, interface{}, error)) error {
for {
key, rawVal, err := fn()
if err != nil {
// fn is done giving us data
break
}
f.AddField(key, rawVal)
}
return nil
} | go | func (f *fieldHolder) AddFunc(fn func() (string, interface{}, error)) error {
for {
key, rawVal, err := fn()
if err != nil {
// fn is done giving us data
break
}
f.AddField(key, rawVal)
}
return nil
} | [
"func",
"(",
"f",
"*",
"fieldHolder",
")",
"AddFunc",
"(",
"fn",
"func",
"(",
")",
"(",
"string",
",",
"interface",
"{",
"}",
",",
"error",
")",
")",
"error",
"{",
"for",
"{",
"key",
",",
"rawVal",
",",
"err",
":=",
"fn",
"(",
")",
"\n",
"if",
... | // AddFunc takes a function and runs it repeatedly, adding the return values
// as fields.
// The function should return error when it has exhausted its values | [
"AddFunc",
"takes",
"a",
"function",
"and",
"runs",
"it",
"repeatedly",
"adding",
"the",
"return",
"values",
"as",
"fields",
".",
"The",
"function",
"should",
"return",
"error",
"when",
"it",
"has",
"exhausted",
"its",
"values"
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L643-L653 |
141,359 | honeycombio/libhoney-go | libhoney.go | AddFunc | func (e *Event) AddFunc(fn func() (string, interface{}, error)) error {
e.sendLock.Lock()
defer e.sendLock.Unlock()
if e.sent == true {
return nil
}
return e.fieldHolder.AddFunc(fn)
} | go | func (e *Event) AddFunc(fn func() (string, interface{}, error)) error {
e.sendLock.Lock()
defer e.sendLock.Unlock()
if e.sent == true {
return nil
}
return e.fieldHolder.AddFunc(fn)
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"AddFunc",
"(",
"fn",
"func",
"(",
")",
"(",
"string",
",",
"interface",
"{",
"}",
",",
"error",
")",
")",
"error",
"{",
"e",
".",
"sendLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"sendLock",
".",... | // AddFunc takes a function and runs it repeatedly, adding the return values
// as fields.
// The function should return error when it has exhausted its values
//
// Adds to an event that happen after it has been sent will return without
// having any effect. | [
"AddFunc",
"takes",
"a",
"function",
"and",
"runs",
"it",
"repeatedly",
"adding",
"the",
"return",
"values",
"as",
"fields",
".",
"The",
"function",
"should",
"return",
"error",
"when",
"it",
"has",
"exhausted",
"its",
"values",
"Adds",
"to",
"an",
"event",
... | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L701-L708 |
141,360 | honeycombio/libhoney-go | libhoney.go | shouldDrop | func shouldDrop(rate uint) bool {
if rate <= 1 {
return false
}
return rand.Intn(int(rate)) != 0
} | go | func shouldDrop(rate uint) bool {
if rate <= 1 {
return false
}
return rand.Intn(int(rate)) != 0
} | [
"func",
"shouldDrop",
"(",
"rate",
"uint",
")",
"bool",
"{",
"if",
"rate",
"<=",
"1",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"rand",
".",
"Intn",
"(",
"int",
"(",
"rate",
")",
")",
"!=",
"0",
"\n",
"}"
] | // returns true if the sample should be dropped | [
"returns",
"true",
"if",
"the",
"sample",
"should",
"be",
"dropped"
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L811-L817 |
141,361 | honeycombio/libhoney-go | libhoney.go | AddDynamicField | func (b *Builder) AddDynamicField(name string, fn func() interface{}) error {
b.dynFieldsLock.Lock()
defer b.dynFieldsLock.Unlock()
dynFn := dynamicField{
name: name,
fn: fn,
}
b.dynFields = append(b.dynFields, dynFn)
return nil
} | go | func (b *Builder) AddDynamicField(name string, fn func() interface{}) error {
b.dynFieldsLock.Lock()
defer b.dynFieldsLock.Unlock()
dynFn := dynamicField{
name: name,
fn: fn,
}
b.dynFields = append(b.dynFields, dynFn)
return nil
} | [
"func",
"(",
"b",
"*",
"Builder",
")",
"AddDynamicField",
"(",
"name",
"string",
",",
"fn",
"func",
"(",
")",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
".",
"dynFieldsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"dynFieldsLock",
".",
... | // AddDynamicField adds a dynamic field to the builder. Any events
// created from this builder will get this metric added. | [
"AddDynamicField",
"adds",
"a",
"dynamic",
"field",
"to",
"the",
"builder",
".",
"Any",
"events",
"created",
"from",
"this",
"builder",
"will",
"get",
"this",
"metric",
"added",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L821-L830 |
141,362 | honeycombio/libhoney-go | libhoney.go | NewEvent | func (b *Builder) NewEvent() *Event {
e := &Event{
WriteKey: b.WriteKey,
Dataset: b.Dataset,
SampleRate: b.SampleRate,
APIHost: b.APIHost,
Timestamp: time.Now(),
client: b.client,
}
e.data = make(map[string]interface{})
b.lock.RLock()
defer b.lock.RUnlock()
for k, v := range b.data {
e... | go | func (b *Builder) NewEvent() *Event {
e := &Event{
WriteKey: b.WriteKey,
Dataset: b.Dataset,
SampleRate: b.SampleRate,
APIHost: b.APIHost,
Timestamp: time.Now(),
client: b.client,
}
e.data = make(map[string]interface{})
b.lock.RLock()
defer b.lock.RUnlock()
for k, v := range b.data {
e... | [
"func",
"(",
"b",
"*",
"Builder",
")",
"NewEvent",
"(",
")",
"*",
"Event",
"{",
"e",
":=",
"&",
"Event",
"{",
"WriteKey",
":",
"b",
".",
"WriteKey",
",",
"Dataset",
":",
"b",
".",
"Dataset",
",",
"SampleRate",
":",
"b",
".",
"SampleRate",
",",
"A... | // NewEvent creates a new Event prepopulated with fields, dynamic
// field values, and configuration inherited from the builder. | [
"NewEvent",
"creates",
"a",
"new",
"Event",
"prepopulated",
"with",
"fields",
"dynamic",
"field",
"values",
"and",
"configuration",
"inherited",
"from",
"the",
"builder",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L850-L873 |
141,363 | honeycombio/libhoney-go | libhoney.go | Clone | func (b *Builder) Clone() *Builder {
newB := &Builder{
WriteKey: b.WriteKey,
Dataset: b.Dataset,
SampleRate: b.SampleRate,
APIHost: b.APIHost,
dynFields: make([]dynamicField, 0, len(b.dynFields)),
client: b.client,
}
newB.data = make(map[string]interface{})
b.lock.RLock()
defer b.lock.RUnl... | go | func (b *Builder) Clone() *Builder {
newB := &Builder{
WriteKey: b.WriteKey,
Dataset: b.Dataset,
SampleRate: b.SampleRate,
APIHost: b.APIHost,
dynFields: make([]dynamicField, 0, len(b.dynFields)),
client: b.client,
}
newB.data = make(map[string]interface{})
b.lock.RLock()
defer b.lock.RUnl... | [
"func",
"(",
"b",
"*",
"Builder",
")",
"Clone",
"(",
")",
"*",
"Builder",
"{",
"newB",
":=",
"&",
"Builder",
"{",
"WriteKey",
":",
"b",
".",
"WriteKey",
",",
"Dataset",
":",
"b",
".",
"Dataset",
",",
"SampleRate",
":",
"b",
".",
"SampleRate",
",",
... | // Clone creates a new builder that inherits all traits of this builder and
// creates its own scope in which to add additional static and dynamic fields. | [
"Clone",
"creates",
"a",
"new",
"builder",
"that",
"inherits",
"all",
"traits",
"of",
"this",
"builder",
"and",
"creates",
"its",
"own",
"scope",
"in",
"which",
"to",
"add",
"additional",
"static",
"and",
"dynamic",
"fields",
"."
] | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/libhoney.go#L877-L899 |
141,364 | honeycombio/libhoney-go | transmission/response.go | writeToResponse | func writeToResponse(responses chan Response, resp Response, block bool) (dropped bool) {
if block {
responses <- resp
} else {
select {
case responses <- resp:
default:
return true
}
}
return false
} | go | func writeToResponse(responses chan Response, resp Response, block bool) (dropped bool) {
if block {
responses <- resp
} else {
select {
case responses <- resp:
default:
return true
}
}
return false
} | [
"func",
"writeToResponse",
"(",
"responses",
"chan",
"Response",
",",
"resp",
"Response",
",",
"block",
"bool",
")",
"(",
"dropped",
"bool",
")",
"{",
"if",
"block",
"{",
"responses",
"<-",
"resp",
"\n",
"}",
"else",
"{",
"select",
"{",
"case",
"response... | // writeToResponse adds the response to the response queue. Returns true if it
// dropped the response because it's set to not block on the queue being full
// and the queue was full. | [
"writeToResponse",
"adds",
"the",
"response",
"to",
"the",
"response",
"queue",
".",
"Returns",
"true",
"if",
"it",
"dropped",
"the",
"response",
"because",
"it",
"s",
"set",
"to",
"not",
"block",
"on",
"the",
"queue",
"being",
"full",
"and",
"the",
"queue... | 05d1382bc21ae054131360ef0fd95b70f473009a | https://github.com/honeycombio/libhoney-go/blob/05d1382bc21ae054131360ef0fd95b70f473009a/transmission/response.go#L56-L67 |
141,365 | robfig/glock | sync.go | truncate | func truncate(rev string) string {
rev = strings.TrimSpace(rev)
if len(rev) > 12 {
return rev[:12]
}
return rev
} | go | func truncate(rev string) string {
rev = strings.TrimSpace(rev)
if len(rev) > 12 {
return rev[:12]
}
return rev
} | [
"func",
"truncate",
"(",
"rev",
"string",
")",
"string",
"{",
"rev",
"=",
"strings",
".",
"TrimSpace",
"(",
"rev",
")",
"\n",
"if",
"len",
"(",
"rev",
")",
">",
"12",
"{",
"return",
"rev",
"[",
":",
"12",
"]",
"\n",
"}",
"\n",
"return",
"rev",
... | // truncate a revision to the 12-digit prefix. | [
"truncate",
"a",
"revision",
"to",
"the",
"12",
"-",
"digit",
"prefix",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/sync.go#L146-L152 |
141,366 | robfig/glock | http.go | httpGET | func httpGET(url string) ([]byte, error) {
resp, err := httpClient.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("%s: %s", url, resp.Status)
}
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("%s: %v", url, e... | go | func httpGET(url string) ([]byte, error) {
resp, err := httpClient.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("%s: %s", url, resp.Status)
}
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("%s: %v", url, e... | [
"func",
"httpGET",
"(",
"url",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"httpClient",
".",
"Get",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",... | // httpGET returns the data from an HTTP GET request for the given URL. | [
"httpGET",
"returns",
"the",
"data",
"from",
"an",
"HTTP",
"GET",
"request",
"for",
"the",
"given",
"URL",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/http.go#L28-L42 |
141,367 | robfig/glock | http.go | httpsOrHTTP | func httpsOrHTTP(importPath string) (urlStr string, body io.ReadCloser, err error) {
fetch := func(scheme string) (urlStr string, res *http.Response, err error) {
u, err := url.Parse(scheme + "://" + importPath)
if err != nil {
return "", nil, err
}
u.RawQuery = "go-get=1"
urlStr = u.String()
if buildV ... | go | func httpsOrHTTP(importPath string) (urlStr string, body io.ReadCloser, err error) {
fetch := func(scheme string) (urlStr string, res *http.Response, err error) {
u, err := url.Parse(scheme + "://" + importPath)
if err != nil {
return "", nil, err
}
u.RawQuery = "go-get=1"
urlStr = u.String()
if buildV ... | [
"func",
"httpsOrHTTP",
"(",
"importPath",
"string",
")",
"(",
"urlStr",
"string",
",",
"body",
"io",
".",
"ReadCloser",
",",
"err",
"error",
")",
"{",
"fetch",
":=",
"func",
"(",
"scheme",
"string",
")",
"(",
"urlStr",
"string",
",",
"res",
"*",
"http"... | // httpsOrHTTP returns the body of either the importPath's
// https resource or, if unavailable, the http resource. | [
"httpsOrHTTP",
"returns",
"the",
"body",
"of",
"either",
"the",
"importPath",
"s",
"https",
"resource",
"or",
"if",
"unavailable",
"the",
"http",
"resource",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/http.go#L46-L87 |
141,368 | robfig/glock | util.go | managedRepoRoot | func managedRepoRoot(importPath string) (*managedRepo, error) {
var pkg, err = build.Import(importPath, "", build.FindOnly)
if err != nil {
return nil, err
}
var dir = pkg.Dir
for len(dir) > 1 {
vcs, err := lookVCS(dir)
if err == nil {
return &managedRepo{vcs, dir}, nil
}
dir = filepath.Dir(dir)
}
... | go | func managedRepoRoot(importPath string) (*managedRepo, error) {
var pkg, err = build.Import(importPath, "", build.FindOnly)
if err != nil {
return nil, err
}
var dir = pkg.Dir
for len(dir) > 1 {
vcs, err := lookVCS(dir)
if err == nil {
return &managedRepo{vcs, dir}, nil
}
dir = filepath.Dir(dir)
}
... | [
"func",
"managedRepoRoot",
"(",
"importPath",
"string",
")",
"(",
"*",
"managedRepo",
",",
"error",
")",
"{",
"var",
"pkg",
",",
"err",
"=",
"build",
".",
"Import",
"(",
"importPath",
",",
"\"",
"\"",
",",
"build",
".",
"FindOnly",
")",
"\n",
"if",
"... | // managedRepoRoot finds the VCS root for a given import path. Unlike
// dependency repos, the source repo is allowed to have its root outside of the
// GOPATH. This supports the use case of mounting your GOPATH within a
// repository, common in polyglot repos. | [
"managedRepoRoot",
"finds",
"the",
"VCS",
"root",
"for",
"a",
"given",
"import",
"path",
".",
"Unlike",
"dependency",
"repos",
"the",
"source",
"repo",
"is",
"allowed",
"to",
"have",
"its",
"root",
"outside",
"of",
"the",
"GOPATH",
".",
"This",
"supports",
... | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/util.go#L23-L38 |
141,369 | robfig/glock | util.go | fastRepoRoot | func fastRepoRoot(rootImportPath string) (*repoRoot, error) {
pkg, err := build.Import(rootImportPath, "", build.FindOnly)
if err != nil {
return nil, err
}
vcs, err := lookVCS(pkg.Dir)
if err != nil {
return nil, err
}
return &repoRoot{
vcs: vcs,
repo: "",
path: pkg.Dir,
root: rootImportPath,
},... | go | func fastRepoRoot(rootImportPath string) (*repoRoot, error) {
pkg, err := build.Import(rootImportPath, "", build.FindOnly)
if err != nil {
return nil, err
}
vcs, err := lookVCS(pkg.Dir)
if err != nil {
return nil, err
}
return &repoRoot{
vcs: vcs,
repo: "",
path: pkg.Dir,
root: rootImportPath,
},... | [
"func",
"fastRepoRoot",
"(",
"rootImportPath",
"string",
")",
"(",
"*",
"repoRoot",
",",
"error",
")",
"{",
"pkg",
",",
"err",
":=",
"build",
".",
"Import",
"(",
"rootImportPath",
",",
"\"",
"\"",
",",
"build",
".",
"FindOnly",
")",
"\n",
"if",
"err",
... | // fastRepoRoot just checks for existence of VCS dot directories to determine
// which VCS to use for the given import path.
// If none are found, an error is returned. | [
"fastRepoRoot",
"just",
"checks",
"for",
"existence",
"of",
"VCS",
"dot",
"directories",
"to",
"determine",
"which",
"VCS",
"to",
"use",
"for",
"the",
"given",
"import",
"path",
".",
"If",
"none",
"are",
"found",
"an",
"error",
"is",
"returned",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/util.go#L63-L80 |
141,370 | robfig/glock | vcs.go | runVerboseOnly | func (v *vcsCmd) runVerboseOnly(dir string, cmd string, keyval ...string) error {
_, err := v.run1(dir, cmd, keyval, false)
return err
} | go | func (v *vcsCmd) runVerboseOnly(dir string, cmd string, keyval ...string) error {
_, err := v.run1(dir, cmd, keyval, false)
return err
} | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"runVerboseOnly",
"(",
"dir",
"string",
",",
"cmd",
"string",
",",
"keyval",
"...",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"v",
".",
"run1",
"(",
"dir",
",",
"cmd",
",",
"keyval",
",",
"false",
"... | // runVerboseOnly is like run but only generates error output to standard error in verbose mode. | [
"runVerboseOnly",
"is",
"like",
"run",
"but",
"only",
"generates",
"error",
"output",
"to",
"standard",
"error",
"in",
"verbose",
"mode",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L165-L168 |
141,371 | robfig/glock | vcs.go | runOutput | func (v *vcsCmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error) {
return v.run1(dir, cmd, keyval, true)
} | go | func (v *vcsCmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error) {
return v.run1(dir, cmd, keyval, true)
} | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"runOutput",
"(",
"dir",
"string",
",",
"cmd",
"string",
",",
"keyval",
"...",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"v",
".",
"run1",
"(",
"dir",
",",
"cmd",
",",
"keyval",
... | // runOutput is like run but returns the output of the command. | [
"runOutput",
"is",
"like",
"run",
"but",
"returns",
"the",
"output",
"of",
"the",
"command",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L171-L173 |
141,372 | robfig/glock | vcs.go | ping | func (v *vcsCmd) ping(scheme, repo string) error {
return v.runVerboseOnly(".", v.pingCmd, "scheme", scheme, "repo", repo)
} | go | func (v *vcsCmd) ping(scheme, repo string) error {
return v.runVerboseOnly(".", v.pingCmd, "scheme", scheme, "repo", repo)
} | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"ping",
"(",
"scheme",
",",
"repo",
"string",
")",
"error",
"{",
"return",
"v",
".",
"runVerboseOnly",
"(",
"\"",
"\"",
",",
"v",
".",
"pingCmd",
",",
"\"",
"\"",
",",
"scheme",
",",
"\"",
"\"",
",",
"repo",
... | // ping pings to determine scheme to use. | [
"ping",
"pings",
"to",
"determine",
"scheme",
"to",
"use",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L217-L219 |
141,373 | robfig/glock | vcs.go | create | func (v *vcsCmd) create(dir, repo string) error {
return v.run(".", v.createCmd, "dir", dir, "repo", repo)
} | go | func (v *vcsCmd) create(dir, repo string) error {
return v.run(".", v.createCmd, "dir", dir, "repo", repo)
} | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"create",
"(",
"dir",
",",
"repo",
"string",
")",
"error",
"{",
"return",
"v",
".",
"run",
"(",
"\"",
"\"",
",",
"v",
".",
"createCmd",
",",
"\"",
"\"",
",",
"dir",
",",
"\"",
"\"",
",",
"repo",
")",
"\n"... | // create creates a new copy of repo in dir.
// The parent of dir must exist; dir must not. | [
"create",
"creates",
"a",
"new",
"copy",
"of",
"repo",
"in",
"dir",
".",
"The",
"parent",
"of",
"dir",
"must",
"exist",
";",
"dir",
"must",
"not",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L223-L225 |
141,374 | robfig/glock | vcs.go | download | func (v *vcsCmd) download(dir string) error {
if err := v.fixDetachedHead(dir); err != nil {
return err
}
return v.run(dir, v.downloadCmd)
} | go | func (v *vcsCmd) download(dir string) error {
if err := v.fixDetachedHead(dir); err != nil {
return err
}
return v.run(dir, v.downloadCmd)
} | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"download",
"(",
"dir",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"v",
".",
"fixDetachedHead",
"(",
"dir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"v",
".",
"run",... | // download downloads any new changes for the repo in dir. | [
"download",
"downloads",
"any",
"new",
"changes",
"for",
"the",
"repo",
"in",
"dir",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L228-L233 |
141,375 | robfig/glock | vcs.go | tags | func (v *vcsCmd) tags(dir string) ([]string, error) {
var tags []string
for _, tc := range v.tagCmd {
out, err := v.runOutput(dir, tc.cmd)
if err != nil {
return nil, err
}
re := regexp.MustCompile(`(?m-s)` + tc.pattern)
for _, m := range re.FindAllStringSubmatch(string(out), -1) {
tags = append(tags,... | go | func (v *vcsCmd) tags(dir string) ([]string, error) {
var tags []string
for _, tc := range v.tagCmd {
out, err := v.runOutput(dir, tc.cmd)
if err != nil {
return nil, err
}
re := regexp.MustCompile(`(?m-s)` + tc.pattern)
for _, m := range re.FindAllStringSubmatch(string(out), -1) {
tags = append(tags,... | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"tags",
"(",
"dir",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"tags",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"tc",
":=",
"range",
"v",
".",
"tagCmd",
"{",
"out",
",",
"err... | // tags returns the list of available tags for the repo in dir. | [
"tags",
"returns",
"the",
"list",
"of",
"available",
"tags",
"for",
"the",
"repo",
"in",
"dir",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L260-L273 |
141,376 | robfig/glock | vcs.go | tagSync | func (v *vcsCmd) tagSync(dir, tag string) error {
if v.tagSyncCmd == "" {
return nil
}
if tag != "" {
for _, tc := range v.tagLookupCmd {
out, err := v.runOutput(dir, tc.cmd, "tag", tag)
if err != nil {
return err
}
re := regexp.MustCompile(`(?m-s)` + tc.pattern)
m := re.FindStringSubmatch(str... | go | func (v *vcsCmd) tagSync(dir, tag string) error {
if v.tagSyncCmd == "" {
return nil
}
if tag != "" {
for _, tc := range v.tagLookupCmd {
out, err := v.runOutput(dir, tc.cmd, "tag", tag)
if err != nil {
return err
}
re := regexp.MustCompile(`(?m-s)` + tc.pattern)
m := re.FindStringSubmatch(str... | [
"func",
"(",
"v",
"*",
"vcsCmd",
")",
"tagSync",
"(",
"dir",
",",
"tag",
"string",
")",
"error",
"{",
"if",
"v",
".",
"tagSyncCmd",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"tag",
"!=",
"\"",
"\"",
"{",
"for",
"_",
",",
... | // tagSync syncs the repo in dir to the named tag,
// which either is a tag returned by tags or is v.tagDefault. | [
"tagSync",
"syncs",
"the",
"repo",
"in",
"dir",
"to",
"the",
"named",
"tag",
"which",
"either",
"is",
"a",
"tag",
"returned",
"by",
"tags",
"or",
"is",
"v",
".",
"tagDefault",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L277-L299 |
141,377 | robfig/glock | vcs.go | matchGoImport | func matchGoImport(imports []metaImport, importPath string) (_ metaImport, err error) {
match := -1
for i, im := range imports {
if !strings.HasPrefix(importPath, im.Prefix) {
continue
}
if match != -1 {
err = fmt.Errorf("multiple meta tags match import path %q", importPath)
return
}
match = i
}
... | go | func matchGoImport(imports []metaImport, importPath string) (_ metaImport, err error) {
match := -1
for i, im := range imports {
if !strings.HasPrefix(importPath, im.Prefix) {
continue
}
if match != -1 {
err = fmt.Errorf("multiple meta tags match import path %q", importPath)
return
}
match = i
}
... | [
"func",
"matchGoImport",
"(",
"imports",
"[",
"]",
"metaImport",
",",
"importPath",
"string",
")",
"(",
"_",
"metaImport",
",",
"err",
"error",
")",
"{",
"match",
":=",
"-",
"1",
"\n",
"for",
"i",
",",
"im",
":=",
"range",
"imports",
"{",
"if",
"!",
... | // matchGoImport returns the metaImport from imports matching importPath.
// An error is returned if there are multiple matches.
// errNoMatch is returned if none match. | [
"matchGoImport",
"returns",
"the",
"metaImport",
"from",
"imports",
"matching",
"importPath",
".",
"An",
"error",
"is",
"returned",
"if",
"there",
"are",
"multiple",
"matches",
".",
"errNoMatch",
"is",
"returned",
"if",
"none",
"match",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L377-L394 |
141,378 | robfig/glock | vcs.go | noVCSSuffix | func noVCSSuffix(match map[string]string) error {
repo := match["repo"]
for _, vcs := range vcsList {
if strings.HasSuffix(repo, "."+vcs.cmd) {
return fmt.Errorf("invalid version control suffix in %s path", match["prefix"])
}
}
return nil
} | go | func noVCSSuffix(match map[string]string) error {
repo := match["repo"]
for _, vcs := range vcsList {
if strings.HasSuffix(repo, "."+vcs.cmd) {
return fmt.Errorf("invalid version control suffix in %s path", match["prefix"])
}
}
return nil
} | [
"func",
"noVCSSuffix",
"(",
"match",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"repo",
":=",
"match",
"[",
"\"",
"\"",
"]",
"\n",
"for",
"_",
",",
"vcs",
":=",
"range",
"vcsList",
"{",
"if",
"strings",
".",
"HasSuffix",
"(",
"repo",
"... | // noVCSSuffix checks that the repository name does not
// end in .foo for any version control system foo.
// The usual culprit is ".git". | [
"noVCSSuffix",
"checks",
"that",
"the",
"repository",
"name",
"does",
"not",
"end",
"in",
".",
"foo",
"for",
"any",
"version",
"control",
"system",
"foo",
".",
"The",
"usual",
"culprit",
"is",
".",
"git",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L465-L473 |
141,379 | robfig/glock | vcs.go | bitbucketVCS | func bitbucketVCS(match map[string]string) error {
if err := noVCSSuffix(match); err != nil {
return err
}
var resp struct {
SCM string `json:"scm"`
}
url := expand(match, "https://api.bitbucket.org/1.0/repositories/{bitname}")
data, err := httpGET(url)
if err != nil {
return err
}
if err := json.Unmars... | go | func bitbucketVCS(match map[string]string) error {
if err := noVCSSuffix(match); err != nil {
return err
}
var resp struct {
SCM string `json:"scm"`
}
url := expand(match, "https://api.bitbucket.org/1.0/repositories/{bitname}")
data, err := httpGET(url)
if err != nil {
return err
}
if err := json.Unmars... | [
"func",
"bitbucketVCS",
"(",
"match",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"noVCSSuffix",
"(",
"match",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"resp",
"struct",
"{",
"SCM",
... | // bitbucketVCS determines the version control system for a
// Bitbucket repository, by using the Bitbucket API. | [
"bitbucketVCS",
"determines",
"the",
"version",
"control",
"system",
"for",
"a",
"Bitbucket",
"repository",
"by",
"using",
"the",
"Bitbucket",
"API",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/vcs.go#L516-L542 |
141,380 | robfig/glock | install.go | calcGlockfilePath | func calcGlockfilePath(importPath string, repo *managedRepo) string {
var pkg, err = build.Import(importPath, "", build.FindOnly)
if err != nil {
perror(err)
}
var relPath = ""
if len(repo.dir) < len(pkg.Dir) {
relPath = pkg.Dir[len(repo.dir)+1:]
}
return filepath.Join(relPath, "GLOCKFILE")
} | go | func calcGlockfilePath(importPath string, repo *managedRepo) string {
var pkg, err = build.Import(importPath, "", build.FindOnly)
if err != nil {
perror(err)
}
var relPath = ""
if len(repo.dir) < len(pkg.Dir) {
relPath = pkg.Dir[len(repo.dir)+1:]
}
return filepath.Join(relPath, "GLOCKFILE")
} | [
"func",
"calcGlockfilePath",
"(",
"importPath",
"string",
",",
"repo",
"*",
"managedRepo",
")",
"string",
"{",
"var",
"pkg",
",",
"err",
"=",
"build",
".",
"Import",
"(",
"importPath",
",",
"\"",
"\"",
",",
"build",
".",
"FindOnly",
")",
"\n",
"if",
"e... | // calcGlockfilePath calculates the relative path to the GLOCKFILE from the root
// of the repo. | [
"calcGlockfilePath",
"calculates",
"the",
"relative",
"path",
"to",
"the",
"GLOCKFILE",
"from",
"the",
"root",
"of",
"the",
"repo",
"."
] | 428181ba14e0e3722090fe6e63402643a099e8bd | https://github.com/robfig/glock/blob/428181ba14e0e3722090fe6e63402643a099e8bd/install.go#L78-L90 |
141,381 | anacrolix/utp | socket.go | NewSocket | func NewSocket(network, addr string) (s *Socket, err error) {
if network == "" {
network = "udp"
}
pc, err := listenPacket(network, addr)
if err != nil {
return
}
return NewSocketFromPacketConn(pc)
} | go | func NewSocket(network, addr string) (s *Socket, err error) {
if network == "" {
network = "udp"
}
pc, err := listenPacket(network, addr)
if err != nil {
return
}
return NewSocketFromPacketConn(pc)
} | [
"func",
"NewSocket",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"s",
"*",
"Socket",
",",
"err",
"error",
")",
"{",
"if",
"network",
"==",
"\"",
"\"",
"{",
"network",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"pc",
",",
"err",
":=",
"listenPacket",
... | // NewSocket creates a net.PacketConn with the given network and address, and
// returns a Socket dispatching on it. | [
"NewSocket",
"creates",
"a",
"net",
".",
"PacketConn",
"with",
"the",
"given",
"network",
"and",
"address",
"and",
"returns",
"a",
"Socket",
"dispatching",
"on",
"it",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L61-L70 |
141,382 | anacrolix/utp | socket.go | NewSocketFromPacketConn | func NewSocketFromPacketConn(pc net.PacketConn) (s *Socket, err error) {
s = &Socket{
backlog: make(map[syn]struct{}, backlog),
pc: pc,
unusedReads: make(chan read, 100),
wgReadWrite: sync.WaitGroup{},
}
mu.Lock()
sockets[s] = struct{}{}
mu.Unlock()
go s.reader()
return
} | go | func NewSocketFromPacketConn(pc net.PacketConn) (s *Socket, err error) {
s = &Socket{
backlog: make(map[syn]struct{}, backlog),
pc: pc,
unusedReads: make(chan read, 100),
wgReadWrite: sync.WaitGroup{},
}
mu.Lock()
sockets[s] = struct{}{}
mu.Unlock()
go s.reader()
return
} | [
"func",
"NewSocketFromPacketConn",
"(",
"pc",
"net",
".",
"PacketConn",
")",
"(",
"s",
"*",
"Socket",
",",
"err",
"error",
")",
"{",
"s",
"=",
"&",
"Socket",
"{",
"backlog",
":",
"make",
"(",
"map",
"[",
"syn",
"]",
"struct",
"{",
"}",
",",
"backlo... | // Create a Socket, using the provided net.PacketConn. If you want to retain
// use of the net.PacketConn after the Socket closes it, override the
// net.PacketConn's Close method, or use NetSocketFromPacketConnNoClose. | [
"Create",
"a",
"Socket",
"using",
"the",
"provided",
"net",
".",
"PacketConn",
".",
"If",
"you",
"want",
"to",
"retain",
"use",
"of",
"the",
"net",
".",
"PacketConn",
"after",
"the",
"Socket",
"closes",
"it",
"override",
"the",
"net",
".",
"PacketConn",
... | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L75-L87 |
141,383 | anacrolix/utp | socket.go | NewSocketFromPacketConnNoClose | func NewSocketFromPacketConnNoClose(pc net.PacketConn) (s *Socket, err error) {
return NewSocketFromPacketConn(packetConnNopCloser{pc})
} | go | func NewSocketFromPacketConnNoClose(pc net.PacketConn) (s *Socket, err error) {
return NewSocketFromPacketConn(packetConnNopCloser{pc})
} | [
"func",
"NewSocketFromPacketConnNoClose",
"(",
"pc",
"net",
".",
"PacketConn",
")",
"(",
"s",
"*",
"Socket",
",",
"err",
"error",
")",
"{",
"return",
"NewSocketFromPacketConn",
"(",
"packetConnNopCloser",
"{",
"pc",
"}",
")",
"\n",
"}"
] | // Create a Socket using the provided PacketConn, that doesn't close the
// PacketConn when the Socket is closed. | [
"Create",
"a",
"Socket",
"using",
"the",
"provided",
"PacketConn",
"that",
"doesn",
"t",
"close",
"the",
"PacketConn",
"when",
"the",
"Socket",
"is",
"closed",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L91-L93 |
141,384 | anacrolix/utp | socket.go | reset | func (s *Socket) reset(addr net.Addr, ackNr, connId uint16) {
b := make([]byte, 0, maxHeaderSize)
h := header{
Type: stReset,
Version: 1,
ConnID: connId,
AckNr: ackNr,
}
b = b[:h.Marshal(b)]
go s.writeTo(b, addr)
} | go | func (s *Socket) reset(addr net.Addr, ackNr, connId uint16) {
b := make([]byte, 0, maxHeaderSize)
h := header{
Type: stReset,
Version: 1,
ConnID: connId,
AckNr: ackNr,
}
b = b[:h.Marshal(b)]
go s.writeTo(b, addr)
} | [
"func",
"(",
"s",
"*",
"Socket",
")",
"reset",
"(",
"addr",
"net",
".",
"Addr",
",",
"ackNr",
",",
"connId",
"uint16",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"maxHeaderSize",
")",
"\n",
"h",
":=",
"header",
"{",
"Typ... | // Send a reset in response to a packet with the given header. | [
"Send",
"a",
"reset",
"in",
"response",
"to",
"a",
"packet",
"with",
"the",
"given",
"header",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L251-L261 |
141,385 | anacrolix/utp | socket.go | newConnID | func (s *Socket) newConnID(remoteAddr resolvedAddrStr) (id uint16) {
// Rather than use math.Rand, which requires generating all the IDs up
// front and allocating a slice, we do it on the stack, generating the IDs
// only as required. To do this, we use the fact that the array is
// default-initialized. IDs that a... | go | func (s *Socket) newConnID(remoteAddr resolvedAddrStr) (id uint16) {
// Rather than use math.Rand, which requires generating all the IDs up
// front and allocating a slice, we do it on the stack, generating the IDs
// only as required. To do this, we use the fact that the array is
// default-initialized. IDs that a... | [
"func",
"(",
"s",
"*",
"Socket",
")",
"newConnID",
"(",
"remoteAddr",
"resolvedAddrStr",
")",
"(",
"id",
"uint16",
")",
"{",
"// Rather than use math.Rand, which requires generating all the IDs up",
"// front and allocating a slice, we do it on the stack, generating the IDs",
"//... | // Return a recv_id that should be free. Handling the case where it isn't is
// deferred to a more appropriate function. | [
"Return",
"a",
"recv_id",
"that",
"should",
"be",
"free",
".",
"Handling",
"the",
"case",
"where",
"it",
"isn",
"t",
"is",
"deferred",
"to",
"a",
"more",
"appropriate",
"function",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L265-L303 |
141,386 | anacrolix/utp | socket.go | registerConn | func (s *Socket) registerConn(recvID uint16, remoteAddr resolvedAddrStr, c *Conn) bool {
if s.conns == nil {
s.conns = make(map[connKey]*Conn)
}
key := connKey{remoteAddr, recvID}
if _, ok := s.conns[key]; ok {
return false
}
c.connKey = key
s.conns[key] = c
return true
} | go | func (s *Socket) registerConn(recvID uint16, remoteAddr resolvedAddrStr, c *Conn) bool {
if s.conns == nil {
s.conns = make(map[connKey]*Conn)
}
key := connKey{remoteAddr, recvID}
if _, ok := s.conns[key]; ok {
return false
}
c.connKey = key
s.conns[key] = c
return true
} | [
"func",
"(",
"s",
"*",
"Socket",
")",
"registerConn",
"(",
"recvID",
"uint16",
",",
"remoteAddr",
"resolvedAddrStr",
",",
"c",
"*",
"Conn",
")",
"bool",
"{",
"if",
"s",
".",
"conns",
"==",
"nil",
"{",
"s",
".",
"conns",
"=",
"make",
"(",
"map",
"["... | // Returns true if the connection was newly registered, false otherwise. | [
"Returns",
"true",
"if",
"the",
"connection",
"was",
"newly",
"registered",
"false",
"otherwise",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L437-L448 |
141,387 | anacrolix/utp | socket.go | ackSyn | func (s *Socket) ackSyn(syn syn) (c *Conn, ok bool) {
c = s.newConn(s.strNetAddr(syn.addr))
c.send_id = syn.conn_id
c.recv_id = c.send_id + 1
c.seq_nr = uint16(rand.Int())
c.lastAck = c.seq_nr - 1
c.ack_nr = syn.seq_nr
c.synAcked = true
c.updateCanWrite()
if !s.registerConn(c.recv_id, resolvedAddrStr(syn.addr)... | go | func (s *Socket) ackSyn(syn syn) (c *Conn, ok bool) {
c = s.newConn(s.strNetAddr(syn.addr))
c.send_id = syn.conn_id
c.recv_id = c.send_id + 1
c.seq_nr = uint16(rand.Int())
c.lastAck = c.seq_nr - 1
c.ack_nr = syn.seq_nr
c.synAcked = true
c.updateCanWrite()
if !s.registerConn(c.recv_id, resolvedAddrStr(syn.addr)... | [
"func",
"(",
"s",
"*",
"Socket",
")",
"ackSyn",
"(",
"syn",
"syn",
")",
"(",
"c",
"*",
"Conn",
",",
"ok",
"bool",
")",
"{",
"c",
"=",
"s",
".",
"newConn",
"(",
"s",
".",
"strNetAddr",
"(",
"syn",
".",
"addr",
")",
")",
"\n",
"c",
".",
"send... | // ACK a SYN, and return a new Conn for it. ok is false if the SYN is bad, and
// the Conn invalid. | [
"ACK",
"a",
"SYN",
"and",
"return",
"a",
"new",
"Conn",
"for",
"it",
".",
"ok",
"is",
"false",
"if",
"the",
"SYN",
"is",
"bad",
"and",
"the",
"Conn",
"invalid",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L480-L502 |
141,388 | anacrolix/utp | socket.go | Accept | func (s *Socket) Accept() (net.Conn, error) {
mu.Lock()
defer mu.Unlock()
for {
syn, err := s.nextSyn()
if err != nil {
return nil, err
}
c, ok := s.ackSyn(syn)
if ok {
c.updateCanWrite()
return c, nil
}
}
} | go | func (s *Socket) Accept() (net.Conn, error) {
mu.Lock()
defer mu.Unlock()
for {
syn, err := s.nextSyn()
if err != nil {
return nil, err
}
c, ok := s.ackSyn(syn)
if ok {
c.updateCanWrite()
return c, nil
}
}
} | [
"func",
"(",
"s",
"*",
"Socket",
")",
"Accept",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"{",
"syn",
",",
"err",
":=",
"s",
".",
"next... | // Accept and return a new uTP connection. | [
"Accept",
"and",
"return",
"a",
"new",
"uTP",
"connection",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/socket.go#L505-L519 |
141,389 | anacrolix/utp | send.go | Ack | func (s *send) Ack() (latency time.Duration, first bool) {
first = !s.acked.IsSet()
if first {
latency = missinggo.MonotonicSince(s.started)
}
if s.payload != nil {
sendBufferPool.Put(s.payload[:0:minMTU])
s.payload = nil
}
s.acked.Set()
if s.resendTimer != nil {
s.resendTimer.Stop()
s.resendTimer = ni... | go | func (s *send) Ack() (latency time.Duration, first bool) {
first = !s.acked.IsSet()
if first {
latency = missinggo.MonotonicSince(s.started)
}
if s.payload != nil {
sendBufferPool.Put(s.payload[:0:minMTU])
s.payload = nil
}
s.acked.Set()
if s.resendTimer != nil {
s.resendTimer.Stop()
s.resendTimer = ni... | [
"func",
"(",
"s",
"*",
"send",
")",
"Ack",
"(",
")",
"(",
"latency",
"time",
".",
"Duration",
",",
"first",
"bool",
")",
"{",
"first",
"=",
"!",
"s",
".",
"acked",
".",
"IsSet",
"(",
")",
"\n",
"if",
"first",
"{",
"latency",
"=",
"missinggo",
"... | // first is true if this is the first time the send is acked. latency is
// calculated for the first ack. | [
"first",
"is",
"true",
"if",
"this",
"is",
"the",
"first",
"time",
"the",
"send",
"is",
"acked",
".",
"latency",
"is",
"calculated",
"for",
"the",
"first",
"ack",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/send.go#L27-L42 |
141,390 | anacrolix/utp | utp.go | DialContext | func DialContext(ctx context.Context, addr string) (nc net.Conn, err error) {
s, err := NewSocket("udp", ":0")
if err != nil {
return
}
defer s.Close()
return s.DialContext(ctx, "", addr)
} | go | func DialContext(ctx context.Context, addr string) (nc net.Conn, err error) {
s, err := NewSocket("udp", ":0")
if err != nil {
return
}
defer s.Close()
return s.DialContext(ctx, "", addr)
} | [
"func",
"DialContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"addr",
"string",
")",
"(",
"nc",
"net",
".",
"Conn",
",",
"err",
"error",
")",
"{",
"s",
",",
"err",
":=",
"NewSocket",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
... | // Same as Dial with a timeout parameter. Creates a Socket just for the
// connection, which will be closed with the Conn is. To reuse another Socket,
// see Socket.Dial. | [
"Same",
"as",
"Dial",
"with",
"a",
"timeout",
"parameter",
".",
"Creates",
"a",
"Socket",
"just",
"for",
"the",
"connection",
"which",
"will",
"be",
"closed",
"with",
"the",
"Conn",
"is",
".",
"To",
"reuse",
"another",
"Socket",
"see",
"Socket",
".",
"Di... | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/utp.go#L169-L176 |
141,391 | anacrolix/utp | conn.go | sendPendingState | func (c *Conn) sendPendingState() {
if c.destroyed.IsSet() {
c.sendReset()
} else {
c.sendState()
}
} | go | func (c *Conn) sendPendingState() {
if c.destroyed.IsSet() {
c.sendReset()
} else {
c.sendState()
}
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"sendPendingState",
"(",
")",
"{",
"if",
"c",
".",
"destroyed",
".",
"IsSet",
"(",
")",
"{",
"c",
".",
"sendReset",
"(",
")",
"\n",
"}",
"else",
"{",
"c",
".",
"sendState",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Send a state packet, if one is needed. | [
"Send",
"a",
"state",
"packet",
"if",
"one",
"is",
"needed",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L83-L89 |
141,392 | anacrolix/utp | conn.go | wndSize | func (c *Conn) wndSize() uint32 {
if len(c.readBuf)+c.inboundWnd > readBufferLen {
return 0
}
return uint32(readBufferLen - len(c.readBuf) - c.inboundWnd)
} | go | func (c *Conn) wndSize() uint32 {
if len(c.readBuf)+c.inboundWnd > readBufferLen {
return 0
}
return uint32(readBufferLen - len(c.readBuf) - c.inboundWnd)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"wndSize",
"(",
")",
"uint32",
"{",
"if",
"len",
"(",
"c",
".",
"readBuf",
")",
"+",
"c",
".",
"inboundWnd",
">",
"readBufferLen",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"uint32",
"(",
"readBufferLen",
"-... | // So far as the spec makes clear, this is how many more, as-yet-unacked bytes
// we can fit into our receive buffers. | [
"So",
"far",
"as",
"the",
"spec",
"makes",
"clear",
"this",
"is",
"how",
"many",
"more",
"as",
"-",
"yet",
"-",
"unacked",
"bytes",
"we",
"can",
"fit",
"into",
"our",
"receive",
"buffers",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L93-L98 |
141,393 | anacrolix/utp | conn.go | send | func (c *Conn) send(_type st, connID uint16, payload []byte, seqNr uint16) (err error) {
p := c.makePacket(_type, connID, seqNr, payload)
n1, err := c.socket.writeTo(p, c.remoteSocketAddr)
sendBufferPool.Put(p[:0:minMTU])
if err != nil {
return
}
if n1 != len(p) {
panic(n1)
}
if c.unpendSendState() && _type... | go | func (c *Conn) send(_type st, connID uint16, payload []byte, seqNr uint16) (err error) {
p := c.makePacket(_type, connID, seqNr, payload)
n1, err := c.socket.writeTo(p, c.remoteSocketAddr)
sendBufferPool.Put(p[:0:minMTU])
if err != nil {
return
}
if n1 != len(p) {
panic(n1)
}
if c.unpendSendState() && _type... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"send",
"(",
"_type",
"st",
",",
"connID",
"uint16",
",",
"payload",
"[",
"]",
"byte",
",",
"seqNr",
"uint16",
")",
"(",
"err",
"error",
")",
"{",
"p",
":=",
"c",
".",
"makePacket",
"(",
"_type",
",",
"connID",... | // Send the given payload with an up to date header. | [
"Send",
"the",
"given",
"payload",
"with",
"an",
"up",
"to",
"date",
"header",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L140-L156 |
141,394 | anacrolix/utp | conn.go | ack | func (c *Conn) ack(nr uint16) {
if !seqLess(c.lastAck, nr) {
// Already acked.
return
}
i := nr - c.lastAck - 1
if int(i) >= len(c.unackedSends) {
// Remote has acknowledged receipt of packets we haven't even sent.
acksReceivedAheadOfSyn.Add(1)
// log.Printf("got ack ahead of syn (%x > %x)", nr, c.seq_nr-... | go | func (c *Conn) ack(nr uint16) {
if !seqLess(c.lastAck, nr) {
// Already acked.
return
}
i := nr - c.lastAck - 1
if int(i) >= len(c.unackedSends) {
// Remote has acknowledged receipt of packets we haven't even sent.
acksReceivedAheadOfSyn.Add(1)
// log.Printf("got ack ahead of syn (%x > %x)", nr, c.seq_nr-... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ack",
"(",
"nr",
"uint16",
")",
"{",
"if",
"!",
"seqLess",
"(",
"c",
".",
"lastAck",
",",
"nr",
")",
"{",
"// Already acked.",
"return",
"\n",
"}",
"\n",
"i",
":=",
"nr",
"-",
"c",
".",
"lastAck",
"-",
"1",
... | // Ack our send with the given sequence number. | [
"Ack",
"our",
"send",
"with",
"the",
"given",
"sequence",
"number",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L252-L282 |
141,395 | anacrolix/utp | conn.go | seqSend | func (c *Conn) seqSend(seqNr uint16) *send {
if !seqLess(c.lastAck, seqNr) {
// Presumably already acked.
return nil
}
i := int(seqNr - c.lastAck - 1)
if i >= len(c.unackedSends) {
// No such send.
return nil
}
return c.unackedSends[i]
} | go | func (c *Conn) seqSend(seqNr uint16) *send {
if !seqLess(c.lastAck, seqNr) {
// Presumably already acked.
return nil
}
i := int(seqNr - c.lastAck - 1)
if i >= len(c.unackedSends) {
// No such send.
return nil
}
return c.unackedSends[i]
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"seqSend",
"(",
"seqNr",
"uint16",
")",
"*",
"send",
"{",
"if",
"!",
"seqLess",
"(",
"c",
".",
"lastAck",
",",
"seqNr",
")",
"{",
"// Presumably already acked.",
"return",
"nil",
"\n",
"}",
"\n",
"i",
":=",
"int",
... | // Return the send state for the sequence number. Returns nil if there's no
// outstanding send for that sequence number. | [
"Return",
"the",
"send",
"state",
"for",
"the",
"sequence",
"number",
".",
"Returns",
"nil",
"if",
"there",
"s",
"no",
"outstanding",
"send",
"for",
"that",
"sequence",
"number",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L295-L306 |
141,396 | anacrolix/utp | conn.go | receivePacket | func (c *Conn) receivePacket(h header, payload []byte) {
c.packetReadTimeoutTimer.Reset(packetReadTimeout)
c.processDelivery(h, payload)
} | go | func (c *Conn) receivePacket(h header, payload []byte) {
c.packetReadTimeoutTimer.Reset(packetReadTimeout)
c.processDelivery(h, payload)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"receivePacket",
"(",
"h",
"header",
",",
"payload",
"[",
"]",
"byte",
")",
"{",
"c",
".",
"packetReadTimeoutTimer",
".",
"Reset",
"(",
"packetReadTimeout",
")",
"\n",
"c",
".",
"processDelivery",
"(",
"h",
",",
"pay... | // Handle a packet destined for this connection. | [
"Handle",
"a",
"packet",
"destined",
"for",
"this",
"connection",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L333-L336 |
141,397 | anacrolix/utp | conn.go | recvSynAck | func (c *Conn) recvSynAck() (err error) {
mu.Lock()
defer mu.Unlock()
c.waitAck(1)
if c.err != nil {
err = c.err
}
c.synAcked = true
c.updateCanWrite()
return err
} | go | func (c *Conn) recvSynAck() (err error) {
mu.Lock()
defer mu.Unlock()
c.waitAck(1)
if c.err != nil {
err = c.err
}
c.synAcked = true
c.updateCanWrite()
return err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"recvSynAck",
"(",
")",
"(",
"err",
"error",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"waitAck",
"(",
"1",
")",
"\n",
"if",
"c",
".",
"err",
"!=... | // Waits for sent SYN to be ACKed. Returns any errors. | [
"Waits",
"for",
"sent",
"SYN",
"to",
"be",
"ACKed",
".",
"Returns",
"any",
"errors",
"."
] | 9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9 | https://github.com/anacrolix/utp/blob/9e0e1d1d0572f5a09a669d4ea0372d8e8078dcc9/conn.go#L470-L480 |
141,398 | djherbis/nio | nio.go | Copy | func Copy(dst io.Writer, src io.Reader, buf Buffer) (n int64, err error) {
return io.Copy(dst, NewReader(src, buf))
} | go | func Copy(dst io.Writer, src io.Reader, buf Buffer) (n int64, err error) {
return io.Copy(dst, NewReader(src, buf))
} | [
"func",
"Copy",
"(",
"dst",
"io",
".",
"Writer",
",",
"src",
"io",
".",
"Reader",
",",
"buf",
"Buffer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"return",
"io",
".",
"Copy",
"(",
"dst",
",",
"NewReader",
"(",
"src",
",",
"buf",
")... | // Copy copies from src to buf, and from buf to dst in parallel until
// either EOF is reached on src or an error occurs. It returns the number of bytes
// copied to dst and the first error encountered while copying, if any.
// EOF is not considered to be an error. If src implements WriterTo, it is used to
// write to ... | [
"Copy",
"copies",
"from",
"src",
"to",
"buf",
"and",
"from",
"buf",
"to",
"dst",
"in",
"parallel",
"until",
"either",
"EOF",
"is",
"reached",
"on",
"src",
"or",
"an",
"error",
"occurs",
".",
"It",
"returns",
"the",
"number",
"of",
"bytes",
"copied",
"t... | 6c5b9b79551263eaa2fbdf53e87b8b981539dbe2 | https://github.com/djherbis/nio/blob/6c5b9b79551263eaa2fbdf53e87b8b981539dbe2/nio.go#L39-L41 |
141,399 | djherbis/nio | nio.go | NewReader | func NewReader(src io.Reader, buf Buffer) io.ReadCloser {
r, w := Pipe(buf)
go func() {
_, err := io.Copy(w, src)
w.CloseWithError(err)
}()
return r
} | go | func NewReader(src io.Reader, buf Buffer) io.ReadCloser {
r, w := Pipe(buf)
go func() {
_, err := io.Copy(w, src)
w.CloseWithError(err)
}()
return r
} | [
"func",
"NewReader",
"(",
"src",
"io",
".",
"Reader",
",",
"buf",
"Buffer",
")",
"io",
".",
"ReadCloser",
"{",
"r",
",",
"w",
":=",
"Pipe",
"(",
"buf",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"_",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"... | // NewReader reads from the buffer which is concurrently filled with data from the passed src. | [
"NewReader",
"reads",
"from",
"the",
"buffer",
"which",
"is",
"concurrently",
"filled",
"with",
"data",
"from",
"the",
"passed",
"src",
"."
] | 6c5b9b79551263eaa2fbdf53e87b8b981539dbe2 | https://github.com/djherbis/nio/blob/6c5b9b79551263eaa2fbdf53e87b8b981539dbe2/nio.go#L44-L53 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.