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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
144,600 | memcachier/mc | client.go | Decr | func (c *Client) Decr(key string, delta, init uint64, exp uint32, ocas uint64) (n, cas uint64, err error) {
return c.incrdecr(opDecrement, key, delta, init, exp, ocas)
} | go | func (c *Client) Decr(key string, delta, init uint64, exp uint32, ocas uint64) (n, cas uint64, err error) {
return c.incrdecr(opDecrement, key, delta, init, exp, ocas)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Decr",
"(",
"key",
"string",
",",
"delta",
",",
"init",
"uint64",
",",
"exp",
"uint32",
",",
"ocas",
"uint64",
")",
"(",
"n",
",",
"cas",
"uint64",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"incrdec... | // Decr decrements a value in the cache. The value must be an unsigned 64bit
// integer stored as an ASCII string. It can't be decremented below 0. | [
"Decr",
"decrements",
"a",
"value",
"in",
"the",
"cache",
".",
"The",
"value",
"must",
"be",
"an",
"unsigned",
"64bit",
"integer",
"stored",
"as",
"an",
"ASCII",
"string",
".",
"It",
"can",
"t",
"be",
"decremented",
"below",
"0",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L248-L250 |
144,601 | memcachier/mc | client.go | Append | func (c *Client) Append(key, val string, ocas uint64) (cas uint64, err error) {
// Variants: [R] Append [Q]
// Request : MUST key, value; MUST NOT extras
// Response: MUST NOT key, value, extras
m := &msg{
header: header{
Op: opAppend,
CAS: ocas,
},
key: key,
val: val,
}
err = c.perform(m)
return... | go | func (c *Client) Append(key, val string, ocas uint64) (cas uint64, err error) {
// Variants: [R] Append [Q]
// Request : MUST key, value; MUST NOT extras
// Response: MUST NOT key, value, extras
m := &msg{
header: header{
Op: opAppend,
CAS: ocas,
},
key: key,
val: val,
}
err = c.perform(m)
return... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Append",
"(",
"key",
",",
"val",
"string",
",",
"ocas",
"uint64",
")",
"(",
"cas",
"uint64",
",",
"err",
"error",
")",
"{",
"// Variants: [R] Append [Q]",
"// Request : MUST key, value; MUST NOT extras",
"// Response: MUST NO... | // Append appends the value to the existing value for the key specified. An
// error is thrown if the key doesn't exist. | [
"Append",
"appends",
"the",
"value",
"to",
"the",
"existing",
"value",
"for",
"the",
"key",
"specified",
".",
"An",
"error",
"is",
"thrown",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L294-L309 |
144,602 | memcachier/mc | client.go | NoOp | func (c *Client) NoOp() (err error) {
// Variants: NoOp
// Request : MUST NOT key, value, extras
// Response: MUST NOT key, value, extras
m := &msg{
header: header{
Op: opNoop,
},
}
for _, s := range c.servers {
if s.isAlive {
err = s.perform(m)
}
}
return err // retrns err from last perform but ... | go | func (c *Client) NoOp() (err error) {
// Variants: NoOp
// Request : MUST NOT key, value, extras
// Response: MUST NOT key, value, extras
m := &msg{
header: header{
Op: opNoop,
},
}
for _, s := range c.servers {
if s.isAlive {
err = s.perform(m)
}
}
return err // retrns err from last perform but ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NoOp",
"(",
")",
"(",
"err",
"error",
")",
"{",
"// Variants: NoOp",
"// Request : MUST NOT key, value, extras",
"// Response: MUST NOT key, value, extras",
"m",
":=",
"&",
"msg",
"{",
"header",
":",
"header",
"{",
"Op",
":... | // NoOp sends a No-Op message to the memcache server. This can be used as a
// heartbeat for the server to check it's functioning fine still. | [
"NoOp",
"sends",
"a",
"No",
"-",
"Op",
"message",
"to",
"the",
"memcache",
"server",
".",
"This",
"can",
"be",
"used",
"as",
"a",
"heartbeat",
"for",
"the",
"server",
"to",
"check",
"it",
"s",
"functioning",
"fine",
"still",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L381-L397 |
144,603 | memcachier/mc | client.go | Version | func (c *Client) Version() (vers map[string]string, err error) {
// Variants: Version
// Request : MUST NOT key, value, extras
// Response: MUST NOT key, extras; MUST value
// value is the version as a string in form "X.Y.Z"
m := &msg{
header: header{
Op: opVersion,
},
}
vers = make(map[string]string)
... | go | func (c *Client) Version() (vers map[string]string, err error) {
// Variants: Version
// Request : MUST NOT key, value, extras
// Response: MUST NOT key, extras; MUST value
// value is the version as a string in form "X.Y.Z"
m := &msg{
header: header{
Op: opVersion,
},
}
vers = make(map[string]string)
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Version",
"(",
")",
"(",
"vers",
"map",
"[",
"string",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// Variants: Version",
"// Request : MUST NOT key, value, extras",
"// Response: MUST NOT key, extras; MUST value",
"// value i... | // Version gets the version of the memcached server connected to. | [
"Version",
"gets",
"the",
"version",
"of",
"the",
"memcached",
"server",
"connected",
"to",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L400-L423 |
144,604 | memcachier/mc | client.go | StatsWithKey | func (c *Client) StatsWithKey(key string) (map[string]McStats, error) {
// Variants: Stats
// Request : MAY HAVE key, MUST NOT value, extra
// Response: Serries of responses that MUST HAVE key, value; followed by one
// response that MUST NOT have key, value. ALL MUST NOT extras.
m := &msg{
header: hea... | go | func (c *Client) StatsWithKey(key string) (map[string]McStats, error) {
// Variants: Stats
// Request : MAY HAVE key, MUST NOT value, extra
// Response: Serries of responses that MUST HAVE key, value; followed by one
// response that MUST NOT have key, value. ALL MUST NOT extras.
m := &msg{
header: hea... | [
"func",
"(",
"c",
"*",
"Client",
")",
"StatsWithKey",
"(",
"key",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"McStats",
",",
"error",
")",
"{",
"// Variants: Stats",
"// Request : MAY HAVE key, MUST NOT value, extra",
"// Response: Serries of responses that MUST HAV... | // StatsWithKey returns some statistics about the memcached server. It supports
// sending across a key to the server to select which statistics should be
// returned. | [
"StatsWithKey",
"returns",
"some",
"statistics",
"about",
"the",
"memcached",
"server",
".",
"It",
"supports",
"sending",
"across",
"a",
"key",
"to",
"the",
"server",
"to",
"select",
"which",
"statistics",
"should",
"be",
"returned",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L444-L468 |
144,605 | memcachier/mc | client.go | Stats | func (c *Client) Stats() (stats map[string]McStats, err error) {
return c.StatsWithKey("")
} | go | func (c *Client) Stats() (stats map[string]McStats, err error) {
return c.StatsWithKey("")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Stats",
"(",
")",
"(",
"stats",
"map",
"[",
"string",
"]",
"McStats",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"StatsWithKey",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Stats returns some statistics about the memcached server. | [
"Stats",
"returns",
"some",
"statistics",
"about",
"the",
"memcached",
"server",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L471-L473 |
144,606 | memcachier/mc | client.go | StatsReset | func (c *Client) StatsReset() (err error) {
_, err = c.StatsWithKey("reset")
return err
} | go | func (c *Client) StatsReset() (err error) {
_, err = c.StatsWithKey("reset")
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"StatsReset",
"(",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"c",
".",
"StatsWithKey",
"(",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // StatsReset resets the statistics stored at the memcached server. | [
"StatsReset",
"resets",
"the",
"statistics",
"stored",
"at",
"the",
"memcached",
"server",
"."
] | 5d1620e2c6d86be00ea70065e3c1301ee1cb1894 | https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L476-L479 |
144,607 | 10gen/openssl | ctx.go | CheckPrivateKey | func (c *Ctx) CheckPrivateKey() error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if int(C.SSL_CTX_check_private_key(c.ctx)) != 1 {
return errorFromErrorQueue()
}
return nil
} | go | func (c *Ctx) CheckPrivateKey() error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if int(C.SSL_CTX_check_private_key(c.ctx)) != 1 {
return errorFromErrorQueue()
}
return nil
} | [
"func",
"(",
"c",
"*",
"Ctx",
")",
"CheckPrivateKey",
"(",
")",
"error",
"{",
"runtime",
".",
"LockOSThread",
"(",
")",
"\n",
"defer",
"runtime",
".",
"UnlockOSThread",
"(",
")",
"\n",
"if",
"int",
"(",
"C",
".",
"SSL_CTX_check_private_key",
"(",
"c",
... | // CheckPrivateKey verifies that the private key agrees with the corresponding
// public key in the certificate | [
"CheckPrivateKey",
"verifies",
"that",
"the",
"private",
"key",
"agrees",
"with",
"the",
"corresponding",
"public",
"key",
"in",
"the",
"certificate"
] | 2862bcc79a773edf6d701e41fb4880badad12cca | https://github.com/10gen/openssl/blob/2862bcc79a773edf6d701e41fb4880badad12cca/ctx.go#L268-L275 |
144,608 | 10gen/openssl | ctx.go | AddLookup | func (s *CertificateStore) AddLookup(method X509LookupMethod) (*CertificateStoreLookup, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var lookup *C.X509_LOOKUP
lookup = C.X509_STORE_add_lookup(s.store, method)
if lookup != nil {
return &CertificateStoreLookup{
lookup: lookup,
store: s,
... | go | func (s *CertificateStore) AddLookup(method X509LookupMethod) (*CertificateStoreLookup, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var lookup *C.X509_LOOKUP
lookup = C.X509_STORE_add_lookup(s.store, method)
if lookup != nil {
return &CertificateStoreLookup{
lookup: lookup,
store: s,
... | [
"func",
"(",
"s",
"*",
"CertificateStore",
")",
"AddLookup",
"(",
"method",
"X509LookupMethod",
")",
"(",
"*",
"CertificateStoreLookup",
",",
"error",
")",
"{",
"runtime",
".",
"LockOSThread",
"(",
")",
"\n",
"defer",
"runtime",
".",
"UnlockOSThread",
"(",
"... | // AddLookup creates a CertificateStoreLookup of type X509LookupMethod in the
// CertificateStore | [
"AddLookup",
"creates",
"a",
"CertificateStoreLookup",
"of",
"type",
"X509LookupMethod",
"in",
"the",
"CertificateStore"
] | 2862bcc79a773edf6d701e41fb4880badad12cca | https://github.com/10gen/openssl/blob/2862bcc79a773edf6d701e41fb4880badad12cca/ctx.go#L459-L471 |
144,609 | 10gen/openssl | ctx.go | LoadCRLFile | func (l *CertificateStoreLookup) LoadCRLFile(crl_file string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var c_crl_file *C.char
if crl_file != "" {
c_crl_file = C.CString(crl_file)
defer C.free(unsafe.Pointer(c_crl_file))
}
if int(C.X509_load_crl_file(l.lookup, c_crl_file, C.X509_FILETYPE_P... | go | func (l *CertificateStoreLookup) LoadCRLFile(crl_file string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var c_crl_file *C.char
if crl_file != "" {
c_crl_file = C.CString(crl_file)
defer C.free(unsafe.Pointer(c_crl_file))
}
if int(C.X509_load_crl_file(l.lookup, c_crl_file, C.X509_FILETYPE_P... | [
"func",
"(",
"l",
"*",
"CertificateStoreLookup",
")",
"LoadCRLFile",
"(",
"crl_file",
"string",
")",
"error",
"{",
"runtime",
".",
"LockOSThread",
"(",
")",
"\n",
"defer",
"runtime",
".",
"UnlockOSThread",
"(",
")",
"\n",
"var",
"c_crl_file",
"*",
"C",
"."... | // LoadCRLFile adds a file to a CertificateStoreLookup in the
// CertificateStore
// I suspect that the CertificateStoreLookup needs to have been created with
// X509LookupFile as the lookup method | [
"LoadCRLFile",
"adds",
"a",
"file",
"to",
"a",
"CertificateStoreLookup",
"in",
"the",
"CertificateStore",
"I",
"suspect",
"that",
"the",
"CertificateStoreLookup",
"needs",
"to",
"have",
"been",
"created",
"with",
"X509LookupFile",
"as",
"the",
"lookup",
"method"
] | 2862bcc79a773edf6d701e41fb4880badad12cca | https://github.com/10gen/openssl/blob/2862bcc79a773edf6d701e41fb4880badad12cca/ctx.go#L477-L489 |
144,610 | alexcesaro/log | buflog/buflog.go | New | func New(out io.Writer, threshold log.Level, flushThreshold log.Level) *Logger {
logger := &Logger{
Logger: golog.New(out, threshold),
flush: flushThreshold,
buffer: bufio.NewWriter(out),
}
replaceWriter(logger)
return logger
} | go | func New(out io.Writer, threshold log.Level, flushThreshold log.Level) *Logger {
logger := &Logger{
Logger: golog.New(out, threshold),
flush: flushThreshold,
buffer: bufio.NewWriter(out),
}
replaceWriter(logger)
return logger
} | [
"func",
"New",
"(",
"out",
"io",
".",
"Writer",
",",
"threshold",
"log",
".",
"Level",
",",
"flushThreshold",
"log",
".",
"Level",
")",
"*",
"Logger",
"{",
"logger",
":=",
"&",
"Logger",
"{",
"Logger",
":",
"golog",
".",
"New",
"(",
"out",
",",
"th... | // New creates a new Logger. The out variable sets the destination to which
// log data will be written. The threshold variable defines the level under
// which logging will be ignored. The flushThreshold variable defines the
// level above which logging will be output. | [
"New",
"creates",
"a",
"new",
"Logger",
".",
"The",
"out",
"variable",
"sets",
"the",
"destination",
"to",
"which",
"log",
"data",
"will",
"be",
"written",
".",
"The",
"threshold",
"variable",
"defines",
"the",
"level",
"under",
"which",
"logging",
"will",
... | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/buflog/buflog.go#L31-L40 |
144,611 | alexcesaro/log | golog/golog.go | New | func New(out io.Writer, threshold log.Level) *Logger {
return &Logger{
out: out,
threshold: threshold,
Formatter: defaultFormater,
Writer: defaultWriter,
}
} | go | func New(out io.Writer, threshold log.Level) *Logger {
return &Logger{
out: out,
threshold: threshold,
Formatter: defaultFormater,
Writer: defaultWriter,
}
} | [
"func",
"New",
"(",
"out",
"io",
".",
"Writer",
",",
"threshold",
"log",
".",
"Level",
")",
"*",
"Logger",
"{",
"return",
"&",
"Logger",
"{",
"out",
":",
"out",
",",
"threshold",
":",
"threshold",
",",
"Formatter",
":",
"defaultFormater",
",",
"Writer"... | // New creates a new Logger. The out variable sets the destination to which log
// data will be written. The threshold variable defines the level under which
// logging will be ignored. | [
"New",
"creates",
"a",
"new",
"Logger",
".",
"The",
"out",
"variable",
"sets",
"the",
"destination",
"to",
"which",
"log",
"data",
"will",
"be",
"written",
".",
"The",
"threshold",
"variable",
"defines",
"the",
"level",
"under",
"which",
"logging",
"will",
... | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L52-L59 |
144,612 | alexcesaro/log | golog/golog.go | Emergencyf | func (logger *Logger) Emergencyf(format string, args ...interface{}) {
logger.output(log.Emergency, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Emergencyf(format string, args ...interface{}) {
logger.output(log.Emergency, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Emergencyf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Emergency",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...... | // Emergencyf logs with an emergency level.
// Arguments are handled in the manner of fmt.Printf. | [
"Emergencyf",
"logs",
"with",
"an",
"emergency",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L68-L70 |
144,613 | alexcesaro/log | golog/golog.go | Alertf | func (logger *Logger) Alertf(format string, args ...interface{}) {
logger.output(log.Alert, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Alertf(format string, args ...interface{}) {
logger.output(log.Alert, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Alertf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Alert",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")"... | // Alertf logs with an alert level.
// Arguments are handled in the manner of fmt.Printf. | [
"Alertf",
"logs",
"with",
"an",
"alert",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L79-L81 |
144,614 | alexcesaro/log | golog/golog.go | Criticalf | func (logger *Logger) Criticalf(format string, args ...interface{}) {
logger.output(log.Critical, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Criticalf(format string, args ...interface{}) {
logger.output(log.Critical, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Criticalf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Critical",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",... | // Criticalf logs with a critical level.
// Arguments are handled in the manner of fmt.Printf. | [
"Criticalf",
"logs",
"with",
"a",
"critical",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L90-L92 |
144,615 | alexcesaro/log | golog/golog.go | Errorf | func (logger *Logger) Errorf(format string, args ...interface{}) {
logger.output(log.Error, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Errorf(format string, args ...interface{}) {
logger.output(log.Error, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Errorf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Error",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")"... | // Errorf logs with an error level.
// Arguments are handled in the manner of fmt.Printf. | [
"Errorf",
"logs",
"with",
"an",
"error",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L101-L103 |
144,616 | alexcesaro/log | golog/golog.go | Warningf | func (logger *Logger) Warningf(format string, args ...interface{}) {
logger.output(log.Warning, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Warningf(format string, args ...interface{}) {
logger.output(log.Warning, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Warningf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Warning",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
... | // Warningf logs with a warning level.
// Arguments are handled in the manner of fmt.Printf. | [
"Warningf",
"logs",
"with",
"a",
"warning",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L112-L114 |
144,617 | alexcesaro/log | golog/golog.go | Noticef | func (logger *Logger) Noticef(format string, args ...interface{}) {
logger.output(log.Notice, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Noticef(format string, args ...interface{}) {
logger.output(log.Notice, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Noticef",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Notice",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
"... | // Noticef logs with a notice level.
// Arguments are handled in the manner of fmt.Printf. | [
"Noticef",
"logs",
"with",
"a",
"notice",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L123-L125 |
144,618 | alexcesaro/log | golog/golog.go | Infof | func (logger *Logger) Infof(format string, args ...interface{}) {
logger.output(log.Info, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Infof(format string, args ...interface{}) {
logger.output(log.Info, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Infof",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Info",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
... | // Infof logs with an info level.
// Arguments are handled in the manner of fmt.Printf. | [
"Infof",
"logs",
"with",
"an",
"info",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L134-L136 |
144,619 | alexcesaro/log | golog/golog.go | Debugf | func (logger *Logger) Debugf(format string, args ...interface{}) {
logger.output(log.Debug, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Debugf(format string, args ...interface{}) {
logger.output(log.Debug, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Debugf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"log",
".",
"Debug",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")"... | // Debugf logs with a debug level.
// Arguments are handled in the manner of fmt.Printf. | [
"Debugf",
"logs",
"with",
"a",
"debug",
"level",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L145-L147 |
144,620 | alexcesaro/log | golog/golog.go | Log | func (logger *Logger) Log(level log.Level, args ...interface{}) {
logger.output(level, args...)
} | go | func (logger *Logger) Log(level log.Level, args ...interface{}) {
logger.output(level, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Log",
"(",
"level",
"log",
".",
"Level",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"level",
",",
"args",
"...",
")",
"\n",
"}"
] | // Log logs at the level passed in argument. | [
"Log",
"logs",
"at",
"the",
"level",
"passed",
"in",
"argument",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L150-L152 |
144,621 | alexcesaro/log | golog/golog.go | Logf | func (logger *Logger) Logf(level log.Level, format string, args ...interface{}) {
logger.output(level, fmt.Sprintf(format, args...))
} | go | func (logger *Logger) Logf(level log.Level, format string, args ...interface{}) {
logger.output(level, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Logf",
"(",
"level",
"log",
".",
"Level",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"output",
"(",
"level",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",... | // Logf logs at the level passed in argument.
// Arguments are handled in the manner of fmt.Printf. | [
"Logf",
"logs",
"at",
"the",
"level",
"passed",
"in",
"argument",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L156-L158 |
144,622 | alexcesaro/log | golog/golog.go | LogLevel | func (logger *Logger) LogLevel(level log.Level) bool {
return logger.threshold >= level
} | go | func (logger *Logger) LogLevel(level log.Level) bool {
return logger.threshold >= level
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"LogLevel",
"(",
"level",
"log",
".",
"Level",
")",
"bool",
"{",
"return",
"logger",
".",
"threshold",
">=",
"level",
"\n",
"}"
] | // LogLevel returns true if the log level is at or below the level argument. | [
"LogLevel",
"returns",
"true",
"if",
"the",
"log",
"level",
"is",
"at",
"or",
"below",
"the",
"level",
"argument",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L201-L203 |
144,623 | alexcesaro/log | golog/golog.go | addTimestamp | func addTimestamp(buffer *bytes.Buffer) {
now := now()
year, month, day := now.Date()
hour, minute, second := now.Clock()
var tmp = new([23]byte)
writeInt(tmp, 4, 0, year)
tmp[4] = '-'
writeInt(tmp, 2, 5, int(month))
tmp[7] = '-'
writeInt(tmp, 2, 8, day)
tmp[10] = ' '
writeInt(tmp, 2, 11, hour)
tmp[13] = '... | go | func addTimestamp(buffer *bytes.Buffer) {
now := now()
year, month, day := now.Date()
hour, minute, second := now.Clock()
var tmp = new([23]byte)
writeInt(tmp, 4, 0, year)
tmp[4] = '-'
writeInt(tmp, 2, 5, int(month))
tmp[7] = '-'
writeInt(tmp, 2, 8, day)
tmp[10] = ' '
writeInt(tmp, 2, 11, hour)
tmp[13] = '... | [
"func",
"addTimestamp",
"(",
"buffer",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"now",
":=",
"now",
"(",
")",
"\n",
"year",
",",
"month",
",",
"day",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"hour",
",",
"minute",
",",
"second",
":=",
"now",
".",
... | // Avoid Fprintf because it is expensive. Doing it manually is about six times
// faster and makes the entire call of a logging function to stdout two times
// faster. | [
"Avoid",
"Fprintf",
"because",
"it",
"is",
"expensive",
".",
"Doing",
"it",
"manually",
"is",
"about",
"six",
"times",
"faster",
"and",
"makes",
"the",
"entire",
"call",
"of",
"a",
"logging",
"function",
"to",
"stdout",
"two",
"times",
"faster",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L233-L253 |
144,624 | alexcesaro/log | golog/golog.go | getBuffer | func (logger *Logger) getBuffer() *buffer {
logger.bufferListMutex.Lock()
b := logger.bufferList
if b != nil {
logger.bufferList = b.next
}
logger.bufferListMutex.Unlock()
if b == nil {
b = new(buffer)
} else {
b.next = nil
b.Reset()
}
return b
} | go | func (logger *Logger) getBuffer() *buffer {
logger.bufferListMutex.Lock()
b := logger.bufferList
if b != nil {
logger.bufferList = b.next
}
logger.bufferListMutex.Unlock()
if b == nil {
b = new(buffer)
} else {
b.next = nil
b.Reset()
}
return b
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"getBuffer",
"(",
")",
"*",
"buffer",
"{",
"logger",
".",
"bufferListMutex",
".",
"Lock",
"(",
")",
"\n",
"b",
":=",
"logger",
".",
"bufferList",
"\n",
"if",
"b",
"!=",
"nil",
"{",
"logger",
".",
"bufferList... | // getBuffer returns a new, ready-to-use buffer. | [
"getBuffer",
"returns",
"a",
"new",
"ready",
"-",
"to",
"-",
"use",
"buffer",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L295-L309 |
144,625 | alexcesaro/log | golog/golog.go | putBuffer | func (logger *Logger) putBuffer(b *buffer) {
if b.Len() >= 256 {
// Let big buffers die a natural death.
return
}
logger.bufferListMutex.Lock()
b.next = logger.bufferList
logger.bufferList = b
logger.bufferListMutex.Unlock()
} | go | func (logger *Logger) putBuffer(b *buffer) {
if b.Len() >= 256 {
// Let big buffers die a natural death.
return
}
logger.bufferListMutex.Lock()
b.next = logger.bufferList
logger.bufferList = b
logger.bufferListMutex.Unlock()
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"putBuffer",
"(",
"b",
"*",
"buffer",
")",
"{",
"if",
"b",
".",
"Len",
"(",
")",
">=",
"256",
"{",
"// Let big buffers die a natural death.",
"return",
"\n",
"}",
"\n",
"logger",
".",
"bufferListMutex",
".",
"Lo... | // putBuffer returns a buffer to the list. | [
"putBuffer",
"returns",
"a",
"buffer",
"to",
"the",
"list",
"."
] | 61e686294e58a8698a9e1091268bb4ac1116bd5e | https://github.com/alexcesaro/log/blob/61e686294e58a8698a9e1091268bb4ac1116bd5e/golog/golog.go#L312-L321 |
144,626 | facebookarchive/structtag | structtag.go | Extract | func Extract(name, tag string) (found bool, value string, err error) {
for tag != "" {
// skip leading space
i := 0
for i < len(tag) && tag[i] == ' ' {
i++
}
tag = tag[i:]
if tag == "" {
break
}
// scan to colon.
// a space or a quote is a syntax error
i = 0
for i < len(tag) && tag[i] != '... | go | func Extract(name, tag string) (found bool, value string, err error) {
for tag != "" {
// skip leading space
i := 0
for i < len(tag) && tag[i] == ' ' {
i++
}
tag = tag[i:]
if tag == "" {
break
}
// scan to colon.
// a space or a quote is a syntax error
i = 0
for i < len(tag) && tag[i] != '... | [
"func",
"Extract",
"(",
"name",
",",
"tag",
"string",
")",
"(",
"found",
"bool",
",",
"value",
"string",
",",
"err",
"error",
")",
"{",
"for",
"tag",
"!=",
"\"",
"\"",
"{",
"// skip leading space",
"i",
":=",
"0",
"\n",
"for",
"i",
"<",
"len",
"(",... | // Extract the quoted value for the given name returning it if it is found. The
// found boolean helps differentiate between the "empty and found" vs "empty
// and not found" nature of default empty strings. | [
"Extract",
"the",
"quoted",
"value",
"for",
"the",
"given",
"name",
"returning",
"it",
"if",
"it",
"is",
"found",
".",
"The",
"found",
"boolean",
"helps",
"differentiate",
"between",
"the",
"empty",
"and",
"found",
"vs",
"empty",
"and",
"not",
"found",
"na... | 217e25fb96916cc60332e399c9aa63f5c422ceed | https://github.com/facebookarchive/structtag/blob/217e25fb96916cc60332e399c9aa63f5c422ceed/structtag.go#L14-L61 |
144,627 | dgryski/go-bits | popcnt.go | Popcnt | func Popcnt(x uint64) uint64 {
// bit population count, see
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
x -= (x >> 1) & 0x5555555555555555
x = (x>>2)&0x3333333333333333 + x&0x3333333333333333
x += x >> 4
x &= 0x0f0f0f0f0f0f0f0f
x *= 0x0101010101010101
return x >> 56
} | go | func Popcnt(x uint64) uint64 {
// bit population count, see
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
x -= (x >> 1) & 0x5555555555555555
x = (x>>2)&0x3333333333333333 + x&0x3333333333333333
x += x >> 4
x &= 0x0f0f0f0f0f0f0f0f
x *= 0x0101010101010101
return x >> 56
} | [
"func",
"Popcnt",
"(",
"x",
"uint64",
")",
"uint64",
"{",
"// bit population count, see",
"// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel",
"x",
"-=",
"(",
"x",
">>",
"1",
")",
"&",
"0x5555555555555555",
"\n",
"x",
"=",
"(",
"x",
">>",
"... | // Popcnt counts the number of bits set | [
"Popcnt",
"counts",
"the",
"number",
"of",
"bits",
"set"
] | bd8a69a71dc203aa976f9d918b428db9ac605f57 | https://github.com/dgryski/go-bits/blob/bd8a69a71dc203aa976f9d918b428db9ac605f57/popcnt.go#L6-L15 |
144,628 | dgryski/go-bits | clz.go | Clz | func Clz(x uint64) uint64 {
var n uint64
n = 1
if (x >> 32) == 0 {
n = n + 32
x = x << 32
}
if (x >> (32 + 16)) == 0 {
n = n + 16
x = x << 16
}
if (x >> (32 + 16 + 8)) == 0 {
n = n + 8
x = x << 8
}
if (x >> (32 + 16 + 8 + 4)) == 0 {
n = n + 4
x = x << 4
}
if (x >> (32 + 16 + 8 + 4 + 2)) ... | go | func Clz(x uint64) uint64 {
var n uint64
n = 1
if (x >> 32) == 0 {
n = n + 32
x = x << 32
}
if (x >> (32 + 16)) == 0 {
n = n + 16
x = x << 16
}
if (x >> (32 + 16 + 8)) == 0 {
n = n + 8
x = x << 8
}
if (x >> (32 + 16 + 8 + 4)) == 0 {
n = n + 4
x = x << 4
}
if (x >> (32 + 16 + 8 + 4 + 2)) ... | [
"func",
"Clz",
"(",
"x",
"uint64",
")",
"uint64",
"{",
"var",
"n",
"uint64",
"\n\n",
"n",
"=",
"1",
"\n\n",
"if",
"(",
"x",
">>",
"32",
")",
"==",
"0",
"{",
"n",
"=",
"n",
"+",
"32",
"\n",
"x",
"=",
"x",
"<<",
"32",
"\n",
"}",
"\n",
"if",... | // Clz counts leading zeroes | [
"Clz",
"counts",
"leading",
"zeroes"
] | bd8a69a71dc203aa976f9d918b428db9ac605f57 | https://github.com/dgryski/go-bits/blob/bd8a69a71dc203aa976f9d918b428db9ac605f57/clz.go#L6-L37 |
144,629 | dgryski/go-bits | ctz.go | Ctz | func Ctz(x uint64) uint64 {
if x == 0 {
return 64
}
var n uint64
if (x & 0x00000000FFFFFFFF) == 0 {
n = n + 32
x = x >> 32
}
if (x & 0x000000000000FFFF) == 0 {
n = n + 16
x = x >> 16
}
if (x & 0x00000000000000FF) == 0 {
n = n + 8
x = x >> 8
}
if (x & 0x000000000000000F) == 0 {
n = n + 4
x... | go | func Ctz(x uint64) uint64 {
if x == 0 {
return 64
}
var n uint64
if (x & 0x00000000FFFFFFFF) == 0 {
n = n + 32
x = x >> 32
}
if (x & 0x000000000000FFFF) == 0 {
n = n + 16
x = x >> 16
}
if (x & 0x00000000000000FF) == 0 {
n = n + 8
x = x >> 8
}
if (x & 0x000000000000000F) == 0 {
n = n + 4
x... | [
"func",
"Ctz",
"(",
"x",
"uint64",
")",
"uint64",
"{",
"if",
"x",
"==",
"0",
"{",
"return",
"64",
"\n",
"}",
"\n\n",
"var",
"n",
"uint64",
"\n\n",
"if",
"(",
"x",
"&",
"0x00000000FFFFFFFF",
")",
"==",
"0",
"{",
"n",
"=",
"n",
"+",
"32",
"\n",
... | // Ctz counts trailing zeroes | [
"Ctz",
"counts",
"trailing",
"zeroes"
] | bd8a69a71dc203aa976f9d918b428db9ac605f57 | https://github.com/dgryski/go-bits/blob/bd8a69a71dc203aa976f9d918b428db9ac605f57/ctz.go#L6-L39 |
144,630 | qor/cache | redis/redis.go | New | func New(config *redis.Options) *Redis {
client := redis.NewClient(config)
return &Redis{Config: config, Client: client}
} | go | func New(config *redis.Options) *Redis {
client := redis.NewClient(config)
return &Redis{Config: config, Client: client}
} | [
"func",
"New",
"(",
"config",
"*",
"redis",
".",
"Options",
")",
"*",
"Redis",
"{",
"client",
":=",
"redis",
".",
"NewClient",
"(",
"config",
")",
"\n",
"return",
"&",
"Redis",
"{",
"Config",
":",
"config",
",",
"Client",
":",
"client",
"}",
"\n",
... | // New returns an initialized Redis cache object. | [
"New",
"returns",
"an",
"initialized",
"Redis",
"cache",
"object",
"."
] | c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4 | https://github.com/qor/cache/blob/c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4/redis/redis.go#L16-L19 |
144,631 | qor/cache | redis/redis.go | Get | func (r *Redis) Get(key string) (string, error) {
return r.Client.Get(key).Result()
} | go | func (r *Redis) Get(key string) (string, error) {
return r.Client.Get(key).Result()
} | [
"func",
"(",
"r",
"*",
"Redis",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"r",
".",
"Client",
".",
"Get",
"(",
"key",
")",
".",
"Result",
"(",
")",
"\n",
"}"
] | // Get returns the value saved under a given key. | [
"Get",
"returns",
"the",
"value",
"saved",
"under",
"a",
"given",
"key",
"."
] | c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4 | https://github.com/qor/cache/blob/c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4/redis/redis.go#L22-L24 |
144,632 | qor/cache | redis/redis.go | Unmarshal | func (r *Redis) Unmarshal(key string, object interface{}) error {
value, err := r.Get(key)
if err == nil {
err = json.Unmarshal([]byte(value), object)
}
return err
} | go | func (r *Redis) Unmarshal(key string, object interface{}) error {
value, err := r.Get(key)
if err == nil {
err = json.Unmarshal([]byte(value), object)
}
return err
} | [
"func",
"(",
"r",
"*",
"Redis",
")",
"Unmarshal",
"(",
"key",
"string",
",",
"object",
"interface",
"{",
"}",
")",
"error",
"{",
"value",
",",
"err",
":=",
"r",
".",
"Get",
"(",
"key",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"err",
"=",
"json... | // Unmarshal retrieves a value from the Redis server and unmarshals
// it into the passed object. | [
"Unmarshal",
"retrieves",
"a",
"value",
"from",
"the",
"Redis",
"server",
"and",
"unmarshals",
"it",
"into",
"the",
"passed",
"object",
"."
] | c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4 | https://github.com/qor/cache/blob/c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4/redis/redis.go#L28-L34 |
144,633 | qor/cache | redis/redis.go | Set | func (r *Redis) Set(key string, value interface{}) error {
return r.Client.Set(key, convertToBytes(value), 0).Err()
} | go | func (r *Redis) Set(key string, value interface{}) error {
return r.Client.Set(key, convertToBytes(value), 0).Err()
} | [
"func",
"(",
"r",
"*",
"Redis",
")",
"Set",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"r",
".",
"Client",
".",
"Set",
"(",
"key",
",",
"convertToBytes",
"(",
"value",
")",
",",
"0",
")",
".",
"Err",
... | // Set saves an arbitrary value under a specific key. | [
"Set",
"saves",
"an",
"arbitrary",
"value",
"under",
"a",
"specific",
"key",
"."
] | c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4 | https://github.com/qor/cache/blob/c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4/redis/redis.go#L37-L39 |
144,634 | qor/cache | redis/redis.go | Fetch | func (r *Redis) Fetch(key string, fc func() interface{}) (string, error) {
if str, err := r.Get(key); err == nil {
return str, nil
}
results := convertToBytes(fc())
return string(results), r.Set(key, results)
} | go | func (r *Redis) Fetch(key string, fc func() interface{}) (string, error) {
if str, err := r.Get(key); err == nil {
return str, nil
}
results := convertToBytes(fc())
return string(results), r.Set(key, results)
} | [
"func",
"(",
"r",
"*",
"Redis",
")",
"Fetch",
"(",
"key",
"string",
",",
"fc",
"func",
"(",
")",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"str",
",",
"err",
":=",
"r",
".",
"Get",
"(",
"key",
")",
";",
"err",
... | // Fetch returns the value for the key if it exists or sets and returns the value via the passed function. | [
"Fetch",
"returns",
"the",
"value",
"for",
"the",
"key",
"if",
"it",
"exists",
"or",
"sets",
"and",
"returns",
"the",
"value",
"via",
"the",
"passed",
"function",
"."
] | c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4 | https://github.com/qor/cache/blob/c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4/redis/redis.go#L54-L60 |
144,635 | qor/cache | redis/redis.go | Delete | func (r *Redis) Delete(key string) error {
return r.Client.Del(key).Err()
} | go | func (r *Redis) Delete(key string) error {
return r.Client.Del(key).Err()
} | [
"func",
"(",
"r",
"*",
"Redis",
")",
"Delete",
"(",
"key",
"string",
")",
"error",
"{",
"return",
"r",
".",
"Client",
".",
"Del",
"(",
"key",
")",
".",
"Err",
"(",
")",
"\n",
"}"
] | // Delete removes a specific key and its value from the Redis server. | [
"Delete",
"removes",
"a",
"specific",
"key",
"and",
"its",
"value",
"from",
"the",
"Redis",
"server",
"."
] | c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4 | https://github.com/qor/cache/blob/c9d48d1f13ba2e1ad06a3f8d55be7ea3edf2d0c4/redis/redis.go#L63-L65 |
144,636 | thanhpk/randstr | randstr.go | Bytes | func Bytes(n int) []byte {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
panic(err)
}
return b
} | go | func Bytes(n int) []byte {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
panic(err)
}
return b
} | [
"func",
"Bytes",
"(",
"n",
"int",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"n",
")",
"\n",
"_",
",",
"err",
":=",
"rand",
".",
"Read",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"er... | // Bytes generates n random bytes | [
"Bytes",
"generates",
"n",
"random",
"bytes"
] | ac5b2d62bffbc6bd4d35a03d99dda19e93dc7c9f | https://github.com/thanhpk/randstr/blob/ac5b2d62bffbc6bd4d35a03d99dda19e93dc7c9f/randstr.go#L12-L19 |
144,637 | thanhpk/randstr | randstr.go | String | func String(n int, letters ...string) string {
var letterRunes []rune
if len(letters) == 0 {
letterRunes = defLetters
} else {
letterRunes = []rune(letters[0])
}
var bb bytes.Buffer
bb.Grow(n)
l := uint32(len(letterRunes))
// on each loop, generate one random rune and append to output
for i := 0; i < n; i... | go | func String(n int, letters ...string) string {
var letterRunes []rune
if len(letters) == 0 {
letterRunes = defLetters
} else {
letterRunes = []rune(letters[0])
}
var bb bytes.Buffer
bb.Grow(n)
l := uint32(len(letterRunes))
// on each loop, generate one random rune and append to output
for i := 0; i < n; i... | [
"func",
"String",
"(",
"n",
"int",
",",
"letters",
"...",
"string",
")",
"string",
"{",
"var",
"letterRunes",
"[",
"]",
"rune",
"\n",
"if",
"len",
"(",
"letters",
")",
"==",
"0",
"{",
"letterRunes",
"=",
"defLetters",
"\n",
"}",
"else",
"{",
"letterR... | // String generates a random string using only letters provided in the letters parameter
// if user ommit letters parameters, this function will use defLetters instead | [
"String",
"generates",
"a",
"random",
"string",
"using",
"only",
"letters",
"provided",
"in",
"the",
"letters",
"parameter",
"if",
"user",
"ommit",
"letters",
"parameters",
"this",
"function",
"will",
"use",
"defLetters",
"instead"
] | ac5b2d62bffbc6bd4d35a03d99dda19e93dc7c9f | https://github.com/thanhpk/randstr/blob/ac5b2d62bffbc6bd4d35a03d99dda19e93dc7c9f/randstr.go#L41-L57 |
144,638 | bradleyfalzon/apicompat | vcs.go | NewGit | func NewGit(path string) (*Git, error) {
// Find the directory of .git, assumes git can find it via cwd
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
cmd.Dir = path
dir, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("error running %v: %v output: %q", cmd.Args, err, dir)
}
bas... | go | func NewGit(path string) (*Git, error) {
// Find the directory of .git, assumes git can find it via cwd
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
cmd.Dir = path
dir, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("error running %v: %v output: %q", cmd.Args, err, dir)
}
bas... | [
"func",
"NewGit",
"(",
"path",
"string",
")",
"(",
"*",
"Git",
",",
"error",
")",
"{",
"// Find the directory of .git, assumes git can find it via cwd",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd... | // NewGit returns a VCS based based on git. | [
"NewGit",
"returns",
"a",
"VCS",
"based",
"based",
"on",
"git",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L41-L55 |
144,639 | bradleyfalzon/apicompat | vcs.go | rel | func (g *Git) rel(path string) (string, error) {
relPath, err := filepath.Rel(g.base, path)
if err != nil {
return "", fmt.Errorf("git cannot make path relative: %v", err)
}
return relPath, nil
} | go | func (g *Git) rel(path string) (string, error) {
relPath, err := filepath.Rel(g.base, path)
if err != nil {
return "", fmt.Errorf("git cannot make path relative: %v", err)
}
return relPath, nil
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"rel",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"relPath",
",",
"err",
":=",
"filepath",
".",
"Rel",
"(",
"g",
".",
"base",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // rel returns the relative path to this path. | [
"rel",
"returns",
"the",
"relative",
"path",
"to",
"this",
"path",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L58-L64 |
144,640 | bradleyfalzon/apicompat | vcs.go | ReadDir | func (g *Git) ReadDir(revision, path string) ([]os.FileInfo, error) {
if revision == revisionFS {
return ioutil.ReadDir(path)
}
relPath, err := g.rel(path)
if err != nil {
return nil, err
}
relPath += string(os.PathSeparator)
args := []string{"--git-dir", g.dir, "ls-tree", revision, relPath}
ls, err := ex... | go | func (g *Git) ReadDir(revision, path string) ([]os.FileInfo, error) {
if revision == revisionFS {
return ioutil.ReadDir(path)
}
relPath, err := g.rel(path)
if err != nil {
return nil, err
}
relPath += string(os.PathSeparator)
args := []string{"--git-dir", g.dir, "ls-tree", revision, relPath}
ls, err := ex... | [
"func",
"(",
"g",
"*",
"Git",
")",
"ReadDir",
"(",
"revision",
",",
"path",
"string",
")",
"(",
"[",
"]",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"if",
"revision",
"==",
"revisionFS",
"{",
"return",
"ioutil",
".",
"ReadDir",
"(",
"path",
")"... | // ReadDir returns a list of files in a directory at revision | [
"ReadDir",
"returns",
"a",
"list",
"of",
"files",
"in",
"a",
"directory",
"at",
"revision"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L67-L100 |
144,641 | bradleyfalzon/apicompat | vcs.go | OpenFile | func (g *Git) OpenFile(revision, path string) (io.ReadCloser, error) {
if revision == revisionFS {
return os.Open(path)
}
relPath, err := g.rel(path)
if err != nil {
return nil, err
}
var args = []string{"--git-dir", g.dir, "show", revision + ":" + relPath}
contents, err := exec.Command("git", args...).Out... | go | func (g *Git) OpenFile(revision, path string) (io.ReadCloser, error) {
if revision == revisionFS {
return os.Open(path)
}
relPath, err := g.rel(path)
if err != nil {
return nil, err
}
var args = []string{"--git-dir", g.dir, "show", revision + ":" + relPath}
contents, err := exec.Command("git", args...).Out... | [
"func",
"(",
"g",
"*",
"Git",
")",
"OpenFile",
"(",
"revision",
",",
"path",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"if",
"revision",
"==",
"revisionFS",
"{",
"return",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"}",
... | // OpenFile returns a reader for a given absolute path at a revision | [
"OpenFile",
"returns",
"a",
"reader",
"for",
"a",
"given",
"absolute",
"path",
"at",
"a",
"revision"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L103-L119 |
144,642 | bradleyfalzon/apicompat | vcs.go | DefaultRevision | func (g *Git) DefaultRevision() (string, string) {
// Check if there's unstaged changes, if so, return dot
contents, _ := exec.Command("git", "--git-dir", g.dir, "ls-files", "-m").Output()
if len(contents) > 0 {
return "HEAD", "."
}
return "HEAD~1", "HEAD"
} | go | func (g *Git) DefaultRevision() (string, string) {
// Check if there's unstaged changes, if so, return dot
contents, _ := exec.Command("git", "--git-dir", g.dir, "ls-files", "-m").Output()
if len(contents) > 0 {
return "HEAD", "."
}
return "HEAD~1", "HEAD"
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"DefaultRevision",
"(",
")",
"(",
"string",
",",
"string",
")",
"{",
"// Check if there's unstaged changes, if so, return dot",
"contents",
",",
"_",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"g... | // DefaultRevision returns the default revisions if none specified | [
"DefaultRevision",
"returns",
"the",
"default",
"revisions",
"if",
"none",
"specified"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L122-L129 |
144,643 | bradleyfalzon/apicompat | vcs.go | SetFile | func (v *StrVCS) SetFile(revision, path string, contents []byte) {
if v.files == nil {
v.files = make(map[string]map[string][]byte)
}
if _, ok := v.files[revision]; !ok {
v.files[revision] = make(map[string][]byte)
}
v.files[revision][path] = contents
} | go | func (v *StrVCS) SetFile(revision, path string, contents []byte) {
if v.files == nil {
v.files = make(map[string]map[string][]byte)
}
if _, ok := v.files[revision]; !ok {
v.files[revision] = make(map[string][]byte)
}
v.files[revision][path] = contents
} | [
"func",
"(",
"v",
"*",
"StrVCS",
")",
"SetFile",
"(",
"revision",
",",
"path",
"string",
",",
"contents",
"[",
"]",
"byte",
")",
"{",
"if",
"v",
".",
"files",
"==",
"nil",
"{",
"v",
".",
"files",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"ma... | // SetFile contents for a particular revision and path | [
"SetFile",
"contents",
"for",
"a",
"particular",
"revision",
"and",
"path"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L165-L173 |
144,644 | bradleyfalzon/apicompat | vcs.go | ReadDir | func (v StrVCS) ReadDir(revision, path string) (files []os.FileInfo, err error) {
for file := range v.files[revision] {
files = append(files, fileInfo{
name: file,
})
}
return files, nil
} | go | func (v StrVCS) ReadDir(revision, path string) (files []os.FileInfo, err error) {
for file := range v.files[revision] {
files = append(files, fileInfo{
name: file,
})
}
return files, nil
} | [
"func",
"(",
"v",
"StrVCS",
")",
"ReadDir",
"(",
"revision",
",",
"path",
"string",
")",
"(",
"files",
"[",
"]",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"{",
"for",
"file",
":=",
"range",
"v",
".",
"files",
"[",
"revision",
"]",
"{",
"fi... | // ReadDir implements VCS.ReadDir | [
"ReadDir",
"implements",
"VCS",
".",
"ReadDir"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L176-L183 |
144,645 | bradleyfalzon/apicompat | vcs.go | OpenFile | func (v StrVCS) OpenFile(revision, path string) (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(v.files[revision][filepath.Base(path)])), nil
} | go | func (v StrVCS) OpenFile(revision, path string) (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(v.files[revision][filepath.Base(path)])), nil
} | [
"func",
"(",
"v",
"StrVCS",
")",
"OpenFile",
"(",
"revision",
",",
"path",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"return",
"ioutil",
".",
"NopCloser",
"(",
"bytes",
".",
"NewReader",
"(",
"v",
".",
"files",
"[",
"revisi... | // OpenFile implements VCS.OpenFile | [
"OpenFile",
"implements",
"VCS",
".",
"OpenFile"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/vcs.go#L186-L188 |
144,646 | bradleyfalzon/apicompat | apicompat.go | New | func New(options ...func(*Checker)) *Checker {
c := &Checker{}
for _, option := range options {
option(c)
}
return c
} | go | func New(options ...func(*Checker)) *Checker {
c := &Checker{}
for _, option := range options {
option(c)
}
return c
} | [
"func",
"New",
"(",
"options",
"...",
"func",
"(",
"*",
"Checker",
")",
")",
"*",
"Checker",
"{",
"c",
":=",
"&",
"Checker",
"{",
"}",
"\n",
"for",
"_",
",",
"option",
":=",
"range",
"options",
"{",
"option",
"(",
"c",
")",
"\n",
"}",
"\n",
"re... | // New returns a Checker with the given options. | [
"New",
"returns",
"a",
"Checker",
"with",
"the",
"given",
"options",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L53-L59 |
144,647 | bradleyfalzon/apicompat | apicompat.go | SetVLog | func SetVLog(w io.Writer) func(*Checker) {
return func(c *Checker) {
c.vlog = w
}
} | go | func SetVLog(w io.Writer) func(*Checker) {
return func(c *Checker) {
c.vlog = w
}
} | [
"func",
"SetVLog",
"(",
"w",
"io",
".",
"Writer",
")",
"func",
"(",
"*",
"Checker",
")",
"{",
"return",
"func",
"(",
"c",
"*",
"Checker",
")",
"{",
"c",
".",
"vlog",
"=",
"w",
"\n",
"}",
"\n",
"}"
] | // SetVLog is an option to New that sets the logger for the checker. | [
"SetVLog",
"is",
"an",
"option",
"to",
"New",
"that",
"sets",
"the",
"logger",
"for",
"the",
"checker",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L69-L73 |
144,648 | bradleyfalzon/apicompat | apicompat.go | SetExcludeFile | func SetExcludeFile(pattern string) func(*Checker) {
return func(c *Checker) {
c.excludeFile = regexp.MustCompile(pattern)
}
} | go | func SetExcludeFile(pattern string) func(*Checker) {
return func(c *Checker) {
c.excludeFile = regexp.MustCompile(pattern)
}
} | [
"func",
"SetExcludeFile",
"(",
"pattern",
"string",
")",
"func",
"(",
"*",
"Checker",
")",
"{",
"return",
"func",
"(",
"c",
"*",
"Checker",
")",
"{",
"c",
".",
"excludeFile",
"=",
"regexp",
".",
"MustCompile",
"(",
"pattern",
")",
"\n",
"}",
"\n",
"}... | // SetExcludeFile excludes checking of files based on regexp pattern | [
"SetExcludeFile",
"excludes",
"checking",
"of",
"files",
"based",
"on",
"regexp",
"pattern"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L76-L80 |
144,649 | bradleyfalzon/apicompat | apicompat.go | SetExcludeDir | func SetExcludeDir(pattern string) func(*Checker) {
return func(c *Checker) {
c.excludeDir = regexp.MustCompile(pattern)
}
} | go | func SetExcludeDir(pattern string) func(*Checker) {
return func(c *Checker) {
c.excludeDir = regexp.MustCompile(pattern)
}
} | [
"func",
"SetExcludeDir",
"(",
"pattern",
"string",
")",
"func",
"(",
"*",
"Checker",
")",
"{",
"return",
"func",
"(",
"c",
"*",
"Checker",
")",
"{",
"c",
".",
"excludeDir",
"=",
"regexp",
".",
"MustCompile",
"(",
"pattern",
")",
"\n",
"}",
"\n",
"}"
... | // SetExcludeDir excludes checking of a directory based on regexp pattern.
// Usually only help when running recursively. | [
"SetExcludeDir",
"excludes",
"checking",
"of",
"a",
"directory",
"based",
"on",
"regexp",
"pattern",
".",
"Usually",
"only",
"help",
"when",
"running",
"recursively",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L84-L88 |
144,650 | bradleyfalzon/apicompat | apicompat.go | Check | func (c *Checker) Check(rel string, recurse bool, beforeRev, afterRev string) ([]Change, error) {
// If revision is unset use VCS's default revision
dBefore, dAfter := c.vcs.DefaultRevision()
if beforeRev == "" {
beforeRev = dBefore
}
if afterRev == "" {
afterRev = dAfter
}
c.recurse = recurse
var err erro... | go | func (c *Checker) Check(rel string, recurse bool, beforeRev, afterRev string) ([]Change, error) {
// If revision is unset use VCS's default revision
dBefore, dAfter := c.vcs.DefaultRevision()
if beforeRev == "" {
beforeRev = dBefore
}
if afterRev == "" {
afterRev = dAfter
}
c.recurse = recurse
var err erro... | [
"func",
"(",
"c",
"*",
"Checker",
")",
"Check",
"(",
"rel",
"string",
",",
"recurse",
"bool",
",",
"beforeRev",
",",
"afterRev",
"string",
")",
"(",
"[",
"]",
"Change",
",",
"error",
")",
"{",
"// If revision is unset use VCS's default revision",
"dBefore",
... | // Check an import path and before and after revision for changes. Import path
// maybe empty, if so, the current working directory will be used. If a
// revision is blank, the default VCS revision is used. | [
"Check",
"an",
"import",
"path",
"and",
"before",
"and",
"after",
"revision",
"for",
"changes",
".",
"Import",
"path",
"maybe",
"empty",
"if",
"so",
"the",
"current",
"working",
"directory",
"will",
"be",
"used",
".",
"If",
"a",
"revision",
"is",
"blank",
... | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L93-L143 |
144,651 | bradleyfalzon/apicompat | apicompat.go | getDirsRecursive | func (c Checker) getDirsRecursive(base, rev, rel, prefix string) (dirs []string) {
paths, err := c.vcs.ReadDir(rev, filepath.Join(base, rel))
if err != nil {
c.logf("could not read path: %s revision: %s, error: %s\n", filepath.Join(base, rel), rev, err)
return dirs
}
for _, path := range paths {
if !path.IsD... | go | func (c Checker) getDirsRecursive(base, rev, rel, prefix string) (dirs []string) {
paths, err := c.vcs.ReadDir(rev, filepath.Join(base, rel))
if err != nil {
c.logf("could not read path: %s revision: %s, error: %s\n", filepath.Join(base, rel), rev, err)
return dirs
}
for _, path := range paths {
if !path.IsD... | [
"func",
"(",
"c",
"Checker",
")",
"getDirsRecursive",
"(",
"base",
",",
"rev",
",",
"rel",
",",
"prefix",
"string",
")",
"(",
"dirs",
"[",
"]",
"string",
")",
"{",
"paths",
",",
"err",
":=",
"c",
".",
"vcs",
".",
"ReadDir",
"(",
"rev",
",",
"file... | // getDirsRecursive returns relative paths to all subdirectories within base
// at revision rev. Paths can be prefixed with prefix | [
"getDirsRecursive",
"returns",
"relative",
"paths",
"to",
"all",
"subdirectories",
"within",
"base",
"at",
"revision",
"rev",
".",
"Paths",
"can",
"be",
"prefixed",
"with",
"prefix"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L291-L307 |
144,652 | bradleyfalzon/apicompat | apicompat.go | compareDecls | func (c Checker) compareDecls() ([]Change, error) {
var changes []Change
for pkgName, bpkg := range c.b {
apkg, ok := c.a[pkgName]
if !ok {
c := Change{Pkg: pkgName, Change: Breaking, Msg: "package removed"}
changes = append(changes, c)
continue
}
d := NewDeclChecker(bpkg.info, apkg.info)
for id, ... | go | func (c Checker) compareDecls() ([]Change, error) {
var changes []Change
for pkgName, bpkg := range c.b {
apkg, ok := c.a[pkgName]
if !ok {
c := Change{Pkg: pkgName, Change: Breaking, Msg: "package removed"}
changes = append(changes, c)
continue
}
d := NewDeclChecker(bpkg.info, apkg.info)
for id, ... | [
"func",
"(",
"c",
"Checker",
")",
"compareDecls",
"(",
")",
"(",
"[",
"]",
"Change",
",",
"error",
")",
"{",
"var",
"changes",
"[",
"]",
"Change",
"\n",
"for",
"pkgName",
",",
"bpkg",
":=",
"range",
"c",
".",
"b",
"{",
"apkg",
",",
"ok",
":=",
... | // compareDecls compares a Checker's before and after declarations and returns
// all changes or nil and an error | [
"compareDecls",
"compares",
"a",
"Checker",
"s",
"before",
"and",
"after",
"declarations",
"and",
"returns",
"all",
"changes",
"or",
"nil",
"and",
"an",
"error"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L650-L700 |
144,653 | bradleyfalzon/apicompat | apicompat.go | pos | func pos(fset *token.FileSet, p token.Pos) string {
pos := fset.Position(p)
return fmt.Sprintf("%s:%d", pos.Filename, pos.Line)
} | go | func pos(fset *token.FileSet, p token.Pos) string {
pos := fset.Position(p)
return fmt.Sprintf("%s:%d", pos.Filename, pos.Line)
} | [
"func",
"pos",
"(",
"fset",
"*",
"token",
".",
"FileSet",
",",
"p",
"token",
".",
"Pos",
")",
"string",
"{",
"pos",
":=",
"fset",
".",
"Position",
"(",
"p",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"pos",
".",
"Filename",... | // pos returns the declaration's position within a file. | [
"pos",
"returns",
"the",
"declaration",
"s",
"position",
"within",
"a",
"file",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/apicompat.go#L703-L706 |
144,654 | bradleyfalzon/apicompat | ast.go | NewDeclChecker | func NewDeclChecker(bi, ai *types.Info) *DeclChecker {
return &DeclChecker{binfo: bi, ainfo: ai}
} | go | func NewDeclChecker(bi, ai *types.Info) *DeclChecker {
return &DeclChecker{binfo: bi, ainfo: ai}
} | [
"func",
"NewDeclChecker",
"(",
"bi",
",",
"ai",
"*",
"types",
".",
"Info",
")",
"*",
"DeclChecker",
"{",
"return",
"&",
"DeclChecker",
"{",
"binfo",
":",
"bi",
",",
"ainfo",
":",
"ai",
"}",
"\n",
"}"
] | // NewDeclChecker creates a DeclChecker. | [
"NewDeclChecker",
"creates",
"a",
"DeclChecker",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/ast.go#L41-L43 |
144,655 | bradleyfalzon/apicompat | ast.go | Check | func (c DeclChecker) Check(before, after ast.Decl) (DeclChange, error) {
// compare types, ignore comments etc, so reflect.DeepEqual isn't good enough
if reflect.TypeOf(before) != reflect.TypeOf(after) {
// Declaration type changed, such as GenDecl to FuncDecl (eg var/const to func)
return breaking("changed decl... | go | func (c DeclChecker) Check(before, after ast.Decl) (DeclChange, error) {
// compare types, ignore comments etc, so reflect.DeepEqual isn't good enough
if reflect.TypeOf(before) != reflect.TypeOf(after) {
// Declaration type changed, such as GenDecl to FuncDecl (eg var/const to func)
return breaking("changed decl... | [
"func",
"(",
"c",
"DeclChecker",
")",
"Check",
"(",
"before",
",",
"after",
"ast",
".",
"Decl",
")",
"(",
"DeclChange",
",",
"error",
")",
"{",
"// compare types, ignore comments etc, so reflect.DeepEqual isn't good enough",
"if",
"reflect",
".",
"TypeOf",
"(",
"b... | // Check compares two declarations and returns the DeclChange associated with
// that change. For example, comments aren't compared, names of arguments aren't
// compared etc. | [
"Check",
"compares",
"two",
"declarations",
"and",
"returns",
"the",
"DeclChange",
"associated",
"with",
"that",
"change",
".",
"For",
"example",
"comments",
"aren",
"t",
"compared",
"names",
"of",
"arguments",
"aren",
"t",
"compared",
"etc",
"."
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/ast.go#L57-L123 |
144,656 | bradleyfalzon/apicompat | ast.go | Changed | func (d diffResult) Changed() bool {
return len(d.added) > 0 || len(d.removed) > 0 || len(d.modified) > 0
} | go | func (d diffResult) Changed() bool {
return len(d.added) > 0 || len(d.removed) > 0 || len(d.modified) > 0
} | [
"func",
"(",
"d",
"diffResult",
")",
"Changed",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"d",
".",
"added",
")",
">",
"0",
"||",
"len",
"(",
"d",
".",
"removed",
")",
">",
"0",
"||",
"len",
"(",
"d",
".",
"modified",
")",
">",
"0",
"\n",
... | // Changed returns true if any of the fields were added, removed or modified | [
"Changed",
"returns",
"true",
"if",
"any",
"of",
"the",
"fields",
"were",
"added",
"removed",
"or",
"modified"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/ast.go#L271-L273 |
144,657 | bradleyfalzon/apicompat | ast.go | RemoveVariadicCompatible | func (d *diffResult) RemoveVariadicCompatible(chkr DeclChecker) (msg string) {
if len(d.added) == 1 && !d.Removed() && !d.Modified() {
if _, ok := d.added[0].Type.(*ast.Ellipsis); ok {
// we're adding a variadic
d.added = nil
return "added a variadic parameter"
}
}
if !d.Added() && !d.Removed() && len(... | go | func (d *diffResult) RemoveVariadicCompatible(chkr DeclChecker) (msg string) {
if len(d.added) == 1 && !d.Removed() && !d.Modified() {
if _, ok := d.added[0].Type.(*ast.Ellipsis); ok {
// we're adding a variadic
d.added = nil
return "added a variadic parameter"
}
}
if !d.Added() && !d.Removed() && len(... | [
"func",
"(",
"d",
"*",
"diffResult",
")",
"RemoveVariadicCompatible",
"(",
"chkr",
"DeclChecker",
")",
"(",
"msg",
"string",
")",
"{",
"if",
"len",
"(",
"d",
".",
"added",
")",
"==",
"1",
"&&",
"!",
"d",
".",
"Removed",
"(",
")",
"&&",
"!",
"d",
... | // RemoveVariadicCompatible removes changes and returns a short msg describing
// the change if the added, removed and changed fields only represent an
// addition of variadic parameters or changes an existing field to variadic.
// If no compatible variadic changes were detected, msg will be an empty msg. | [
"RemoveVariadicCompatible",
"removes",
"changes",
"and",
"returns",
"a",
"short",
"msg",
"describing",
"the",
"change",
"if",
"the",
"added",
"removed",
"and",
"changed",
"fields",
"only",
"represent",
"an",
"addition",
"of",
"variadic",
"parameters",
"or",
"chang... | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/ast.go#L287-L307 |
144,658 | bradleyfalzon/apicompat | ast.go | exprEqual | func (c DeclChecker) exprEqual(before, after ast.Expr) bool {
if reflect.TypeOf(before) != reflect.TypeOf(after) {
return false
}
switch before.(type) {
case *ast.ChanType:
change, _ := c.checkChan(before.(*ast.ChanType), after.(*ast.ChanType))
return change.Change != Breaking
case *ast.FuncType:
change, ... | go | func (c DeclChecker) exprEqual(before, after ast.Expr) bool {
if reflect.TypeOf(before) != reflect.TypeOf(after) {
return false
}
switch before.(type) {
case *ast.ChanType:
change, _ := c.checkChan(before.(*ast.ChanType), after.(*ast.ChanType))
return change.Change != Breaking
case *ast.FuncType:
change, ... | [
"func",
"(",
"c",
"DeclChecker",
")",
"exprEqual",
"(",
"before",
",",
"after",
"ast",
".",
"Expr",
")",
"bool",
"{",
"if",
"reflect",
".",
"TypeOf",
"(",
"before",
")",
"!=",
"reflect",
".",
"TypeOf",
"(",
"after",
")",
"{",
"return",
"false",
"\n",... | // exprEqual compares two ast.Expr to determine if they are equal | [
"exprEqual",
"compares",
"two",
"ast",
".",
"Expr",
"to",
"determine",
"if",
"they",
"are",
"equal"
] | 5f916b1b6db7928fc26f43ca060831b27bf31abe | https://github.com/bradleyfalzon/apicompat/blob/5f916b1b6db7928fc26f43ca060831b27bf31abe/ast.go#L438-L468 |
144,659 | aead/siphash | siphash128.go | Sum128 | func Sum128(msg []byte, key *[KeySize]byte) [16]byte {
k0 := binary.LittleEndian.Uint64(key[0:])
k1 := binary.LittleEndian.Uint64(key[8:])
var hVal [4]uint64
hVal[0] = k0 ^ c0
hVal[1] = k1 ^ c1 ^ 0xee
hVal[2] = k0 ^ c2
hVal[3] = k1 ^ c3
n := len(msg)
ctr := byte(n)
if n >= BlockSize {
n &= (^(BlockSize -... | go | func Sum128(msg []byte, key *[KeySize]byte) [16]byte {
k0 := binary.LittleEndian.Uint64(key[0:])
k1 := binary.LittleEndian.Uint64(key[8:])
var hVal [4]uint64
hVal[0] = k0 ^ c0
hVal[1] = k1 ^ c1 ^ 0xee
hVal[2] = k0 ^ c2
hVal[3] = k1 ^ c3
n := len(msg)
ctr := byte(n)
if n >= BlockSize {
n &= (^(BlockSize -... | [
"func",
"Sum128",
"(",
"msg",
"[",
"]",
"byte",
",",
"key",
"*",
"[",
"KeySize",
"]",
"byte",
")",
"[",
"16",
"]",
"byte",
"{",
"k0",
":=",
"binary",
".",
"LittleEndian",
".",
"Uint64",
"(",
"key",
"[",
"0",
":",
"]",
")",
"\n",
"k1",
":=",
"... | // Sum128 returns the 128 bit authenticator for msg using a 128 bit secret key. | [
"Sum128",
"returns",
"the",
"128",
"bit",
"authenticator",
"for",
"msg",
"using",
"a",
"128",
"bit",
"secret",
"key",
"."
] | 83563a290f60225eb120d724600b9690c3fb536f | https://github.com/aead/siphash/blob/83563a290f60225eb120d724600b9690c3fb536f/siphash128.go#L13-L39 |
144,660 | arangodb/go-velocypack | decoder.go | Decode | func (e *Decoder) Decode(v interface{}) error {
s, err := SliceFromReader(e.r)
if err != nil {
return WithStack(err)
}
if err := unmarshalSlice(s, v); err != nil {
return WithStack(err)
}
return nil
} | go | func (e *Decoder) Decode(v interface{}) error {
s, err := SliceFromReader(e.r)
if err != nil {
return WithStack(err)
}
if err := unmarshalSlice(s, v); err != nil {
return WithStack(err)
}
return nil
} | [
"func",
"(",
"e",
"*",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"s",
",",
"err",
":=",
"SliceFromReader",
"(",
"e",
".",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"WithStack",
"(",
"err",
")",
... | // Decode reads v from the decoder stream. | [
"Decode",
"reads",
"v",
"from",
"the",
"decoder",
"stream",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/decoder.go#L131-L140 |
144,661 | arangodb/go-velocypack | decoder.go | unmarshalSlice | func unmarshalSlice(data Slice, v interface{}) (err error) {
defer func() {
if r := recover(); r != nil {
if _, ok := r.(runtime.Error); ok {
panic(r)
}
err = r.(error)
}
}()
rv := reflect.ValueOf(v)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return &InvalidUnmarshalError{reflect.TypeOf(v)}
}
... | go | func unmarshalSlice(data Slice, v interface{}) (err error) {
defer func() {
if r := recover(); r != nil {
if _, ok := r.(runtime.Error); ok {
panic(r)
}
err = r.(error)
}
}()
rv := reflect.ValueOf(v)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return &InvalidUnmarshalError{reflect.TypeOf(v)}
}
... | [
"func",
"unmarshalSlice",
"(",
"data",
"Slice",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"if",
"_",
",",
"ok",
":=",
... | // unmarshalSlice reads v from the given slice. | [
"unmarshalSlice",
"reads",
"v",
"from",
"the",
"given",
"slice",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/decoder.go#L143-L163 |
144,662 | arangodb/go-velocypack | decoder.go | unmarshalValue | func (d *decodeState) unmarshalValue(data Slice, v reflect.Value) {
if !v.IsValid() {
return
}
switch data.Type() {
case Array:
d.unmarshalArray(data, v)
case Object:
d.unmarshalObject(data, v)
case Bool, Int, SmallInt, UInt, Double, Binary, BCD, String:
d.unmarshalLiteral(data, v)
}
} | go | func (d *decodeState) unmarshalValue(data Slice, v reflect.Value) {
if !v.IsValid() {
return
}
switch data.Type() {
case Array:
d.unmarshalArray(data, v)
case Object:
d.unmarshalObject(data, v)
case Bool, Int, SmallInt, UInt, Double, Binary, BCD, String:
d.unmarshalLiteral(data, v)
}
} | [
"func",
"(",
"d",
"*",
"decodeState",
")",
"unmarshalValue",
"(",
"data",
"Slice",
",",
"v",
"reflect",
".",
"Value",
")",
"{",
"if",
"!",
"v",
".",
"IsValid",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"switch",
"data",
".",
"Type",
"(",
")",
"... | // unmarshalValue unmarshals any slice into given v. | [
"unmarshalValue",
"unmarshals",
"any",
"slice",
"into",
"given",
"v",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/decoder.go#L206-L219 |
144,663 | arangodb/go-velocypack | decoder.go | unmarshalLiteral | func (d *decodeState) unmarshalLiteral(data Slice, v reflect.Value) {
d.literalStore(data, v, false)
} | go | func (d *decodeState) unmarshalLiteral(data Slice, v reflect.Value) {
d.literalStore(data, v, false)
} | [
"func",
"(",
"d",
"*",
"decodeState",
")",
"unmarshalLiteral",
"(",
"data",
"Slice",
",",
"v",
"reflect",
".",
"Value",
")",
"{",
"d",
".",
"literalStore",
"(",
"data",
",",
"v",
",",
"false",
")",
"\n",
"}"
] | // unmarshalLiteral unmarshals a literal slice into given v. | [
"unmarshalLiteral",
"unmarshals",
"a",
"literal",
"slice",
"into",
"given",
"v",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/decoder.go#L557-L559 |
144,664 | arangodb/go-velocypack | slice_factory.go | StringSlice | func StringSlice(s string) Slice {
raw := []byte(s)
l := len(raw)
if l <= 126 {
return Slice(append([]byte{byte(0x40 + l)}, raw...))
}
buf := make([]byte, 1+8+l)
buf[0] = 0xbf
binary.LittleEndian.PutUint64(buf[1:], uint64(l))
copy(buf[1+8:], raw)
return buf
} | go | func StringSlice(s string) Slice {
raw := []byte(s)
l := len(raw)
if l <= 126 {
return Slice(append([]byte{byte(0x40 + l)}, raw...))
}
buf := make([]byte, 1+8+l)
buf[0] = 0xbf
binary.LittleEndian.PutUint64(buf[1:], uint64(l))
copy(buf[1+8:], raw)
return buf
} | [
"func",
"StringSlice",
"(",
"s",
"string",
")",
"Slice",
"{",
"raw",
":=",
"[",
"]",
"byte",
"(",
"s",
")",
"\n",
"l",
":=",
"len",
"(",
"raw",
")",
"\n",
"if",
"l",
"<=",
"126",
"{",
"return",
"Slice",
"(",
"append",
"(",
"[",
"]",
"byte",
"... | // StringSlice creates a slice of type String with given string value | [
"StringSlice",
"creates",
"a",
"slice",
"of",
"type",
"String",
"with",
"given",
"string",
"value"
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/slice_factory.go#L58-L69 |
144,665 | arangodb/go-velocypack | value_length.go | getVariableValueLength | func getVariableValueLength(value ValueLength) ValueLength {
l := ValueLength(1)
for value >= 0x80 {
value >>= 7
l++
}
return l
} | go | func getVariableValueLength(value ValueLength) ValueLength {
l := ValueLength(1)
for value >= 0x80 {
value >>= 7
l++
}
return l
} | [
"func",
"getVariableValueLength",
"(",
"value",
"ValueLength",
")",
"ValueLength",
"{",
"l",
":=",
"ValueLength",
"(",
"1",
")",
"\n",
"for",
"value",
">=",
"0x80",
"{",
"value",
">>=",
"7",
"\n",
"l",
"++",
"\n",
"}",
"\n",
"return",
"l",
"\n",
"}"
] | // getVariableValueLength calculates the length of a variable length integer in unsigned LEB128 format | [
"getVariableValueLength",
"calculates",
"the",
"length",
"of",
"a",
"variable",
"length",
"integer",
"in",
"unsigned",
"LEB128",
"format"
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/value_length.go#L37-L44 |
144,666 | arangodb/go-velocypack | slice_reader.go | sliceFromBufReader | func sliceFromBufReader(r *bufio.Reader) (Slice, error) {
// ByteSize is always found within first 16 bytes
hdr, err := r.Peek(maxByteSizeBytes)
if len(hdr) == 0 && err != nil {
if Cause(err) == io.EOF {
// Empty slice
return nil, nil
}
return nil, WithStack(err)
}
s := Slice(hdr)
size, err := s.ByteS... | go | func sliceFromBufReader(r *bufio.Reader) (Slice, error) {
// ByteSize is always found within first 16 bytes
hdr, err := r.Peek(maxByteSizeBytes)
if len(hdr) == 0 && err != nil {
if Cause(err) == io.EOF {
// Empty slice
return nil, nil
}
return nil, WithStack(err)
}
s := Slice(hdr)
size, err := s.ByteS... | [
"func",
"sliceFromBufReader",
"(",
"r",
"*",
"bufio",
".",
"Reader",
")",
"(",
"Slice",
",",
"error",
")",
"{",
"// ByteSize is always found within first 16 bytes",
"hdr",
",",
"err",
":=",
"r",
".",
"Peek",
"(",
"maxByteSizeBytes",
")",
"\n",
"if",
"len",
"... | // sliceFromBufReader reads a slice from the given buffered reader. | [
"sliceFromBufReader",
"reads",
"a",
"slice",
"from",
"the",
"given",
"buffered",
"reader",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/slice_reader.go#L169-L197 |
144,667 | arangodb/go-velocypack | error.go | IsInvalidType | func IsInvalidType(err error) bool {
_, ok := Cause(err).(InvalidTypeError)
return ok
} | go | func IsInvalidType(err error) bool {
_, ok := Cause(err).(InvalidTypeError)
return ok
} | [
"func",
"IsInvalidType",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"InvalidTypeError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsInvalidType returns true if the given error is an InvalidTypeError. | [
"IsInvalidType",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"an",
"InvalidTypeError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L41-L44 |
144,668 | arangodb/go-velocypack | error.go | isCausedByFunc | func isCausedByFunc(cause error) func(err error) bool {
return func(err error) bool {
return Cause(err) == cause
}
} | go | func isCausedByFunc(cause error) func(err error) bool {
return func(err error) bool {
return Cause(err) == cause
}
} | [
"func",
"isCausedByFunc",
"(",
"cause",
"error",
")",
"func",
"(",
"err",
"error",
")",
"bool",
"{",
"return",
"func",
"(",
"err",
"error",
")",
"bool",
"{",
"return",
"Cause",
"(",
"err",
")",
"==",
"cause",
"\n",
"}",
"\n",
"}"
] | // isCausedByFunc creates an error test function. | [
"isCausedByFunc",
"creates",
"an",
"error",
"test",
"function",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L105-L109 |
144,669 | arangodb/go-velocypack | error.go | IsBuilderUnexpectedType | func IsBuilderUnexpectedType(err error) bool {
_, ok := Cause(err).(BuilderUnexpectedTypeError)
return ok
} | go | func IsBuilderUnexpectedType(err error) bool {
_, ok := Cause(err).(BuilderUnexpectedTypeError)
return ok
} | [
"func",
"IsBuilderUnexpectedType",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"BuilderUnexpectedTypeError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsBuilderUnexpectedType returns true if the given error is an BuilderUnexpectedTypeError. | [
"IsBuilderUnexpectedType",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"an",
"BuilderUnexpectedTypeError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L122-L125 |
144,670 | arangodb/go-velocypack | error.go | IsMarshaler | func IsMarshaler(err error) bool {
_, ok := Cause(err).(MarshalerError)
return ok
} | go | func IsMarshaler(err error) bool {
_, ok := Cause(err).(MarshalerError)
return ok
} | [
"func",
"IsMarshaler",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"MarshalerError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsMarshaler returns true if the given error is an MarshalerError. | [
"IsMarshaler",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"an",
"MarshalerError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L139-L142 |
144,671 | arangodb/go-velocypack | error.go | IsUnsupportedType | func IsUnsupportedType(err error) bool {
_, ok := Cause(err).(UnsupportedTypeError)
return ok
} | go | func IsUnsupportedType(err error) bool {
_, ok := Cause(err).(UnsupportedTypeError)
return ok
} | [
"func",
"IsUnsupportedType",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"UnsupportedTypeError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsUnsupportedType returns true if the given error is an UnsupportedTypeError. | [
"IsUnsupportedType",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"an",
"UnsupportedTypeError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L155-L158 |
144,672 | arangodb/go-velocypack | error.go | IsInvalidUnmarshal | func IsInvalidUnmarshal(err error) bool {
_, ok := Cause(err).(*InvalidUnmarshalError)
return ok
} | go | func IsInvalidUnmarshal(err error) bool {
_, ok := Cause(err).(*InvalidUnmarshalError)
return ok
} | [
"func",
"IsInvalidUnmarshal",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"*",
"InvalidUnmarshalError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsInvalidUnmarshal returns true if the given error is an InvalidUnmarshalError. | [
"IsInvalidUnmarshal",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"an",
"InvalidUnmarshalError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L178-L181 |
144,673 | arangodb/go-velocypack | error.go | IsUnmarshalType | func IsUnmarshalType(err error) bool {
_, ok := Cause(err).(*UnmarshalTypeError)
return ok
} | go | func IsUnmarshalType(err error) bool {
_, ok := Cause(err).(*UnmarshalTypeError)
return ok
} | [
"func",
"IsUnmarshalType",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"*",
"UnmarshalTypeError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsUnmarshalType returns true if the given error is an UnmarshalTypeError. | [
"IsUnmarshalType",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"an",
"UnmarshalTypeError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L200-L203 |
144,674 | arangodb/go-velocypack | error.go | IsParse | func IsParse(err error) bool {
_, ok := Cause(err).(*ParseError)
return ok
} | go | func IsParse(err error) bool {
_, ok := Cause(err).(*ParseError)
return ok
} | [
"func",
"IsParse",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"*",
"ParseError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsParse returns true if the given error is a ParseError. | [
"IsParse",
"returns",
"true",
"if",
"the",
"given",
"error",
"is",
"a",
"ParseError",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/error.go#L216-L219 |
144,675 | arangodb/go-velocypack | builder_sort_entry.go | partition | func partition(s sortEntries) int {
hi := len(s) - 1
pivot := s[hi]
i := 0
for j := 0; j < hi; j++ {
r := bytes.Compare(s[j].Name, pivot.Name)
if r <= 0 {
s[i], s[j] = s[j], s[i]
i++
}
}
s[i], s[hi] = s[hi], s[i]
return i
} | go | func partition(s sortEntries) int {
hi := len(s) - 1
pivot := s[hi]
i := 0
for j := 0; j < hi; j++ {
r := bytes.Compare(s[j].Name, pivot.Name)
if r <= 0 {
s[i], s[j] = s[j], s[i]
i++
}
}
s[i], s[hi] = s[hi], s[i]
return i
} | [
"func",
"partition",
"(",
"s",
"sortEntries",
")",
"int",
"{",
"hi",
":=",
"len",
"(",
"s",
")",
"-",
"1",
"\n",
"pivot",
":=",
"s",
"[",
"hi",
"]",
"\n",
"i",
":=",
"0",
"\n",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"hi",
";",
"j",
"++",
"... | // partition picks the last element as a pivot and reorders the array so that
// all elements with values less than the pivot come before the pivot and all
// elements with values greater than the pivot come after it. | [
"partition",
"picks",
"the",
"last",
"element",
"as",
"a",
"pivot",
"and",
"reorders",
"the",
"array",
"so",
"that",
"all",
"elements",
"with",
"values",
"less",
"than",
"the",
"pivot",
"come",
"before",
"the",
"pivot",
"and",
"all",
"elements",
"with",
"v... | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_sort_entry.go#L50-L63 |
144,676 | arangodb/go-velocypack | builder_stack.go | Push | func (s *builderStack) Push(v ValueLength) {
if s.stack == nil {
s.stack = s.bootstrap[0:1]
s.stack[0] = v
} else {
s.stack = append(s.stack, v)
}
} | go | func (s *builderStack) Push(v ValueLength) {
if s.stack == nil {
s.stack = s.bootstrap[0:1]
s.stack[0] = v
} else {
s.stack = append(s.stack, v)
}
} | [
"func",
"(",
"s",
"*",
"builderStack",
")",
"Push",
"(",
"v",
"ValueLength",
")",
"{",
"if",
"s",
".",
"stack",
"==",
"nil",
"{",
"s",
".",
"stack",
"=",
"s",
".",
"bootstrap",
"[",
"0",
":",
"1",
"]",
"\n",
"s",
".",
"stack",
"[",
"0",
"]",
... | // Push the given value on top of the stack | [
"Push",
"the",
"given",
"value",
"on",
"top",
"of",
"the",
"stack"
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_stack.go#L32-L39 |
144,677 | arangodb/go-velocypack | builder_stack.go | Pop | func (s *builderStack) Pop() {
l := len(s.stack)
if l > 0 {
s.stack = s.stack[:l-1]
}
} | go | func (s *builderStack) Pop() {
l := len(s.stack)
if l > 0 {
s.stack = s.stack[:l-1]
}
} | [
"func",
"(",
"s",
"*",
"builderStack",
")",
"Pop",
"(",
")",
"{",
"l",
":=",
"len",
"(",
"s",
".",
"stack",
")",
"\n",
"if",
"l",
">",
"0",
"{",
"s",
".",
"stack",
"=",
"s",
".",
"stack",
"[",
":",
"l",
"-",
"1",
"]",
"\n",
"}",
"\n",
"... | // Pop removes the top of the stack. | [
"Pop",
"removes",
"the",
"top",
"of",
"the",
"stack",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_stack.go#L42-L47 |
144,678 | arangodb/go-velocypack | value.go | NewReflectValue | func NewReflectValue(v reflect.Value) Value {
vt := v.Type()
switch vt.Kind() {
case reflect.Bool:
return NewBoolValue(v.Bool())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return NewIntValue(v.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uin... | go | func NewReflectValue(v reflect.Value) Value {
vt := v.Type()
switch vt.Kind() {
case reflect.Bool:
return NewBoolValue(v.Bool())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return NewIntValue(v.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uin... | [
"func",
"NewReflectValue",
"(",
"v",
"reflect",
".",
"Value",
")",
"Value",
"{",
"vt",
":=",
"v",
".",
"Type",
"(",
")",
"\n",
"switch",
"vt",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Bool",
":",
"return",
"NewBoolValue",
"(",
"v",
".",... | // NewReflectValue creates a new Value with type derived from Go type of given reflect value.
// If the given value is not a supported type, a Value of type Illegal is returned. | [
"NewReflectValue",
"creates",
"a",
"new",
"Value",
"with",
"type",
"derived",
"from",
"Go",
"type",
"of",
"given",
"reflect",
"value",
".",
"If",
"the",
"given",
"value",
"is",
"not",
"a",
"supported",
"type",
"a",
"Value",
"of",
"type",
"Illegal",
"is",
... | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/value.go#L47-L80 |
144,679 | arangodb/go-velocypack | value.go | NewIntValue | func NewIntValue(value int64) Value {
if value >= -6 && value <= 9 {
return Value{SmallInt, value, false}
}
return Value{Int, value, false}
} | go | func NewIntValue(value int64) Value {
if value >= -6 && value <= 9 {
return Value{SmallInt, value, false}
}
return Value{Int, value, false}
} | [
"func",
"NewIntValue",
"(",
"value",
"int64",
")",
"Value",
"{",
"if",
"value",
">=",
"-",
"6",
"&&",
"value",
"<=",
"9",
"{",
"return",
"Value",
"{",
"SmallInt",
",",
"value",
",",
"false",
"}",
"\n",
"}",
"\n",
"return",
"Value",
"{",
"Int",
",",... | // NewIntValue creates a new Value of type Int with given value. | [
"NewIntValue",
"creates",
"a",
"new",
"Value",
"of",
"type",
"Int",
"with",
"given",
"value",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/value.go#L88-L93 |
144,680 | arangodb/go-velocypack | value.go | NewObjectValue | func NewObjectValue(unindexed ...bool) Value {
return Value{Object, nil, optionalBool(unindexed, false)}
} | go | func NewObjectValue(unindexed ...bool) Value {
return Value{Object, nil, optionalBool(unindexed, false)}
} | [
"func",
"NewObjectValue",
"(",
"unindexed",
"...",
"bool",
")",
"Value",
"{",
"return",
"Value",
"{",
"Object",
",",
"nil",
",",
"optionalBool",
"(",
"unindexed",
",",
"false",
")",
"}",
"\n",
"}"
] | // NewObjectValue creates a new Value that opens a new object. | [
"NewObjectValue",
"creates",
"a",
"new",
"Value",
"that",
"opens",
"a",
"new",
"object",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/value.go#L126-L128 |
144,681 | arangodb/go-velocypack | value.go | NewArrayValue | func NewArrayValue(unindexed ...bool) Value {
return Value{Array, nil, optionalBool(unindexed, false)}
} | go | func NewArrayValue(unindexed ...bool) Value {
return Value{Array, nil, optionalBool(unindexed, false)}
} | [
"func",
"NewArrayValue",
"(",
"unindexed",
"...",
"bool",
")",
"Value",
"{",
"return",
"Value",
"{",
"Array",
",",
"nil",
",",
"optionalBool",
"(",
"unindexed",
",",
"false",
")",
"}",
"\n",
"}"
] | // NewArrayValue creates a new Value that opens a new array. | [
"NewArrayValue",
"creates",
"a",
"new",
"Value",
"that",
"opens",
"a",
"new",
"array",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/value.go#L131-L133 |
144,682 | arangodb/go-velocypack | value.go | IsSlice | func (v Value) IsSlice() bool {
_, ok := v.data.(Slice)
return ok
} | go | func (v Value) IsSlice() bool {
_, ok := v.data.(Slice)
return ok
} | [
"func",
"(",
"v",
"Value",
")",
"IsSlice",
"(",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"v",
".",
"data",
".",
"(",
"Slice",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsSlice returns true when the value already contains a slice. | [
"IsSlice",
"returns",
"true",
"when",
"the",
"value",
"already",
"contains",
"a",
"slice",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/value.go#L156-L159 |
144,683 | arangodb/go-velocypack | util.go | storeVariableValueLength | func storeVariableValueLength(dst []byte, offset, value ValueLength, reverse bool) {
vpackAssert(value > 0)
idx := offset
if reverse {
for value >= 0x80 {
dst[idx] = byte(value | 0x80)
idx--
value >>= 7
}
dst[idx] = byte(value & 0x7f)
} else {
for value >= 0x80 {
dst[idx] = byte(value | 0x80)
... | go | func storeVariableValueLength(dst []byte, offset, value ValueLength, reverse bool) {
vpackAssert(value > 0)
idx := offset
if reverse {
for value >= 0x80 {
dst[idx] = byte(value | 0x80)
idx--
value >>= 7
}
dst[idx] = byte(value & 0x7f)
} else {
for value >= 0x80 {
dst[idx] = byte(value | 0x80)
... | [
"func",
"storeVariableValueLength",
"(",
"dst",
"[",
"]",
"byte",
",",
"offset",
",",
"value",
"ValueLength",
",",
"reverse",
"bool",
")",
"{",
"vpackAssert",
"(",
"value",
">",
"0",
")",
"\n\n",
"idx",
":=",
"offset",
"\n",
"if",
"reverse",
"{",
"for",
... | // store a variable length integer in unsigned LEB128 format | [
"store",
"a",
"variable",
"length",
"integer",
"in",
"unsigned",
"LEB128",
"format"
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/util.go#L168-L187 |
144,684 | arangodb/go-velocypack | util.go | optionalBool | func optionalBool(arg []bool, defaultValue bool) bool {
if len(arg) == 0 {
return defaultValue
}
return arg[0]
} | go | func optionalBool(arg []bool, defaultValue bool) bool {
if len(arg) == 0 {
return defaultValue
}
return arg[0]
} | [
"func",
"optionalBool",
"(",
"arg",
"[",
"]",
"bool",
",",
"defaultValue",
"bool",
")",
"bool",
"{",
"if",
"len",
"(",
"arg",
")",
"==",
"0",
"{",
"return",
"defaultValue",
"\n",
"}",
"\n",
"return",
"arg",
"[",
"0",
"]",
"\n",
"}"
] | // optionalBool returns the first arg element if available, otherwise returns defaultValue. | [
"optionalBool",
"returns",
"the",
"first",
"arg",
"element",
"if",
"available",
"otherwise",
"returns",
"defaultValue",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/util.go#L190-L195 |
144,685 | arangodb/go-velocypack | util.go | alignAt | func alignAt(value, alignment uint) uint {
mask := ^(alignment - 1)
return (value + alignment - 1) & mask
} | go | func alignAt(value, alignment uint) uint {
mask := ^(alignment - 1)
return (value + alignment - 1) & mask
} | [
"func",
"alignAt",
"(",
"value",
",",
"alignment",
"uint",
")",
"uint",
"{",
"mask",
":=",
"^",
"(",
"alignment",
"-",
"1",
")",
"\n",
"return",
"(",
"value",
"+",
"alignment",
"-",
"1",
")",
"&",
"mask",
"\n",
"}"
] | // alignAt returns the first number >= value that is aligned at the given alignment.
// alignment must be a power of 2. | [
"alignAt",
"returns",
"the",
"first",
"number",
">",
"=",
"value",
"that",
"is",
"aligned",
"at",
"the",
"given",
"alignment",
".",
"alignment",
"must",
"be",
"a",
"power",
"of",
"2",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/util.go#L199-L202 |
144,686 | arangodb/go-velocypack | parser.go | ParseJSON | func ParseJSON(r io.Reader, options ...ParserOptions) (Slice, error) {
builder := &Builder{}
p := NewParser(r, builder, options...)
if err := p.Parse(); err != nil {
return nil, WithStack(err)
}
slice, err := builder.Slice()
if err != nil {
return nil, WithStack(err)
}
return slice, nil
} | go | func ParseJSON(r io.Reader, options ...ParserOptions) (Slice, error) {
builder := &Builder{}
p := NewParser(r, builder, options...)
if err := p.Parse(); err != nil {
return nil, WithStack(err)
}
slice, err := builder.Slice()
if err != nil {
return nil, WithStack(err)
}
return slice, nil
} | [
"func",
"ParseJSON",
"(",
"r",
"io",
".",
"Reader",
",",
"options",
"...",
"ParserOptions",
")",
"(",
"Slice",
",",
"error",
")",
"{",
"builder",
":=",
"&",
"Builder",
"{",
"}",
"\n",
"p",
":=",
"NewParser",
"(",
"r",
",",
"builder",
",",
"options",
... | // ParseJSON parses JSON from the given reader and returns the
// VPack equivalent. | [
"ParseJSON",
"parses",
"JSON",
"from",
"the",
"given",
"reader",
"and",
"returns",
"the",
"VPack",
"equivalent",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/parser.go#L50-L61 |
144,687 | arangodb/go-velocypack | parser.go | ParseJSONFromString | func ParseJSONFromString(json string, options ...ParserOptions) (Slice, error) {
return ParseJSON(strings.NewReader(json), options...)
} | go | func ParseJSONFromString(json string, options ...ParserOptions) (Slice, error) {
return ParseJSON(strings.NewReader(json), options...)
} | [
"func",
"ParseJSONFromString",
"(",
"json",
"string",
",",
"options",
"...",
"ParserOptions",
")",
"(",
"Slice",
",",
"error",
")",
"{",
"return",
"ParseJSON",
"(",
"strings",
".",
"NewReader",
"(",
"json",
")",
",",
"options",
"...",
")",
"\n",
"}"
] | // ParseJSONFromString parses the given JSON string and returns the
// VPack equivalent. | [
"ParseJSONFromString",
"parses",
"the",
"given",
"JSON",
"string",
"and",
"returns",
"the",
"VPack",
"equivalent",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/parser.go#L65-L67 |
144,688 | arangodb/go-velocypack | parser.go | ParseJSONFromUTF8 | func ParseJSONFromUTF8(json []byte, options ...ParserOptions) (Slice, error) {
return ParseJSON(bytes.NewReader(json), options...)
} | go | func ParseJSONFromUTF8(json []byte, options ...ParserOptions) (Slice, error) {
return ParseJSON(bytes.NewReader(json), options...)
} | [
"func",
"ParseJSONFromUTF8",
"(",
"json",
"[",
"]",
"byte",
",",
"options",
"...",
"ParserOptions",
")",
"(",
"Slice",
",",
"error",
")",
"{",
"return",
"ParseJSON",
"(",
"bytes",
".",
"NewReader",
"(",
"json",
")",
",",
"options",
"...",
")",
"\n",
"}... | // ParseJSONFromUTF8 parses the given JSON string and returns the
// VPack equivalent. | [
"ParseJSONFromUTF8",
"parses",
"the",
"given",
"JSON",
"string",
"and",
"returns",
"the",
"VPack",
"equivalent",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/parser.go#L71-L73 |
144,689 | arangodb/go-velocypack | parser.go | NewParser | func NewParser(r io.Reader, builder *Builder, options ...ParserOptions) *Parser {
d := json.NewDecoder(r)
d.UseNumber()
p := &Parser{
decoder: d,
builder: builder,
}
if len(options) > 0 {
p.options = options[0]
}
return p
} | go | func NewParser(r io.Reader, builder *Builder, options ...ParserOptions) *Parser {
d := json.NewDecoder(r)
d.UseNumber()
p := &Parser{
decoder: d,
builder: builder,
}
if len(options) > 0 {
p.options = options[0]
}
return p
} | [
"func",
"NewParser",
"(",
"r",
"io",
".",
"Reader",
",",
"builder",
"*",
"Builder",
",",
"options",
"...",
"ParserOptions",
")",
"*",
"Parser",
"{",
"d",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
")",
"\n",
"d",
".",
"UseNumber",
"(",
")",
"\n",
"... | // NewParser initializes a new Parser with JSON from the given reader and
// it will store the parsers output in the given builder. | [
"NewParser",
"initializes",
"a",
"new",
"Parser",
"with",
"JSON",
"from",
"the",
"given",
"reader",
"and",
"it",
"will",
"store",
"the",
"parsers",
"output",
"in",
"the",
"given",
"builder",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/parser.go#L77-L88 |
144,690 | arangodb/go-velocypack | parser.go | Parse | func (p *Parser) Parse() error {
for {
t, err := p.decoder.Token()
if err == io.EOF {
break
} else if serr, ok := err.(*json.SyntaxError); ok {
return WithStack(&ParseError{msg: err.Error(), Offset: serr.Offset})
} else if err != nil {
return WithStack(&ParseError{msg: err.Error()})
}
switch x := ... | go | func (p *Parser) Parse() error {
for {
t, err := p.decoder.Token()
if err == io.EOF {
break
} else if serr, ok := err.(*json.SyntaxError); ok {
return WithStack(&ParseError{msg: err.Error(), Offset: serr.Offset})
} else if err != nil {
return WithStack(&ParseError{msg: err.Error()})
}
switch x := ... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"Parse",
"(",
")",
"error",
"{",
"for",
"{",
"t",
",",
"err",
":=",
"p",
".",
"decoder",
".",
"Token",
"(",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"else",
"if",
"serr",
... | // Parse JSON from the parsers reader and build VPack structures in the
// parsers builder. | [
"Parse",
"JSON",
"from",
"the",
"parsers",
"reader",
"and",
"build",
"VPack",
"structures",
"in",
"the",
"parsers",
"builder",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/parser.go#L92-L151 |
144,691 | arangodb/go-velocypack | array_iterator.go | NewArrayIterator | func NewArrayIterator(s Slice) (*ArrayIterator, error) {
if !s.IsArray() {
return nil, InvalidTypeError{"Expected Array slice"}
}
size, err := s.Length()
if err != nil {
return nil, WithStack(err)
}
i := &ArrayIterator{
s: s,
position: 0,
size: size,
}
if size > 0 {
i.current, err = s.At(... | go | func NewArrayIterator(s Slice) (*ArrayIterator, error) {
if !s.IsArray() {
return nil, InvalidTypeError{"Expected Array slice"}
}
size, err := s.Length()
if err != nil {
return nil, WithStack(err)
}
i := &ArrayIterator{
s: s,
position: 0,
size: size,
}
if size > 0 {
i.current, err = s.At(... | [
"func",
"NewArrayIterator",
"(",
"s",
"Slice",
")",
"(",
"*",
"ArrayIterator",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"IsArray",
"(",
")",
"{",
"return",
"nil",
",",
"InvalidTypeError",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"size",
",",
"err... | // NewArrayIterator initializes an iterator at position 0 of the given object slice. | [
"NewArrayIterator",
"initializes",
"an",
"iterator",
"at",
"position",
"0",
"of",
"the",
"given",
"object",
"slice",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/array_iterator.go#L33-L53 |
144,692 | arangodb/go-velocypack | builder_buffer.go | WriteByte | func (b *builderBuffer) WriteByte(v byte) {
off := len(*b)
b.growCapacity(1)
*b = (*b)[:off+1]
(*b)[off] = v
} | go | func (b *builderBuffer) WriteByte(v byte) {
off := len(*b)
b.growCapacity(1)
*b = (*b)[:off+1]
(*b)[off] = v
} | [
"func",
"(",
"b",
"*",
"builderBuffer",
")",
"WriteByte",
"(",
"v",
"byte",
")",
"{",
"off",
":=",
"len",
"(",
"*",
"b",
")",
"\n",
"b",
".",
"growCapacity",
"(",
"1",
")",
"\n",
"*",
"b",
"=",
"(",
"*",
"b",
")",
"[",
":",
"off",
"+",
"1",... | // WriteByte appends a single byte to the buffer. | [
"WriteByte",
"appends",
"a",
"single",
"byte",
"to",
"the",
"buffer",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_buffer.go#L52-L57 |
144,693 | arangodb/go-velocypack | builder_buffer.go | WriteBytes | func (b *builderBuffer) WriteBytes(v byte, count uint) {
if count == 0 {
return
}
off := uint(len(*b))
b.growCapacity(count)
*b = (*b)[:off+count]
for i := uint(0); i < count; i++ {
(*b)[off+i] = v
}
} | go | func (b *builderBuffer) WriteBytes(v byte, count uint) {
if count == 0 {
return
}
off := uint(len(*b))
b.growCapacity(count)
*b = (*b)[:off+count]
for i := uint(0); i < count; i++ {
(*b)[off+i] = v
}
} | [
"func",
"(",
"b",
"*",
"builderBuffer",
")",
"WriteBytes",
"(",
"v",
"byte",
",",
"count",
"uint",
")",
"{",
"if",
"count",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"off",
":=",
"uint",
"(",
"len",
"(",
"*",
"b",
")",
")",
"\n",
"b",
".",
"... | // WriteBytes appends a series of identical bytes to the buffer. | [
"WriteBytes",
"appends",
"a",
"series",
"of",
"identical",
"bytes",
"to",
"the",
"buffer",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_buffer.go#L60-L70 |
144,694 | arangodb/go-velocypack | builder_buffer.go | Write | func (b *builderBuffer) Write(v []byte) {
l := uint(len(v))
if l > 0 {
off := uint(len(*b))
b.growCapacity(l)
*b = (*b)[:off+l]
copy((*b)[off:], v)
}
} | go | func (b *builderBuffer) Write(v []byte) {
l := uint(len(v))
if l > 0 {
off := uint(len(*b))
b.growCapacity(l)
*b = (*b)[:off+l]
copy((*b)[off:], v)
}
} | [
"func",
"(",
"b",
"*",
"builderBuffer",
")",
"Write",
"(",
"v",
"[",
"]",
"byte",
")",
"{",
"l",
":=",
"uint",
"(",
"len",
"(",
"v",
")",
")",
"\n",
"if",
"l",
">",
"0",
"{",
"off",
":=",
"uint",
"(",
"len",
"(",
"*",
"b",
")",
")",
"\n",... | // Write appends a series of bytes to the buffer. | [
"Write",
"appends",
"a",
"series",
"of",
"bytes",
"to",
"the",
"buffer",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_buffer.go#L73-L81 |
144,695 | arangodb/go-velocypack | builder_buffer.go | Grow | func (b *builderBuffer) Grow(n uint) []byte {
l := uint(len(*b))
if n > 0 {
b.growCapacity(n)
*b = (*b)[:l+n]
}
return (*b)[l:]
} | go | func (b *builderBuffer) Grow(n uint) []byte {
l := uint(len(*b))
if n > 0 {
b.growCapacity(n)
*b = (*b)[:l+n]
}
return (*b)[l:]
} | [
"func",
"(",
"b",
"*",
"builderBuffer",
")",
"Grow",
"(",
"n",
"uint",
")",
"[",
"]",
"byte",
"{",
"l",
":=",
"uint",
"(",
"len",
"(",
"*",
"b",
")",
")",
"\n",
"if",
"n",
">",
"0",
"{",
"b",
".",
"growCapacity",
"(",
"n",
")",
"\n",
"*",
... | // Grow adds n elements to the buffer, returning a slice where the added elements start. | [
"Grow",
"adds",
"n",
"elements",
"to",
"the",
"buffer",
"returning",
"a",
"slice",
"where",
"the",
"added",
"elements",
"start",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_buffer.go#L102-L109 |
144,696 | arangodb/go-velocypack | builder_buffer.go | growCapacity | func (b *builderBuffer) growCapacity(n uint) {
_b := *b
curLen := uint(len(_b))
curCap := uint(cap(_b))
newCap := curLen + n
if newCap <= curCap {
// No need to do anything
return
}
// Increase the capacity
extra := newCap // Grow a bit more to avoid copying all the time
if extra < minGrowDelta {
extra =... | go | func (b *builderBuffer) growCapacity(n uint) {
_b := *b
curLen := uint(len(_b))
curCap := uint(cap(_b))
newCap := curLen + n
if newCap <= curCap {
// No need to do anything
return
}
// Increase the capacity
extra := newCap // Grow a bit more to avoid copying all the time
if extra < minGrowDelta {
extra =... | [
"func",
"(",
"b",
"*",
"builderBuffer",
")",
"growCapacity",
"(",
"n",
"uint",
")",
"{",
"_b",
":=",
"*",
"b",
"\n",
"curLen",
":=",
"uint",
"(",
"len",
"(",
"_b",
")",
")",
"\n",
"curCap",
":=",
"uint",
"(",
"cap",
"(",
"_b",
")",
")",
"\n",
... | // growCapacity ensures that there is enough capacity in the buffer to add n elements. | [
"growCapacity",
"ensures",
"that",
"there",
"is",
"enough",
"capacity",
"in",
"the",
"buffer",
"to",
"add",
"n",
"elements",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/builder_buffer.go#L112-L131 |
144,697 | arangodb/go-velocypack | slice.go | SliceFromHex | func SliceFromHex(v string) Slice {
if bytes, err := hex.DecodeString(v); err != nil {
return nil
} else {
return Slice(bytes)
}
} | go | func SliceFromHex(v string) Slice {
if bytes, err := hex.DecodeString(v); err != nil {
return nil
} else {
return Slice(bytes)
}
} | [
"func",
"SliceFromHex",
"(",
"v",
"string",
")",
"Slice",
"{",
"if",
"bytes",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"else",
"{",
"return",
"Slice",
"(",
"bytes",
")",
... | // SliceFromHex creates a Slice by decoding the given hex string into a Slice.
// If decoding fails, nil is returned. | [
"SliceFromHex",
"creates",
"a",
"Slice",
"by",
"decoding",
"the",
"given",
"hex",
"string",
"into",
"a",
"Slice",
".",
"If",
"decoding",
"fails",
"nil",
"is",
"returned",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/slice.go#L38-L44 |
144,698 | arangodb/go-velocypack | slice.go | JSONString | func (s Slice) JSONString(options ...DumperOptions) (string, error) {
buf := &bytes.Buffer{}
var opt *DumperOptions
if len(options) > 0 {
opt = &options[0]
}
d := NewDumper(buf, opt)
if err := d.Append(s); err != nil {
return "", WithStack(err)
}
return buf.String(), nil
} | go | func (s Slice) JSONString(options ...DumperOptions) (string, error) {
buf := &bytes.Buffer{}
var opt *DumperOptions
if len(options) > 0 {
opt = &options[0]
}
d := NewDumper(buf, opt)
if err := d.Append(s); err != nil {
return "", WithStack(err)
}
return buf.String(), nil
} | [
"func",
"(",
"s",
"Slice",
")",
"JSONString",
"(",
"options",
"...",
"DumperOptions",
")",
"(",
"string",
",",
"error",
")",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"var",
"opt",
"*",
"DumperOptions",
"\n",
"if",
"len",
"(",
... | // JSONString converts the contents of the slice to JSON. | [
"JSONString",
"converts",
"the",
"contents",
"of",
"the",
"slice",
"to",
"JSON",
"."
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/slice.go#L52-L63 |
144,699 | arangodb/go-velocypack | slice.go | ByteSize | func (s Slice) ByteSize() (ValueLength, error) {
h := s.head()
// check if the type has a fixed length first
l := fixedTypeLengths[h]
if l != 0 {
// return fixed length
return ValueLength(l), nil
}
// types with dynamic lengths need special treatment:
switch s.Type() {
case Array, Object:
if h == 0x13 ||... | go | func (s Slice) ByteSize() (ValueLength, error) {
h := s.head()
// check if the type has a fixed length first
l := fixedTypeLengths[h]
if l != 0 {
// return fixed length
return ValueLength(l), nil
}
// types with dynamic lengths need special treatment:
switch s.Type() {
case Array, Object:
if h == 0x13 ||... | [
"func",
"(",
"s",
"Slice",
")",
"ByteSize",
"(",
")",
"(",
"ValueLength",
",",
"error",
")",
"{",
"h",
":=",
"s",
".",
"head",
"(",
")",
"\n",
"// check if the type has a fixed length first",
"l",
":=",
"fixedTypeLengths",
"[",
"h",
"]",
"\n",
"if",
"l",... | // ByteSize returns the total byte size for the slice, including the head byte | [
"ByteSize",
"returns",
"the",
"total",
"byte",
"size",
"for",
"the",
"slice",
"including",
"the",
"head",
"byte"
] | 7896a965b4adc3bcc556b17d494537e30b4c1bd7 | https://github.com/arangodb/go-velocypack/blob/7896a965b4adc3bcc556b17d494537e30b4c1bd7/slice.go#L74-L129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.