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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,700 | araddon/qlbridge | exec/source.go | NewSource | func NewSource(ctx *plan.Context, p *plan.Source) (*Source, error) {
if p.Stmt == nil {
return nil, fmt.Errorf("must have from for Source")
}
if p.Conn == nil {
return nil, fmt.Errorf("Must have existing connection on Plan")
}
scanner, hasScanner := p.Conn.(schema.ConnScanner)
// Some sources require conte... | go | func NewSource(ctx *plan.Context, p *plan.Source) (*Source, error) {
if p.Stmt == nil {
return nil, fmt.Errorf("must have from for Source")
}
if p.Conn == nil {
return nil, fmt.Errorf("Must have existing connection on Plan")
}
scanner, hasScanner := p.Conn.(schema.ConnScanner)
// Some sources require conte... | [
"func",
"NewSource",
"(",
"ctx",
"*",
"plan",
".",
"Context",
",",
"p",
"*",
"plan",
".",
"Source",
")",
"(",
"*",
"Source",
",",
"error",
")",
"{",
"if",
"p",
".",
"Stmt",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\""... | // NewSource create a scanner to read from data source | [
"NewSource",
"create",
"a",
"scanner",
"to",
"read",
"from",
"data",
"source"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/source.go#L49-L84 |
20,701 | araddon/qlbridge | exec/results.go | NewResultExecWriter | func NewResultExecWriter(ctx *plan.Context) *ResultExecWriter {
m := &ResultExecWriter{
TaskBase: NewTaskBase(ctx),
}
m.Handler = func(ctx *plan.Context, msg schema.Message) bool {
switch mt := msg.(type) {
case *datasource.SqlDriverMessage:
if len(mt.Vals) > 1 {
m.lastInsertID = mt.Vals[0].(int64)
... | go | func NewResultExecWriter(ctx *plan.Context) *ResultExecWriter {
m := &ResultExecWriter{
TaskBase: NewTaskBase(ctx),
}
m.Handler = func(ctx *plan.Context, msg schema.Message) bool {
switch mt := msg.(type) {
case *datasource.SqlDriverMessage:
if len(mt.Vals) > 1 {
m.lastInsertID = mt.Vals[0].(int64)
... | [
"func",
"NewResultExecWriter",
"(",
"ctx",
"*",
"plan",
".",
"Context",
")",
"*",
"ResultExecWriter",
"{",
"m",
":=",
"&",
"ResultExecWriter",
"{",
"TaskBase",
":",
"NewTaskBase",
"(",
"ctx",
")",
",",
"}",
"\n",
"m",
".",
"Handler",
"=",
"func",
"(",
... | // NewResultExecWriter a result writer for exect task | [
"NewResultExecWriter",
"a",
"result",
"writer",
"for",
"exect",
"task"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/results.go#L55-L78 |
20,702 | araddon/qlbridge | exec/results.go | NewResultWriter | func NewResultWriter(ctx *plan.Context) *ResultWriter {
m := &ResultWriter{
TaskBase: NewTaskBase(ctx),
}
m.Handler = resultWrite(m)
return m
} | go | func NewResultWriter(ctx *plan.Context) *ResultWriter {
m := &ResultWriter{
TaskBase: NewTaskBase(ctx),
}
m.Handler = resultWrite(m)
return m
} | [
"func",
"NewResultWriter",
"(",
"ctx",
"*",
"plan",
".",
"Context",
")",
"*",
"ResultWriter",
"{",
"m",
":=",
"&",
"ResultWriter",
"{",
"TaskBase",
":",
"NewTaskBase",
"(",
"ctx",
")",
",",
"}",
"\n",
"m",
".",
"Handler",
"=",
"resultWrite",
"(",
"m",
... | // NewResultWriter for a plan | [
"NewResultWriter",
"for",
"a",
"plan"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/results.go#L81-L87 |
20,703 | araddon/qlbridge | exec/results.go | NewResultRows | func NewResultRows(ctx *plan.Context, cols []string) *ResultWriter {
stepper := NewTaskStepper(ctx)
m := &ResultWriter{
TaskBase: stepper.TaskBase,
cols: cols,
}
return m
} | go | func NewResultRows(ctx *plan.Context, cols []string) *ResultWriter {
stepper := NewTaskStepper(ctx)
m := &ResultWriter{
TaskBase: stepper.TaskBase,
cols: cols,
}
return m
} | [
"func",
"NewResultRows",
"(",
"ctx",
"*",
"plan",
".",
"Context",
",",
"cols",
"[",
"]",
"string",
")",
"*",
"ResultWriter",
"{",
"stepper",
":=",
"NewTaskStepper",
"(",
"ctx",
")",
"\n",
"m",
":=",
"&",
"ResultWriter",
"{",
"TaskBase",
":",
"stepper",
... | // NewResultRows a resultwriter | [
"NewResultRows",
"a",
"resultwriter"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/results.go#L90-L97 |
20,704 | araddon/qlbridge | exec/results.go | NewResultBuffer | func NewResultBuffer(ctx *plan.Context, writeTo *[]schema.Message) *ResultBuffer {
m := &ResultBuffer{
TaskBase: NewTaskBase(ctx),
}
m.Handler = func(ctx *plan.Context, msg schema.Message) bool {
*writeTo = append(*writeTo, msg)
//u.Infof("write to msgs: %v", len(*writeTo))
return true
}
return m
} | go | func NewResultBuffer(ctx *plan.Context, writeTo *[]schema.Message) *ResultBuffer {
m := &ResultBuffer{
TaskBase: NewTaskBase(ctx),
}
m.Handler = func(ctx *plan.Context, msg schema.Message) bool {
*writeTo = append(*writeTo, msg)
//u.Infof("write to msgs: %v", len(*writeTo))
return true
}
return m
} | [
"func",
"NewResultBuffer",
"(",
"ctx",
"*",
"plan",
".",
"Context",
",",
"writeTo",
"*",
"[",
"]",
"schema",
".",
"Message",
")",
"*",
"ResultBuffer",
"{",
"m",
":=",
"&",
"ResultBuffer",
"{",
"TaskBase",
":",
"NewTaskBase",
"(",
"ctx",
")",
",",
"}",
... | // NewResultBuffer create a result buffer to write temp tasks into results. | [
"NewResultBuffer",
"create",
"a",
"result",
"buffer",
"to",
"write",
"temp",
"tasks",
"into",
"results",
"."
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/results.go#L100-L110 |
20,705 | araddon/qlbridge | exec/results.go | Result | func (m *ResultExecWriter) Result() driver.Result {
return &qlbResult{m.lastInsertID, m.rowsAffected, m.err}
} | go | func (m *ResultExecWriter) Result() driver.Result {
return &qlbResult{m.lastInsertID, m.rowsAffected, m.err}
} | [
"func",
"(",
"m",
"*",
"ResultExecWriter",
")",
"Result",
"(",
")",
"driver",
".",
"Result",
"{",
"return",
"&",
"qlbResult",
"{",
"m",
".",
"lastInsertID",
",",
"m",
".",
"rowsAffected",
",",
"m",
".",
"err",
"}",
"\n",
"}"
] | // Result of exec task | [
"Result",
"of",
"exec",
"task"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/results.go#L113-L115 |
20,706 | araddon/qlbridge | datasource/files/scanner_json.go | NewJsonHandlerTables | func NewJsonHandlerTables(lh datasource.FileLineHandler, tables []string) FileHandler {
return &jsonHandlerTables{
FileHandler: &jsonHandler{lh},
tables: tables,
}
} | go | func NewJsonHandlerTables(lh datasource.FileLineHandler, tables []string) FileHandler {
return &jsonHandlerTables{
FileHandler: &jsonHandler{lh},
tables: tables,
}
} | [
"func",
"NewJsonHandlerTables",
"(",
"lh",
"datasource",
".",
"FileLineHandler",
",",
"tables",
"[",
"]",
"string",
")",
"FileHandler",
"{",
"return",
"&",
"jsonHandlerTables",
"{",
"FileHandler",
":",
"&",
"jsonHandler",
"{",
"lh",
"}",
",",
"tables",
":",
... | // NewJsonHandler creates a json file handler for paging new-line
// delimited rows of json file | [
"NewJsonHandler",
"creates",
"a",
"json",
"file",
"handler",
"for",
"paging",
"new",
"-",
"line",
"delimited",
"rows",
"of",
"json",
"file"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/files/scanner_json.go#L39-L44 |
20,707 | araddon/qlbridge | generators/elasticsearch/gentypes/gen.go | Numeric | func (f *FieldType) Numeric() bool {
if f.Type == value.NumberType || f.Type == value.IntType {
return true
}
// If a nested field with numeric values it's numeric
if f.Nested() {
switch f.Type {
case value.MapIntType, value.MapNumberType:
return true
}
}
// Nothing else is numeric
return false
} | go | func (f *FieldType) Numeric() bool {
if f.Type == value.NumberType || f.Type == value.IntType {
return true
}
// If a nested field with numeric values it's numeric
if f.Nested() {
switch f.Type {
case value.MapIntType, value.MapNumberType:
return true
}
}
// Nothing else is numeric
return false
} | [
"func",
"(",
"f",
"*",
"FieldType",
")",
"Numeric",
"(",
")",
"bool",
"{",
"if",
"f",
".",
"Type",
"==",
"value",
".",
"NumberType",
"||",
"f",
".",
"Type",
"==",
"value",
".",
"IntType",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"// If a nested fiel... | // Numeric returns true if field type has numeric values. | [
"Numeric",
"returns",
"true",
"if",
"field",
"type",
"has",
"numeric",
"values",
"."
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/generators/elasticsearch/gentypes/gen.go#L68-L83 |
20,708 | araddon/qlbridge | exec/sqldriver.go | Exec | func (m *qlbConn) Exec(query string, args []driver.Value) (driver.Result, error) {
stmt := &qlbStmt{conn: m, query: query}
return stmt.Exec(args)
} | go | func (m *qlbConn) Exec(query string, args []driver.Value) (driver.Result, error) {
stmt := &qlbStmt{conn: m, query: query}
return stmt.Exec(args)
} | [
"func",
"(",
"m",
"*",
"qlbConn",
")",
"Exec",
"(",
"query",
"string",
",",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"driver",
".",
"Result",
",",
"error",
")",
"{",
"stmt",
":=",
"&",
"qlbStmt",
"{",
"conn",
":",
"m",
",",
"query",
... | // Exec may return ErrSkip.
//
// Execer implementation. To be used for queries that do not return any rows
// such as Create Index, Insert, Upset, Delete etc | [
"Exec",
"may",
"return",
"ErrSkip",
".",
"Execer",
"implementation",
".",
"To",
"be",
"used",
"for",
"queries",
"that",
"do",
"not",
"return",
"any",
"rows",
"such",
"as",
"Create",
"Index",
"Insert",
"Upset",
"Delete",
"etc"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/sqldriver.go#L115-L118 |
20,709 | araddon/qlbridge | exec/sqldriver.go | Query | func (m *qlbConn) Query(query string, args []driver.Value) (driver.Rows, error) {
stmt := &qlbStmt{conn: m, query: query}
return stmt.Query(args)
} | go | func (m *qlbConn) Query(query string, args []driver.Value) (driver.Rows, error) {
stmt := &qlbStmt{conn: m, query: query}
return stmt.Query(args)
} | [
"func",
"(",
"m",
"*",
"qlbConn",
")",
"Query",
"(",
"query",
"string",
",",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"driver",
".",
"Rows",
",",
"error",
")",
"{",
"stmt",
":=",
"&",
"qlbStmt",
"{",
"conn",
":",
"m",
",",
"query",
"... | // Queryer implementation
// Query may return ErrSkip
// | [
"Queryer",
"implementation",
"Query",
"may",
"return",
"ErrSkip"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/sqldriver.go#L123-L126 |
20,710 | araddon/qlbridge | exec/sqldriver.go | Close | func (m *qlbStmt) Close() error {
if m.job != nil {
m.job.Close()
}
return nil
} | go | func (m *qlbStmt) Close() error {
if m.job != nil {
m.job.Close()
}
return nil
} | [
"func",
"(",
"m",
"*",
"qlbStmt",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"m",
".",
"job",
"!=",
"nil",
"{",
"m",
".",
"job",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close closes the statement.
//
// As of Go 1.1, a Stmt will not be closed if it's in use
// by any queries. | [
"Close",
"closes",
"the",
"statement",
".",
"As",
"of",
"Go",
"1",
".",
"1",
"a",
"Stmt",
"will",
"not",
"be",
"closed",
"if",
"it",
"s",
"in",
"use",
"by",
"any",
"queries",
"."
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/sqldriver.go#L174-L179 |
20,711 | araddon/qlbridge | exec/sqldriver.go | Exec | func (m *qlbStmt) Exec(args []driver.Value) (driver.Result, error) {
var err error
if len(args) > 0 {
m.query, err = queryArgsConvert(m.query, args)
if err != nil {
return nil, err
}
}
// Create a Job, which is Dag of Tasks that Run()
ctx := plan.NewContext(m.query)
ctx.Schema = m.conn.schema
job, err ... | go | func (m *qlbStmt) Exec(args []driver.Value) (driver.Result, error) {
var err error
if len(args) > 0 {
m.query, err = queryArgsConvert(m.query, args)
if err != nil {
return nil, err
}
}
// Create a Job, which is Dag of Tasks that Run()
ctx := plan.NewContext(m.query)
ctx.Schema = m.conn.schema
job, err ... | [
"func",
"(",
"m",
"*",
"qlbStmt",
")",
"Exec",
"(",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"driver",
".",
"Result",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"m",
".",
"que... | // Exec executes a query that doesn't return rows, such
// as an INSERT, UPDATE, DELETE | [
"Exec",
"executes",
"a",
"query",
"that",
"doesn",
"t",
"return",
"rows",
"such",
"as",
"an",
"INSERT",
"UPDATE",
"DELETE"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/sqldriver.go#L194-L225 |
20,712 | araddon/qlbridge | exec/sqldriver.go | Query | func (m *qlbStmt) Query(args []driver.Value) (driver.Rows, error) {
var err error
if len(args) > 0 {
m.query, err = queryArgsConvert(m.query, args)
if err != nil {
return nil, err
}
}
u.Debugf("query: %v", m.query)
// Create a Job, which is Dag of Tasks that Run()
ctx := plan.NewContext(m.query)
ctx.Sc... | go | func (m *qlbStmt) Query(args []driver.Value) (driver.Rows, error) {
var err error
if len(args) > 0 {
m.query, err = queryArgsConvert(m.query, args)
if err != nil {
return nil, err
}
}
u.Debugf("query: %v", m.query)
// Create a Job, which is Dag of Tasks that Run()
ctx := plan.NewContext(m.query)
ctx.Sc... | [
"func",
"(",
"m",
"*",
"qlbStmt",
")",
"Query",
"(",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"driver",
".",
"Rows",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"m",
".",
"quer... | // Query executes a query that may return rows, such as a SELECT | [
"Query",
"executes",
"a",
"query",
"that",
"may",
"return",
"rows",
"such",
"as",
"a",
"SELECT"
] | 23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac | https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/exec/sqldriver.go#L228-L280 |
20,713 | progrium/go-basher | basher.go | Application | func Application(
funcs map[string]func([]string),
scripts []string,
loader func(string) ([]byte, error),
copyEnv bool) {
bashDir, err := homedir.Expand("~/.basher")
if err != nil {
log.Fatal(err, "1")
}
bashPath := bashDir + "/bash"
if _, err := os.Stat(bashPath); os.IsNotExist(err) {
err = RestoreAsset... | go | func Application(
funcs map[string]func([]string),
scripts []string,
loader func(string) ([]byte, error),
copyEnv bool) {
bashDir, err := homedir.Expand("~/.basher")
if err != nil {
log.Fatal(err, "1")
}
bashPath := bashDir + "/bash"
if _, err := os.Stat(bashPath); os.IsNotExist(err) {
err = RestoreAsset... | [
"func",
"Application",
"(",
"funcs",
"map",
"[",
"string",
"]",
"func",
"(",
"[",
"]",
"string",
")",
",",
"scripts",
"[",
"]",
"string",
",",
"loader",
"func",
"(",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
",",
"copyEnv",
"bool",
... | // Application sets up a common entrypoint for a Bash application that
// uses exported Go functions. It uses the DEBUG environment variable
// to set debug on the Context, and SHELL for the Bash binary if it
// includes the string "bash". You can pass a loader function to use
// for the sourced files, and a boolean fo... | [
"Application",
"sets",
"up",
"a",
"common",
"entrypoint",
"for",
"a",
"Bash",
"application",
"that",
"uses",
"exported",
"Go",
"functions",
".",
"It",
"uses",
"the",
"DEBUG",
"environment",
"variable",
"to",
"set",
"debug",
"on",
"the",
"Context",
"and",
"SH... | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L39-L59 |
20,714 | progrium/go-basher | basher.go | ApplicationWithPath | func ApplicationWithPath(
funcs map[string]func([]string),
scripts []string,
loader func(string) ([]byte, error),
copyEnv bool,
bashPath string) {
bash, err := NewContext(bashPath, os.Getenv("DEBUG") != "")
if err != nil {
log.Fatal(err)
}
for name, fn := range funcs {
bash.ExportFunc(name, fn)
}
if bas... | go | func ApplicationWithPath(
funcs map[string]func([]string),
scripts []string,
loader func(string) ([]byte, error),
copyEnv bool,
bashPath string) {
bash, err := NewContext(bashPath, os.Getenv("DEBUG") != "")
if err != nil {
log.Fatal(err)
}
for name, fn := range funcs {
bash.ExportFunc(name, fn)
}
if bas... | [
"func",
"ApplicationWithPath",
"(",
"funcs",
"map",
"[",
"string",
"]",
"func",
"(",
"[",
"]",
"string",
")",
",",
"scripts",
"[",
"]",
"string",
",",
"loader",
"func",
"(",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
",",
"copyEnv",
"... | // ApplicationWithPath functions as Application does while also
// allowing the developer to modify the specified bashPath. | [
"ApplicationWithPath",
"functions",
"as",
"Application",
"does",
"while",
"also",
"allowing",
"the",
"developer",
"to",
"modify",
"the",
"specified",
"bashPath",
"."
] | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L63-L92 |
20,715 | progrium/go-basher | basher.go | NewContext | func NewContext(bashpath string, debug bool) (*Context, error) {
executable, err := osext.Executable()
if err != nil {
return nil, err
}
return &Context{
Debug: debug,
BashPath: bashpath,
SelfPath: executable,
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
scripts: make([][]byte, ... | go | func NewContext(bashpath string, debug bool) (*Context, error) {
executable, err := osext.Executable()
if err != nil {
return nil, err
}
return &Context{
Debug: debug,
BashPath: bashpath,
SelfPath: executable,
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
scripts: make([][]byte, ... | [
"func",
"NewContext",
"(",
"bashpath",
"string",
",",
"debug",
"bool",
")",
"(",
"*",
"Context",
",",
"error",
")",
"{",
"executable",
",",
"err",
":=",
"osext",
".",
"Executable",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // Creates and initializes a new Context that will use the given Bash executable.
// The debug mode will leave the produced temporary BASH_ENV file for inspection. | [
"Creates",
"and",
"initializes",
"a",
"new",
"Context",
"that",
"will",
"use",
"the",
"given",
"Bash",
"executable",
".",
"The",
"debug",
"mode",
"will",
"leave",
"the",
"produced",
"temporary",
"BASH_ENV",
"file",
"for",
"inspection",
"."
] | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L127-L143 |
20,716 | progrium/go-basher | basher.go | CopyEnv | func (c *Context) CopyEnv() {
c.Lock()
defer c.Unlock()
c.vars = append(c.vars, os.Environ()...)
} | go | func (c *Context) CopyEnv() {
c.Lock()
defer c.Unlock()
c.vars = append(c.vars, os.Environ()...)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"CopyEnv",
"(",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"vars",
"=",
"append",
"(",
"c",
".",
"vars",
",",
"os",
".",
"Environ",
"(",
")",
"..... | // Copies the current environment variables into the Context | [
"Copies",
"the",
"current",
"environment",
"variables",
"into",
"the",
"Context"
] | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L146-L150 |
20,717 | progrium/go-basher | basher.go | Source | func (c *Context) Source(filepath string, loader func(string) ([]byte, error)) error {
if loader == nil {
loader = ioutil.ReadFile
}
data, err := loader(filepath)
if err != nil {
return err
}
c.Lock()
defer c.Unlock()
c.scripts = append(c.scripts, data)
return nil
} | go | func (c *Context) Source(filepath string, loader func(string) ([]byte, error)) error {
if loader == nil {
loader = ioutil.ReadFile
}
data, err := loader(filepath)
if err != nil {
return err
}
c.Lock()
defer c.Unlock()
c.scripts = append(c.scripts, data)
return nil
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Source",
"(",
"filepath",
"string",
",",
"loader",
"func",
"(",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
")",
"error",
"{",
"if",
"loader",
"==",
"nil",
"{",
"loader",
"=",
"ioutil",
".",
"R... | // Source adds a shell script to the Context environment. The loader argument can be nil
// which means it will use ioutil.Readfile and load from disk, but it exists so you
// can use the Asset function produced by go-bindata when including script files in
// your Go binary. Calls to Source adds files to the environmen... | [
"Source",
"adds",
"a",
"shell",
"script",
"to",
"the",
"Context",
"environment",
".",
"The",
"loader",
"argument",
"can",
"be",
"nil",
"which",
"means",
"it",
"will",
"use",
"ioutil",
".",
"Readfile",
"and",
"load",
"from",
"disk",
"but",
"it",
"exists",
... | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L156-L168 |
20,718 | progrium/go-basher | basher.go | Export | func (c *Context) Export(name string, value string) {
c.Lock()
defer c.Unlock()
c.vars = append(c.vars, name+"="+value)
} | go | func (c *Context) Export(name string, value string) {
c.Lock()
defer c.Unlock()
c.vars = append(c.vars, name+"="+value)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Export",
"(",
"name",
"string",
",",
"value",
"string",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"vars",
"=",
"append",
"(",
"c",
".",
"vars",
"... | // Export adds an environment variable to the Context | [
"Export",
"adds",
"an",
"environment",
"variable",
"to",
"the",
"Context"
] | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L171-L175 |
20,719 | progrium/go-basher | basher.go | ExportFunc | func (c *Context) ExportFunc(name string, fn func([]string)) {
c.Lock()
defer c.Unlock()
c.funcs[name] = fn
} | go | func (c *Context) ExportFunc(name string, fn func([]string)) {
c.Lock()
defer c.Unlock()
c.funcs[name] = fn
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"ExportFunc",
"(",
"name",
"string",
",",
"fn",
"func",
"(",
"[",
"]",
"string",
")",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"funcs",
"[",
"nam... | // Registers a function with the Context that will produce a Bash function in the environment
// that calls back into your executable triggering the function defined as fn. | [
"Registers",
"a",
"function",
"with",
"the",
"Context",
"that",
"will",
"produce",
"a",
"Bash",
"function",
"in",
"the",
"environment",
"that",
"calls",
"back",
"into",
"your",
"executable",
"triggering",
"the",
"function",
"defined",
"as",
"fn",
"."
] | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L179-L183 |
20,720 | progrium/go-basher | basher.go | HandleFuncs | func (c *Context) HandleFuncs(args []string) bool {
for i, arg := range args {
if arg == ":::" && len(args) > i+1 {
c.Lock()
defer c.Unlock()
for cmd := range c.funcs {
if cmd == args[i+1] {
c.funcs[cmd](args[i+2:])
return true
}
}
return false
}
}
return false
} | go | func (c *Context) HandleFuncs(args []string) bool {
for i, arg := range args {
if arg == ":::" && len(args) > i+1 {
c.Lock()
defer c.Unlock()
for cmd := range c.funcs {
if cmd == args[i+1] {
c.funcs[cmd](args[i+2:])
return true
}
}
return false
}
}
return false
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"HandleFuncs",
"(",
"args",
"[",
"]",
"string",
")",
"bool",
"{",
"for",
"i",
",",
"arg",
":=",
"range",
"args",
"{",
"if",
"arg",
"==",
"\"",
"\"",
"&&",
"len",
"(",
"args",
")",
">",
"i",
"+",
"1",
"{"... | // Expects your os.Args to parse and handle any callbacks to Go functions registered with
// ExportFunc. You normally call this at the beginning of your program. If a registered
// function is found and handled, HandleFuncs will exit with the appropriate exit code for you. | [
"Expects",
"your",
"os",
".",
"Args",
"to",
"parse",
"and",
"handle",
"any",
"callbacks",
"to",
"Go",
"functions",
"registered",
"with",
"ExportFunc",
".",
"You",
"normally",
"call",
"this",
"at",
"the",
"beginning",
"of",
"your",
"program",
".",
"If",
"a"... | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/basher.go#L188-L203 |
20,721 | progrium/go-basher | bash_linux.go | MustAsset | func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
} | go | func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
} | [
"func",
"MustAsset",
"(",
"name",
"string",
")",
"[",
"]",
"byte",
"{",
"a",
",",
"err",
":=",
"Asset",
"(",
"name",
")",
"\n",
"if",
"(",
"err",
"!=",
"nil",
")",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"name",
"+",
"\"",
"\"",
"+",
"err",
".",
... | // MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables. | [
"MustAsset",
"is",
"like",
"Asset",
"but",
"panics",
"when",
"Asset",
"would",
"return",
"an",
"error",
".",
"It",
"simplifies",
"safe",
"initialization",
"of",
"global",
"variables",
"."
] | b674c80834b00079887df7847b9892f013c8bb54 | https://github.com/progrium/go-basher/blob/b674c80834b00079887df7847b9892f013c8bb54/bash_linux.go#L103-L110 |
20,722 | keybase/go-keychain | macos_1.10.go | createTrustedApplication | func createTrustedApplication(trustedApplication string) (C.CFTypeRef, error) {
var trustedApplicationCStr *C.char
if trustedApplication != "" {
trustedApplicationCStr = C.CString(trustedApplication)
defer C.free(unsafe.Pointer(trustedApplicationCStr))
}
var trustedApplicationRef C.SecTrustedApplicationRef
er... | go | func createTrustedApplication(trustedApplication string) (C.CFTypeRef, error) {
var trustedApplicationCStr *C.char
if trustedApplication != "" {
trustedApplicationCStr = C.CString(trustedApplication)
defer C.free(unsafe.Pointer(trustedApplicationCStr))
}
var trustedApplicationRef C.SecTrustedApplicationRef
er... | [
"func",
"createTrustedApplication",
"(",
"trustedApplication",
"string",
")",
"(",
"C",
".",
"CFTypeRef",
",",
"error",
")",
"{",
"var",
"trustedApplicationCStr",
"*",
"C",
".",
"char",
"\n",
"if",
"trustedApplication",
"!=",
"\"",
"\"",
"{",
"trustedApplication... | // createTrustedApplication creates a SecTrustedApplicationRef as a CFTypeRef.
// The returned SecTrustedApplicationRef, if non-nil, must be released via CFRelease. | [
"createTrustedApplication",
"creates",
"a",
"SecTrustedApplicationRef",
"as",
"a",
"CFTypeRef",
".",
"The",
"returned",
"SecTrustedApplicationRef",
"if",
"non",
"-",
"nil",
"must",
"be",
"released",
"via",
"CFRelease",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L81-L96 |
20,723 | keybase/go-keychain | macos_1.10.go | Convert | func (a Access) Convert() (C.CFTypeRef, error) {
return createAccess(a.Label, a.TrustedApplications)
} | go | func (a Access) Convert() (C.CFTypeRef, error) {
return createAccess(a.Label, a.TrustedApplications)
} | [
"func",
"(",
"a",
"Access",
")",
"Convert",
"(",
")",
"(",
"C",
".",
"CFTypeRef",
",",
"error",
")",
"{",
"return",
"createAccess",
"(",
"a",
".",
"Label",
",",
"a",
".",
"TrustedApplications",
")",
"\n",
"}"
] | // Convert converts Access to CFTypeRef.
// The returned CFTypeRef, if non-nil, must be released via CFRelease. | [
"Convert",
"converts",
"Access",
"to",
"CFTypeRef",
".",
"The",
"returned",
"CFTypeRef",
"if",
"non",
"-",
"nil",
"must",
"be",
"released",
"via",
"CFRelease",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L106-L108 |
20,724 | keybase/go-keychain | macos_1.10.go | SetAccess | func (k *Item) SetAccess(a *Access) {
if a != nil {
k.attr[AccessKey] = a
} else {
delete(k.attr, AccessKey)
}
} | go | func (k *Item) SetAccess(a *Access) {
if a != nil {
k.attr[AccessKey] = a
} else {
delete(k.attr, AccessKey)
}
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetAccess",
"(",
"a",
"*",
"Access",
")",
"{",
"if",
"a",
"!=",
"nil",
"{",
"k",
".",
"attr",
"[",
"AccessKey",
"]",
"=",
"a",
"\n",
"}",
"else",
"{",
"delete",
"(",
"k",
".",
"attr",
",",
"AccessKey",
")"... | // SetAccess sets Access on Item | [
"SetAccess",
"sets",
"Access",
"on",
"Item"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L111-L117 |
20,725 | keybase/go-keychain | macos_1.10.go | DeleteItemRef | func DeleteItemRef(ref C.CFTypeRef) error {
errCode := C.SecKeychainItemDelete(C.SecKeychainItemRef(ref))
return checkError(errCode)
} | go | func DeleteItemRef(ref C.CFTypeRef) error {
errCode := C.SecKeychainItemDelete(C.SecKeychainItemRef(ref))
return checkError(errCode)
} | [
"func",
"DeleteItemRef",
"(",
"ref",
"C",
".",
"CFTypeRef",
")",
"error",
"{",
"errCode",
":=",
"C",
".",
"SecKeychainItemDelete",
"(",
"C",
".",
"SecKeychainItemRef",
"(",
"ref",
")",
")",
"\n",
"return",
"checkError",
"(",
"errCode",
")",
"\n",
"}"
] | // DeleteItemRef deletes a keychain item reference. | [
"DeleteItemRef",
"deletes",
"a",
"keychain",
"item",
"reference",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L120-L123 |
20,726 | keybase/go-keychain | macos_1.10.go | NewKeychain | func NewKeychain(path string, password string) (Keychain, error) {
return newKeychain(path, password, false)
} | go | func NewKeychain(path string, password string) (Keychain, error) {
return newKeychain(path, password, false)
} | [
"func",
"NewKeychain",
"(",
"path",
"string",
",",
"password",
"string",
")",
"(",
"Keychain",
",",
"error",
")",
"{",
"return",
"newKeychain",
"(",
"path",
",",
"password",
",",
"false",
")",
"\n",
"}"
] | // NewKeychain creates a new keychain file with a password | [
"NewKeychain",
"creates",
"a",
"new",
"keychain",
"file",
"with",
"a",
"password"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L138-L140 |
20,727 | keybase/go-keychain | macos_1.10.go | Status | func (kc Keychain) Status() error {
// returns no error even if it doesn't exist
kref, err := openKeychainRef(kc.path)
if err != nil {
return err
}
defer C.CFRelease(C.CFTypeRef(kref))
var status C.SecKeychainStatus
return checkError(C.SecKeychainGetStatus(kref, &status))
} | go | func (kc Keychain) Status() error {
// returns no error even if it doesn't exist
kref, err := openKeychainRef(kc.path)
if err != nil {
return err
}
defer C.CFRelease(C.CFTypeRef(kref))
var status C.SecKeychainStatus
return checkError(C.SecKeychainGetStatus(kref, &status))
} | [
"func",
"(",
"kc",
"Keychain",
")",
"Status",
"(",
")",
"error",
"{",
"// returns no error even if it doesn't exist",
"kref",
",",
"err",
":=",
"openKeychainRef",
"(",
"kc",
".",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // Status returns the status of the keychain | [
"Status",
"returns",
"the",
"status",
"of",
"the",
"keychain"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L182-L192 |
20,728 | keybase/go-keychain | macos_1.10.go | openKeychainRef | func openKeychainRef(path string) (C.SecKeychainRef, error) {
pathName := C.CString(path)
defer C.free(unsafe.Pointer(pathName))
var kref C.SecKeychainRef
if err := checkError(C.SecKeychainOpen(pathName, &kref)); err != nil {
return 0, err
}
return kref, nil
} | go | func openKeychainRef(path string) (C.SecKeychainRef, error) {
pathName := C.CString(path)
defer C.free(unsafe.Pointer(pathName))
var kref C.SecKeychainRef
if err := checkError(C.SecKeychainOpen(pathName, &kref)); err != nil {
return 0, err
}
return kref, nil
} | [
"func",
"openKeychainRef",
"(",
"path",
"string",
")",
"(",
"C",
".",
"SecKeychainRef",
",",
"error",
")",
"{",
"pathName",
":=",
"C",
".",
"CString",
"(",
"path",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"pathName",
... | // The returned SecKeychainRef, if non-nil, must be released via CFRelease. | [
"The",
"returned",
"SecKeychainRef",
"if",
"non",
"-",
"nil",
"must",
"be",
"released",
"via",
"CFRelease",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L195-L205 |
20,729 | keybase/go-keychain | macos_1.10.go | UnlockAtPath | func UnlockAtPath(path string, password string) error {
kref, err := openKeychainRef(path)
defer Release(C.CFTypeRef(kref))
if err != nil {
return err
}
passwordRef := C.CString(password)
defer C.free(unsafe.Pointer(passwordRef))
return checkError(C.SecKeychainUnlock(kref, C.UInt32(len(password)), unsafe.Point... | go | func UnlockAtPath(path string, password string) error {
kref, err := openKeychainRef(path)
defer Release(C.CFTypeRef(kref))
if err != nil {
return err
}
passwordRef := C.CString(password)
defer C.free(unsafe.Pointer(passwordRef))
return checkError(C.SecKeychainUnlock(kref, C.UInt32(len(password)), unsafe.Point... | [
"func",
"UnlockAtPath",
"(",
"path",
"string",
",",
"password",
"string",
")",
"error",
"{",
"kref",
",",
"err",
":=",
"openKeychainRef",
"(",
"path",
")",
"\n",
"defer",
"Release",
"(",
"C",
".",
"CFTypeRef",
"(",
"kref",
")",
")",
"\n",
"if",
"err",
... | // UnlockAtPath unlocks keychain at path | [
"UnlockAtPath",
"unlocks",
"keychain",
"at",
"path"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L208-L217 |
20,730 | keybase/go-keychain | macos_1.10.go | LockAtPath | func LockAtPath(path string) error {
kref, err := openKeychainRef(path)
defer Release(C.CFTypeRef(kref))
if err != nil {
return err
}
return checkError(C.SecKeychainLock(kref))
} | go | func LockAtPath(path string) error {
kref, err := openKeychainRef(path)
defer Release(C.CFTypeRef(kref))
if err != nil {
return err
}
return checkError(C.SecKeychainLock(kref))
} | [
"func",
"LockAtPath",
"(",
"path",
"string",
")",
"error",
"{",
"kref",
",",
"err",
":=",
"openKeychainRef",
"(",
"path",
")",
"\n",
"defer",
"Release",
"(",
"C",
".",
"CFTypeRef",
"(",
"kref",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // LockAtPath locks keychain at path | [
"LockAtPath",
"locks",
"keychain",
"at",
"path"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L220-L227 |
20,731 | keybase/go-keychain | macos_1.10.go | Convert | func (kc Keychain) Convert() (C.CFTypeRef, error) {
keyRef, err := openKeychainRef(kc.path)
return C.CFTypeRef(keyRef), err
} | go | func (kc Keychain) Convert() (C.CFTypeRef, error) {
keyRef, err := openKeychainRef(kc.path)
return C.CFTypeRef(keyRef), err
} | [
"func",
"(",
"kc",
"Keychain",
")",
"Convert",
"(",
")",
"(",
"C",
".",
"CFTypeRef",
",",
"error",
")",
"{",
"keyRef",
",",
"err",
":=",
"openKeychainRef",
"(",
"kc",
".",
"path",
")",
"\n",
"return",
"C",
".",
"CFTypeRef",
"(",
"keyRef",
")",
",",... | // Convert Keychain to CFTypeRef.
// The returned CFTypeRef, if non-nil, must be released via CFRelease. | [
"Convert",
"Keychain",
"to",
"CFTypeRef",
".",
"The",
"returned",
"CFTypeRef",
"if",
"non",
"-",
"nil",
"must",
"be",
"released",
"via",
"CFRelease",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L236-L239 |
20,732 | keybase/go-keychain | macos_1.10.go | Convert | func (ka keychainArray) Convert() (C.CFTypeRef, error) {
var refs = make([]C.CFTypeRef, len(ka))
var err error
for idx, kc := range ka {
if refs[idx], err = kc.Convert(); err != nil {
// If we error trying to convert lets release any we converted before
for _, ref := range refs {
if ref != 0 {
Rele... | go | func (ka keychainArray) Convert() (C.CFTypeRef, error) {
var refs = make([]C.CFTypeRef, len(ka))
var err error
for idx, kc := range ka {
if refs[idx], err = kc.Convert(); err != nil {
// If we error trying to convert lets release any we converted before
for _, ref := range refs {
if ref != 0 {
Rele... | [
"func",
"(",
"ka",
"keychainArray",
")",
"Convert",
"(",
")",
"(",
"C",
".",
"CFTypeRef",
",",
"error",
")",
"{",
"var",
"refs",
"=",
"make",
"(",
"[",
"]",
"C",
".",
"CFTypeRef",
",",
"len",
"(",
"ka",
")",
")",
"\n",
"var",
"err",
"error",
"\... | // Convert the keychainArray to a CFTypeRef.
// The returned CFTypeRef, if non-nil, must be released via CFRelease. | [
"Convert",
"the",
"keychainArray",
"to",
"a",
"CFTypeRef",
".",
"The",
"returned",
"CFTypeRef",
"if",
"non",
"-",
"nil",
"must",
"be",
"released",
"via",
"CFRelease",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L245-L262 |
20,733 | keybase/go-keychain | macos_1.10.go | SetMatchSearchList | func (k *Item) SetMatchSearchList(karr ...Keychain) {
k.attr[MatchSearchListKey] = keychainArray(karr)
} | go | func (k *Item) SetMatchSearchList(karr ...Keychain) {
k.attr[MatchSearchListKey] = keychainArray(karr)
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetMatchSearchList",
"(",
"karr",
"...",
"Keychain",
")",
"{",
"k",
".",
"attr",
"[",
"MatchSearchListKey",
"]",
"=",
"keychainArray",
"(",
"karr",
")",
"\n",
"}"
] | // SetMatchSearchList sets match type on keychains | [
"SetMatchSearchList",
"sets",
"match",
"type",
"on",
"keychains"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_1.10.go#L265-L267 |
20,734 | keybase/go-keychain | bind/bind.go | AddGenericPassword | func AddGenericPassword(service string, account string, label string, password string, accessGroup string) error {
item := keychain.NewGenericPassword(service, account, label, []byte(password), accessGroup)
return keychain.AddItem(item)
} | go | func AddGenericPassword(service string, account string, label string, password string, accessGroup string) error {
item := keychain.NewGenericPassword(service, account, label, []byte(password), accessGroup)
return keychain.AddItem(item)
} | [
"func",
"AddGenericPassword",
"(",
"service",
"string",
",",
"account",
"string",
",",
"label",
"string",
",",
"password",
"string",
",",
"accessGroup",
"string",
")",
"error",
"{",
"item",
":=",
"keychain",
".",
"NewGenericPassword",
"(",
"service",
",",
"acc... | // AddGenericPassword adds generic password | [
"AddGenericPassword",
"adds",
"generic",
"password"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/bind/bind.go#L18-L21 |
20,735 | keybase/go-keychain | bind/bind.go | DeleteGenericPassword | func DeleteGenericPassword(service string, account string, accessGroup string) error {
item := keychain.NewItem()
item.SetSecClass(keychain.SecClassGenericPassword)
item.SetService(service)
item.SetAccount(account)
item.SetAccessGroup(accessGroup)
return keychain.DeleteItem(item)
} | go | func DeleteGenericPassword(service string, account string, accessGroup string) error {
item := keychain.NewItem()
item.SetSecClass(keychain.SecClassGenericPassword)
item.SetService(service)
item.SetAccount(account)
item.SetAccessGroup(accessGroup)
return keychain.DeleteItem(item)
} | [
"func",
"DeleteGenericPassword",
"(",
"service",
"string",
",",
"account",
"string",
",",
"accessGroup",
"string",
")",
"error",
"{",
"item",
":=",
"keychain",
".",
"NewItem",
"(",
")",
"\n",
"item",
".",
"SetSecClass",
"(",
"keychain",
".",
"SecClassGenericPa... | // DeleteGenericPassword deletes generic password | [
"DeleteGenericPassword",
"deletes",
"generic",
"password"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/bind/bind.go#L24-L31 |
20,736 | keybase/go-keychain | secretservice/secretservice.go | PromptAndWait | func (s *SecretService) PromptAndWait(prompt dbus.ObjectPath) (paths *dbus.Variant, err error) {
if prompt == NullPrompt {
return nil, nil
}
call := s.Obj(prompt).Call("org.freedesktop.Secret.Prompt.Prompt", NilFlags, "Keyring Prompt")
if call.Err != nil {
return nil, errors.Wrap(err, "failed to prompt")
}
fo... | go | func (s *SecretService) PromptAndWait(prompt dbus.ObjectPath) (paths *dbus.Variant, err error) {
if prompt == NullPrompt {
return nil, nil
}
call := s.Obj(prompt).Call("org.freedesktop.Secret.Prompt.Prompt", NilFlags, "Keyring Prompt")
if call.Err != nil {
return nil, errors.Wrap(err, "failed to prompt")
}
fo... | [
"func",
"(",
"s",
"*",
"SecretService",
")",
"PromptAndWait",
"(",
"prompt",
"dbus",
".",
"ObjectPath",
")",
"(",
"paths",
"*",
"dbus",
".",
"Variant",
",",
"err",
"error",
")",
"{",
"if",
"prompt",
"==",
"NullPrompt",
"{",
"return",
"nil",
",",
"nil",... | // PromptAndWait is NOT thread-safe. | [
"PromptAndWait",
"is",
"NOT",
"thread",
"-",
"safe",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/secretservice/secretservice.go#L266-L293 |
20,737 | keybase/go-keychain | datetime.go | CFDateToTime | func CFDateToTime(d C.CFDateRef) time.Time {
abs := C.CFDateGetAbsoluteTime(d)
s, ns := absoluteTimeToUnix(abs)
return time.Unix(s, ns)
} | go | func CFDateToTime(d C.CFDateRef) time.Time {
abs := C.CFDateGetAbsoluteTime(d)
s, ns := absoluteTimeToUnix(abs)
return time.Unix(s, ns)
} | [
"func",
"CFDateToTime",
"(",
"d",
"C",
".",
"CFDateRef",
")",
"time",
".",
"Time",
"{",
"abs",
":=",
"C",
".",
"CFDateGetAbsoluteTime",
"(",
"d",
")",
"\n",
"s",
",",
"ns",
":=",
"absoluteTimeToUnix",
"(",
"abs",
")",
"\n",
"return",
"time",
".",
"Un... | // CFDateToTime will convert the given CFDateRef to a time.Time. | [
"CFDateToTime",
"will",
"convert",
"the",
"given",
"CFDateRef",
"to",
"a",
"time",
".",
"Time",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/datetime.go#L67-L71 |
20,738 | keybase/go-keychain | corefoundation_1.10.go | CFDataToBytes | func CFDataToBytes(cfData C.CFDataRef) ([]byte, error) {
return C.GoBytes(unsafe.Pointer(C.CFDataGetBytePtr(cfData)), C.int(C.CFDataGetLength(cfData))), nil
} | go | func CFDataToBytes(cfData C.CFDataRef) ([]byte, error) {
return C.GoBytes(unsafe.Pointer(C.CFDataGetBytePtr(cfData)), C.int(C.CFDataGetLength(cfData))), nil
} | [
"func",
"CFDataToBytes",
"(",
"cfData",
"C",
".",
"CFDataRef",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"C",
".",
"GoBytes",
"(",
"unsafe",
".",
"Pointer",
"(",
"C",
".",
"CFDataGetBytePtr",
"(",
"cfData",
")",
")",
",",
"C",
"... | // CFDataToBytes converts CFData to bytes. | [
"CFDataToBytes",
"converts",
"CFData",
"to",
"bytes",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/corefoundation_1.10.go#L63-L65 |
20,739 | keybase/go-keychain | corefoundation_1.10.go | CFStringToString | func CFStringToString(s C.CFStringRef) string {
p := C.CFStringGetCStringPtr(s, C.kCFStringEncodingUTF8)
if p != nil {
return C.GoString(p)
}
length := C.CFStringGetLength(s)
if length == 0 {
return ""
}
maxBufLen := C.CFStringGetMaximumSizeForEncoding(length, C.kCFStringEncodingUTF8)
if maxBufLen == 0 {
... | go | func CFStringToString(s C.CFStringRef) string {
p := C.CFStringGetCStringPtr(s, C.kCFStringEncodingUTF8)
if p != nil {
return C.GoString(p)
}
length := C.CFStringGetLength(s)
if length == 0 {
return ""
}
maxBufLen := C.CFStringGetMaximumSizeForEncoding(length, C.kCFStringEncodingUTF8)
if maxBufLen == 0 {
... | [
"func",
"CFStringToString",
"(",
"s",
"C",
".",
"CFStringRef",
")",
"string",
"{",
"p",
":=",
"C",
".",
"CFStringGetCStringPtr",
"(",
"s",
",",
"C",
".",
"kCFStringEncodingUTF8",
")",
"\n",
"if",
"p",
"!=",
"nil",
"{",
"return",
"C",
".",
"GoString",
"... | // CFStringToString converts a CFStringRef to a string. | [
"CFStringToString",
"converts",
"a",
"CFStringRef",
"to",
"a",
"string",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/corefoundation_1.10.go#L122-L139 |
20,740 | keybase/go-keychain | corefoundation_1.10.go | CFTypeDescription | func CFTypeDescription(ref C.CFTypeRef) string {
typeID := C.CFGetTypeID(ref)
typeDesc := C.CFCopyTypeIDDescription(typeID)
defer Release(C.CFTypeRef(typeDesc))
return CFStringToString(typeDesc)
} | go | func CFTypeDescription(ref C.CFTypeRef) string {
typeID := C.CFGetTypeID(ref)
typeDesc := C.CFCopyTypeIDDescription(typeID)
defer Release(C.CFTypeRef(typeDesc))
return CFStringToString(typeDesc)
} | [
"func",
"CFTypeDescription",
"(",
"ref",
"C",
".",
"CFTypeRef",
")",
"string",
"{",
"typeID",
":=",
"C",
".",
"CFGetTypeID",
"(",
"ref",
")",
"\n",
"typeDesc",
":=",
"C",
".",
"CFCopyTypeIDDescription",
"(",
"typeID",
")",
"\n",
"defer",
"Release",
"(",
... | // CFTypeDescription returns type string for CFTypeRef. | [
"CFTypeDescription",
"returns",
"type",
"string",
"for",
"CFTypeRef",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/corefoundation_1.10.go#L226-L231 |
20,741 | keybase/go-keychain | corefoundation_1.10.go | Convert | func Convert(ref C.CFTypeRef) (interface{}, error) {
typeID := C.CFGetTypeID(ref)
if typeID == C.CFStringGetTypeID() {
return CFStringToString(C.CFStringRef(ref)), nil
} else if typeID == C.CFDictionaryGetTypeID() {
return ConvertCFDictionary(C.CFDictionaryRef(ref))
} else if typeID == C.CFArrayGetTypeID() {
... | go | func Convert(ref C.CFTypeRef) (interface{}, error) {
typeID := C.CFGetTypeID(ref)
if typeID == C.CFStringGetTypeID() {
return CFStringToString(C.CFStringRef(ref)), nil
} else if typeID == C.CFDictionaryGetTypeID() {
return ConvertCFDictionary(C.CFDictionaryRef(ref))
} else if typeID == C.CFArrayGetTypeID() {
... | [
"func",
"Convert",
"(",
"ref",
"C",
".",
"CFTypeRef",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"typeID",
":=",
"C",
".",
"CFGetTypeID",
"(",
"ref",
")",
"\n",
"if",
"typeID",
"==",
"C",
".",
"CFStringGetTypeID",
"(",
")",
"{",
"retu... | // Convert converts a CFTypeRef to a go instance. | [
"Convert",
"converts",
"a",
"CFTypeRef",
"to",
"a",
"go",
"instance",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/corefoundation_1.10.go#L234-L267 |
20,742 | keybase/go-keychain | util.go | RandBytes | func RandBytes(length int) ([]byte, error) {
buf := make([]byte, length)
if _, err := randRead(buf); err != nil {
return nil, err
}
return buf, nil
} | go | func RandBytes(length int) ([]byte, error) {
buf := make([]byte, length)
if _, err := randRead(buf); err != nil {
return nil, err
}
return buf, nil
} | [
"func",
"RandBytes",
"(",
"length",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"randRead",
"(",
"buf",
")",
";",
"err",
"!=",
"... | // RandBytes returns random bytes of length | [
"RandBytes",
"returns",
"random",
"bytes",
"of",
"length"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/util.go#L25-L31 |
20,743 | keybase/go-keychain | corefoundation_pre1.10.go | CFDictionaryToMap | func CFDictionaryToMap(cfDict C.CFDictionaryRef) (m map[C.CFTypeRef]uintptr) {
count := C.CFDictionaryGetCount(cfDict)
if count > 0 {
keys := make([]C.CFTypeRef, count)
values := make([]C.CFTypeRef, count)
C.CFDictionaryGetKeysAndValues(cfDict, (*unsafe.Pointer)(&keys[0]), (*unsafe.Pointer)(&values[0]))
m = m... | go | func CFDictionaryToMap(cfDict C.CFDictionaryRef) (m map[C.CFTypeRef]uintptr) {
count := C.CFDictionaryGetCount(cfDict)
if count > 0 {
keys := make([]C.CFTypeRef, count)
values := make([]C.CFTypeRef, count)
C.CFDictionaryGetKeysAndValues(cfDict, (*unsafe.Pointer)(&keys[0]), (*unsafe.Pointer)(&values[0]))
m = m... | [
"func",
"CFDictionaryToMap",
"(",
"cfDict",
"C",
".",
"CFDictionaryRef",
")",
"(",
"m",
"map",
"[",
"C",
".",
"CFTypeRef",
"]",
"uintptr",
")",
"{",
"count",
":=",
"C",
".",
"CFDictionaryGetCount",
"(",
"cfDict",
")",
"\n",
"if",
"count",
">",
"0",
"{"... | // CFDictionaryToMap converts CFDictionaryRef to a map. | [
"CFDictionaryToMap",
"converts",
"CFDictionaryRef",
"to",
"a",
"map",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/corefoundation_pre1.10.go#L72-L86 |
20,744 | keybase/go-keychain | corefoundation_pre1.10.go | CFArrayToArray | func CFArrayToArray(cfArray C.CFArrayRef) (a []C.CFTypeRef) {
count := C.CFArrayGetCount(cfArray)
if count > 0 {
a = make([]C.CFTypeRef, count)
C.CFArrayGetValues(cfArray, C.CFRange{0, count}, (*unsafe.Pointer)(&a[0]))
}
return
} | go | func CFArrayToArray(cfArray C.CFArrayRef) (a []C.CFTypeRef) {
count := C.CFArrayGetCount(cfArray)
if count > 0 {
a = make([]C.CFTypeRef, count)
C.CFArrayGetValues(cfArray, C.CFRange{0, count}, (*unsafe.Pointer)(&a[0]))
}
return
} | [
"func",
"CFArrayToArray",
"(",
"cfArray",
"C",
".",
"CFArrayRef",
")",
"(",
"a",
"[",
"]",
"C",
".",
"CFTypeRef",
")",
"{",
"count",
":=",
"C",
".",
"CFArrayGetCount",
"(",
"cfArray",
")",
"\n",
"if",
"count",
">",
"0",
"{",
"a",
"=",
"make",
"(",
... | // CFArrayToArray converts a CFArrayRef to an array of CFTypes. | [
"CFArrayToArray",
"converts",
"a",
"CFArrayRef",
"to",
"an",
"array",
"of",
"CFTypes",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/corefoundation_pre1.10.go#L142-L149 |
20,745 | keybase/go-keychain | keychain_1.10.go | SetSecClass | func (k *Item) SetSecClass(sc SecClass) {
k.attr[SecClassKey] = secClassTypeRef[sc]
} | go | func (k *Item) SetSecClass(sc SecClass) {
k.attr[SecClassKey] = secClassTypeRef[sc]
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetSecClass",
"(",
"sc",
"SecClass",
")",
"{",
"k",
".",
"attr",
"[",
"SecClassKey",
"]",
"=",
"secClassTypeRef",
"[",
"sc",
"]",
"\n",
"}"
] | // SetSecClass sets the security class | [
"SetSecClass",
"sets",
"the",
"security",
"class"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L211-L213 |
20,746 | keybase/go-keychain | keychain_1.10.go | SetString | func (k *Item) SetString(key string, s string) {
if s != "" {
k.attr[key] = s
} else {
delete(k.attr, key)
}
} | go | func (k *Item) SetString(key string, s string) {
if s != "" {
k.attr[key] = s
} else {
delete(k.attr, key)
}
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetString",
"(",
"key",
"string",
",",
"s",
"string",
")",
"{",
"if",
"s",
"!=",
"\"",
"\"",
"{",
"k",
".",
"attr",
"[",
"key",
"]",
"=",
"s",
"\n",
"}",
"else",
"{",
"delete",
"(",
"k",
".",
"attr",
","... | // SetString sets a string attibute for a string key | [
"SetString",
"sets",
"a",
"string",
"attibute",
"for",
"a",
"string",
"key"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L216-L222 |
20,747 | keybase/go-keychain | keychain_1.10.go | SetData | func (k *Item) SetData(b []byte) {
if b != nil {
k.attr[DataKey] = b
} else {
delete(k.attr, DataKey)
}
} | go | func (k *Item) SetData(b []byte) {
if b != nil {
k.attr[DataKey] = b
} else {
delete(k.attr, DataKey)
}
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetData",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"if",
"b",
"!=",
"nil",
"{",
"k",
".",
"attr",
"[",
"DataKey",
"]",
"=",
"b",
"\n",
"}",
"else",
"{",
"delete",
"(",
"k",
".",
"attr",
",",
"DataKey",
")",... | // SetData sets the data attribute | [
"SetData",
"sets",
"the",
"data",
"attribute"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L245-L251 |
20,748 | keybase/go-keychain | keychain_1.10.go | SetSynchronizable | func (k *Item) SetSynchronizable(sync Synchronizable) {
if sync != SynchronizableDefault {
k.attr[SynchronizableKey] = syncTypeRef[sync]
} else {
delete(k.attr, SynchronizableKey)
}
} | go | func (k *Item) SetSynchronizable(sync Synchronizable) {
if sync != SynchronizableDefault {
k.attr[SynchronizableKey] = syncTypeRef[sync]
} else {
delete(k.attr, SynchronizableKey)
}
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetSynchronizable",
"(",
"sync",
"Synchronizable",
")",
"{",
"if",
"sync",
"!=",
"SynchronizableDefault",
"{",
"k",
".",
"attr",
"[",
"SynchronizableKey",
"]",
"=",
"syncTypeRef",
"[",
"sync",
"]",
"\n",
"}",
"else",
... | // SetSynchronizable sets the synchronizable attribute | [
"SetSynchronizable",
"sets",
"the",
"synchronizable",
"attribute"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L259-L265 |
20,749 | keybase/go-keychain | keychain_1.10.go | SetAccessible | func (k *Item) SetAccessible(accessible Accessible) {
if accessible != AccessibleDefault {
k.attr[AccessibleKey] = accessibleTypeRef[accessible]
} else {
delete(k.attr, AccessibleKey)
}
} | go | func (k *Item) SetAccessible(accessible Accessible) {
if accessible != AccessibleDefault {
k.attr[AccessibleKey] = accessibleTypeRef[accessible]
} else {
delete(k.attr, AccessibleKey)
}
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetAccessible",
"(",
"accessible",
"Accessible",
")",
"{",
"if",
"accessible",
"!=",
"AccessibleDefault",
"{",
"k",
".",
"attr",
"[",
"AccessibleKey",
"]",
"=",
"accessibleTypeRef",
"[",
"accessible",
"]",
"\n",
"}",
"e... | // SetAccessible sets the accessible attribute | [
"SetAccessible",
"sets",
"the",
"accessible",
"attribute"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L268-L274 |
20,750 | keybase/go-keychain | keychain_1.10.go | SetMatchLimit | func (k *Item) SetMatchLimit(matchLimit MatchLimit) {
if matchLimit != MatchLimitDefault {
k.attr[MatchLimitKey] = matchTypeRef[matchLimit]
} else {
delete(k.attr, MatchLimitKey)
}
} | go | func (k *Item) SetMatchLimit(matchLimit MatchLimit) {
if matchLimit != MatchLimitDefault {
k.attr[MatchLimitKey] = matchTypeRef[matchLimit]
} else {
delete(k.attr, MatchLimitKey)
}
} | [
"func",
"(",
"k",
"*",
"Item",
")",
"SetMatchLimit",
"(",
"matchLimit",
"MatchLimit",
")",
"{",
"if",
"matchLimit",
"!=",
"MatchLimitDefault",
"{",
"k",
".",
"attr",
"[",
"MatchLimitKey",
"]",
"=",
"matchTypeRef",
"[",
"matchLimit",
"]",
"\n",
"}",
"else",... | // SetMatchLimit sets the match limit | [
"SetMatchLimit",
"sets",
"the",
"match",
"limit"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L277-L283 |
20,751 | keybase/go-keychain | keychain_1.10.go | NewGenericPassword | func NewGenericPassword(service string, account string, label string, data []byte, accessGroup string) Item {
item := NewItem()
item.SetSecClass(SecClassGenericPassword)
item.SetService(service)
item.SetAccount(account)
item.SetLabel(label)
item.SetData(data)
item.SetAccessGroup(accessGroup)
return item
} | go | func NewGenericPassword(service string, account string, label string, data []byte, accessGroup string) Item {
item := NewItem()
item.SetSecClass(SecClassGenericPassword)
item.SetService(service)
item.SetAccount(account)
item.SetLabel(label)
item.SetData(data)
item.SetAccessGroup(accessGroup)
return item
} | [
"func",
"NewGenericPassword",
"(",
"service",
"string",
",",
"account",
"string",
",",
"label",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"accessGroup",
"string",
")",
"Item",
"{",
"item",
":=",
"NewItem",
"(",
")",
"\n",
"item",
".",
"SetSecClass",
... | // NewGenericPassword creates a generic password item with the default keychain. This is a convenience method. | [
"NewGenericPassword",
"creates",
"a",
"generic",
"password",
"item",
"with",
"the",
"default",
"keychain",
".",
"This",
"is",
"a",
"convenience",
"method",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L306-L315 |
20,752 | keybase/go-keychain | keychain_1.10.go | AddItem | func AddItem(item Item) error {
cfDict, err := ConvertMapToCFDictionary(item.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDict))
errCode := C.SecItemAdd(cfDict, nil)
err = checkError(errCode)
return err
} | go | func AddItem(item Item) error {
cfDict, err := ConvertMapToCFDictionary(item.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDict))
errCode := C.SecItemAdd(cfDict, nil)
err = checkError(errCode)
return err
} | [
"func",
"AddItem",
"(",
"item",
"Item",
")",
"error",
"{",
"cfDict",
",",
"err",
":=",
"ConvertMapToCFDictionary",
"(",
"item",
".",
"attr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"Release",
"(",
"C",
"."... | // AddItem adds a Item to a Keychain | [
"AddItem",
"adds",
"a",
"Item",
"to",
"a",
"Keychain"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L318-L328 |
20,753 | keybase/go-keychain | keychain_1.10.go | UpdateItem | func UpdateItem(queryItem Item, updateItem Item) error {
cfDict, err := ConvertMapToCFDictionary(queryItem.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDict))
cfDictUpdate, err := ConvertMapToCFDictionary(updateItem.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDictUpdate)... | go | func UpdateItem(queryItem Item, updateItem Item) error {
cfDict, err := ConvertMapToCFDictionary(queryItem.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDict))
cfDictUpdate, err := ConvertMapToCFDictionary(updateItem.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDictUpdate)... | [
"func",
"UpdateItem",
"(",
"queryItem",
"Item",
",",
"updateItem",
"Item",
")",
"error",
"{",
"cfDict",
",",
"err",
":=",
"ConvertMapToCFDictionary",
"(",
"queryItem",
".",
"attr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n... | // UpdateItem updates the queryItem with the parameters from updateItem | [
"UpdateItem",
"updates",
"the",
"queryItem",
"with",
"the",
"parameters",
"from",
"updateItem"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L331-L345 |
20,754 | keybase/go-keychain | keychain_1.10.go | DeleteGenericPasswordItem | func DeleteGenericPasswordItem(service string, account string) error {
item := NewItem()
item.SetSecClass(SecClassGenericPassword)
item.SetService(service)
item.SetAccount(account)
return DeleteItem(item)
} | go | func DeleteGenericPasswordItem(service string, account string) error {
item := NewItem()
item.SetSecClass(SecClassGenericPassword)
item.SetService(service)
item.SetAccount(account)
return DeleteItem(item)
} | [
"func",
"DeleteGenericPasswordItem",
"(",
"service",
"string",
",",
"account",
"string",
")",
"error",
"{",
"item",
":=",
"NewItem",
"(",
")",
"\n",
"item",
".",
"SetSecClass",
"(",
"SecClassGenericPassword",
")",
"\n",
"item",
".",
"SetService",
"(",
"service... | // DeleteGenericPasswordItem removes a generic password item. | [
"DeleteGenericPasswordItem",
"removes",
"a",
"generic",
"password",
"item",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L465-L471 |
20,755 | keybase/go-keychain | keychain_1.10.go | DeleteItem | func DeleteItem(item Item) error {
cfDict, err := ConvertMapToCFDictionary(item.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDict))
errCode := C.SecItemDelete(cfDict)
return checkError(errCode)
} | go | func DeleteItem(item Item) error {
cfDict, err := ConvertMapToCFDictionary(item.attr)
if err != nil {
return err
}
defer Release(C.CFTypeRef(cfDict))
errCode := C.SecItemDelete(cfDict)
return checkError(errCode)
} | [
"func",
"DeleteItem",
"(",
"item",
"Item",
")",
"error",
"{",
"cfDict",
",",
"err",
":=",
"ConvertMapToCFDictionary",
"(",
"item",
".",
"attr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"Release",
"(",
"C",
... | // DeleteItem removes a Item | [
"DeleteItem",
"removes",
"a",
"Item"
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L474-L483 |
20,756 | keybase/go-keychain | keychain_1.10.go | GetGenericPasswordAccounts | func GetGenericPasswordAccounts(service string) ([]string, error) {
query := NewItem()
query.SetSecClass(SecClassGenericPassword)
query.SetService(service)
query.SetMatchLimit(MatchLimitAll)
query.SetReturnAttributes(true)
results, err := QueryItem(query)
if err != nil {
return nil, err
}
accounts := make([... | go | func GetGenericPasswordAccounts(service string) ([]string, error) {
query := NewItem()
query.SetSecClass(SecClassGenericPassword)
query.SetService(service)
query.SetMatchLimit(MatchLimitAll)
query.SetReturnAttributes(true)
results, err := QueryItem(query)
if err != nil {
return nil, err
}
accounts := make([... | [
"func",
"GetGenericPasswordAccounts",
"(",
"service",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"query",
":=",
"NewItem",
"(",
")",
"\n",
"query",
".",
"SetSecClass",
"(",
"SecClassGenericPassword",
")",
"\n",
"query",
".",
"SetService"... | // GetGenericPasswordAccounts returns generic password accounts for service. This is a convenience method. | [
"GetGenericPasswordAccounts",
"returns",
"generic",
"password",
"accounts",
"for",
"service",
".",
"This",
"is",
"a",
"convenience",
"method",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L491-L508 |
20,757 | keybase/go-keychain | keychain_1.10.go | GetGenericPassword | func GetGenericPassword(service string, account string, label string, accessGroup string) ([]byte, error) {
query := NewItem()
query.SetSecClass(SecClassGenericPassword)
query.SetService(service)
query.SetAccount(account)
query.SetLabel(label)
query.SetAccessGroup(accessGroup)
query.SetMatchLimit(MatchLimitOne)
... | go | func GetGenericPassword(service string, account string, label string, accessGroup string) ([]byte, error) {
query := NewItem()
query.SetSecClass(SecClassGenericPassword)
query.SetService(service)
query.SetAccount(account)
query.SetLabel(label)
query.SetAccessGroup(accessGroup)
query.SetMatchLimit(MatchLimitOne)
... | [
"func",
"GetGenericPassword",
"(",
"service",
"string",
",",
"account",
"string",
",",
"label",
"string",
",",
"accessGroup",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"query",
":=",
"NewItem",
"(",
")",
"\n",
"query",
".",
"SetSecCla... | // GetGenericPassword returns password data for service and account. This is a convenience method.
// If item is not found returns nil, nil. | [
"GetGenericPassword",
"returns",
"password",
"data",
"for",
"service",
"and",
"account",
".",
"This",
"is",
"a",
"convenience",
"method",
".",
"If",
"item",
"is",
"not",
"found",
"returns",
"nil",
"nil",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_1.10.go#L512-L532 |
20,758 | keybase/go-keychain | macos_pre1.10.go | createAccess | func createAccess(label string, trustedApplications []string) (C.CFTypeRef, error) {
var err error
var labelRef C.CFStringRef
if labelRef, err = StringToCFString(label); err != nil {
return nil, err
}
defer C.CFRelease(C.CFTypeRef(labelRef))
var trustedApplicationsArray C.CFArrayRef
if trustedApplications != ... | go | func createAccess(label string, trustedApplications []string) (C.CFTypeRef, error) {
var err error
var labelRef C.CFStringRef
if labelRef, err = StringToCFString(label); err != nil {
return nil, err
}
defer C.CFRelease(C.CFTypeRef(labelRef))
var trustedApplicationsArray C.CFArrayRef
if trustedApplications != ... | [
"func",
"createAccess",
"(",
"label",
"string",
",",
"trustedApplications",
"[",
"]",
"string",
")",
"(",
"C",
".",
"CFTypeRef",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"labelRef",
"C",
".",
"CFStringRef",
"\n",
"if",
"labelRef",
",",... | // createAccess creates a SecAccessRef as CFTypeRef.
// The returned SecAccessRef, if non-nil, must be released via CFRelease. | [
"createAccess",
"creates",
"a",
"SecAccessRef",
"as",
"CFTypeRef",
".",
"The",
"returned",
"SecAccessRef",
"if",
"non",
"-",
"nil",
"must",
"be",
"released",
"via",
"CFRelease",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/macos_pre1.10.go#L41-L79 |
20,759 | keybase/go-keychain | keychain_pre1.10.go | QueryItemRef | func QueryItemRef(item Item) (C.CFTypeRef, error) {
cfDict, err := ConvertMapToCFDictionary(item.attr)
if err != nil {
return nil, err
}
defer Release(C.CFTypeRef(cfDict))
var resultsRef C.CFTypeRef
errCode := C.SecItemCopyMatching(cfDict, &resultsRef)
if Error(errCode) == ErrorItemNotFound {
return nil, ni... | go | func QueryItemRef(item Item) (C.CFTypeRef, error) {
cfDict, err := ConvertMapToCFDictionary(item.attr)
if err != nil {
return nil, err
}
defer Release(C.CFTypeRef(cfDict))
var resultsRef C.CFTypeRef
errCode := C.SecItemCopyMatching(cfDict, &resultsRef)
if Error(errCode) == ErrorItemNotFound {
return nil, ni... | [
"func",
"QueryItemRef",
"(",
"item",
"Item",
")",
"(",
"C",
".",
"CFTypeRef",
",",
"error",
")",
"{",
"cfDict",
",",
"err",
":=",
"ConvertMapToCFDictionary",
"(",
"item",
".",
"attr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"e... | // QueryItemRef returns query result as CFTypeRef. You must release it when you are done. | [
"QueryItemRef",
"returns",
"query",
"result",
"as",
"CFTypeRef",
".",
"You",
"must",
"release",
"it",
"when",
"you",
"are",
"done",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_pre1.10.go#L389-L406 |
20,760 | keybase/go-keychain | keychain_pre1.10.go | QueryItem | func QueryItem(item Item) ([]QueryResult, error) {
resultsRef, err := QueryItemRef(item)
if err != nil {
return nil, err
}
if resultsRef == nil {
return nil, nil
}
defer Release(resultsRef)
results := make([]QueryResult, 0, 1)
typeID := C.CFGetTypeID(resultsRef)
if typeID == C.CFArrayGetTypeID() {
arr ... | go | func QueryItem(item Item) ([]QueryResult, error) {
resultsRef, err := QueryItemRef(item)
if err != nil {
return nil, err
}
if resultsRef == nil {
return nil, nil
}
defer Release(resultsRef)
results := make([]QueryResult, 0, 1)
typeID := C.CFGetTypeID(resultsRef)
if typeID == C.CFArrayGetTypeID() {
arr ... | [
"func",
"QueryItem",
"(",
"item",
"Item",
")",
"(",
"[",
"]",
"QueryResult",
",",
"error",
")",
"{",
"resultsRef",
",",
"err",
":=",
"QueryItemRef",
"(",
"item",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n"... | // QueryItem returns a list of query results. | [
"QueryItem",
"returns",
"a",
"list",
"of",
"query",
"results",
"."
] | 8441f7257eb146425dca61e269cdb931987e6455 | https://github.com/keybase/go-keychain/blob/8441f7257eb146425dca61e269cdb931987e6455/keychain_pre1.10.go#L409-L454 |
20,761 | hashicorp/net-rpc-msgpackrpc | msgpackrpc.go | NewClientCodec | func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec {
return NewCodec(true, true, conn)
} | go | func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec {
return NewCodec(true, true, conn)
} | [
"func",
"NewClientCodec",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"rpc",
".",
"ClientCodec",
"{",
"return",
"NewCodec",
"(",
"true",
",",
"true",
",",
"conn",
")",
"\n",
"}"
] | // NewClientCodec returns a new rpc.ClientCodec using MessagePack-RPC on conn. | [
"NewClientCodec",
"returns",
"a",
"new",
"rpc",
".",
"ClientCodec",
"using",
"MessagePack",
"-",
"RPC",
"on",
"conn",
"."
] | a14192a58a694c123d8fe5481d4a4727d6ae82f3 | https://github.com/hashicorp/net-rpc-msgpackrpc/blob/a14192a58a694c123d8fe5481d4a4727d6ae82f3/msgpackrpc.go#L28-L30 |
20,762 | hashicorp/net-rpc-msgpackrpc | msgpackrpc.go | NewServerCodec | func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec {
return NewCodec(true, true, conn)
} | go | func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec {
return NewCodec(true, true, conn)
} | [
"func",
"NewServerCodec",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"rpc",
".",
"ServerCodec",
"{",
"return",
"NewCodec",
"(",
"true",
",",
"true",
",",
"conn",
")",
"\n",
"}"
] | // NewServerCodec returns a new rpc.ServerCodec using MessagePack-RPC on conn. | [
"NewServerCodec",
"returns",
"a",
"new",
"rpc",
".",
"ServerCodec",
"using",
"MessagePack",
"-",
"RPC",
"on",
"conn",
"."
] | a14192a58a694c123d8fe5481d4a4727d6ae82f3 | https://github.com/hashicorp/net-rpc-msgpackrpc/blob/a14192a58a694c123d8fe5481d4a4727d6ae82f3/msgpackrpc.go#L33-L35 |
20,763 | hashicorp/net-rpc-msgpackrpc | codec.go | NewCodec | func NewCodec(bufReads, bufWrites bool, conn io.ReadWriteCloser) *MsgpackCodec {
return NewCodecFromHandle(bufReads, bufWrites, conn, msgpackHandle)
} | go | func NewCodec(bufReads, bufWrites bool, conn io.ReadWriteCloser) *MsgpackCodec {
return NewCodecFromHandle(bufReads, bufWrites, conn, msgpackHandle)
} | [
"func",
"NewCodec",
"(",
"bufReads",
",",
"bufWrites",
"bool",
",",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"*",
"MsgpackCodec",
"{",
"return",
"NewCodecFromHandle",
"(",
"bufReads",
",",
"bufWrites",
",",
"conn",
",",
"msgpackHandle",
")",
"\n",
"}"
] | // NewCodec returns a MsgpackCodec that can be used as either a Client or Server
// rpc Codec using a default handle. It also provides controls for enabling and
// disabling buffering for both reads and writes. | [
"NewCodec",
"returns",
"a",
"MsgpackCodec",
"that",
"can",
"be",
"used",
"as",
"either",
"a",
"Client",
"or",
"Server",
"rpc",
"Codec",
"using",
"a",
"default",
"handle",
".",
"It",
"also",
"provides",
"controls",
"for",
"enabling",
"and",
"disabling",
"buff... | a14192a58a694c123d8fe5481d4a4727d6ae82f3 | https://github.com/hashicorp/net-rpc-msgpackrpc/blob/a14192a58a694c123d8fe5481d4a4727d6ae82f3/codec.go#L32-L34 |
20,764 | hashicorp/net-rpc-msgpackrpc | codec.go | NewCodecFromHandle | func NewCodecFromHandle(bufReads, bufWrites bool, conn io.ReadWriteCloser,
h *codec.MsgpackHandle) *MsgpackCodec {
cc := &MsgpackCodec{
conn: conn,
}
if bufReads {
cc.bufR = bufio.NewReader(conn)
cc.dec = codec.NewDecoder(cc.bufR, h)
} else {
cc.dec = codec.NewDecoder(cc.conn, h)
}
if bufWrites {
cc.bu... | go | func NewCodecFromHandle(bufReads, bufWrites bool, conn io.ReadWriteCloser,
h *codec.MsgpackHandle) *MsgpackCodec {
cc := &MsgpackCodec{
conn: conn,
}
if bufReads {
cc.bufR = bufio.NewReader(conn)
cc.dec = codec.NewDecoder(cc.bufR, h)
} else {
cc.dec = codec.NewDecoder(cc.conn, h)
}
if bufWrites {
cc.bu... | [
"func",
"NewCodecFromHandle",
"(",
"bufReads",
",",
"bufWrites",
"bool",
",",
"conn",
"io",
".",
"ReadWriteCloser",
",",
"h",
"*",
"codec",
".",
"MsgpackHandle",
")",
"*",
"MsgpackCodec",
"{",
"cc",
":=",
"&",
"MsgpackCodec",
"{",
"conn",
":",
"conn",
",",... | // NewCodecFromHandle returns a MsgpackCodec that can be used as either a Client
// or Server rpc Codec using the passed handle. It also provides controls for
// enabling and disabling buffering for both reads and writes. | [
"NewCodecFromHandle",
"returns",
"a",
"MsgpackCodec",
"that",
"can",
"be",
"used",
"as",
"either",
"a",
"Client",
"or",
"Server",
"rpc",
"Codec",
"using",
"the",
"passed",
"handle",
".",
"It",
"also",
"provides",
"controls",
"for",
"enabling",
"and",
"disablin... | a14192a58a694c123d8fe5481d4a4727d6ae82f3 | https://github.com/hashicorp/net-rpc-msgpackrpc/blob/a14192a58a694c123d8fe5481d4a4727d6ae82f3/codec.go#L39-L57 |
20,765 | googleapis/gax-go | v2/header.go | XGoogHeader | func XGoogHeader(keyval ...string) string {
if len(keyval) == 0 {
return ""
}
if len(keyval)%2 != 0 {
panic("gax.Header: odd argument count")
}
var buf bytes.Buffer
for i := 0; i < len(keyval); i += 2 {
buf.WriteByte(' ')
buf.WriteString(keyval[i])
buf.WriteByte('/')
buf.WriteString(keyval[i+1])
}
r... | go | func XGoogHeader(keyval ...string) string {
if len(keyval) == 0 {
return ""
}
if len(keyval)%2 != 0 {
panic("gax.Header: odd argument count")
}
var buf bytes.Buffer
for i := 0; i < len(keyval); i += 2 {
buf.WriteByte(' ')
buf.WriteString(keyval[i])
buf.WriteByte('/')
buf.WriteString(keyval[i+1])
}
r... | [
"func",
"XGoogHeader",
"(",
"keyval",
"...",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"keyval",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"len",
"(",
"keyval",
")",
"%",
"2",
"!=",
"0",
"{",
"panic",
"(",
"\"",
"\... | // XGoogHeader is for use by the Google Cloud Libraries only.
//
// XGoogHeader formats key-value pairs.
// The resulting string is suitable for x-goog-api-client header. | [
"XGoogHeader",
"is",
"for",
"use",
"by",
"the",
"Google",
"Cloud",
"Libraries",
"only",
".",
"XGoogHeader",
"formats",
"key",
"-",
"value",
"pairs",
".",
"The",
"resulting",
"string",
"is",
"suitable",
"for",
"x",
"-",
"goog",
"-",
"api",
"-",
"client",
... | 9e334198cafcf7b281a9673424d7b1c3a02ebd50 | https://github.com/googleapis/gax-go/blob/9e334198cafcf7b281a9673424d7b1c3a02ebd50/v2/header.go#L38-L53 |
20,766 | googleapis/gax-go | v2/invoke.go | invoke | func invoke(ctx context.Context, call APICall, settings CallSettings, sp sleeper) error {
var retryer Retryer
for {
err := call(ctx, settings)
if err == nil {
return nil
}
if settings.Retry == nil {
return err
}
// Never retry permanent certificate errors. (e.x. if ca-certificates
// are not insta... | go | func invoke(ctx context.Context, call APICall, settings CallSettings, sp sleeper) error {
var retryer Retryer
for {
err := call(ctx, settings)
if err == nil {
return nil
}
if settings.Retry == nil {
return err
}
// Never retry permanent certificate errors. (e.x. if ca-certificates
// are not insta... | [
"func",
"invoke",
"(",
"ctx",
"context",
".",
"Context",
",",
"call",
"APICall",
",",
"settings",
"CallSettings",
",",
"sp",
"sleeper",
")",
"error",
"{",
"var",
"retryer",
"Retryer",
"\n",
"for",
"{",
"err",
":=",
"call",
"(",
"ctx",
",",
"settings",
... | // invoke implements Invoke, taking an additional sleeper argument for testing. | [
"invoke",
"implements",
"Invoke",
"taking",
"an",
"additional",
"sleeper",
"argument",
"for",
"testing",
"."
] | 9e334198cafcf7b281a9673424d7b1c3a02ebd50 | https://github.com/googleapis/gax-go/blob/9e334198cafcf7b281a9673424d7b1c3a02ebd50/v2/invoke.go#L67-L99 |
20,767 | googleapis/gax-go | v2/call_option.go | Pause | func (bo *Backoff) Pause() time.Duration {
if bo.Initial == 0 {
bo.Initial = time.Second
}
if bo.cur == 0 {
bo.cur = bo.Initial
}
if bo.Max == 0 {
bo.Max = 30 * time.Second
}
if bo.Multiplier < 1 {
bo.Multiplier = 2
}
// Select a duration between 1ns and the current max. It might seem
// counterintuit... | go | func (bo *Backoff) Pause() time.Duration {
if bo.Initial == 0 {
bo.Initial = time.Second
}
if bo.cur == 0 {
bo.cur = bo.Initial
}
if bo.Max == 0 {
bo.Max = 30 * time.Second
}
if bo.Multiplier < 1 {
bo.Multiplier = 2
}
// Select a duration between 1ns and the current max. It might seem
// counterintuit... | [
"func",
"(",
"bo",
"*",
"Backoff",
")",
"Pause",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"bo",
".",
"Initial",
"==",
"0",
"{",
"bo",
".",
"Initial",
"=",
"time",
".",
"Second",
"\n",
"}",
"\n",
"if",
"bo",
".",
"cur",
"==",
"0",
"{",
"b... | // Pause returns the next time.Duration that the caller should use to backoff. | [
"Pause",
"returns",
"the",
"next",
"time",
".",
"Duration",
"that",
"the",
"caller",
"should",
"use",
"to",
"backoff",
"."
] | 9e334198cafcf7b281a9673424d7b1c3a02ebd50 | https://github.com/googleapis/gax-go/blob/9e334198cafcf7b281a9673424d7b1c3a02ebd50/v2/call_option.go#L117-L140 |
20,768 | googleapis/gax-go | v2/call_option.go | WithGRPCOptions | func WithGRPCOptions(opt ...grpc.CallOption) CallOption {
return grpcOpt(append([]grpc.CallOption(nil), opt...))
} | go | func WithGRPCOptions(opt ...grpc.CallOption) CallOption {
return grpcOpt(append([]grpc.CallOption(nil), opt...))
} | [
"func",
"WithGRPCOptions",
"(",
"opt",
"...",
"grpc",
".",
"CallOption",
")",
"CallOption",
"{",
"return",
"grpcOpt",
"(",
"append",
"(",
"[",
"]",
"grpc",
".",
"CallOption",
"(",
"nil",
")",
",",
"opt",
"...",
")",
")",
"\n",
"}"
] | // WithGRPCOptions allows passing gRPC call options during client creation. | [
"WithGRPCOptions",
"allows",
"passing",
"gRPC",
"call",
"options",
"during",
"client",
"creation",
"."
] | 9e334198cafcf7b281a9673424d7b1c3a02ebd50 | https://github.com/googleapis/gax-go/blob/9e334198cafcf7b281a9673424d7b1c3a02ebd50/v2/call_option.go#L149-L151 |
20,769 | bsm/redis-lock | lock.go | Run | func Run(client RedisClient, key string, opts *Options, handler func()) error {
locker, err := Obtain(client, key, opts)
if err != nil {
return err
}
sem := make(chan struct{})
go func() {
handler()
close(sem)
}()
select {
case <-sem:
return locker.Unlock()
case <-time.After(locker.opts.LockTimeout):... | go | func Run(client RedisClient, key string, opts *Options, handler func()) error {
locker, err := Obtain(client, key, opts)
if err != nil {
return err
}
sem := make(chan struct{})
go func() {
handler()
close(sem)
}()
select {
case <-sem:
return locker.Unlock()
case <-time.After(locker.opts.LockTimeout):... | [
"func",
"Run",
"(",
"client",
"RedisClient",
",",
"key",
"string",
",",
"opts",
"*",
"Options",
",",
"handler",
"func",
"(",
")",
")",
"error",
"{",
"locker",
",",
"err",
":=",
"Obtain",
"(",
"client",
",",
"key",
",",
"opts",
")",
"\n",
"if",
"err... | // Run runs a callback handler with a Redis lock. It may return ErrLockNotObtained
// if a lock was not successfully acquired. | [
"Run",
"runs",
"a",
"callback",
"handler",
"with",
"a",
"Redis",
"lock",
".",
"It",
"may",
"return",
"ErrLockNotObtained",
"if",
"a",
"lock",
"was",
"not",
"successfully",
"acquired",
"."
] | a411a6dd9badb340368e4e97ad9de11ea0e63811 | https://github.com/bsm/redis-lock/blob/a411a6dd9badb340368e4e97ad9de11ea0e63811/lock.go#L49-L67 |
20,770 | bsm/redis-lock | lock.go | New | func New(client RedisClient, key string, opts *Options) *Locker {
var o Options
if opts != nil {
o = *opts
}
o.normalize()
return &Locker{client: client, key: key, opts: o}
} | go | func New(client RedisClient, key string, opts *Options) *Locker {
var o Options
if opts != nil {
o = *opts
}
o.normalize()
return &Locker{client: client, key: key, opts: o}
} | [
"func",
"New",
"(",
"client",
"RedisClient",
",",
"key",
"string",
",",
"opts",
"*",
"Options",
")",
"*",
"Locker",
"{",
"var",
"o",
"Options",
"\n",
"if",
"opts",
"!=",
"nil",
"{",
"o",
"=",
"*",
"opts",
"\n",
"}",
"\n",
"o",
".",
"normalize",
"... | // New creates a new distributed locker on a given key. | [
"New",
"creates",
"a",
"new",
"distributed",
"locker",
"on",
"a",
"given",
"key",
"."
] | a411a6dd9badb340368e4e97ad9de11ea0e63811 | https://github.com/bsm/redis-lock/blob/a411a6dd9badb340368e4e97ad9de11ea0e63811/lock.go#L82-L90 |
20,771 | bsm/redis-lock | lock.go | IsLocked | func (l *Locker) IsLocked() bool {
l.mutex.Lock()
locked := l.token != ""
l.mutex.Unlock()
return locked
} | go | func (l *Locker) IsLocked() bool {
l.mutex.Lock()
locked := l.token != ""
l.mutex.Unlock()
return locked
} | [
"func",
"(",
"l",
"*",
"Locker",
")",
"IsLocked",
"(",
")",
"bool",
"{",
"l",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"locked",
":=",
"l",
".",
"token",
"!=",
"\"",
"\"",
"\n",
"l",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
... | // IsLocked returns true if a lock is still being held. | [
"IsLocked",
"returns",
"true",
"if",
"a",
"lock",
"is",
"still",
"being",
"held",
"."
] | a411a6dd9badb340368e4e97ad9de11ea0e63811 | https://github.com/bsm/redis-lock/blob/a411a6dd9badb340368e4e97ad9de11ea0e63811/lock.go#L93-L99 |
20,772 | bsm/redis-lock | lock.go | LockWithContext | func (l *Locker) LockWithContext(ctx context.Context) (bool, error) {
l.mutex.Lock()
defer l.mutex.Unlock()
if l.token != "" {
return l.refresh(ctx)
}
return l.create(ctx)
} | go | func (l *Locker) LockWithContext(ctx context.Context) (bool, error) {
l.mutex.Lock()
defer l.mutex.Unlock()
if l.token != "" {
return l.refresh(ctx)
}
return l.create(ctx)
} | [
"func",
"(",
"l",
"*",
"Locker",
")",
"LockWithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"bool",
",",
"error",
")",
"{",
"l",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",... | // LockWithContext is like Lock but allows to pass an additional context which allows cancelling
// lock attempts prematurely. | [
"LockWithContext",
"is",
"like",
"Lock",
"but",
"allows",
"to",
"pass",
"an",
"additional",
"context",
"which",
"allows",
"cancelling",
"lock",
"attempts",
"prematurely",
"."
] | a411a6dd9badb340368e4e97ad9de11ea0e63811 | https://github.com/bsm/redis-lock/blob/a411a6dd9badb340368e4e97ad9de11ea0e63811/lock.go#L108-L116 |
20,773 | bsm/redis-lock | lock.go | Unlock | func (l *Locker) Unlock() error {
l.mutex.Lock()
err := l.release()
l.mutex.Unlock()
return err
} | go | func (l *Locker) Unlock() error {
l.mutex.Lock()
err := l.release()
l.mutex.Unlock()
return err
} | [
"func",
"(",
"l",
"*",
"Locker",
")",
"Unlock",
"(",
")",
"error",
"{",
"l",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"err",
":=",
"l",
".",
"release",
"(",
")",
"\n",
"l",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"err",
"\n... | // Unlock releases the lock | [
"Unlock",
"releases",
"the",
"lock"
] | a411a6dd9badb340368e4e97ad9de11ea0e63811 | https://github.com/bsm/redis-lock/blob/a411a6dd9badb340368e4e97ad9de11ea0e63811/lock.go#L119-L125 |
20,774 | satyrius/gonx | entry.go | Field | func (entry *Entry) Field(name string) (value string, err error) {
value, ok := entry.fields[name]
if !ok {
err = fmt.Errorf("field '%v' does not found in record %+v", name, *entry)
}
return
} | go | func (entry *Entry) Field(name string) (value string, err error) {
value, ok := entry.fields[name]
if !ok {
err = fmt.Errorf("field '%v' does not found in record %+v", name, *entry)
}
return
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"Field",
"(",
"name",
"string",
")",
"(",
"value",
"string",
",",
"err",
"error",
")",
"{",
"value",
",",
"ok",
":=",
"entry",
".",
"fields",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fm... | // Field returns an entry field value by name or empty string and error if it
// does not exist. | [
"Field",
"returns",
"an",
"entry",
"field",
"value",
"by",
"name",
"or",
"empty",
"string",
"and",
"error",
"if",
"it",
"does",
"not",
"exist",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L35-L41 |
20,775 | satyrius/gonx | entry.go | FloatField | func (entry *Entry) FloatField(name string) (value float64, err error) {
tmp, err := entry.Field(name)
if err == nil {
value, err = strconv.ParseFloat(tmp, 64)
}
return
} | go | func (entry *Entry) FloatField(name string) (value float64, err error) {
tmp, err := entry.Field(name)
if err == nil {
value, err = strconv.ParseFloat(tmp, 64)
}
return
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"FloatField",
"(",
"name",
"string",
")",
"(",
"value",
"float64",
",",
"err",
"error",
")",
"{",
"tmp",
",",
"err",
":=",
"entry",
".",
"Field",
"(",
"name",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"val... | // FloatField returns an entry field value as float64. Return nil if field does not exist
// and conversion error if cannot cast a type. | [
"FloatField",
"returns",
"an",
"entry",
"field",
"value",
"as",
"float64",
".",
"Return",
"nil",
"if",
"field",
"does",
"not",
"exist",
"and",
"conversion",
"error",
"if",
"cannot",
"cast",
"a",
"type",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L45-L51 |
20,776 | satyrius/gonx | entry.go | SetField | func (entry *Entry) SetField(name string, value string) {
entry.fields[name] = value
} | go | func (entry *Entry) SetField(name string, value string) {
entry.fields[name] = value
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"SetField",
"(",
"name",
"string",
",",
"value",
"string",
")",
"{",
"entry",
".",
"fields",
"[",
"name",
"]",
"=",
"value",
"\n",
"}"
] | // SetField sets the value of a field | [
"SetField",
"sets",
"the",
"value",
"of",
"a",
"field"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L54-L56 |
20,777 | satyrius/gonx | entry.go | SetFloatField | func (entry *Entry) SetFloatField(name string, value float64) {
entry.SetField(name, strconv.FormatFloat(value, 'f', 2, 64))
} | go | func (entry *Entry) SetFloatField(name string, value float64) {
entry.SetField(name, strconv.FormatFloat(value, 'f', 2, 64))
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"SetFloatField",
"(",
"name",
"string",
",",
"value",
"float64",
")",
"{",
"entry",
".",
"SetField",
"(",
"name",
",",
"strconv",
".",
"FormatFloat",
"(",
"value",
",",
"'f'",
",",
"2",
",",
"64",
")",
")",
... | // SetFloatField is a Float field value setter. It accepts float64, but still store it as a
// string in the same fields map. The precision is 2, its enough for log
// parsing task | [
"SetFloatField",
"is",
"a",
"Float",
"field",
"value",
"setter",
".",
"It",
"accepts",
"float64",
"but",
"still",
"store",
"it",
"as",
"a",
"string",
"in",
"the",
"same",
"fields",
"map",
".",
"The",
"precision",
"is",
"2",
"its",
"enough",
"for",
"log",... | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L61-L63 |
20,778 | satyrius/gonx | entry.go | SetUintField | func (entry *Entry) SetUintField(name string, value uint64) {
entry.SetField(name, strconv.FormatUint(uint64(value), 10))
} | go | func (entry *Entry) SetUintField(name string, value uint64) {
entry.SetField(name, strconv.FormatUint(uint64(value), 10))
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"SetUintField",
"(",
"name",
"string",
",",
"value",
"uint64",
")",
"{",
"entry",
".",
"SetField",
"(",
"name",
",",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"value",
")",
",",
"10",
")",
")",
"\n",
... | // SetUintField is a Integer field value setter. It accepts float64, but still store it as a
// string in the same fields map. | [
"SetUintField",
"is",
"a",
"Integer",
"field",
"value",
"setter",
".",
"It",
"accepts",
"float64",
"but",
"still",
"store",
"it",
"as",
"a",
"string",
"in",
"the",
"same",
"fields",
"map",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L67-L69 |
20,779 | satyrius/gonx | entry.go | Merge | func (entry *Entry) Merge(merge *Entry) {
for name, value := range merge.fields {
entry.SetField(name, value)
}
} | go | func (entry *Entry) Merge(merge *Entry) {
for name, value := range merge.fields {
entry.SetField(name, value)
}
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"Merge",
"(",
"merge",
"*",
"Entry",
")",
"{",
"for",
"name",
",",
"value",
":=",
"range",
"merge",
".",
"fields",
"{",
"entry",
".",
"SetField",
"(",
"name",
",",
"value",
")",
"\n",
"}",
"\n",
"}"
] | // Merge two entries by updating values for master entry with given. | [
"Merge",
"two",
"entries",
"by",
"updating",
"values",
"for",
"master",
"entry",
"with",
"given",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L72-L76 |
20,780 | satyrius/gonx | entry.go | FieldsHash | func (entry *Entry) FieldsHash(fields []string) string {
var key []string
for _, name := range fields {
value, err := entry.Field(name)
if err != nil {
value = "NULL"
}
key = append(key, fmt.Sprintf("'%v'=%v", name, value))
}
return strings.Join(key, ";")
} | go | func (entry *Entry) FieldsHash(fields []string) string {
var key []string
for _, name := range fields {
value, err := entry.Field(name)
if err != nil {
value = "NULL"
}
key = append(key, fmt.Sprintf("'%v'=%v", name, value))
}
return strings.Join(key, ";")
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"FieldsHash",
"(",
"fields",
"[",
"]",
"string",
")",
"string",
"{",
"var",
"key",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"fields",
"{",
"value",
",",
"err",
":=",
"entry",
".",
... | // FieldsHash returns a hash of all fields | [
"FieldsHash",
"returns",
"a",
"hash",
"of",
"all",
"fields"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L79-L89 |
20,781 | satyrius/gonx | entry.go | Partial | func (entry *Entry) Partial(fields []string) *Entry {
partial := NewEmptyEntry()
for _, name := range fields {
value, _ := entry.Field(name)
partial.SetField(name, value)
}
return partial
} | go | func (entry *Entry) Partial(fields []string) *Entry {
partial := NewEmptyEntry()
for _, name := range fields {
value, _ := entry.Field(name)
partial.SetField(name, value)
}
return partial
} | [
"func",
"(",
"entry",
"*",
"Entry",
")",
"Partial",
"(",
"fields",
"[",
"]",
"string",
")",
"*",
"Entry",
"{",
"partial",
":=",
"NewEmptyEntry",
"(",
")",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"fields",
"{",
"value",
",",
"_",
":=",
"entry"... | // Partial returns a partial field entry with the specified fields | [
"Partial",
"returns",
"a",
"partial",
"field",
"entry",
"with",
"the",
"specified",
"fields"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/entry.go#L92-L99 |
20,782 | satyrius/gonx | reader.go | NewReader | func NewReader(logFile io.Reader, format string) *Reader {
return NewParserReader(logFile, NewParser(format))
} | go | func NewReader(logFile io.Reader, format string) *Reader {
return NewParserReader(logFile, NewParser(format))
} | [
"func",
"NewReader",
"(",
"logFile",
"io",
".",
"Reader",
",",
"format",
"string",
")",
"*",
"Reader",
"{",
"return",
"NewParserReader",
"(",
"logFile",
",",
"NewParser",
"(",
"format",
")",
")",
"\n",
"}"
] | // NewReader creates a reader for a custom log format. | [
"NewReader",
"creates",
"a",
"reader",
"for",
"a",
"custom",
"log",
"format",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reader.go#L15-L17 |
20,783 | satyrius/gonx | reader.go | NewParserReader | func NewParserReader(logFile io.Reader, parser StringParser) *Reader {
return &Reader{
file: logFile,
parser: parser,
}
} | go | func NewParserReader(logFile io.Reader, parser StringParser) *Reader {
return &Reader{
file: logFile,
parser: parser,
}
} | [
"func",
"NewParserReader",
"(",
"logFile",
"io",
".",
"Reader",
",",
"parser",
"StringParser",
")",
"*",
"Reader",
"{",
"return",
"&",
"Reader",
"{",
"file",
":",
"logFile",
",",
"parser",
":",
"parser",
",",
"}",
"\n",
"}"
] | // NewParserReader creates a reader with the given parser | [
"NewParserReader",
"creates",
"a",
"reader",
"with",
"the",
"given",
"parser"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reader.go#L20-L25 |
20,784 | satyrius/gonx | reader.go | NewNginxReader | func NewNginxReader(logFile io.Reader, nginxConf io.Reader, formatName string) (reader *Reader, err error) {
parser, err := NewNginxParser(nginxConf, formatName)
if err != nil {
return nil, err
}
reader = &Reader{
file: logFile,
parser: parser,
}
return
} | go | func NewNginxReader(logFile io.Reader, nginxConf io.Reader, formatName string) (reader *Reader, err error) {
parser, err := NewNginxParser(nginxConf, formatName)
if err != nil {
return nil, err
}
reader = &Reader{
file: logFile,
parser: parser,
}
return
} | [
"func",
"NewNginxReader",
"(",
"logFile",
"io",
".",
"Reader",
",",
"nginxConf",
"io",
".",
"Reader",
",",
"formatName",
"string",
")",
"(",
"reader",
"*",
"Reader",
",",
"err",
"error",
")",
"{",
"parser",
",",
"err",
":=",
"NewNginxParser",
"(",
"nginx... | // NewNginxReader creates a reader for the nginx log format. Nginx config parser will be used
// to get particular format from the conf file. | [
"NewNginxReader",
"creates",
"a",
"reader",
"for",
"the",
"nginx",
"log",
"format",
".",
"Nginx",
"config",
"parser",
"will",
"be",
"used",
"to",
"get",
"particular",
"format",
"from",
"the",
"conf",
"file",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reader.go#L29-L39 |
20,785 | satyrius/gonx | reader.go | Read | func (r *Reader) Read() (entry *Entry, err error) {
if r.entries == nil {
r.entries = MapReduce(r.file, r.parser, new(ReadAll))
}
entry, ok := <-r.entries
if !ok {
err = io.EOF
}
return
} | go | func (r *Reader) Read() (entry *Entry, err error) {
if r.entries == nil {
r.entries = MapReduce(r.file, r.parser, new(ReadAll))
}
entry, ok := <-r.entries
if !ok {
err = io.EOF
}
return
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Read",
"(",
")",
"(",
"entry",
"*",
"Entry",
",",
"err",
"error",
")",
"{",
"if",
"r",
".",
"entries",
"==",
"nil",
"{",
"r",
".",
"entries",
"=",
"MapReduce",
"(",
"r",
".",
"file",
",",
"r",
".",
"pars... | // Read next parsed Entry from the log file. Return EOF if there are no Entries to read. | [
"Read",
"next",
"parsed",
"Entry",
"from",
"the",
"log",
"file",
".",
"Return",
"EOF",
"if",
"there",
"are",
"no",
"Entries",
"to",
"read",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reader.go#L42-L51 |
20,786 | satyrius/gonx | parser.go | NewParser | func NewParser(format string) *Parser {
// First split up multiple concatenated fields with placeholder
placeholder := " _PLACEHOLDER___ "
preparedFormat := format
concatenatedRe := regexp.MustCompile(`[A-Za-z0-9_]\$[A-Za-z0-9_]`)
for concatenatedRe.MatchString(preparedFormat) {
preparedFormat = regexp.MustCompi... | go | func NewParser(format string) *Parser {
// First split up multiple concatenated fields with placeholder
placeholder := " _PLACEHOLDER___ "
preparedFormat := format
concatenatedRe := regexp.MustCompile(`[A-Za-z0-9_]\$[A-Za-z0-9_]`)
for concatenatedRe.MatchString(preparedFormat) {
preparedFormat = regexp.MustCompi... | [
"func",
"NewParser",
"(",
"format",
"string",
")",
"*",
"Parser",
"{",
"// First split up multiple concatenated fields with placeholder",
"placeholder",
":=",
"\"",
"\"",
"\n",
"preparedFormat",
":=",
"format",
"\n",
"concatenatedRe",
":=",
"regexp",
".",
"MustCompile",... | // NewParser returns a new Parser, use given log format to create its internal
// strings parsing regexp. | [
"NewParser",
"returns",
"a",
"new",
"Parser",
"use",
"given",
"log",
"format",
"to",
"create",
"its",
"internal",
"strings",
"parsing",
"regexp",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/parser.go#L24-L43 |
20,787 | satyrius/gonx | parser.go | ParseString | func (parser *Parser) ParseString(line string) (entry *Entry, err error) {
re := parser.regexp
fields := re.FindStringSubmatch(line)
if fields == nil {
err = fmt.Errorf("access log line '%v' does not match given format '%v'", line, re)
return
}
// Iterate over subexp foung and fill the map record
entry = New... | go | func (parser *Parser) ParseString(line string) (entry *Entry, err error) {
re := parser.regexp
fields := re.FindStringSubmatch(line)
if fields == nil {
err = fmt.Errorf("access log line '%v' does not match given format '%v'", line, re)
return
}
// Iterate over subexp foung and fill the map record
entry = New... | [
"func",
"(",
"parser",
"*",
"Parser",
")",
"ParseString",
"(",
"line",
"string",
")",
"(",
"entry",
"*",
"Entry",
",",
"err",
"error",
")",
"{",
"re",
":=",
"parser",
".",
"regexp",
"\n",
"fields",
":=",
"re",
".",
"FindStringSubmatch",
"(",
"line",
... | // ParseString parses a log file line using internal format regexp. If a line
// does not match the given format an error will be returned. | [
"ParseString",
"parses",
"a",
"log",
"file",
"line",
"using",
"internal",
"format",
"regexp",
".",
"If",
"a",
"line",
"does",
"not",
"match",
"the",
"given",
"format",
"an",
"error",
"will",
"be",
"returned",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/parser.go#L47-L64 |
20,788 | satyrius/gonx | parser.go | NewNginxParser | func NewNginxParser(conf io.Reader, name string) (parser *Parser, err error) {
scanner := bufio.NewScanner(conf)
re := regexp.MustCompile(fmt.Sprintf(`^\s*log_format\s+%v\s+(.+)\s*$`, name))
found := false
var format string
for scanner.Scan() {
var line string
if !found {
// Find a log_format definition
... | go | func NewNginxParser(conf io.Reader, name string) (parser *Parser, err error) {
scanner := bufio.NewScanner(conf)
re := regexp.MustCompile(fmt.Sprintf(`^\s*log_format\s+%v\s+(.+)\s*$`, name))
found := false
var format string
for scanner.Scan() {
var line string
if !found {
// Find a log_format definition
... | [
"func",
"NewNginxParser",
"(",
"conf",
"io",
".",
"Reader",
",",
"name",
"string",
")",
"(",
"parser",
"*",
"Parser",
",",
"err",
"error",
")",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"conf",
")",
"\n",
"re",
":=",
"regexp",
".",
"Must... | // NewNginxParser parses the nginx conf file to find log_format with the given
// name and returns a parser for this format. It returns an error if cannot find
// the given log format. | [
"NewNginxParser",
"parses",
"the",
"nginx",
"conf",
"file",
"to",
"find",
"log_format",
"with",
"the",
"given",
"name",
"and",
"returns",
"a",
"parser",
"for",
"this",
"format",
".",
"It",
"returns",
"an",
"error",
"if",
"cannot",
"find",
"the",
"given",
"... | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/parser.go#L69-L105 |
20,789 | satyrius/gonx | mapreduce.go | MapReduce | func MapReduce(file io.Reader, parser StringParser, reducer Reducer) chan *Entry {
// Input file lines. This channel is unbuffered to publish
// next line to handle only when previous is taken by mapper.
var lines = make(chan string)
// Host thread to spawn new mappers
var entries = make(chan *Entry, 10)
go func... | go | func MapReduce(file io.Reader, parser StringParser, reducer Reducer) chan *Entry {
// Input file lines. This channel is unbuffered to publish
// next line to handle only when previous is taken by mapper.
var lines = make(chan string)
// Host thread to spawn new mappers
var entries = make(chan *Entry, 10)
go func... | [
"func",
"MapReduce",
"(",
"file",
"io",
".",
"Reader",
",",
"parser",
"StringParser",
",",
"reducer",
"Reducer",
")",
"chan",
"*",
"Entry",
"{",
"// Input file lines. This channel is unbuffered to publish",
"// next line to handle only when previous is taken by mapper.",
"var... | // MapReduce iterates over given file and map each it's line into Entry record using
// parser and apply reducer to the Entries channel. Execution terminates
// when result will be readed from reducer's output channel, but the mapper
// works and fills input Entries channel until all lines will be read from
// the five... | [
"MapReduce",
"iterates",
"over",
"given",
"file",
"and",
"map",
"each",
"it",
"s",
"line",
"into",
"Entry",
"record",
"using",
"parser",
"and",
"apply",
"reducer",
"to",
"the",
"Entries",
"channel",
".",
"Execution",
"terminates",
"when",
"result",
"will",
"... | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/mapreduce.go#L19-L91 |
20,790 | satyrius/gonx | filter.go | Filter | func (i *Datetime) Filter(entry *Entry) (validEntry *Entry) {
val, err := entry.Field(i.Field)
if err != nil {
// TODO handle error
return
}
t, err := time.Parse(i.Format, val)
if err != nil {
// TODO handle error
return
}
if i.withinBounds(t) {
validEntry = entry
}
return
} | go | func (i *Datetime) Filter(entry *Entry) (validEntry *Entry) {
val, err := entry.Field(i.Field)
if err != nil {
// TODO handle error
return
}
t, err := time.Parse(i.Format, val)
if err != nil {
// TODO handle error
return
}
if i.withinBounds(t) {
validEntry = entry
}
return
} | [
"func",
"(",
"i",
"*",
"Datetime",
")",
"Filter",
"(",
"entry",
"*",
"Entry",
")",
"(",
"validEntry",
"*",
"Entry",
")",
"{",
"val",
",",
"err",
":=",
"entry",
".",
"Field",
"(",
"i",
".",
"Field",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// ... | // Filter checks a field value to be in desired datetime range. | [
"Filter",
"checks",
"a",
"field",
"value",
"to",
"be",
"in",
"desired",
"datetime",
"range",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/filter.go#L24-L39 |
20,791 | satyrius/gonx | filter.go | Reduce | func (i *Datetime) Reduce(input chan *Entry, output chan *Entry) {
for entry := range input {
if valid := i.Filter(entry); valid != nil {
output <- valid
}
}
close(output)
} | go | func (i *Datetime) Reduce(input chan *Entry, output chan *Entry) {
for entry := range input {
if valid := i.Filter(entry); valid != nil {
output <- valid
}
}
close(output)
} | [
"func",
"(",
"i",
"*",
"Datetime",
")",
"Reduce",
"(",
"input",
"chan",
"*",
"Entry",
",",
"output",
"chan",
"*",
"Entry",
")",
"{",
"for",
"entry",
":=",
"range",
"input",
"{",
"if",
"valid",
":=",
"i",
".",
"Filter",
"(",
"entry",
")",
";",
"va... | // Reduce implements the Reducer interface. Go through input and apply Filter. | [
"Reduce",
"implements",
"the",
"Reducer",
"interface",
".",
"Go",
"through",
"input",
"and",
"apply",
"Filter",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/filter.go#L42-L49 |
20,792 | satyrius/gonx | reducer.go | Reduce | func (r *ReadAll) Reduce(input chan *Entry, output chan *Entry) {
for entry := range input {
output <- entry
}
close(output)
} | go | func (r *ReadAll) Reduce(input chan *Entry, output chan *Entry) {
for entry := range input {
output <- entry
}
close(output)
} | [
"func",
"(",
"r",
"*",
"ReadAll",
")",
"Reduce",
"(",
"input",
"chan",
"*",
"Entry",
",",
"output",
"chan",
"*",
"Entry",
")",
"{",
"for",
"entry",
":=",
"range",
"input",
"{",
"output",
"<-",
"entry",
"\n",
"}",
"\n",
"close",
"(",
"output",
")",
... | // Reduce redirects input Entries channel directly to the output without any
// modifications. It is useful when you want jast to read file fast
// using asynchronous with mapper routines. | [
"Reduce",
"redirects",
"input",
"Entries",
"channel",
"directly",
"to",
"the",
"output",
"without",
"any",
"modifications",
".",
"It",
"is",
"useful",
"when",
"you",
"want",
"jast",
"to",
"read",
"file",
"fast",
"using",
"asynchronous",
"with",
"mapper",
"rout... | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L22-L27 |
20,793 | satyrius/gonx | reducer.go | Reduce | func (r *Count) Reduce(input chan *Entry, output chan *Entry) {
var count uint64
for {
_, ok := <-input
if !ok {
break
}
count++
}
entry := NewEmptyEntry()
entry.SetUintField("count", count)
output <- entry
close(output)
} | go | func (r *Count) Reduce(input chan *Entry, output chan *Entry) {
var count uint64
for {
_, ok := <-input
if !ok {
break
}
count++
}
entry := NewEmptyEntry()
entry.SetUintField("count", count)
output <- entry
close(output)
} | [
"func",
"(",
"r",
"*",
"Count",
")",
"Reduce",
"(",
"input",
"chan",
"*",
"Entry",
",",
"output",
"chan",
"*",
"Entry",
")",
"{",
"var",
"count",
"uint64",
"\n",
"for",
"{",
"_",
",",
"ok",
":=",
"<-",
"input",
"\n",
"if",
"!",
"ok",
"{",
"brea... | // Reduce simply counts entries and write a sum to the output channel | [
"Reduce",
"simply",
"counts",
"entries",
"and",
"write",
"a",
"sum",
"to",
"the",
"output",
"channel"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L34-L47 |
20,794 | satyrius/gonx | reducer.go | Reduce | func (r *Sum) Reduce(input chan *Entry, output chan *Entry) {
sum := make(map[string]float64)
for entry := range input {
for _, name := range r.Fields {
val, err := entry.FloatField(name)
if err == nil {
sum[name] += val
}
}
}
entry := NewEmptyEntry()
for name, val := range sum {
entry.SetFloatF... | go | func (r *Sum) Reduce(input chan *Entry, output chan *Entry) {
sum := make(map[string]float64)
for entry := range input {
for _, name := range r.Fields {
val, err := entry.FloatField(name)
if err == nil {
sum[name] += val
}
}
}
entry := NewEmptyEntry()
for name, val := range sum {
entry.SetFloatF... | [
"func",
"(",
"r",
"*",
"Sum",
")",
"Reduce",
"(",
"input",
"chan",
"*",
"Entry",
",",
"output",
"chan",
"*",
"Entry",
")",
"{",
"sum",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"float64",
")",
"\n",
"for",
"entry",
":=",
"range",
"input",
"{"... | // Reduce summarizes given Entry fields and return a map with result for each field. | [
"Reduce",
"summarizes",
"given",
"Entry",
"fields",
"and",
"return",
"a",
"map",
"with",
"result",
"for",
"each",
"field",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L55-L71 |
20,795 | satyrius/gonx | reducer.go | NewChain | func NewChain(reducers ...Reducer) *Chain {
chain := new(Chain)
for _, r := range reducers {
if f, ok := interface{}(r).(Filter); ok {
chain.filters = append(chain.filters, f)
} else {
chain.reducers = append(chain.reducers, r)
}
}
return chain
} | go | func NewChain(reducers ...Reducer) *Chain {
chain := new(Chain)
for _, r := range reducers {
if f, ok := interface{}(r).(Filter); ok {
chain.filters = append(chain.filters, f)
} else {
chain.reducers = append(chain.reducers, r)
}
}
return chain
} | [
"func",
"NewChain",
"(",
"reducers",
"...",
"Reducer",
")",
"*",
"Chain",
"{",
"chain",
":=",
"new",
"(",
"Chain",
")",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"reducers",
"{",
"if",
"f",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"r",
")",
... | // NewChain creates a new chain of Reducers | [
"NewChain",
"creates",
"a",
"new",
"chain",
"of",
"Reducers"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L107-L117 |
20,796 | satyrius/gonx | reducer.go | Reduce | func (r *Chain) Reduce(input chan *Entry, output chan *Entry) {
// Make input and output channel for each reducer
subInput := make([]chan *Entry, len(r.reducers))
subOutput := make([]chan *Entry, len(r.reducers))
for i, reducer := range r.reducers {
subInput[i] = make(chan *Entry, cap(input))
subOutput[i] = mak... | go | func (r *Chain) Reduce(input chan *Entry, output chan *Entry) {
// Make input and output channel for each reducer
subInput := make([]chan *Entry, len(r.reducers))
subOutput := make([]chan *Entry, len(r.reducers))
for i, reducer := range r.reducers {
subInput[i] = make(chan *Entry, cap(input))
subOutput[i] = mak... | [
"func",
"(",
"r",
"*",
"Chain",
")",
"Reduce",
"(",
"input",
"chan",
"*",
"Entry",
",",
"output",
"chan",
"*",
"Entry",
")",
"{",
"// Make input and output channel for each reducer",
"subInput",
":=",
"make",
"(",
"[",
"]",
"chan",
"*",
"Entry",
",",
"len"... | // Reduce applies a chain of reducers to the input channel of entries and merge results | [
"Reduce",
"applies",
"a",
"chain",
"of",
"reducers",
"to",
"the",
"input",
"channel",
"of",
"entries",
"and",
"merge",
"results"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L120-L157 |
20,797 | satyrius/gonx | reducer.go | NewGroupBy | func NewGroupBy(fields []string, reducers ...Reducer) *GroupBy {
return &GroupBy{
Fields: fields,
reducers: reducers,
}
} | go | func NewGroupBy(fields []string, reducers ...Reducer) *GroupBy {
return &GroupBy{
Fields: fields,
reducers: reducers,
}
} | [
"func",
"NewGroupBy",
"(",
"fields",
"[",
"]",
"string",
",",
"reducers",
"...",
"Reducer",
")",
"*",
"GroupBy",
"{",
"return",
"&",
"GroupBy",
"{",
"Fields",
":",
"fields",
",",
"reducers",
":",
"reducers",
",",
"}",
"\n",
"}"
] | // NewGroupBy creates a new GroupBy Reducer | [
"NewGroupBy",
"creates",
"a",
"new",
"GroupBy",
"Reducer"
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L167-L172 |
20,798 | satyrius/gonx | reducer.go | Reduce | func (r *GroupBy) Reduce(input chan *Entry, output chan *Entry) {
subInput := make(map[string]chan *Entry)
subOutput := make(map[string]chan *Entry)
// Read reducer master input channel and create discinct input chanel
// for each entry key we group by
for entry := range input {
key := entry.FieldsHash(r.Fields... | go | func (r *GroupBy) Reduce(input chan *Entry, output chan *Entry) {
subInput := make(map[string]chan *Entry)
subOutput := make(map[string]chan *Entry)
// Read reducer master input channel and create discinct input chanel
// for each entry key we group by
for entry := range input {
key := entry.FieldsHash(r.Fields... | [
"func",
"(",
"r",
"*",
"GroupBy",
")",
"Reduce",
"(",
"input",
"chan",
"*",
"Entry",
",",
"output",
"chan",
"*",
"Entry",
")",
"{",
"subInput",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"chan",
"*",
"Entry",
")",
"\n",
"subOutput",
":=",
"make"... | // Reduce applies related reducers and group data by Fields. | [
"Reduce",
"applies",
"related",
"reducers",
"and",
"group",
"data",
"by",
"Fields",
"."
] | d96bd26e3b2c9d8b84b4694d858bb70b5e904d63 | https://github.com/satyrius/gonx/blob/d96bd26e3b2c9d8b84b4694d858bb70b5e904d63/reducer.go#L175-L200 |
20,799 | go-gl/mathgl | mgl32/vecn.go | destroy | func (vn *VecN) destroy() {
if vn == nil || vn.vec == nil {
return
}
if shouldPool {
returnToPool(vn.vec)
}
vn.vec = nil
} | go | func (vn *VecN) destroy() {
if vn == nil || vn.vec == nil {
return
}
if shouldPool {
returnToPool(vn.vec)
}
vn.vec = nil
} | [
"func",
"(",
"vn",
"*",
"VecN",
")",
"destroy",
"(",
")",
"{",
"if",
"vn",
"==",
"nil",
"||",
"vn",
".",
"vec",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"shouldPool",
"{",
"returnToPool",
"(",
"vn",
".",
"vec",
")",
"\n",
"}",
"\n",... | // Sends the allocated memory through the callback if it exists | [
"Sends",
"the",
"allocated",
"memory",
"through",
"the",
"callback",
"if",
"it",
"exists"
] | c4601bc793c7a480dab005cf969aab0d7a7fb07d | https://github.com/go-gl/mathgl/blob/c4601bc793c7a480dab005cf969aab0d7a7fb07d/mgl32/vecn.go#L72-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.