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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,300 | tideland/golib | sml/reader.go | readRune | func (mr *mlReader) readRune() (r rune, rc int, err error) {
var size int
mr.index++
r, size, err = mr.reader.ReadRune()
if err != nil {
return 0, 0, err
}
switch {
case size == 0:
rc = rcEOF
case r == chOpen:
rc = rcOpen
case r == chClose:
rc = rcClose
case r == chEscape:
rc = rcEscape
case r == c... | go | func (mr *mlReader) readRune() (r rune, rc int, err error) {
var size int
mr.index++
r, size, err = mr.reader.ReadRune()
if err != nil {
return 0, 0, err
}
switch {
case size == 0:
rc = rcEOF
case r == chOpen:
rc = rcOpen
case r == chClose:
rc = rcClose
case r == chEscape:
rc = rcEscape
case r == c... | [
"func",
"(",
"mr",
"*",
"mlReader",
")",
"readRune",
"(",
")",
"(",
"r",
"rune",
",",
"rc",
"int",
",",
"err",
"error",
")",
"{",
"var",
"size",
"int",
"\n",
"mr",
".",
"index",
"++",
"\n",
"r",
",",
"size",
",",
"err",
"=",
"mr",
".",
"reade... | // Reads one rune of the reader. | [
"Reads",
"one",
"rune",
"of",
"the",
"reader",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L263-L297 |
150,301 | tideland/golib | redis/redis.go | Open | func Open(options ...Option) (*Database, error) {
db := &Database{
address: defaultSocket,
network: defaultNetwork,
timeout: defaultTimeout,
index: defaultIndex,
password: defaultPassword,
poolsize: defaultPoolSize,
logging: defaultLogging,
monitoring: defaultMonitoring,
}
for _,... | go | func Open(options ...Option) (*Database, error) {
db := &Database{
address: defaultSocket,
network: defaultNetwork,
timeout: defaultTimeout,
index: defaultIndex,
password: defaultPassword,
poolsize: defaultPoolSize,
logging: defaultLogging,
monitoring: defaultMonitoring,
}
for _,... | [
"func",
"Open",
"(",
"options",
"...",
"Option",
")",
"(",
"*",
"Database",
",",
"error",
")",
"{",
"db",
":=",
"&",
"Database",
"{",
"address",
":",
"defaultSocket",
",",
"network",
":",
"defaultNetwork",
",",
"timeout",
":",
"defaultTimeout",
",",
"ind... | // Open opens the connection to a Redis database based on the
// passed options. | [
"Open",
"opens",
"the",
"connection",
"to",
"a",
"Redis",
"database",
"based",
"on",
"the",
"passed",
"options",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/redis.go#L40-L58 |
150,302 | tideland/golib | redis/redis.go | Options | func (db *Database) Options() Options {
db.mux.Lock()
defer db.mux.Unlock()
return Options{
Address: db.address,
Network: db.network,
Timeout: db.timeout,
Index: db.index,
Password: db.password,
PoolSize: db.poolsize,
Logging: db.logging,
Monitoring: db.monitoring,
}
} | go | func (db *Database) Options() Options {
db.mux.Lock()
defer db.mux.Unlock()
return Options{
Address: db.address,
Network: db.network,
Timeout: db.timeout,
Index: db.index,
Password: db.password,
PoolSize: db.poolsize,
Logging: db.logging,
Monitoring: db.monitoring,
}
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Options",
"(",
")",
"Options",
"{",
"db",
".",
"mux",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"mux",
".",
"Unlock",
"(",
")",
"\n",
"return",
"Options",
"{",
"Address",
":",
"db",
".",
"address",... | // Options returns the configuration of the database. | [
"Options",
"returns",
"the",
"configuration",
"of",
"the",
"database",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/redis.go#L61-L74 |
150,303 | tideland/golib | redis/redis.go | Close | func (db *Database) Close() error {
db.mux.Lock()
defer db.mux.Unlock()
return db.pool.close()
} | go | func (db *Database) Close() error {
db.mux.Lock()
defer db.mux.Unlock()
return db.pool.close()
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Close",
"(",
")",
"error",
"{",
"db",
".",
"mux",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"mux",
".",
"Unlock",
"(",
")",
"\n",
"return",
"db",
".",
"pool",
".",
"close",
"(",
")",
"\n",
"}"
... | // Close closes the database client. | [
"Close",
"closes",
"the",
"database",
"client",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/redis.go#L102-L106 |
150,304 | tideland/golib | redis/redis.go | String | func (db *Database) String() string {
return fmt.Sprintf("%s:%d", db.address, db.index)
} | go | func (db *Database) String() string {
return fmt.Sprintf("%s:%d", db.address, db.index)
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"db",
".",
"address",
",",
"db",
".",
"index",
")",
"\n",
"}"
] | // String implements the Stringer interface and returns address
// plus index. | [
"String",
"implements",
"the",
"Stringer",
"interface",
"and",
"returns",
"address",
"plus",
"index",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/redis.go#L110-L112 |
150,305 | tideland/golib | audit/environments.go | NewTempDir | func NewTempDir(assert Assertion) *TempDir {
id := make([]byte, 8)
td := &TempDir{
assert: assert,
}
for i := 0; i < 256; i++ {
_, err := rand.Read(id[:])
td.assert.Nil(err)
dir := filepath.Join(os.TempDir(), fmt.Sprintf("gots-%x", id))
if err = os.Mkdir(dir, 0700); err == nil {
td.dir = dir
break
... | go | func NewTempDir(assert Assertion) *TempDir {
id := make([]byte, 8)
td := &TempDir{
assert: assert,
}
for i := 0; i < 256; i++ {
_, err := rand.Read(id[:])
td.assert.Nil(err)
dir := filepath.Join(os.TempDir(), fmt.Sprintf("gots-%x", id))
if err = os.Mkdir(dir, 0700); err == nil {
td.dir = dir
break
... | [
"func",
"NewTempDir",
"(",
"assert",
"Assertion",
")",
"*",
"TempDir",
"{",
"id",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"8",
")",
"\n",
"td",
":=",
"&",
"TempDir",
"{",
"assert",
":",
"assert",
",",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i... | // NewTempDir creates a new temporary directory usable for direct
// usage or further subdirectories. | [
"NewTempDir",
"creates",
"a",
"new",
"temporary",
"directory",
"usable",
"for",
"direct",
"usage",
"or",
"further",
"subdirectories",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/environments.go#L44-L64 |
150,306 | tideland/golib | audit/environments.go | Restore | func (td *TempDir) Restore() {
err := os.RemoveAll(td.dir)
if err != nil {
msg := fmt.Sprintf("cannot remove temporary directory %q: %v", td.dir, err)
td.assert.Fail(msg)
}
} | go | func (td *TempDir) Restore() {
err := os.RemoveAll(td.dir)
if err != nil {
msg := fmt.Sprintf("cannot remove temporary directory %q: %v", td.dir, err)
td.assert.Fail(msg)
}
} | [
"func",
"(",
"td",
"*",
"TempDir",
")",
"Restore",
"(",
")",
"{",
"err",
":=",
"os",
".",
"RemoveAll",
"(",
"td",
".",
"dir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"td",
".",
"dir"... | // Restore deletes the temporary directory and all contents. | [
"Restore",
"deletes",
"the",
"temporary",
"directory",
"and",
"all",
"contents",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/environments.go#L67-L73 |
150,307 | tideland/golib | audit/environments.go | Mkdir | func (td *TempDir) Mkdir(name ...string) string {
innerName := filepath.Join(name...)
fullName := filepath.Join(td.dir, innerName)
if err := os.MkdirAll(fullName, 0700); err != nil {
msg := fmt.Sprintf("cannot create nested temporary directory %q: %v", fullName, err)
td.assert.Fail(msg)
}
return fullName
} | go | func (td *TempDir) Mkdir(name ...string) string {
innerName := filepath.Join(name...)
fullName := filepath.Join(td.dir, innerName)
if err := os.MkdirAll(fullName, 0700); err != nil {
msg := fmt.Sprintf("cannot create nested temporary directory %q: %v", fullName, err)
td.assert.Fail(msg)
}
return fullName
} | [
"func",
"(",
"td",
"*",
"TempDir",
")",
"Mkdir",
"(",
"name",
"...",
"string",
")",
"string",
"{",
"innerName",
":=",
"filepath",
".",
"Join",
"(",
"name",
"...",
")",
"\n",
"fullName",
":=",
"filepath",
".",
"Join",
"(",
"td",
".",
"dir",
",",
"in... | // Mkdir creates a potentially nested directory inside the
// temporary directory. | [
"Mkdir",
"creates",
"a",
"potentially",
"nested",
"directory",
"inside",
"the",
"temporary",
"directory",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/environments.go#L77-L85 |
150,308 | tideland/golib | audit/environments.go | Restore | func (ev *EnvVars) Restore() {
for key, value := range ev.vars {
if err := os.Setenv(key, value); err != nil {
msg := fmt.Sprintf("cannot reset environment variable %q: %v", key, err)
ev.assert.Fail(msg)
}
}
} | go | func (ev *EnvVars) Restore() {
for key, value := range ev.vars {
if err := os.Setenv(key, value); err != nil {
msg := fmt.Sprintf("cannot reset environment variable %q: %v", key, err)
ev.assert.Fail(msg)
}
}
} | [
"func",
"(",
"ev",
"*",
"EnvVars",
")",
"Restore",
"(",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"ev",
".",
"vars",
"{",
"if",
"err",
":=",
"os",
".",
"Setenv",
"(",
"key",
",",
"value",
")",
";",
"err",
"!=",
"nil",
"{",
"msg",
"... | // Restore resets all changed environment variables | [
"Restore",
"resets",
"all",
"changed",
"environment",
"variables"
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/environments.go#L125-L132 |
150,309 | tideland/golib | audit/environments.go | Set | func (ev *EnvVars) Set(key, value string) {
v := os.Getenv(key)
_, ok := ev.vars[key]
if !ok {
ev.vars[key] = v
}
if err := os.Setenv(key, value); err != nil {
msg := fmt.Sprintf("cannot set environment variable %q: %v", key, err)
ev.assert.Fail(msg)
}
} | go | func (ev *EnvVars) Set(key, value string) {
v := os.Getenv(key)
_, ok := ev.vars[key]
if !ok {
ev.vars[key] = v
}
if err := os.Setenv(key, value); err != nil {
msg := fmt.Sprintf("cannot set environment variable %q: %v", key, err)
ev.assert.Fail(msg)
}
} | [
"func",
"(",
"ev",
"*",
"EnvVars",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"{",
"v",
":=",
"os",
".",
"Getenv",
"(",
"key",
")",
"\n",
"_",
",",
"ok",
":=",
"ev",
".",
"vars",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"ev",
... | // Set sets an environment variable to a new value. | [
"Set",
"sets",
"an",
"environment",
"variable",
"to",
"a",
"new",
"value",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/environments.go#L135-L145 |
150,310 | tideland/golib | audit/environments.go | Unset | func (ev *EnvVars) Unset(key string) {
v := os.Getenv(key)
_, ok := ev.vars[key]
if !ok {
ev.vars[key] = v
}
if err := os.Unsetenv(key); err != nil {
msg := fmt.Sprintf("cannot unset environment variable %q: %v", key, err)
ev.assert.Fail(msg)
}
} | go | func (ev *EnvVars) Unset(key string) {
v := os.Getenv(key)
_, ok := ev.vars[key]
if !ok {
ev.vars[key] = v
}
if err := os.Unsetenv(key); err != nil {
msg := fmt.Sprintf("cannot unset environment variable %q: %v", key, err)
ev.assert.Fail(msg)
}
} | [
"func",
"(",
"ev",
"*",
"EnvVars",
")",
"Unset",
"(",
"key",
"string",
")",
"{",
"v",
":=",
"os",
".",
"Getenv",
"(",
"key",
")",
"\n",
"_",
",",
"ok",
":=",
"ev",
".",
"vars",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"ev",
".",
"vars",... | // Unset unsets an environment variable. | [
"Unset",
"unsets",
"an",
"environment",
"variable",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/environments.go#L148-L158 |
150,311 | tideland/golib | logger/nosyslogger.go | NewSysLogger | func NewSysLogger(tag string) (Logger, error) {
if len(tag) > 0 {
tag = "(" + tag + ")"
}
return &SysLogger{tag}, nil
} | go | func NewSysLogger(tag string) (Logger, error) {
if len(tag) > 0 {
tag = "(" + tag + ")"
}
return &SysLogger{tag}, nil
} | [
"func",
"NewSysLogger",
"(",
"tag",
"string",
")",
"(",
"Logger",
",",
"error",
")",
"{",
"if",
"len",
"(",
"tag",
")",
">",
"0",
"{",
"tag",
"=",
"\"",
"\"",
"+",
"tag",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"&",
"SysLogger",
"{",
"tag",... | // NewGoLogger returns a logger implementation using the
// Go syslog package. | [
"NewGoLogger",
"returns",
"a",
"logger",
"implementation",
"using",
"the",
"Go",
"syslog",
"package",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/nosyslogger.go#L32-L37 |
150,312 | tideland/golib | cache/loader.go | Read | func (fb *fileBuffer) Read(p []byte) (int, error) {
return fb.b.Read(p)
} | go | func (fb *fileBuffer) Read(p []byte) (int, error) {
return fb.b.Read(p)
} | [
"func",
"(",
"fb",
"*",
"fileBuffer",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"fb",
".",
"b",
".",
"Read",
"(",
"p",
")",
"\n",
"}"
] | // Read implements the io.ReadCloser interface. | [
"Read",
"implements",
"the",
"io",
".",
"ReadCloser",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/loader.go#L45-L47 |
150,313 | tideland/golib | cache/loader.go | IsOutdated | func (c *fileCacheable) IsOutdated() (bool, error) {
fi, err := os.Stat(c.fullname)
if err != nil {
return false, errors.Annotate(err, ErrFileChecking, errorMessages)
}
if fi.ModTime().After(c.modTime) {
return true, nil
}
return false, nil
} | go | func (c *fileCacheable) IsOutdated() (bool, error) {
fi, err := os.Stat(c.fullname)
if err != nil {
return false, errors.Annotate(err, ErrFileChecking, errorMessages)
}
if fi.ModTime().After(c.modTime) {
return true, nil
}
return false, nil
} | [
"func",
"(",
"c",
"*",
"fileCacheable",
")",
"IsOutdated",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"c",
".",
"fullname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"e... | // IsOutdated implements the Cacheable interface. | [
"IsOutdated",
"implements",
"the",
"Cacheable",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/loader.go#L69-L78 |
150,314 | tideland/golib | cache/loader.go | ReadCloser | func (c *fileCacheable) ReadCloser() (io.ReadCloser, error) {
// Check if the file has to be returned directly because
// it is too large.
if c.tooLarge {
f, err := os.Open(c.fullname)
if err != nil {
return nil, errors.Annotate(err, ErrFileLoading, errorMessages, c.name)
}
return f, nil
}
// It's a cac... | go | func (c *fileCacheable) ReadCloser() (io.ReadCloser, error) {
// Check if the file has to be returned directly because
// it is too large.
if c.tooLarge {
f, err := os.Open(c.fullname)
if err != nil {
return nil, errors.Annotate(err, ErrFileLoading, errorMessages, c.name)
}
return f, nil
}
// It's a cac... | [
"func",
"(",
"c",
"*",
"fileCacheable",
")",
"ReadCloser",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"// Check if the file has to be returned directly because",
"// it is too large.",
"if",
"c",
".",
"tooLarge",
"{",
"f",
",",
"err",
":=",
... | // ReadCloser implements the FileCacheable interface. | [
"ReadCloser",
"implements",
"the",
"FileCacheable",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/loader.go#L86-L98 |
150,315 | tideland/golib | cache/loader.go | NewFileLoader | func NewFileLoader(root string, maxSize int64) CacheableLoader {
return func(name string) (Cacheable, error) {
fn := filepath.Join(root, name)
fi, err := os.Stat(fn)
if err != nil {
return nil, errors.Annotate(err, ErrFileLoading, errorMessages, name)
}
if fi.Size() > maxSize {
return &fileCacheable{
... | go | func NewFileLoader(root string, maxSize int64) CacheableLoader {
return func(name string) (Cacheable, error) {
fn := filepath.Join(root, name)
fi, err := os.Stat(fn)
if err != nil {
return nil, errors.Annotate(err, ErrFileLoading, errorMessages, name)
}
if fi.Size() > maxSize {
return &fileCacheable{
... | [
"func",
"NewFileLoader",
"(",
"root",
"string",
",",
"maxSize",
"int64",
")",
"CacheableLoader",
"{",
"return",
"func",
"(",
"name",
"string",
")",
"(",
"Cacheable",
",",
"error",
")",
"{",
"fn",
":=",
"filepath",
".",
"Join",
"(",
"root",
",",
"name",
... | // NewFileLoader returns a CacheableLoader for files. It
// starts at the given root directory. | [
"NewFileLoader",
"returns",
"a",
"CacheableLoader",
"for",
"files",
".",
"It",
"starts",
"at",
"the",
"given",
"root",
"directory",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/loader.go#L102-L128 |
150,316 | tideland/golib | stringex/defaulter.go | NewDefaulter | func NewDefaulter(id string, log bool) Defaulter {
return &defaulter{
id: id,
log: log,
}
} | go | func NewDefaulter(id string, log bool) Defaulter {
return &defaulter{
id: id,
log: log,
}
} | [
"func",
"NewDefaulter",
"(",
"id",
"string",
",",
"log",
"bool",
")",
"Defaulter",
"{",
"return",
"&",
"defaulter",
"{",
"id",
":",
"id",
",",
"log",
":",
"log",
",",
"}",
"\n",
"}"
] | // NewDefaulter creates a defaulter with the given settings. | [
"NewDefaulter",
"creates",
"a",
"defaulter",
"with",
"the",
"given",
"settings",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L82-L87 |
150,317 | tideland/golib | stringex/defaulter.go | AsString | func (d *defaulter) AsString(v Valuer, dv string) string {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
return value
} | go | func (d *defaulter) AsString(v Valuer, dv string) string {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
return value
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsString",
"(",
"v",
"Valuer",
",",
"dv",
"string",
")",
"string",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"err",... | // AsString implements Defaulter. | [
"AsString",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L90-L97 |
150,318 | tideland/golib | stringex/defaulter.go | AsStringSlice | func (d *defaulter) AsStringSlice(v Valuer, sep string, dv []string) []string {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
return strings.Split(value, sep)
} | go | func (d *defaulter) AsStringSlice(v Valuer, sep string, dv []string) []string {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
return strings.Split(value, sep)
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsStringSlice",
"(",
"v",
"Valuer",
",",
"sep",
"string",
",",
"dv",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"n... | // AsStringSlice implements Defaulter. | [
"AsStringSlice",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L100-L107 |
150,319 | tideland/golib | stringex/defaulter.go | AsStringMap | func (d *defaulter) AsStringMap(v Valuer, rsep, kvsep string, dv map[string]string) map[string]string {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
rows := strings.Split(value, rsep)
mvalue := make(map[string]string, len(rows))
for _, row := range rows {
kv := strings.SplitN(ro... | go | func (d *defaulter) AsStringMap(v Valuer, rsep, kvsep string, dv map[string]string) map[string]string {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
rows := strings.Split(value, rsep)
mvalue := make(map[string]string, len(rows))
for _, row := range rows {
kv := strings.SplitN(ro... | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsStringMap",
"(",
"v",
"Valuer",
",",
"rsep",
",",
"kvsep",
"string",
",",
"dv",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"value",
",",
"err",
":=",
"v",
".",
"... | // AsStringMap implements Defaulter. | [
"AsStringMap",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L110-L127 |
150,320 | tideland/golib | stringex/defaulter.go | AsBool | func (d *defaulter) AsBool(v Valuer, dv bool) bool {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
bvalue, err := strconv.ParseBool(value)
if err != nil {
d.logFormatError("bool", err)
return dv
}
return bvalue
} | go | func (d *defaulter) AsBool(v Valuer, dv bool) bool {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
bvalue, err := strconv.ParseBool(value)
if err != nil {
d.logFormatError("bool", err)
return dv
}
return bvalue
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsBool",
"(",
"v",
"Valuer",
",",
"dv",
"bool",
")",
"bool",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"err",
")"... | // AsBool implements Defaulter. | [
"AsBool",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L130-L142 |
150,321 | tideland/golib | stringex/defaulter.go | AsInt | func (d *defaulter) AsInt(v Valuer, dv int) int {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
ivalue, err := strconv.ParseInt(value, 10, 0)
if err != nil {
d.logFormatError("int", err)
return dv
}
return int(ivalue)
} | go | func (d *defaulter) AsInt(v Valuer, dv int) int {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
ivalue, err := strconv.ParseInt(value, 10, 0)
if err != nil {
d.logFormatError("int", err)
return dv
}
return int(ivalue)
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsInt",
"(",
"v",
"Valuer",
",",
"dv",
"int",
")",
"int",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"err",
")",
... | // AsInt implements Defaulter. | [
"AsInt",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L145-L157 |
150,322 | tideland/golib | stringex/defaulter.go | AsInt64 | func (d *defaulter) AsInt64(v Valuer, dv int64) int64 {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
ivalue, err := strconv.ParseInt(value, 10, 64)
if err != nil {
d.logFormatError("int64", err)
return dv
}
return int64(ivalue)
} | go | func (d *defaulter) AsInt64(v Valuer, dv int64) int64 {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
ivalue, err := strconv.ParseInt(value, 10, 64)
if err != nil {
d.logFormatError("int64", err)
return dv
}
return int64(ivalue)
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsInt64",
"(",
"v",
"Valuer",
",",
"dv",
"int64",
")",
"int64",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"err",
... | // AsInt64 implements Defaulter. | [
"AsInt64",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L160-L172 |
150,323 | tideland/golib | stringex/defaulter.go | AsUint | func (d *defaulter) AsUint(v Valuer, dv uint) uint {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
uivalue, err := strconv.ParseUint(value, 10, 0)
if err != nil {
d.logFormatError("uint", err)
return dv
}
return uint(uivalue)
} | go | func (d *defaulter) AsUint(v Valuer, dv uint) uint {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
uivalue, err := strconv.ParseUint(value, 10, 0)
if err != nil {
d.logFormatError("uint", err)
return dv
}
return uint(uivalue)
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsUint",
"(",
"v",
"Valuer",
",",
"dv",
"uint",
")",
"uint",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"err",
")"... | // AsUint implements Defaulter. | [
"AsUint",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L175-L187 |
150,324 | tideland/golib | stringex/defaulter.go | AsUint64 | func (d *defaulter) AsUint64(v Valuer, dv uint64) uint64 {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
uivalue, err := strconv.ParseUint(value, 10, 64)
if err != nil {
d.logFormatError("uint64", err)
return dv
}
return uint64(uivalue)
} | go | func (d *defaulter) AsUint64(v Valuer, dv uint64) uint64 {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
uivalue, err := strconv.ParseUint(value, 10, 64)
if err != nil {
d.logFormatError("uint64", err)
return dv
}
return uint64(uivalue)
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsUint64",
"(",
"v",
"Valuer",
",",
"dv",
"uint64",
")",
"uint64",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"err",... | // AsUint64 implements Defaulter. | [
"AsUint64",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L190-L202 |
150,325 | tideland/golib | stringex/defaulter.go | AsFloat64 | func (d *defaulter) AsFloat64(v Valuer, dv float64) float64 {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
fvalue, err := strconv.ParseFloat(value, 64)
if err != nil {
d.logFormatError("float64", err)
return dv
}
return fvalue
} | go | func (d *defaulter) AsFloat64(v Valuer, dv float64) float64 {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
fvalue, err := strconv.ParseFloat(value, 64)
if err != nil {
d.logFormatError("float64", err)
return dv
}
return fvalue
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsFloat64",
"(",
"v",
"Valuer",
",",
"dv",
"float64",
")",
"float64",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"logValuerError",
"(",
"er... | // AsFloat64 implements Defaulter. | [
"AsFloat64",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L205-L217 |
150,326 | tideland/golib | stringex/defaulter.go | AsTime | func (d *defaulter) AsTime(v Valuer, layout string, dv time.Time) time.Time {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
tvalue, err := time.Parse(layout, value)
if err != nil {
d.logFormatError("time", err)
return dv
}
return tvalue
} | go | func (d *defaulter) AsTime(v Valuer, layout string, dv time.Time) time.Time {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
tvalue, err := time.Parse(layout, value)
if err != nil {
d.logFormatError("time", err)
return dv
}
return tvalue
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsTime",
"(",
"v",
"Valuer",
",",
"layout",
"string",
",",
"dv",
"time",
".",
"Time",
")",
"time",
".",
"Time",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil... | // AsTime implements Defaulter. | [
"AsTime",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L220-L232 |
150,327 | tideland/golib | stringex/defaulter.go | AsDuration | func (d *defaulter) AsDuration(v Valuer, dv time.Duration) time.Duration {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
dvalue, err := time.ParseDuration(value)
if err != nil {
d.logFormatError("duration", err)
return dv
}
return dvalue
} | go | func (d *defaulter) AsDuration(v Valuer, dv time.Duration) time.Duration {
value, err := v.Value()
if err != nil {
d.logValuerError(err)
return dv
}
dvalue, err := time.ParseDuration(value)
if err != nil {
d.logFormatError("duration", err)
return dv
}
return dvalue
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"AsDuration",
"(",
"v",
"Valuer",
",",
"dv",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"value",
",",
"err",
":=",
"v",
".",
"Value",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"d",
... | // AsDuration implements Defaulter. | [
"AsDuration",
"implements",
"Defaulter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L235-L247 |
150,328 | tideland/golib | stringex/defaulter.go | logFormatError | func (d *defaulter) logFormatError(t string, err error) {
d.logError(fmt.Sprintf("value has illegal format for %q", t), err)
} | go | func (d *defaulter) logFormatError(t string, err error) {
d.logError(fmt.Sprintf("value has illegal format for %q", t), err)
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"logFormatError",
"(",
"t",
"string",
",",
"err",
"error",
")",
"{",
"d",
".",
"logError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"t",
")",
",",
"err",
")",
"\n",
"}"
] | // logFormatError logs the passed format error if configured. | [
"logFormatError",
"logs",
"the",
"passed",
"format",
"error",
"if",
"configured",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L260-L262 |
150,329 | tideland/golib | stringex/defaulter.go | logError | func (d *defaulter) logError(format string, err error) {
if !d.log {
return
}
format += ": %v"
if len(d.id) > 0 {
logger.Errorf("(%s) "+format, d.id, err)
} else {
logger.Errorf(format, err)
}
} | go | func (d *defaulter) logError(format string, err error) {
if !d.log {
return
}
format += ": %v"
if len(d.id) > 0 {
logger.Errorf("(%s) "+format, d.id, err)
} else {
logger.Errorf(format, err)
}
} | [
"func",
"(",
"d",
"*",
"defaulter",
")",
"logError",
"(",
"format",
"string",
",",
"err",
"error",
")",
"{",
"if",
"!",
"d",
".",
"log",
"{",
"return",
"\n",
"}",
"\n",
"format",
"+=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"d",
".",
"id",
")",
... | // logError finally checks logging and formatting before logging an error. | [
"logError",
"finally",
"checks",
"logging",
"and",
"formatting",
"before",
"logging",
"an",
"error",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L265-L275 |
150,330 | tideland/golib | stringex/defaulter.go | Value | func (sv StringValuer) Value() (string, error) {
v := string(sv)
if len(v) == 0 {
return "", errors.New("[-empty-]")
}
return v, nil
} | go | func (sv StringValuer) Value() (string, error) {
v := string(sv)
if len(v) == 0 {
return "", errors.New("[-empty-]")
}
return v, nil
} | [
"func",
"(",
"sv",
"StringValuer",
")",
"Value",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
":=",
"string",
"(",
"sv",
")",
"\n",
"if",
"len",
"(",
"v",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"... | // Value implements the Valuer interface. | [
"Value",
"implements",
"the",
"Valuer",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/defaulter.go#L285-L291 |
150,331 | tideland/golib | redis/resp.go | errorValue | func (r *response) errorValue() Value {
errdata := []byte(r.err.Error())
return Value(errdata)
} | go | func (r *response) errorValue() Value {
errdata := []byte(r.err.Error())
return Value(errdata)
} | [
"func",
"(",
"r",
"*",
"response",
")",
"errorValue",
"(",
")",
"Value",
"{",
"errdata",
":=",
"[",
"]",
"byte",
"(",
"r",
".",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"Value",
"(",
"errdata",
")",
"\n",
"}"
] | // errorValue returns the error as value. | [
"errorValue",
"returns",
"the",
"error",
"as",
"value",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L67-L70 |
150,332 | tideland/golib | redis/resp.go | String | func (r *response) String() string {
descr := responseKindDescr[r.kind]
return fmt.Sprintf("RESPONSE (Kind: %s / Length: %d / Value: %v / Error: %v)", descr, r.length, r.value(), r.err)
} | go | func (r *response) String() string {
descr := responseKindDescr[r.kind]
return fmt.Sprintf("RESPONSE (Kind: %s / Length: %d / Value: %v / Error: %v)", descr, r.length, r.value(), r.err)
} | [
"func",
"(",
"r",
"*",
"response",
")",
"String",
"(",
")",
"string",
"{",
"descr",
":=",
"responseKindDescr",
"[",
"r",
".",
"kind",
"]",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"descr",
",",
"r",
".",
"length",
",",
"r",
".... | // String creates a string representation of the response. | [
"String",
"creates",
"a",
"string",
"representation",
"of",
"the",
"response",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L73-L76 |
150,333 | tideland/golib | redis/resp.go | newResp | func newResp(db *Database) (*resp, error) {
// Dial the database and create the protocol instance.
conn, err := net.DialTimeout(db.network, db.address, db.timeout)
if err != nil {
return nil, errors.Annotate(err, ErrConnectionEstablishing, errorMessages)
}
r := &resp{
database: db,
conn: conn,
reader: ... | go | func newResp(db *Database) (*resp, error) {
// Dial the database and create the protocol instance.
conn, err := net.DialTimeout(db.network, db.address, db.timeout)
if err != nil {
return nil, errors.Annotate(err, ErrConnectionEstablishing, errorMessages)
}
r := &resp{
database: db,
conn: conn,
reader: ... | [
"func",
"newResp",
"(",
"db",
"*",
"Database",
")",
"(",
"*",
"resp",
",",
"error",
")",
"{",
"// Dial the database and create the protocol instance.",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"db",
".",
"network",
",",
"db",
".",
"address",... | // newResp establishes a connection to a Redis database
// based on the configuration of the passed database
// configuration. | [
"newResp",
"establishes",
"a",
"connection",
"to",
"a",
"Redis",
"database",
"based",
"on",
"the",
"configuration",
"of",
"the",
"passed",
"database",
"configuration",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L93-L105 |
150,334 | tideland/golib | redis/resp.go | sendCommand | func (r *resp) sendCommand(cmd string, args ...interface{}) error {
r.cmd = cmd
lengthPart := r.buildLengthPart(args)
cmdPart := r.buildValuePart(cmd)
argsPart := r.buildArgumentsPart(args)
packet := join(lengthPart, cmdPart, argsPart)
_, err := r.conn.Write(packet)
if err != nil {
return errors.Annotate(err,... | go | func (r *resp) sendCommand(cmd string, args ...interface{}) error {
r.cmd = cmd
lengthPart := r.buildLengthPart(args)
cmdPart := r.buildValuePart(cmd)
argsPart := r.buildArgumentsPart(args)
packet := join(lengthPart, cmdPart, argsPart)
_, err := r.conn.Write(packet)
if err != nil {
return errors.Annotate(err,... | [
"func",
"(",
"r",
"*",
"resp",
")",
"sendCommand",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"r",
".",
"cmd",
"=",
"cmd",
"\n",
"lengthPart",
":=",
"r",
".",
"buildLengthPart",
"(",
"args",
")",
"\n",
"cmdP... | // sendCommand sends a command and possible arguments to the server. | [
"sendCommand",
"sends",
"a",
"command",
"and",
"possible",
"arguments",
"to",
"the",
"server",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L108-L120 |
150,335 | tideland/golib | redis/resp.go | receiveResponse | func (r *resp) receiveResponse() *response {
// Receive first line.
line, err := r.reader.ReadBytes('\n')
if err != nil {
rerr := errors.Annotate(err, ErrConnectionBroken, errorMessages, "receive after "+r.cmd)
return &response{receivingError, 0, nil, rerr}
}
content := line[1 : len(line)-2]
// First byte def... | go | func (r *resp) receiveResponse() *response {
// Receive first line.
line, err := r.reader.ReadBytes('\n')
if err != nil {
rerr := errors.Annotate(err, ErrConnectionBroken, errorMessages, "receive after "+r.cmd)
return &response{receivingError, 0, nil, rerr}
}
content := line[1 : len(line)-2]
// First byte def... | [
"func",
"(",
"r",
"*",
"resp",
")",
"receiveResponse",
"(",
")",
"*",
"response",
"{",
"// Receive first line.",
"line",
",",
"err",
":=",
"r",
".",
"reader",
".",
"ReadBytes",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"rerr",
":=",
"er... | // receiveResponse retrieves a response from the server. | [
"receiveResponse",
"retrieves",
"a",
"response",
"from",
"the",
"server",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L123-L176 |
150,336 | tideland/golib | redis/resp.go | receiveResultSet | func (r *resp) receiveResultSet() (*ResultSet, error) {
defer func() { r.cmd = "-none-" }()
result := newResultSet()
current := result
for {
response := r.receiveResponse()
switch response.kind {
case receivingError:
return nil, response.err
case timeoutError:
return nil, errors.New(ErrTimeout, errorM... | go | func (r *resp) receiveResultSet() (*ResultSet, error) {
defer func() { r.cmd = "-none-" }()
result := newResultSet()
current := result
for {
response := r.receiveResponse()
switch response.kind {
case receivingError:
return nil, response.err
case timeoutError:
return nil, errors.New(ErrTimeout, errorM... | [
"func",
"(",
"r",
"*",
"resp",
")",
"receiveResultSet",
"(",
")",
"(",
"*",
"ResultSet",
",",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"r",
".",
"cmd",
"=",
"\"",
"\"",
"}",
"(",
")",
"\n",
"result",
":=",
"newResultSet",
"(",
")",
"\... | // receiveResultSet receives all responses and converts them into a result set. | [
"receiveResultSet",
"receives",
"all",
"responses",
"and",
"converts",
"them",
"into",
"a",
"result",
"set",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L179-L210 |
150,337 | tideland/golib | redis/resp.go | buildLengthPart | func (r *resp) buildLengthPart(args []interface{}) []byte {
length := 1
for _, arg := range args {
switch typedArg := arg.(type) {
case valuer:
length += typedArg.Len()
case Hash:
length += typedArg.Len() * 2
case Hashable:
length += typedArg.Len() * 2
default:
length++
}
}
return join("*", ... | go | func (r *resp) buildLengthPart(args []interface{}) []byte {
length := 1
for _, arg := range args {
switch typedArg := arg.(type) {
case valuer:
length += typedArg.Len()
case Hash:
length += typedArg.Len() * 2
case Hashable:
length += typedArg.Len() * 2
default:
length++
}
}
return join("*", ... | [
"func",
"(",
"r",
"*",
"resp",
")",
"buildLengthPart",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"length",
":=",
"1",
"\n",
"for",
"_",
",",
"arg",
":=",
"range",
"args",
"{",
"switch",
"typedArg",
":=",
"arg",
"."... | // buildLengthPart creates the length part of a command. | [
"buildLengthPart",
"creates",
"the",
"length",
"part",
"of",
"a",
"command",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L213-L228 |
150,338 | tideland/golib | redis/resp.go | buildValuePart | func (r *resp) buildValuePart(value interface{}) []byte {
var raw []byte
if v, ok := value.(Value); ok {
raw = []byte(v)
} else {
raw = valueToBytes(value)
}
return join("$", len(raw), "\r\n", raw, "\r\n")
} | go | func (r *resp) buildValuePart(value interface{}) []byte {
var raw []byte
if v, ok := value.(Value); ok {
raw = []byte(v)
} else {
raw = valueToBytes(value)
}
return join("$", len(raw), "\r\n", raw, "\r\n")
} | [
"func",
"(",
"r",
"*",
"resp",
")",
"buildValuePart",
"(",
"value",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"var",
"raw",
"[",
"]",
"byte",
"\n",
"if",
"v",
",",
"ok",
":=",
"value",
".",
"(",
"Value",
")",
";",
"ok",
"{",
"raw",
"... | // buildValuePart creates one value part of a command. | [
"buildValuePart",
"creates",
"one",
"value",
"part",
"of",
"a",
"command",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L231-L239 |
150,339 | tideland/golib | redis/resp.go | buildArgumentsPart | func (r *resp) buildArgumentsPart(args []interface{}) []byte {
buildValuesPart := func(vs valuer) []byte {
tmp := []byte{}
for _, value := range vs.Values() {
tmp = append(tmp, r.buildValuePart(value)...)
}
return tmp
}
buildHashPart := func(h Hash) []byte {
tmp := []byte{}
for key, value := range h {... | go | func (r *resp) buildArgumentsPart(args []interface{}) []byte {
buildValuesPart := func(vs valuer) []byte {
tmp := []byte{}
for _, value := range vs.Values() {
tmp = append(tmp, r.buildValuePart(value)...)
}
return tmp
}
buildHashPart := func(h Hash) []byte {
tmp := []byte{}
for key, value := range h {... | [
"func",
"(",
"r",
"*",
"resp",
")",
"buildArgumentsPart",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"buildValuesPart",
":=",
"func",
"(",
"vs",
"valuer",
")",
"[",
"]",
"byte",
"{",
"tmp",
":=",
"[",
"]",
"byte",
"... | // buildArgumentsPart creates the the arguments parts of a command. | [
"buildArgumentsPart",
"creates",
"the",
"the",
"arguments",
"parts",
"of",
"a",
"command",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L242-L274 |
150,340 | tideland/golib | redis/resp.go | authenticate | func (r *resp) authenticate() error {
if r.database.password != "" {
err := r.sendCommand("auth", r.database.password)
if err != nil {
return errors.Annotate(err, ErrAuthenticate, errorMessages)
}
result, err := r.receiveResultSet()
if err != nil {
return errors.Annotate(err, ErrAuthenticate, errorMess... | go | func (r *resp) authenticate() error {
if r.database.password != "" {
err := r.sendCommand("auth", r.database.password)
if err != nil {
return errors.Annotate(err, ErrAuthenticate, errorMessages)
}
result, err := r.receiveResultSet()
if err != nil {
return errors.Annotate(err, ErrAuthenticate, errorMess... | [
"func",
"(",
"r",
"*",
"resp",
")",
"authenticate",
"(",
")",
"error",
"{",
"if",
"r",
".",
"database",
".",
"password",
"!=",
"\"",
"\"",
"{",
"err",
":=",
"r",
".",
"sendCommand",
"(",
"\"",
"\"",
",",
"r",
".",
"database",
".",
"password",
")"... | // authenticate authenticates against the server if configured. | [
"authenticate",
"authenticates",
"against",
"the",
"server",
"if",
"configured",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L277-L296 |
150,341 | tideland/golib | redis/resp.go | selectDatabase | func (r *resp) selectDatabase() error {
err := r.sendCommand("select", r.database.index)
if err != nil {
return errors.Annotate(err, ErrSelectDatabase, errorMessages)
}
result, err := r.receiveResultSet()
if err != nil {
return errors.Annotate(err, ErrSelectDatabase, errorMessages)
}
value, err := result.Val... | go | func (r *resp) selectDatabase() error {
err := r.sendCommand("select", r.database.index)
if err != nil {
return errors.Annotate(err, ErrSelectDatabase, errorMessages)
}
result, err := r.receiveResultSet()
if err != nil {
return errors.Annotate(err, ErrSelectDatabase, errorMessages)
}
value, err := result.Val... | [
"func",
"(",
"r",
"*",
"resp",
")",
"selectDatabase",
"(",
")",
"error",
"{",
"err",
":=",
"r",
".",
"sendCommand",
"(",
"\"",
"\"",
",",
"r",
".",
"database",
".",
"index",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Anno... | // selectDatabase selects the database. | [
"selectDatabase",
"selects",
"the",
"database",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resp.go#L299-L316 |
150,342 | tideland/golib | version/version.go | Parse | func Parse(vsnstr string) (Version, error) {
// Split version, pre-release, and metadata.
npmstrs, err := splitVersionString(vsnstr)
if err != nil {
return nil, err
}
// Parse these parts.
nums, err := parseNumberString(npmstrs[0])
if err != nil {
return nil, err
}
prmds := []string{}
if npmstrs[1] != "" ... | go | func Parse(vsnstr string) (Version, error) {
// Split version, pre-release, and metadata.
npmstrs, err := splitVersionString(vsnstr)
if err != nil {
return nil, err
}
// Parse these parts.
nums, err := parseNumberString(npmstrs[0])
if err != nil {
return nil, err
}
prmds := []string{}
if npmstrs[1] != "" ... | [
"func",
"Parse",
"(",
"vsnstr",
"string",
")",
"(",
"Version",
",",
"error",
")",
"{",
"// Split version, pre-release, and metadata.",
"npmstrs",
",",
"err",
":=",
"splitVersionString",
"(",
"vsnstr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // Parse retrieves a version out of a string. | [
"Parse",
"retrieves",
"a",
"version",
"out",
"of",
"a",
"string",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/version/version.go#L123-L144 |
150,343 | tideland/golib | version/version.go | Compare | func (v *vsn) Compare(cv Version) (Precedence, Level) {
// Standard version parts.
switch {
case v.major < cv.Major():
return Older, Major
case v.major > cv.Major():
return Newer, Major
case v.minor < cv.Minor():
return Older, Minor
case v.minor > cv.Minor():
return Newer, Minor
case v.patch < cv.Patch()... | go | func (v *vsn) Compare(cv Version) (Precedence, Level) {
// Standard version parts.
switch {
case v.major < cv.Major():
return Older, Major
case v.major > cv.Major():
return Newer, Major
case v.minor < cv.Minor():
return Older, Minor
case v.minor > cv.Minor():
return Newer, Minor
case v.patch < cv.Patch()... | [
"func",
"(",
"v",
"*",
"vsn",
")",
"Compare",
"(",
"cv",
"Version",
")",
"(",
"Precedence",
",",
"Level",
")",
"{",
"// Standard version parts.",
"switch",
"{",
"case",
"v",
".",
"major",
"<",
"cv",
".",
"Major",
"(",
")",
":",
"return",
"Older",
","... | // Compare implements the Version interface. | [
"Compare",
"implements",
"the",
"Version",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/version/version.go#L172-L232 |
150,344 | tideland/golib | version/version.go | Less | func (v *vsn) Less(cv Version) bool {
precedence, _ := v.Compare(cv)
return precedence == Older
} | go | func (v *vsn) Less(cv Version) bool {
precedence, _ := v.Compare(cv)
return precedence == Older
} | [
"func",
"(",
"v",
"*",
"vsn",
")",
"Less",
"(",
"cv",
"Version",
")",
"bool",
"{",
"precedence",
",",
"_",
":=",
"v",
".",
"Compare",
"(",
"cv",
")",
"\n",
"return",
"precedence",
"==",
"Older",
"\n",
"}"
] | // Less implements the Version interface. | [
"Less",
"implements",
"the",
"Version",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/version/version.go#L235-L238 |
150,345 | tideland/golib | version/version.go | splitVersionString | func splitVersionString(vsnstr string) ([]string, error) {
npXm := strings.SplitN(vsnstr, Metadata, 2)
switch len(npXm) {
case 1:
nXp := strings.SplitN(npXm[0], "-", 2)
switch len(nXp) {
case 1:
return []string{nXp[0], "", ""}, nil
case 2:
return []string{nXp[0], nXp[1], ""}, nil
}
case 2:
nXp := ... | go | func splitVersionString(vsnstr string) ([]string, error) {
npXm := strings.SplitN(vsnstr, Metadata, 2)
switch len(npXm) {
case 1:
nXp := strings.SplitN(npXm[0], "-", 2)
switch len(nXp) {
case 1:
return []string{nXp[0], "", ""}, nil
case 2:
return []string{nXp[0], nXp[1], ""}, nil
}
case 2:
nXp := ... | [
"func",
"splitVersionString",
"(",
"vsnstr",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"npXm",
":=",
"strings",
".",
"SplitN",
"(",
"vsnstr",
",",
"Metadata",
",",
"2",
")",
"\n",
"switch",
"len",
"(",
"npXm",
")",
"{",
"case",
... | // splitVersionString separates the version string into numbers,
// pre-release, and metadata strings. | [
"splitVersionString",
"separates",
"the",
"version",
"string",
"into",
"numbers",
"pre",
"-",
"release",
"and",
"metadata",
"strings",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/version/version.go#L294-L315 |
150,346 | tideland/golib | version/version.go | parseNumberString | func parseNumberString(nstr string) ([]int, error) {
nstrs := strings.Split(nstr, ".")
if len(nstrs) < 1 || len(nstrs) > 3 {
return nil, errors.New(ErrIllegalVersionFormat, errorMessages, "wrong number parts")
}
vsn := []int{1, 0, 0}
for i, nstr := range nstrs {
num, err := strconv.Atoi(nstr)
if err != nil {... | go | func parseNumberString(nstr string) ([]int, error) {
nstrs := strings.Split(nstr, ".")
if len(nstrs) < 1 || len(nstrs) > 3 {
return nil, errors.New(ErrIllegalVersionFormat, errorMessages, "wrong number parts")
}
vsn := []int{1, 0, 0}
for i, nstr := range nstrs {
num, err := strconv.Atoi(nstr)
if err != nil {... | [
"func",
"parseNumberString",
"(",
"nstr",
"string",
")",
"(",
"[",
"]",
"int",
",",
"error",
")",
"{",
"nstrs",
":=",
"strings",
".",
"Split",
"(",
"nstr",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"nstrs",
")",
"<",
"1",
"||",
"len",
"(",
... | // parseNumberString retrieves major, minor, and patch number
// of the passed string. | [
"parseNumberString",
"retrieves",
"major",
"minor",
"and",
"patch",
"number",
"of",
"the",
"passed",
"string",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/version/version.go#L319-L336 |
150,347 | tideland/golib | collections/changer.go | Value | func (c *changer) Value() (interface{}, error) {
if c.err != nil {
return nil, c.err
}
return c.node.content.value(), nil
} | go | func (c *changer) Value() (interface{}, error) {
if c.err != nil {
return nil, c.err
}
return c.node.content.value(), nil
} | [
"func",
"(",
"c",
"*",
"changer",
")",
"Value",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"node",
".",
... | // Value implements the Changer interface. | [
"Value",
"implements",
"the",
"Changer",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L29-L34 |
150,348 | tideland/golib | collections/changer.go | Add | func (c *changer) Add(v interface{}) error {
if c.err != nil {
return c.err
}
_, err := c.node.addChild(justValue{v})
return err
} | go | func (c *changer) Add(v interface{}) error {
if c.err != nil {
return c.err
}
_, err := c.node.addChild(justValue{v})
return err
} | [
"func",
"(",
"c",
"*",
"changer",
")",
"Add",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"node",
".",
"addChild",
... | // Add implements the Changer interface. | [
"Add",
"implements",
"the",
"Changer",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L51-L57 |
150,349 | tideland/golib | collections/changer.go | Remove | func (c *changer) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | go | func (c *changer) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | [
"func",
"(",
"c",
"*",
"changer",
")",
"Remove",
"(",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"node",
".",
"remove",
"(",
")",
"\n",
"}"
] | // Remove implements the Changer interface. | [
"Remove",
"implements",
"the",
"Changer",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L60-L65 |
150,350 | tideland/golib | collections/changer.go | Value | func (c *stringChanger) Value() (string, error) {
if c.err != nil {
return "", c.err
}
if c.node.content.value() == nil {
return "", nil
}
return c.node.content.value().(string), nil
} | go | func (c *stringChanger) Value() (string, error) {
if c.err != nil {
return "", c.err
}
if c.node.content.value() == nil {
return "", nil
}
return c.node.content.value().(string), nil
} | [
"func",
"(",
"c",
"*",
"stringChanger",
")",
"Value",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"if",
"c",
".",
"node",
".",
"content... | // Value implements the StringChanger interface. | [
"Value",
"implements",
"the",
"StringChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L99-L107 |
150,351 | tideland/golib | collections/changer.go | SetValue | func (c *stringChanger) SetValue(v string) (string, error) {
if c.err != nil {
return "", c.err
}
oldValue := c.node.content.value().(string)
newValue := justValue{v}
if !c.node.isAllowed(newValue, true) {
return "", errors.New(ErrDuplicate, errorMessages)
}
c.node.content = newValue
return oldValue, nil
} | go | func (c *stringChanger) SetValue(v string) (string, error) {
if c.err != nil {
return "", c.err
}
oldValue := c.node.content.value().(string)
newValue := justValue{v}
if !c.node.isAllowed(newValue, true) {
return "", errors.New(ErrDuplicate, errorMessages)
}
c.node.content = newValue
return oldValue, nil
} | [
"func",
"(",
"c",
"*",
"stringChanger",
")",
"SetValue",
"(",
"v",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"oldValue",
":=",
"c"... | // SetValue implements the StringChanger interface. | [
"SetValue",
"implements",
"the",
"StringChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L110-L121 |
150,352 | tideland/golib | collections/changer.go | Add | func (c *stringChanger) Add(v string) error {
if c.err != nil {
return c.err
}
_, err := c.node.addChild(justValue{v})
return err
} | go | func (c *stringChanger) Add(v string) error {
if c.err != nil {
return c.err
}
_, err := c.node.addChild(justValue{v})
return err
} | [
"func",
"(",
"c",
"*",
"stringChanger",
")",
"Add",
"(",
"v",
"string",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"node",
".",
"addChild",
"(",
"ju... | // Add implements the StringChanger interface. | [
"Add",
"implements",
"the",
"StringChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L124-L130 |
150,353 | tideland/golib | collections/changer.go | Remove | func (c *stringChanger) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | go | func (c *stringChanger) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | [
"func",
"(",
"c",
"*",
"stringChanger",
")",
"Remove",
"(",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"node",
".",
"remove",
"(",
")",
"\n",
"}"
] | // Remove implements the StringChanger interface. | [
"Remove",
"implements",
"the",
"StringChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L133-L138 |
150,354 | tideland/golib | collections/changer.go | List | func (c *stringChanger) List() ([]string, error) {
if c.err != nil {
return nil, c.err
}
var list []string
err := c.node.doChildren(func(cn *node) error {
list = append(list, cn.content.value().(string))
return nil
})
if err != nil {
return nil, err
}
return list, nil
} | go | func (c *stringChanger) List() ([]string, error) {
if c.err != nil {
return nil, c.err
}
var list []string
err := c.node.doChildren(func(cn *node) error {
list = append(list, cn.content.value().(string))
return nil
})
if err != nil {
return nil, err
}
return list, nil
} | [
"func",
"(",
"c",
"*",
"stringChanger",
")",
"List",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"var",
"list",
"[",
"]",
"string"... | // List implements the StringChanger interface. | [
"List",
"implements",
"the",
"StringChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L141-L154 |
150,355 | tideland/golib | collections/changer.go | Key | func (c *keyValueChanger) Key() (string, error) {
if c.err != nil {
return "", c.err
}
return c.node.content.key().(string), nil
} | go | func (c *keyValueChanger) Key() (string, error) {
if c.err != nil {
return "", c.err
}
return c.node.content.key().(string), nil
} | [
"func",
"(",
"c",
"*",
"keyValueChanger",
")",
"Key",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"node",
".",
"con... | // Key implements the KeyValueChanger interface. | [
"Key",
"implements",
"the",
"KeyValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L172-L177 |
150,356 | tideland/golib | collections/changer.go | SetKey | func (c *keyValueChanger) SetKey(key string) (string, error) {
if c.err != nil {
return "", c.err
}
if !c.node.container.duplicates {
if c.node.hasDuplicateSibling(key) {
return "", errors.New(ErrDuplicate, errorMessages)
}
}
current := c.node.content.key().(string)
c.node.content = keyValue{key, c.node.... | go | func (c *keyValueChanger) SetKey(key string) (string, error) {
if c.err != nil {
return "", c.err
}
if !c.node.container.duplicates {
if c.node.hasDuplicateSibling(key) {
return "", errors.New(ErrDuplicate, errorMessages)
}
}
current := c.node.content.key().(string)
c.node.content = keyValue{key, c.node.... | [
"func",
"(",
"c",
"*",
"keyValueChanger",
")",
"SetKey",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"if",
"!",
"c",
"... | // SetKey implements the KeyValueChanger interface. | [
"SetKey",
"implements",
"the",
"KeyValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L180-L192 |
150,357 | tideland/golib | collections/changer.go | SetValue | func (c *keyValueChanger) SetValue(value interface{}) (interface{}, error) {
if c.err != nil {
return nil, c.err
}
current := c.node.content.value()
c.node.content = keyValue{c.node.content.key(), value}
return current, nil
} | go | func (c *keyValueChanger) SetValue(value interface{}) (interface{}, error) {
if c.err != nil {
return nil, c.err
}
current := c.node.content.value()
c.node.content = keyValue{c.node.content.key(), value}
return current, nil
} | [
"func",
"(",
"c",
"*",
"keyValueChanger",
")",
"SetValue",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"c",
".",
"err",
"\n",
"}",
... | // SetValue implements the KeyValueChanger interface. | [
"SetValue",
"implements",
"the",
"KeyValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L203-L210 |
150,358 | tideland/golib | collections/changer.go | Add | func (c *keyValueChanger) Add(k string, v interface{}) error {
if c.err != nil {
return c.err
}
_, err := c.node.addChild(keyValue{k, v})
return err
} | go | func (c *keyValueChanger) Add(k string, v interface{}) error {
if c.err != nil {
return c.err
}
_, err := c.node.addChild(keyValue{k, v})
return err
} | [
"func",
"(",
"c",
"*",
"keyValueChanger",
")",
"Add",
"(",
"k",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"c",
"."... | // Add implements the KeyValueChanger interface. | [
"Add",
"implements",
"the",
"KeyValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L213-L219 |
150,359 | tideland/golib | collections/changer.go | Remove | func (c *keyValueChanger) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | go | func (c *keyValueChanger) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | [
"func",
"(",
"c",
"*",
"keyValueChanger",
")",
"Remove",
"(",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"node",
".",
"remove",
"(",
")",
"\n",
"}"
] | // Remove implements the KeyValueChanger interface. | [
"Remove",
"implements",
"the",
"KeyValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L222-L227 |
150,360 | tideland/golib | collections/changer.go | List | func (c *keyValueChanger) List() ([]KeyValue, error) {
if c.err != nil {
return nil, c.err
}
var list []KeyValue
err := c.node.doChildren(func(cn *node) error {
list = append(list, KeyValue{cn.content.key().(string), cn.content.value()})
return nil
})
if err != nil {
return nil, err
}
return list, nil
} | go | func (c *keyValueChanger) List() ([]KeyValue, error) {
if c.err != nil {
return nil, c.err
}
var list []KeyValue
err := c.node.doChildren(func(cn *node) error {
list = append(list, KeyValue{cn.content.key().(string), cn.content.value()})
return nil
})
if err != nil {
return nil, err
}
return list, nil
} | [
"func",
"(",
"c",
"*",
"keyValueChanger",
")",
"List",
"(",
")",
"(",
"[",
"]",
"KeyValue",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"var",
"list",
"[",
"]",
"Key... | // List implements the KeyValueChanger interface. | [
"List",
"implements",
"the",
"KeyValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L230-L243 |
150,361 | tideland/golib | collections/changer.go | SetValue | func (c *keyStringValueChanger) SetValue(value string) (string, error) {
if c.err != nil {
return "", c.err
}
current := c.node.content.value().(string)
c.node.content = keyValue{c.node.content.key(), value}
return current, nil
} | go | func (c *keyStringValueChanger) SetValue(value string) (string, error) {
if c.err != nil {
return "", c.err
}
current := c.node.content.value().(string)
c.node.content = keyValue{c.node.content.key(), value}
return current, nil
} | [
"func",
"(",
"c",
"*",
"keyStringValueChanger",
")",
"SetValue",
"(",
"value",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"current",
... | // SetValue implements the KeyStringValueChanger interface. | [
"SetValue",
"implements",
"the",
"KeyStringValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L295-L302 |
150,362 | tideland/golib | collections/changer.go | Remove | func (c *keyStringValueChanger) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | go | func (c *keyStringValueChanger) Remove() error {
if c.err != nil {
return c.err
}
return c.node.remove()
} | [
"func",
"(",
"c",
"*",
"keyStringValueChanger",
")",
"Remove",
"(",
")",
"error",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"c",
".",
"err",
"\n",
"}",
"\n",
"return",
"c",
".",
"node",
".",
"remove",
"(",
")",
"\n",
"}"
] | // Remove implements the KeyStringValueChanger interface. | [
"Remove",
"implements",
"the",
"KeyStringValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L314-L319 |
150,363 | tideland/golib | collections/changer.go | List | func (c *keyStringValueChanger) List() ([]KeyStringValue, error) {
if c.err != nil {
return nil, c.err
}
var list []KeyStringValue
err := c.node.doChildren(func(cn *node) error {
list = append(list, KeyStringValue{cn.content.key().(string), cn.content.value().(string)})
return nil
})
if err != nil {
retur... | go | func (c *keyStringValueChanger) List() ([]KeyStringValue, error) {
if c.err != nil {
return nil, c.err
}
var list []KeyStringValue
err := c.node.doChildren(func(cn *node) error {
list = append(list, KeyStringValue{cn.content.key().(string), cn.content.value().(string)})
return nil
})
if err != nil {
retur... | [
"func",
"(",
"c",
"*",
"keyStringValueChanger",
")",
"List",
"(",
")",
"(",
"[",
"]",
"KeyStringValue",
",",
"error",
")",
"{",
"if",
"c",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"c",
".",
"err",
"\n",
"}",
"\n",
"var",
"list",
"[",
... | // List implements the KeyStringValueChanger interface. | [
"List",
"implements",
"the",
"KeyStringValueChanger",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/changer.go#L322-L335 |
150,364 | tideland/golib | sml/builder.go | Root | func (nb *NodeBuilder) Root() (Node, error) {
if !nb.done {
return nil, errors.New(ErrBuilder, errorMessages, "building is not yet done")
}
return nb.stack[0], nil
} | go | func (nb *NodeBuilder) Root() (Node, error) {
if !nb.done {
return nil, errors.New(ErrBuilder, errorMessages, "building is not yet done")
}
return nb.stack[0], nil
} | [
"func",
"(",
"nb",
"*",
"NodeBuilder",
")",
"Root",
"(",
")",
"(",
"Node",
",",
"error",
")",
"{",
"if",
"!",
"nb",
".",
"done",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"ErrBuilder",
",",
"errorMessages",
",",
"\"",
"\"",
")",
"\n",... | // Root returns the root node of the read document. | [
"Root",
"returns",
"the",
"root",
"node",
"of",
"the",
"read",
"document",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/builder.go#L37-L42 |
150,365 | tideland/golib | sml/builder.go | RawNode | func (nb *NodeBuilder) RawNode(raw string) error {
if nb.done {
return errors.New(ErrBuilder, errorMessages, "building is already done")
}
if len(nb.stack) > 0 {
nb.stack[len(nb.stack)-1].appendRawNode(raw)
return nil
}
return errors.New(ErrBuilder, errorMessages, "no opening tag for raw text")
} | go | func (nb *NodeBuilder) RawNode(raw string) error {
if nb.done {
return errors.New(ErrBuilder, errorMessages, "building is already done")
}
if len(nb.stack) > 0 {
nb.stack[len(nb.stack)-1].appendRawNode(raw)
return nil
}
return errors.New(ErrBuilder, errorMessages, "no opening tag for raw text")
} | [
"func",
"(",
"nb",
"*",
"NodeBuilder",
")",
"RawNode",
"(",
"raw",
"string",
")",
"error",
"{",
"if",
"nb",
".",
"done",
"{",
"return",
"errors",
".",
"New",
"(",
"ErrBuilder",
",",
"errorMessages",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"len... | // RawNode implements the Builder interface. | [
"RawNode",
"implements",
"the",
"Builder",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/builder.go#L87-L96 |
150,366 | tideland/golib | sml/builder.go | Tree | func (tb *KeyStringValueTreeBuilder) Tree() (collections.KeyStringValueTree, error) {
if !tb.done {
return nil, errors.New(ErrBuilder, errorMessages, "building is not yet done")
}
return tb.tree, nil
} | go | func (tb *KeyStringValueTreeBuilder) Tree() (collections.KeyStringValueTree, error) {
if !tb.done {
return nil, errors.New(ErrBuilder, errorMessages, "building is not yet done")
}
return tb.tree, nil
} | [
"func",
"(",
"tb",
"*",
"KeyStringValueTreeBuilder",
")",
"Tree",
"(",
")",
"(",
"collections",
".",
"KeyStringValueTree",
",",
"error",
")",
"{",
"if",
"!",
"tb",
".",
"done",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"ErrBuilder",
",",
"e... | // Tree returns the created tree. | [
"Tree",
"returns",
"the",
"created",
"tree",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/builder.go#L128-L133 |
150,367 | tideland/golib | identifier/uuid.go | NewUUID | func NewUUID() UUID {
uuid, err := NewUUIDv4()
if err != nil {
// Panic due to compatibility reasons.
panic(err)
}
return uuid
} | go | func NewUUID() UUID {
uuid, err := NewUUIDv4()
if err != nil {
// Panic due to compatibility reasons.
panic(err)
}
return uuid
} | [
"func",
"NewUUID",
"(",
")",
"UUID",
"{",
"uuid",
",",
"err",
":=",
"NewUUIDv4",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Panic due to compatibility reasons.",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"uuid",
"\n",
"}"
] | // NewUUID returns a new UUID with based on the default version 4. | [
"NewUUID",
"returns",
"a",
"new",
"UUID",
"with",
"based",
"on",
"the",
"default",
"version",
"4",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/identifier/uuid.go#L49-L56 |
150,368 | tideland/golib | identifier/uuid.go | NewUUIDByHex | func NewUUIDByHex(source string) (UUID, error) {
uuid := UUID{}
if len([]byte(source)) != 32 {
return uuid, errors.New(ErrInvalidHexLength, errorMessages)
}
raw, err := hex.DecodeString(source)
if err != nil {
return uuid, errors.Annotate(err, ErrInvalidHexValue, errorMessages)
}
copy(uuid[:], raw)
return u... | go | func NewUUIDByHex(source string) (UUID, error) {
uuid := UUID{}
if len([]byte(source)) != 32 {
return uuid, errors.New(ErrInvalidHexLength, errorMessages)
}
raw, err := hex.DecodeString(source)
if err != nil {
return uuid, errors.Annotate(err, ErrInvalidHexValue, errorMessages)
}
copy(uuid[:], raw)
return u... | [
"func",
"NewUUIDByHex",
"(",
"source",
"string",
")",
"(",
"UUID",
",",
"error",
")",
"{",
"uuid",
":=",
"UUID",
"{",
"}",
"\n",
"if",
"len",
"(",
"[",
"]",
"byte",
"(",
"source",
")",
")",
"!=",
"32",
"{",
"return",
"uuid",
",",
"errors",
".",
... | // NewUUIDByHex creates a UUID based on the passed hex string which has to
// have the length of 32 bytes. | [
"NewUUIDByHex",
"creates",
"a",
"UUID",
"based",
"on",
"the",
"passed",
"hex",
"string",
"which",
"has",
"to",
"have",
"the",
"length",
"of",
"32",
"bytes",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/identifier/uuid.go#L128-L139 |
150,369 | tideland/golib | identifier/uuid.go | dump | func (uuid UUID) dump() []byte {
dump := make([]byte, len(uuid))
copy(dump, uuid[:])
return dump
} | go | func (uuid UUID) dump() []byte {
dump := make([]byte, len(uuid))
copy(dump, uuid[:])
return dump
} | [
"func",
"(",
"uuid",
"UUID",
")",
"dump",
"(",
")",
"[",
"]",
"byte",
"{",
"dump",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"uuid",
")",
")",
"\n\n",
"copy",
"(",
"dump",
",",
"uuid",
"[",
":",
"]",
")",
"\n\n",
"return",
"dump",... | // dump creates a copy as a byte slice. | [
"dump",
"creates",
"a",
"copy",
"as",
"a",
"byte",
"slice",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/identifier/uuid.go#L164-L170 |
150,370 | tideland/golib | stringex/stringex.go | SplitMap | func SplitMap(s, sep string, m func(p string) (string, bool)) []string {
parts := strings.Split(s, sep)
out := []string{}
for _, part := range parts {
if mp, ok := m(part); ok {
out = append(out, mp)
}
}
return out
} | go | func SplitMap(s, sep string, m func(p string) (string, bool)) []string {
parts := strings.Split(s, sep)
out := []string{}
for _, part := range parts {
if mp, ok := m(part); ok {
out = append(out, mp)
}
}
return out
} | [
"func",
"SplitMap",
"(",
"s",
",",
"sep",
"string",
",",
"m",
"func",
"(",
"p",
"string",
")",
"(",
"string",
",",
"bool",
")",
")",
"[",
"]",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"sep",
")",
"\n",
"out",
":=",
... | // SplitMap splits the string s by the separator
// sep and then maps the parts by the function m.
// Only those where m also returns true will be part
// of the result. So it even could be empty. | [
"SplitMap",
"splits",
"the",
"string",
"s",
"by",
"the",
"separator",
"sep",
"and",
"then",
"maps",
"the",
"parts",
"by",
"the",
"function",
"m",
".",
"Only",
"those",
"where",
"m",
"also",
"returns",
"true",
"will",
"be",
"part",
"of",
"the",
"result",
... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/stringex/stringex.go#L53-L62 |
150,371 | tideland/golib | redis/connection.go | newConnection | func newConnection(db *Database) (*Connection, error) {
conn := &Connection{
database: db,
}
err := conn.ensureProtocol()
if err != nil {
return nil, err
}
// Perform authentication and database selection.
err = conn.resp.authenticate()
if err != nil {
conn.database.pool.kill(conn.resp)
return nil, err
... | go | func newConnection(db *Database) (*Connection, error) {
conn := &Connection{
database: db,
}
err := conn.ensureProtocol()
if err != nil {
return nil, err
}
// Perform authentication and database selection.
err = conn.resp.authenticate()
if err != nil {
conn.database.pool.kill(conn.resp)
return nil, err
... | [
"func",
"newConnection",
"(",
"db",
"*",
"Database",
")",
"(",
"*",
"Connection",
",",
"error",
")",
"{",
"conn",
":=",
"&",
"Connection",
"{",
"database",
":",
"db",
",",
"}",
"\n",
"err",
":=",
"conn",
".",
"ensureProtocol",
"(",
")",
"\n",
"if",
... | // newConnection creates a new connection instance. | [
"newConnection",
"creates",
"a",
"new",
"connection",
"instance",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L33-L53 |
150,372 | tideland/golib | redis/connection.go | DoValue | func (conn *Connection) DoValue(cmd string, args ...interface{}) (Value, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.ValueAt(0)
} | go | func (conn *Connection) DoValue(cmd string, args ...interface{}) (Value, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.ValueAt(0)
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoValue",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"Value",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args",
"...",
")"... | // DoValue executes one Redis command and returns a single value. | [
"DoValue",
"executes",
"one",
"Redis",
"command",
"and",
"returns",
"a",
"single",
"value",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L80-L86 |
150,373 | tideland/golib | redis/connection.go | DoOK | func (conn *Connection) DoOK(cmd string, args ...interface{}) (bool, error) {
value, err := conn.DoValue(cmd, args...)
if err != nil {
return false, err
}
return value.IsOK(), nil
} | go | func (conn *Connection) DoOK(cmd string, args ...interface{}) (bool, error) {
value, err := conn.DoValue(cmd, args...)
if err != nil {
return false, err
}
return value.IsOK(), nil
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoOK",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"value",
",",
"err",
":=",
"conn",
".",
"DoValue",
"(",
"cmd",
",",
"args",
"...",
")"... | // DoOK executes one Redis command and checks if
// it returns the OK string. | [
"DoOK",
"executes",
"one",
"Redis",
"command",
"and",
"checks",
"if",
"it",
"returns",
"the",
"OK",
"string",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L90-L96 |
150,374 | tideland/golib | redis/connection.go | DoBool | func (conn *Connection) DoBool(cmd string, args ...interface{}) (bool, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return false, err
}
return result.BoolAt(0)
} | go | func (conn *Connection) DoBool(cmd string, args ...interface{}) (bool, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return false, err
}
return result.BoolAt(0)
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoBool",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args",
"...",
")",
... | // DoBool executes one Redis command and interpretes
// the result as bool value. | [
"DoBool",
"executes",
"one",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"bool",
"value",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L100-L106 |
150,375 | tideland/golib | redis/connection.go | DoInt | func (conn *Connection) DoInt(cmd string, args ...interface{}) (int, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return 0, err
}
return result.IntAt(0)
} | go | func (conn *Connection) DoInt(cmd string, args ...interface{}) (int, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return 0, err
}
return result.IntAt(0)
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoInt",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args",
"...",
")",
... | // DoInt executes one Redis command and interpretes
// the result as int value. | [
"DoInt",
"executes",
"one",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"int",
"value",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L110-L116 |
150,376 | tideland/golib | redis/connection.go | DoString | func (conn *Connection) DoString(cmd string, args ...interface{}) (string, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return "", err
}
return result.StringAt(0)
} | go | func (conn *Connection) DoString(cmd string, args ...interface{}) (string, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return "", err
}
return result.StringAt(0)
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoString",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args",
"...",
"... | // DoString executes one Redis command and interpretes
// the result as string value. | [
"DoString",
"executes",
"one",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"string",
"value",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L120-L126 |
150,377 | tideland/golib | redis/connection.go | DoStrings | func (conn *Connection) DoStrings(cmd string, args ...interface{}) ([]string, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.Strings(), nil
} | go | func (conn *Connection) DoStrings(cmd string, args ...interface{}) ([]string, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.Strings(), nil
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoStrings",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args... | // DoStrings executes one Redis command and interpretes
// the result as a slice of strings. | [
"DoStrings",
"executes",
"one",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"a",
"slice",
"of",
"strings",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L130-L136 |
150,378 | tideland/golib | redis/connection.go | DoKeyValues | func (conn *Connection) DoKeyValues(cmd string, args ...interface{}) (KeyValues, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.KeyValues()
} | go | func (conn *Connection) DoKeyValues(cmd string, args ...interface{}) (KeyValues, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.KeyValues()
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoKeyValues",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"KeyValues",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args",
"...... | // DoKeyValues executes on Redis command and interpretes
// the result as a list of keys and values. | [
"DoKeyValues",
"executes",
"on",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"a",
"list",
"of",
"keys",
"and",
"values",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L140-L146 |
150,379 | tideland/golib | redis/connection.go | DoHash | func (conn *Connection) DoHash(cmd string, args ...interface{}) (Hash, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.Hash()
} | go | func (conn *Connection) DoHash(cmd string, args ...interface{}) (Hash, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return nil, err
}
return result.Hash()
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoHash",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"Hash",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
",",
"args",
"...",
")",
... | // DoHash executes on Redis command and interpretes
// the result as a hash. | [
"DoHash",
"executes",
"on",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"a",
"hash",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L150-L156 |
150,380 | tideland/golib | redis/connection.go | DoScoredValues | func (conn *Connection) DoScoredValues(cmd string, args ...interface{}) (ScoredValues, error) {
var withScores bool
for _, arg := range args {
if s, ok := arg.(string); ok {
if strings.ToLower(s) == "withscores" {
withScores = true
break
}
}
}
result, err := conn.Do(cmd, args...)
if err != nil {
... | go | func (conn *Connection) DoScoredValues(cmd string, args ...interface{}) (ScoredValues, error) {
var withScores bool
for _, arg := range args {
if s, ok := arg.(string); ok {
if strings.ToLower(s) == "withscores" {
withScores = true
break
}
}
}
result, err := conn.Do(cmd, args...)
if err != nil {
... | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoScoredValues",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"ScoredValues",
",",
"error",
")",
"{",
"var",
"withScores",
"bool",
"\n",
"for",
"_",
",",
"arg",
":=",
"range",
... | // DoScoredValues executes on Redis command and interpretes
// the result as scored values. | [
"DoScoredValues",
"executes",
"on",
"Redis",
"command",
"and",
"interpretes",
"the",
"result",
"as",
"scored",
"values",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L160-L175 |
150,381 | tideland/golib | redis/connection.go | DoScan | func (conn *Connection) DoScan(cmd string, args ...interface{}) (int, *ResultSet, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return 0, nil, err
}
return result.Scanned()
} | go | func (conn *Connection) DoScan(cmd string, args ...interface{}) (int, *ResultSet, error) {
result, err := conn.Do(cmd, args...)
if err != nil {
return 0, nil, err
}
return result.Scanned()
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"DoScan",
"(",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"*",
"ResultSet",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"cmd",
","... | // DoScan executes one Redis command which should be one of the
// scan commands. It returns the cursor and the result set containing
// the key, values or scored values depending on the scan command. | [
"DoScan",
"executes",
"one",
"Redis",
"command",
"which",
"should",
"be",
"one",
"of",
"the",
"scan",
"commands",
".",
"It",
"returns",
"the",
"cursor",
"and",
"the",
"result",
"set",
"containing",
"the",
"key",
"values",
"or",
"scored",
"values",
"depending... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L180-L186 |
150,382 | tideland/golib | redis/connection.go | Return | func (conn *Connection) Return() error {
err := conn.database.pool.push(conn.resp)
conn.resp = nil
return err
} | go | func (conn *Connection) Return() error {
err := conn.database.pool.push(conn.resp)
conn.resp = nil
return err
} | [
"func",
"(",
"conn",
"*",
"Connection",
")",
"Return",
"(",
")",
"error",
"{",
"err",
":=",
"conn",
".",
"database",
".",
"pool",
".",
"push",
"(",
"conn",
".",
"resp",
")",
"\n",
"conn",
".",
"resp",
"=",
"nil",
"\n",
"return",
"err",
"\n",
"}"
... | // Return passes the connection back into the database pool. | [
"Return",
"passes",
"the",
"connection",
"back",
"into",
"the",
"database",
"pool",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/connection.go#L189-L193 |
150,383 | tideland/golib | collections/tree.go | newNodeContainer | func newNodeContainer(c nodeContent, duplicates bool) *nodeContainer {
nc := &nodeContainer{
root: &node{
content: c,
},
duplicates: duplicates,
}
nc.root.container = nc
return nc
} | go | func newNodeContainer(c nodeContent, duplicates bool) *nodeContainer {
nc := &nodeContainer{
root: &node{
content: c,
},
duplicates: duplicates,
}
nc.root.container = nc
return nc
} | [
"func",
"newNodeContainer",
"(",
"c",
"nodeContent",
",",
"duplicates",
"bool",
")",
"*",
"nodeContainer",
"{",
"nc",
":=",
"&",
"nodeContainer",
"{",
"root",
":",
"&",
"node",
"{",
"content",
":",
"c",
",",
"}",
",",
"duplicates",
":",
"duplicates",
","... | // newNodeContainer creates a new node container. | [
"newNodeContainer",
"creates",
"a",
"new",
"node",
"container",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L101-L110 |
150,384 | tideland/golib | collections/tree.go | deepCopy | func (nc *nodeContainer) deepCopy() *nodeContainer {
cnc := &nodeContainer{
duplicates: nc.duplicates,
}
cnc.root = nc.root.deepCopy(cnc, nil)
return cnc
} | go | func (nc *nodeContainer) deepCopy() *nodeContainer {
cnc := &nodeContainer{
duplicates: nc.duplicates,
}
cnc.root = nc.root.deepCopy(cnc, nil)
return cnc
} | [
"func",
"(",
"nc",
"*",
"nodeContainer",
")",
"deepCopy",
"(",
")",
"*",
"nodeContainer",
"{",
"cnc",
":=",
"&",
"nodeContainer",
"{",
"duplicates",
":",
"nc",
".",
"duplicates",
",",
"}",
"\n",
"cnc",
".",
"root",
"=",
"nc",
".",
"root",
".",
"deepC... | // deepCopy creates a copy of the container. | [
"deepCopy",
"creates",
"a",
"copy",
"of",
"the",
"container",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L113-L119 |
150,385 | tideland/golib | collections/tree.go | isAllowed | func (n *node) isAllowed(c nodeContent, here bool) bool {
if n.container.duplicates {
return true
}
checkNode := n
if here {
checkNode = n.parent
}
for _, child := range checkNode.children {
if child.content.key() == c.key() {
return false
}
}
return true
} | go | func (n *node) isAllowed(c nodeContent, here bool) bool {
if n.container.duplicates {
return true
}
checkNode := n
if here {
checkNode = n.parent
}
for _, child := range checkNode.children {
if child.content.key() == c.key() {
return false
}
}
return true
} | [
"func",
"(",
"n",
"*",
"node",
")",
"isAllowed",
"(",
"c",
"nodeContent",
",",
"here",
"bool",
")",
"bool",
"{",
"if",
"n",
".",
"container",
".",
"duplicates",
"{",
"return",
"true",
"\n",
"}",
"\n",
"checkNode",
":=",
"n",
"\n",
"if",
"here",
"{"... | // isAllowed returns true, if adding the content or setting
// it is allowed depending on allowed duplicates. | [
"isAllowed",
"returns",
"true",
"if",
"adding",
"the",
"content",
"or",
"setting",
"it",
"is",
"allowed",
"depending",
"on",
"allowed",
"duplicates",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L135-L149 |
150,386 | tideland/golib | collections/tree.go | hasDuplicateSibling | func (n *node) hasDuplicateSibling(key interface{}) bool {
if n.parent == nil {
return false
}
for _, sibling := range n.parent.children {
if sibling == n {
continue
}
if sibling.content.key() == key {
return true
}
}
return false
} | go | func (n *node) hasDuplicateSibling(key interface{}) bool {
if n.parent == nil {
return false
}
for _, sibling := range n.parent.children {
if sibling == n {
continue
}
if sibling.content.key() == key {
return true
}
}
return false
} | [
"func",
"(",
"n",
"*",
"node",
")",
"hasDuplicateSibling",
"(",
"key",
"interface",
"{",
"}",
")",
"bool",
"{",
"if",
"n",
".",
"parent",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"sibling",
":=",
"range",
"n",
".",
"... | // hasDuplicateSibling checks if the node has a sibling with the same key. | [
"hasDuplicateSibling",
"checks",
"if",
"the",
"node",
"has",
"a",
"sibling",
"with",
"the",
"same",
"key",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L152-L165 |
150,387 | tideland/golib | collections/tree.go | addChild | func (n *node) addChild(c nodeContent) (*node, error) {
if !n.isAllowed(c, false) {
return nil, errors.New(ErrDuplicate, errorMessages)
}
child := &node{
container: n.container,
parent: n,
content: c,
}
n.children = append(n.children, child)
return child, nil
} | go | func (n *node) addChild(c nodeContent) (*node, error) {
if !n.isAllowed(c, false) {
return nil, errors.New(ErrDuplicate, errorMessages)
}
child := &node{
container: n.container,
parent: n,
content: c,
}
n.children = append(n.children, child)
return child, nil
} | [
"func",
"(",
"n",
"*",
"node",
")",
"addChild",
"(",
"c",
"nodeContent",
")",
"(",
"*",
"node",
",",
"error",
")",
"{",
"if",
"!",
"n",
".",
"isAllowed",
"(",
"c",
",",
"false",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"ErrDup... | // addChild adds a child node depending on allowed duplicates. | [
"addChild",
"adds",
"a",
"child",
"node",
"depending",
"on",
"allowed",
"duplicates",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L168-L179 |
150,388 | tideland/golib | collections/tree.go | remove | func (n *node) remove() error {
if n.parent == nil {
return errors.New(ErrCannotRemoveRoot, errorMessages)
}
for i, child := range n.parent.children {
if child == n {
n.parent.children = append(n.parent.children[:i], n.parent.children[i+1:]...)
return nil
}
}
panic("cannot find node to remove at parent... | go | func (n *node) remove() error {
if n.parent == nil {
return errors.New(ErrCannotRemoveRoot, errorMessages)
}
for i, child := range n.parent.children {
if child == n {
n.parent.children = append(n.parent.children[:i], n.parent.children[i+1:]...)
return nil
}
}
panic("cannot find node to remove at parent... | [
"func",
"(",
"n",
"*",
"node",
")",
"remove",
"(",
")",
"error",
"{",
"if",
"n",
".",
"parent",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"ErrCannotRemoveRoot",
",",
"errorMessages",
")",
"\n",
"}",
"\n",
"for",
"i",
",",
"child",
":="... | // remove deletes this node from its parent. | [
"remove",
"deletes",
"this",
"node",
"from",
"its",
"parent",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L182-L193 |
150,389 | tideland/golib | collections/tree.go | at | func (n *node) at(path ...nodeContent) (*node, error) {
if len(path) == 0 || path[0].key() != n.content.key() {
return nil, errors.New(ErrNodeNotFound, errorMessages)
}
if len(path) == 1 {
return n, nil
}
// Check children for rest of the path.
for _, child := range n.children {
found, err := child.at(path[... | go | func (n *node) at(path ...nodeContent) (*node, error) {
if len(path) == 0 || path[0].key() != n.content.key() {
return nil, errors.New(ErrNodeNotFound, errorMessages)
}
if len(path) == 1 {
return n, nil
}
// Check children for rest of the path.
for _, child := range n.children {
found, err := child.at(path[... | [
"func",
"(",
"n",
"*",
"node",
")",
"at",
"(",
"path",
"...",
"nodeContent",
")",
"(",
"*",
"node",
",",
"error",
")",
"{",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"||",
"path",
"[",
"0",
"]",
".",
"key",
"(",
")",
"!=",
"n",
".",
"conten... | // at finds a node by its path. | [
"at",
"finds",
"a",
"node",
"by",
"its",
"path",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L196-L214 |
150,390 | tideland/golib | collections/tree.go | create | func (n *node) create(path ...nodeContent) (*node, error) {
if len(path) == 0 || path[0].key() != n.content.key() {
return nil, errors.New(ErrNodeNotFound, errorMessages)
}
if len(path) == 1 {
return n, nil
}
// Check children for the next path element.
var found *node
for _, child := range n.children {
if... | go | func (n *node) create(path ...nodeContent) (*node, error) {
if len(path) == 0 || path[0].key() != n.content.key() {
return nil, errors.New(ErrNodeNotFound, errorMessages)
}
if len(path) == 1 {
return n, nil
}
// Check children for the next path element.
var found *node
for _, child := range n.children {
if... | [
"func",
"(",
"n",
"*",
"node",
")",
"create",
"(",
"path",
"...",
"nodeContent",
")",
"(",
"*",
"node",
",",
"error",
")",
"{",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"||",
"path",
"[",
"0",
"]",
".",
"key",
"(",
")",
"!=",
"n",
".",
"co... | // create acts like at but if nodes don't exist they will be created. | [
"create",
"acts",
"like",
"at",
"but",
"if",
"nodes",
"don",
"t",
"exist",
"they",
"will",
"be",
"created",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L217-L240 |
150,391 | tideland/golib | collections/tree.go | findFirst | func (n *node) findFirst(f func(fn *node) (bool, error)) (*node, error) {
hasFound, err := f(n)
if err != nil {
return nil, errors.Annotate(err, ErrNodeFindFirst, errorMessages)
}
if hasFound {
return n, nil
}
for _, child := range n.children {
found, err := child.findFirst(f)
if err != nil && !IsNodeNotF... | go | func (n *node) findFirst(f func(fn *node) (bool, error)) (*node, error) {
hasFound, err := f(n)
if err != nil {
return nil, errors.Annotate(err, ErrNodeFindFirst, errorMessages)
}
if hasFound {
return n, nil
}
for _, child := range n.children {
found, err := child.findFirst(f)
if err != nil && !IsNodeNotF... | [
"func",
"(",
"n",
"*",
"node",
")",
"findFirst",
"(",
"f",
"func",
"(",
"fn",
"*",
"node",
")",
"(",
"bool",
",",
"error",
")",
")",
"(",
"*",
"node",
",",
"error",
")",
"{",
"hasFound",
",",
"err",
":=",
"f",
"(",
"n",
")",
"\n",
"if",
"er... | // findFirst returns the first node for which the passed function
// returns true. | [
"findFirst",
"returns",
"the",
"first",
"node",
"for",
"which",
"the",
"passed",
"function",
"returns",
"true",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L244-L262 |
150,392 | tideland/golib | collections/tree.go | findAll | func (n *node) findAll(f func(fn *node) (bool, error)) ([]*node, error) {
var allFound []*node
hasFound, err := f(n)
if err != nil {
return nil, errors.Annotate(err, ErrNodeFindAll, errorMessages)
}
if hasFound {
allFound = append(allFound, n)
}
for _, child := range n.children {
found, err := child.findAl... | go | func (n *node) findAll(f func(fn *node) (bool, error)) ([]*node, error) {
var allFound []*node
hasFound, err := f(n)
if err != nil {
return nil, errors.Annotate(err, ErrNodeFindAll, errorMessages)
}
if hasFound {
allFound = append(allFound, n)
}
for _, child := range n.children {
found, err := child.findAl... | [
"func",
"(",
"n",
"*",
"node",
")",
"findAll",
"(",
"f",
"func",
"(",
"fn",
"*",
"node",
")",
"(",
"bool",
",",
"error",
")",
")",
"(",
"[",
"]",
"*",
"node",
",",
"error",
")",
"{",
"var",
"allFound",
"[",
"]",
"*",
"node",
"\n",
"hasFound",... | // findAll returns all nodes for which the passed function
// returns true. | [
"findAll",
"returns",
"all",
"nodes",
"for",
"which",
"the",
"passed",
"function",
"returns",
"true",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L266-L285 |
150,393 | tideland/golib | collections/tree.go | doAll | func (n *node) doAll(f func(dn *node) error) error {
if err := f(n); err != nil {
return errors.Annotate(err, ErrNodeDoAll, errorMessages)
}
for _, child := range n.children {
if err := child.doAll(f); err != nil {
return errors.Annotate(err, ErrNodeDoAll, errorMessages)
}
}
return nil
} | go | func (n *node) doAll(f func(dn *node) error) error {
if err := f(n); err != nil {
return errors.Annotate(err, ErrNodeDoAll, errorMessages)
}
for _, child := range n.children {
if err := child.doAll(f); err != nil {
return errors.Annotate(err, ErrNodeDoAll, errorMessages)
}
}
return nil
} | [
"func",
"(",
"n",
"*",
"node",
")",
"doAll",
"(",
"f",
"func",
"(",
"dn",
"*",
"node",
")",
"error",
")",
"error",
"{",
"if",
"err",
":=",
"f",
"(",
"n",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Annotate",
"(",
"err",
",",... | // doAll performs the passed function for the node
// and all its children deep to the leafs. | [
"doAll",
"performs",
"the",
"passed",
"function",
"for",
"the",
"node",
"and",
"all",
"its",
"children",
"deep",
"to",
"the",
"leafs",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L289-L299 |
150,394 | tideland/golib | collections/tree.go | doChildren | func (n *node) doChildren(f func(cn *node) error) error {
for _, child := range n.children {
if err := f(child); err != nil {
return errors.Annotate(err, ErrNodeDoChildren, errorMessages)
}
}
return nil
} | go | func (n *node) doChildren(f func(cn *node) error) error {
for _, child := range n.children {
if err := f(child); err != nil {
return errors.Annotate(err, ErrNodeDoChildren, errorMessages)
}
}
return nil
} | [
"func",
"(",
"n",
"*",
"node",
")",
"doChildren",
"(",
"f",
"func",
"(",
"cn",
"*",
"node",
")",
"error",
")",
"error",
"{",
"for",
"_",
",",
"child",
":=",
"range",
"n",
".",
"children",
"{",
"if",
"err",
":=",
"f",
"(",
"child",
")",
";",
"... | // doChildren performs the passed function for all children. | [
"doChildren",
"performs",
"the",
"passed",
"function",
"for",
"all",
"children",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L302-L309 |
150,395 | tideland/golib | collections/tree.go | size | func (n *node) size() int {
l := 1
for _, child := range n.children {
l += child.size()
}
return l
} | go | func (n *node) size() int {
l := 1
for _, child := range n.children {
l += child.size()
}
return l
} | [
"func",
"(",
"n",
"*",
"node",
")",
"size",
"(",
")",
"int",
"{",
"l",
":=",
"1",
"\n",
"for",
"_",
",",
"child",
":=",
"range",
"n",
".",
"children",
"{",
"l",
"+=",
"child",
".",
"size",
"(",
")",
"\n",
"}",
"\n",
"return",
"l",
"\n",
"}"... | // size recursively calculates the size of the nodeContainer. | [
"size",
"recursively",
"calculates",
"the",
"size",
"of",
"the",
"nodeContainer",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L312-L318 |
150,396 | tideland/golib | collections/tree.go | deepCopy | func (n *node) deepCopy(c *nodeContainer, p *node) *node {
cn := &node{
container: c,
parent: p,
content: n.content.deepCopy(),
children: make([]*node, len(n.children)),
}
for i, child := range n.children {
cn.children[i] = child.deepCopy(c, cn)
}
return cn
} | go | func (n *node) deepCopy(c *nodeContainer, p *node) *node {
cn := &node{
container: c,
parent: p,
content: n.content.deepCopy(),
children: make([]*node, len(n.children)),
}
for i, child := range n.children {
cn.children[i] = child.deepCopy(c, cn)
}
return cn
} | [
"func",
"(",
"n",
"*",
"node",
")",
"deepCopy",
"(",
"c",
"*",
"nodeContainer",
",",
"p",
"*",
"node",
")",
"*",
"node",
"{",
"cn",
":=",
"&",
"node",
"{",
"container",
":",
"c",
",",
"parent",
":",
"p",
",",
"content",
":",
"n",
".",
"content"... | // deepCopy creates a copy of the node. | [
"deepCopy",
"creates",
"a",
"copy",
"of",
"the",
"node",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L321-L332 |
150,397 | tideland/golib | collections/tree.go | NewTree | func NewTree(v interface{}, duplicates bool) Tree {
return &tree{
container: newNodeContainer(justValue{v}, duplicates),
}
} | go | func NewTree(v interface{}, duplicates bool) Tree {
return &tree{
container: newNodeContainer(justValue{v}, duplicates),
}
} | [
"func",
"NewTree",
"(",
"v",
"interface",
"{",
"}",
",",
"duplicates",
"bool",
")",
"Tree",
"{",
"return",
"&",
"tree",
"{",
"container",
":",
"newNodeContainer",
"(",
"justValue",
"{",
"v",
"}",
",",
"duplicates",
")",
",",
"}",
"\n",
"}"
] | // NewTree creates a new tree with or without duplicate
// values for children. | [
"NewTree",
"creates",
"a",
"new",
"tree",
"with",
"or",
"without",
"duplicate",
"values",
"for",
"children",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L358-L362 |
150,398 | tideland/golib | collections/tree.go | At | func (t *tree) At(values ...interface{}) Changer {
var path []nodeContent
for _, value := range values {
path = append(path, justValue{value})
}
n, err := t.container.root.at(path...)
return &changer{n, err}
} | go | func (t *tree) At(values ...interface{}) Changer {
var path []nodeContent
for _, value := range values {
path = append(path, justValue{value})
}
n, err := t.container.root.at(path...)
return &changer{n, err}
} | [
"func",
"(",
"t",
"*",
"tree",
")",
"At",
"(",
"values",
"...",
"interface",
"{",
"}",
")",
"Changer",
"{",
"var",
"path",
"[",
"]",
"nodeContent",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"path",
"=",
"append",
"(",
"path",
... | // At implements the Tree interface. | [
"At",
"implements",
"the",
"Tree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L365-L372 |
150,399 | tideland/golib | collections/tree.go | Create | func (t *tree) Create(values ...interface{}) Changer {
var path []nodeContent
for _, value := range values {
path = append(path, justValue{value})
}
n, err := t.container.root.create(path...)
return &changer{n, err}
} | go | func (t *tree) Create(values ...interface{}) Changer {
var path []nodeContent
for _, value := range values {
path = append(path, justValue{value})
}
n, err := t.container.root.create(path...)
return &changer{n, err}
} | [
"func",
"(",
"t",
"*",
"tree",
")",
"Create",
"(",
"values",
"...",
"interface",
"{",
"}",
")",
"Changer",
"{",
"var",
"path",
"[",
"]",
"nodeContent",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"path",
"=",
"append",
"(",
"path"... | // Create implements the Tree interface. | [
"Create",
"implements",
"the",
"Tree",
"interface",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/tree.go#L380-L387 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.