id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,900 | go-ozzo/ozzo-log | logger.go | DefaultFormatter | func DefaultFormatter(l *Logger, e *Entry) string {
return fmt.Sprintf("%v [%v][%v] %v%v", e.Time.Format(time.RFC3339), e.Level, e.Category, e.Message, e.CallStack)
} | go | func DefaultFormatter(l *Logger, e *Entry) string {
return fmt.Sprintf("%v [%v][%v] %v%v", e.Time.Format(time.RFC3339), e.Level, e.Category, e.Message, e.CallStack)
} | [
"func",
"DefaultFormatter",
"(",
"l",
"*",
"Logger",
",",
"e",
"*",
"Entry",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Time",
".",
"Format",
"(",
"time",
".",
"RFC3339",
")",
",",
"e",
".",
"Level",
","... | // DefaultFormatter is the default formatter used to format every log message. | [
"DefaultFormatter",
"is",
"the",
"default",
"formatter",
"used",
"to",
"format",
"every",
"log",
"message",
"."
] | 610cdd147d9aff9523eed107898d2e87ee5336aa | https://github.com/go-ozzo/ozzo-log/blob/610cdd147d9aff9523eed107898d2e87ee5336aa/logger.go#L274-L276 |
17,901 | go-ozzo/ozzo-log | logger.go | GetCallStack | func GetCallStack(skip int, frames int, filter string) string {
buf := new(bytes.Buffer)
for i, count := skip, 0; count < frames; i++ {
_, file, line, ok := runtime.Caller(i)
if !ok {
break
}
if filter == "" || strings.Contains(file, filter) {
fmt.Fprintf(buf, "\n%s:%d", file, line)
count++
}
}
r... | go | func GetCallStack(skip int, frames int, filter string) string {
buf := new(bytes.Buffer)
for i, count := skip, 0; count < frames; i++ {
_, file, line, ok := runtime.Caller(i)
if !ok {
break
}
if filter == "" || strings.Contains(file, filter) {
fmt.Fprintf(buf, "\n%s:%d", file, line)
count++
}
}
r... | [
"func",
"GetCallStack",
"(",
"skip",
"int",
",",
"frames",
"int",
",",
"filter",
"string",
")",
"string",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"for",
"i",
",",
"count",
":=",
"skip",
",",
"0",
";",
"count",
"<",
"frames"... | // GetCallStack returns the current call stack information as a string.
// The skip parameter specifies how many top frames should be skipped, while
// the frames parameter specifies at most how many frames should be returned. | [
"GetCallStack",
"returns",
"the",
"current",
"call",
"stack",
"information",
"as",
"a",
"string",
".",
"The",
"skip",
"parameter",
"specifies",
"how",
"many",
"top",
"frames",
"should",
"be",
"skipped",
"while",
"the",
"frames",
"parameter",
"specifies",
"at",
... | 610cdd147d9aff9523eed107898d2e87ee5336aa | https://github.com/go-ozzo/ozzo-log/blob/610cdd147d9aff9523eed107898d2e87ee5336aa/logger.go#L281-L294 |
17,902 | go-ozzo/ozzo-log | mail.go | Open | func (t *MailTarget) Open(errWriter io.Writer) error {
t.Filter.Init()
if t.Host == "" {
return errors.New("MailTarget.Host must be specified")
}
if t.Username == "" {
return errors.New("MailTarget.Username must be specified")
}
if t.Subject == "" {
return errors.New("MailTarget.Subject must be specified")
... | go | func (t *MailTarget) Open(errWriter io.Writer) error {
t.Filter.Init()
if t.Host == "" {
return errors.New("MailTarget.Host must be specified")
}
if t.Username == "" {
return errors.New("MailTarget.Username must be specified")
}
if t.Subject == "" {
return errors.New("MailTarget.Subject must be specified")
... | [
"func",
"(",
"t",
"*",
"MailTarget",
")",
"Open",
"(",
"errWriter",
"io",
".",
"Writer",
")",
"error",
"{",
"t",
".",
"Filter",
".",
"Init",
"(",
")",
"\n",
"if",
"t",
".",
"Host",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"... | // Open prepares MailTarget for processing log messages. | [
"Open",
"prepares",
"MailTarget",
"for",
"processing",
"log",
"messages",
"."
] | 610cdd147d9aff9523eed107898d2e87ee5336aa | https://github.com/go-ozzo/ozzo-log/blob/610cdd147d9aff9523eed107898d2e87ee5336aa/mail.go#L43-L68 |
17,903 | go-ozzo/ozzo-log | mail.go | Process | func (t *MailTarget) Process(e *Entry) {
if t.Allow(e) {
select {
case t.entries <- e:
default:
}
}
} | go | func (t *MailTarget) Process(e *Entry) {
if t.Allow(e) {
select {
case t.entries <- e:
default:
}
}
} | [
"func",
"(",
"t",
"*",
"MailTarget",
")",
"Process",
"(",
"e",
"*",
"Entry",
")",
"{",
"if",
"t",
".",
"Allow",
"(",
"e",
")",
"{",
"select",
"{",
"case",
"t",
".",
"entries",
"<-",
"e",
":",
"default",
":",
"}",
"\n",
"}",
"\n",
"}"
] | // Process puts filtered log messages into a channel for sending in emails. | [
"Process",
"puts",
"filtered",
"log",
"messages",
"into",
"a",
"channel",
"for",
"sending",
"in",
"emails",
"."
] | 610cdd147d9aff9523eed107898d2e87ee5336aa | https://github.com/go-ozzo/ozzo-log/blob/610cdd147d9aff9523eed107898d2e87ee5336aa/mail.go#L71-L78 |
17,904 | sbinet/go-eval | type.go | NewArrayType | func NewArrayType(len int64, elem Type) *ArrayType {
ts, ok := arrayTypes[len]
if !ok {
ts = make(map[Type]*ArrayType)
arrayTypes[len] = ts
}
t, ok := ts[elem]
if !ok {
t = &ArrayType{commonType{}, len, elem}
ts[elem] = t
}
return t
} | go | func NewArrayType(len int64, elem Type) *ArrayType {
ts, ok := arrayTypes[len]
if !ok {
ts = make(map[Type]*ArrayType)
arrayTypes[len] = ts
}
t, ok := ts[elem]
if !ok {
t = &ArrayType{commonType{}, len, elem}
ts[elem] = t
}
return t
} | [
"func",
"NewArrayType",
"(",
"len",
"int64",
",",
"elem",
"Type",
")",
"*",
"ArrayType",
"{",
"ts",
",",
"ok",
":=",
"arrayTypes",
"[",
"len",
"]",
"\n",
"if",
"!",
"ok",
"{",
"ts",
"=",
"make",
"(",
"map",
"[",
"Type",
"]",
"*",
"ArrayType",
")"... | // Two array types are identical if they have identical element types
// and the same array length. | [
"Two",
"array",
"types",
"are",
"identical",
"if",
"they",
"have",
"identical",
"element",
"types",
"and",
"the",
"same",
"array",
"length",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/type.go#L531-L543 |
17,905 | sbinet/go-eval | type.go | NewStructType | func NewStructType(fields []StructField) *StructType {
// Start by looking up just the types
fts := make([]Type, len(fields))
for i, f := range fields {
fts[i] = f.Type
}
tMapI := structTypes.Get(fts)
if tMapI == nil {
tMapI = structTypes.Put(fts, make(map[string]*StructType))
}
tMap := tMapI.(map[string]*S... | go | func NewStructType(fields []StructField) *StructType {
// Start by looking up just the types
fts := make([]Type, len(fields))
for i, f := range fields {
fts[i] = f.Type
}
tMapI := structTypes.Get(fts)
if tMapI == nil {
tMapI = structTypes.Put(fts, make(map[string]*StructType))
}
tMap := tMapI.(map[string]*S... | [
"func",
"NewStructType",
"(",
"fields",
"[",
"]",
"StructField",
")",
"*",
"StructType",
"{",
"// Start by looking up just the types",
"fts",
":=",
"make",
"(",
"[",
"]",
"Type",
",",
"len",
"(",
"fields",
")",
")",
"\n",
"for",
"i",
",",
"f",
":=",
"ran... | // Two struct types are identical if they have the same sequence of
// fields, and if corresponding fields have the same names and
// identical types. Two anonymous fields are considered to have the
// same name. | [
"Two",
"struct",
"types",
"are",
"identical",
"if",
"they",
"have",
"the",
"same",
"sequence",
"of",
"fields",
"and",
"if",
"corresponding",
"fields",
"have",
"the",
"same",
"names",
"and",
"identical",
"types",
".",
"Two",
"anonymous",
"fields",
"are",
"con... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/type.go#L592-L633 |
17,906 | sbinet/go-eval | type.go | NewPtrType | func NewPtrType(elem Type) *PtrType {
t, ok := ptrTypes[elem]
if !ok {
t = &PtrType{commonType{}, elem}
ptrTypes[elem] = t
}
return t
} | go | func NewPtrType(elem Type) *PtrType {
t, ok := ptrTypes[elem]
if !ok {
t = &PtrType{commonType{}, elem}
ptrTypes[elem] = t
}
return t
} | [
"func",
"NewPtrType",
"(",
"elem",
"Type",
")",
"*",
"PtrType",
"{",
"t",
",",
"ok",
":=",
"ptrTypes",
"[",
"elem",
"]",
"\n",
"if",
"!",
"ok",
"{",
"t",
"=",
"&",
"PtrType",
"{",
"commonType",
"{",
"}",
",",
"elem",
"}",
"\n",
"ptrTypes",
"[",
... | // Two pointer types are identical if they have identical base types. | [
"Two",
"pointer",
"types",
"are",
"identical",
"if",
"they",
"have",
"identical",
"base",
"types",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/type.go#L693-L700 |
17,907 | sbinet/go-eval | type.go | NewFuncType | func NewFuncType(in []Type, variadic bool, out []Type) *FuncType {
inMap := funcTypes
if variadic {
inMap = variadicFuncTypes
}
outMapI := inMap.Get(in)
if outMapI == nil {
outMapI = inMap.Put(in, newTypeArrayMap())
}
outMap := outMapI.(typeArrayMap)
tI := outMap.Get(out)
if tI != nil {
return tI.(*Fun... | go | func NewFuncType(in []Type, variadic bool, out []Type) *FuncType {
inMap := funcTypes
if variadic {
inMap = variadicFuncTypes
}
outMapI := inMap.Get(in)
if outMapI == nil {
outMapI = inMap.Put(in, newTypeArrayMap())
}
outMap := outMapI.(typeArrayMap)
tI := outMap.Get(out)
if tI != nil {
return tI.(*Fun... | [
"func",
"NewFuncType",
"(",
"in",
"[",
"]",
"Type",
",",
"variadic",
"bool",
",",
"out",
"[",
"]",
"Type",
")",
"*",
"FuncType",
"{",
"inMap",
":=",
"funcTypes",
"\n",
"if",
"variadic",
"{",
"inMap",
"=",
"variadicFuncTypes",
"\n",
"}",
"\n\n",
"outMap... | // Two function types are identical if they have the same number of
// parameters and result values and if corresponding parameter and
// result types are identical. All "..." parameters have identical
// type. Parameter and result names are not required to match. | [
"Two",
"function",
"types",
"are",
"identical",
"if",
"they",
"have",
"the",
"same",
"number",
"of",
"parameters",
"and",
"result",
"values",
"and",
"if",
"corresponding",
"parameter",
"and",
"result",
"types",
"are",
"identical",
".",
"All",
"...",
"parameter... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/type.go#L752-L772 |
17,908 | sbinet/go-eval | type.go | implementedBy | func (t *InterfaceType) implementedBy(o Type) (*IMethod, bool) {
if len(t.methods) == 0 {
return nil, true
}
// The methods of a named interface types are those of the
// underlying type.
if it, ok := o.lit().(*InterfaceType); ok {
o = it
}
// XXX(Spec) Interface types: "A type implements any interface
//... | go | func (t *InterfaceType) implementedBy(o Type) (*IMethod, bool) {
if len(t.methods) == 0 {
return nil, true
}
// The methods of a named interface types are those of the
// underlying type.
if it, ok := o.lit().(*InterfaceType); ok {
o = it
}
// XXX(Spec) Interface types: "A type implements any interface
//... | [
"func",
"(",
"t",
"*",
"InterfaceType",
")",
"implementedBy",
"(",
"o",
"Type",
")",
"(",
"*",
"IMethod",
",",
"bool",
")",
"{",
"if",
"len",
"(",
"t",
".",
"methods",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"true",
"\n",
"}",
"\n\n",
"// The ... | // implementedBy tests if o implements t, returning nil, true if it does.
// Otherwise, it returns a method of t that o is missing and false. | [
"implementedBy",
"tests",
"if",
"o",
"implements",
"t",
"returning",
"nil",
"true",
"if",
"it",
"does",
".",
"Otherwise",
"it",
"returns",
"a",
"method",
"of",
"t",
"that",
"o",
"is",
"missing",
"and",
"false",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/type.go#L979-L1029 |
17,909 | sbinet/go-eval | type.go | NewSliceType | func NewSliceType(elem Type) *SliceType {
t, ok := sliceTypes[elem]
if !ok {
t = &SliceType{commonType{}, elem}
sliceTypes[elem] = t
}
return t
} | go | func NewSliceType(elem Type) *SliceType {
t, ok := sliceTypes[elem]
if !ok {
t = &SliceType{commonType{}, elem}
sliceTypes[elem] = t
}
return t
} | [
"func",
"NewSliceType",
"(",
"elem",
"Type",
")",
"*",
"SliceType",
"{",
"t",
",",
"ok",
":=",
"sliceTypes",
"[",
"elem",
"]",
"\n",
"if",
"!",
"ok",
"{",
"t",
"=",
"&",
"SliceType",
"{",
"commonType",
"{",
"}",
",",
"elem",
"}",
"\n",
"sliceTypes"... | // Two slice types are identical if they have identical element types. | [
"Two",
"slice",
"types",
"are",
"identical",
"if",
"they",
"have",
"identical",
"element",
"types",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/type.go#L1046-L1053 |
17,910 | sbinet/go-eval | expr.go | convertToInt | func (a *expr) convertToInt(max int64, negErr string, errOp string) *expr {
switch a.t.lit().(type) {
case *idealIntType:
val := a.asIdealInt()()
if negErr != "" && val.Sign() < 0 {
a.diag("negative %s: %s", negErr, val)
return nil
}
bound := max
if negErr == "slice" {
bound++
}
if max != -1 &&... | go | func (a *expr) convertToInt(max int64, negErr string, errOp string) *expr {
switch a.t.lit().(type) {
case *idealIntType:
val := a.asIdealInt()()
if negErr != "" && val.Sign() < 0 {
a.diag("negative %s: %s", negErr, val)
return nil
}
bound := max
if negErr == "slice" {
bound++
}
if max != -1 &&... | [
"func",
"(",
"a",
"*",
"expr",
")",
"convertToInt",
"(",
"max",
"int64",
",",
"negErr",
"string",
",",
"errOp",
"string",
")",
"*",
"expr",
"{",
"switch",
"a",
".",
"t",
".",
"lit",
"(",
")",
".",
"(",
"type",
")",
"{",
"case",
"*",
"idealIntType... | // convertToInt converts this expression to an integer, if possible,
// or produces an error if not. This accepts ideal ints, uints, and
// ints. If max is not -1, produces an error if possible if the value
// exceeds max. If negErr is not "", produces an error if possible if
// the value is negative. | [
"convertToInt",
"converts",
"this",
"expression",
"to",
"an",
"integer",
"if",
"possible",
"or",
"produces",
"an",
"error",
"if",
"not",
".",
"This",
"accepts",
"ideal",
"ints",
"uints",
"and",
"ints",
".",
"If",
"max",
"is",
"not",
"-",
"1",
"produces",
... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/expr.go#L163-L195 |
17,911 | sbinet/go-eval | expr.go | checkAssign | func (a *compiler) checkAssign(pos token.Pos, rs []*expr, errOp, errPosName string) (*assignCompiler, bool) {
c := &assignCompiler{
compiler: a,
pos: pos,
rs: rs,
errOp: errOp,
errPosName: errPosName,
}
// Is this an unpack?
if len(rs) == 1 && rs[0] != nil {
if rmt, isUnpack := rs... | go | func (a *compiler) checkAssign(pos token.Pos, rs []*expr, errOp, errPosName string) (*assignCompiler, bool) {
c := &assignCompiler{
compiler: a,
pos: pos,
rs: rs,
errOp: errOp,
errPosName: errPosName,
}
// Is this an unpack?
if len(rs) == 1 && rs[0] != nil {
if rmt, isUnpack := rs... | [
"func",
"(",
"a",
"*",
"compiler",
")",
"checkAssign",
"(",
"pos",
"token",
".",
"Pos",
",",
"rs",
"[",
"]",
"*",
"expr",
",",
"errOp",
",",
"errPosName",
"string",
")",
"(",
"*",
"assignCompiler",
",",
"bool",
")",
"{",
"c",
":=",
"&",
"assignComp... | // Type check the RHS of an assignment, returning a new assignCompiler
// and indicating if the type check succeeded. This always returns an
// assignCompiler with rmt set, but if type checking fails, slots in
// the MultiType may be nil. If rs contains nil's, type checking will
// fail and these expressions given a ... | [
"Type",
"check",
"the",
"RHS",
"of",
"an",
"assignment",
"returning",
"a",
"new",
"assignCompiler",
"and",
"indicating",
"if",
"the",
"type",
"check",
"succeeded",
".",
"This",
"always",
"returns",
"an",
"assignCompiler",
"with",
"rmt",
"set",
"but",
"if",
"... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/expr.go#L405-L444 |
17,912 | sbinet/go-eval | expr.go | compileAssign | func (a *compiler) compileAssign(pos token.Pos, b *block, lt Type, rs []*expr, errOp, errPosName string) func(Value, *Thread) {
ac, ok := a.checkAssign(pos, rs, errOp, errPosName)
if !ok {
return nil
}
return ac.compile(b, lt)
} | go | func (a *compiler) compileAssign(pos token.Pos, b *block, lt Type, rs []*expr, errOp, errPosName string) func(Value, *Thread) {
ac, ok := a.checkAssign(pos, rs, errOp, errPosName)
if !ok {
return nil
}
return ac.compile(b, lt)
} | [
"func",
"(",
"a",
"*",
"compiler",
")",
"compileAssign",
"(",
"pos",
"token",
".",
"Pos",
",",
"b",
"*",
"block",
",",
"lt",
"Type",
",",
"rs",
"[",
"]",
"*",
"expr",
",",
"errOp",
",",
"errPosName",
"string",
")",
"func",
"(",
"Value",
",",
"*",... | // compileAssign compiles an assignment operation without the full
// generality of an assignCompiler. See assignCompiler for a
// description of the arguments. | [
"compileAssign",
"compiles",
"an",
"assignment",
"operation",
"without",
"the",
"full",
"generality",
"of",
"an",
"assignCompiler",
".",
"See",
"assignCompiler",
"for",
"a",
"description",
"of",
"the",
"arguments",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/expr.go#L604-L610 |
17,913 | sbinet/go-eval | abort.go | Abort | func (t *Thread) Abort(err error) {
if t.abort == nil {
panic("abort: " + err.Error())
}
t.abort <- err
runtime.Goexit()
} | go | func (t *Thread) Abort(err error) {
if t.abort == nil {
panic("abort: " + err.Error())
}
t.abort <- err
runtime.Goexit()
} | [
"func",
"(",
"t",
"*",
"Thread",
")",
"Abort",
"(",
"err",
"error",
")",
"{",
"if",
"t",
".",
"abort",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"t",
".",
"abort",
"<-",
"err",
"\n... | // Abort aborts the thread's current computation,
// causing the innermost Try to return err. | [
"Abort",
"aborts",
"the",
"thread",
"s",
"current",
"computation",
"causing",
"the",
"innermost",
"Try",
"to",
"return",
"err",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/abort.go#L14-L20 |
17,914 | sbinet/go-eval | abort.go | Try | func (t *Thread) Try(f func(t *Thread)) error {
oc := t.abort
c := make(chan error)
t.abort = c
go func() {
f(t)
c <- nil
}()
err := <-c
t.abort = oc
return err
} | go | func (t *Thread) Try(f func(t *Thread)) error {
oc := t.abort
c := make(chan error)
t.abort = c
go func() {
f(t)
c <- nil
}()
err := <-c
t.abort = oc
return err
} | [
"func",
"(",
"t",
"*",
"Thread",
")",
"Try",
"(",
"f",
"func",
"(",
"t",
"*",
"Thread",
")",
")",
"error",
"{",
"oc",
":=",
"t",
".",
"abort",
"\n",
"c",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"t",
".",
"abort",
"=",
"c",
"\n",
"go"... | // Try executes a computation; if the computation
// Aborts, Try returns the error passed to abort. | [
"Try",
"executes",
"a",
"computation",
";",
"if",
"the",
"computation",
"Aborts",
"Try",
"returns",
"the",
"error",
"passed",
"to",
"abort",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/abort.go#L24-L35 |
17,915 | sbinet/go-eval | bridge.go | FuncFromNative | func FuncFromNative(fn func(*Thread, []Value, []Value), t *FuncType) FuncValue {
return &funcV{&nativeFunc{fn, len(t.In), len(t.Out)}}
} | go | func FuncFromNative(fn func(*Thread, []Value, []Value), t *FuncType) FuncValue {
return &funcV{&nativeFunc{fn, len(t.In), len(t.Out)}}
} | [
"func",
"FuncFromNative",
"(",
"fn",
"func",
"(",
"*",
"Thread",
",",
"[",
"]",
"Value",
",",
"[",
"]",
"Value",
")",
",",
"t",
"*",
"FuncType",
")",
"FuncValue",
"{",
"return",
"&",
"funcV",
"{",
"&",
"nativeFunc",
"{",
"fn",
",",
"len",
"(",
"t... | // FuncFromNative creates an interpreter function from a native
// function that takes its in and out arguments as slices of
// interpreter Value's. While somewhat inconvenient, this avoids
// value marshalling. | [
"FuncFromNative",
"creates",
"an",
"interpreter",
"function",
"from",
"a",
"native",
"function",
"that",
"takes",
"its",
"in",
"and",
"out",
"arguments",
"as",
"slices",
"of",
"interpreter",
"Value",
"s",
".",
"While",
"somewhat",
"inconvenient",
"this",
"avoids... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/bridge.go#L155-L157 |
17,916 | sbinet/go-eval | bridge.go | FuncFromNativeTyped | func FuncFromNativeTyped(fn func(*Thread, []Value, []Value), t interface{}) (*FuncType, FuncValue) {
ft := TypeOfNative(t).(*FuncType)
return ft, FuncFromNative(fn, ft)
} | go | func FuncFromNativeTyped(fn func(*Thread, []Value, []Value), t interface{}) (*FuncType, FuncValue) {
ft := TypeOfNative(t).(*FuncType)
return ft, FuncFromNative(fn, ft)
} | [
"func",
"FuncFromNativeTyped",
"(",
"fn",
"func",
"(",
"*",
"Thread",
",",
"[",
"]",
"Value",
",",
"[",
"]",
"Value",
")",
",",
"t",
"interface",
"{",
"}",
")",
"(",
"*",
"FuncType",
",",
"FuncValue",
")",
"{",
"ft",
":=",
"TypeOfNative",
"(",
"t",... | // FuncFromNativeTyped is like FuncFromNative, but constructs the
// function type from a function pointer using reflection. Typically,
// the type will be given as a nil pointer to a function with the
// desired signature. | [
"FuncFromNativeTyped",
"is",
"like",
"FuncFromNative",
"but",
"constructs",
"the",
"function",
"type",
"from",
"a",
"function",
"pointer",
"using",
"reflection",
".",
"Typically",
"the",
"type",
"will",
"be",
"given",
"as",
"a",
"nil",
"pointer",
"to",
"a",
"f... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/bridge.go#L163-L166 |
17,917 | sbinet/go-eval | stmt.go | put | func (f *flowBuf) put(cond bool, term bool, jumps []*uint) {
pc := f.cb.nextPC()
if ent, ok := f.ents[pc]; ok {
log.Panicf("Flow entry already exists at PC %d: %+v", pc, ent)
}
f.ents[pc] = &flowEnt{cond, term, jumps, false}
} | go | func (f *flowBuf) put(cond bool, term bool, jumps []*uint) {
pc := f.cb.nextPC()
if ent, ok := f.ents[pc]; ok {
log.Panicf("Flow entry already exists at PC %d: %+v", pc, ent)
}
f.ents[pc] = &flowEnt{cond, term, jumps, false}
} | [
"func",
"(",
"f",
"*",
"flowBuf",
")",
"put",
"(",
"cond",
"bool",
",",
"term",
"bool",
",",
"jumps",
"[",
"]",
"*",
"uint",
")",
"{",
"pc",
":=",
"f",
".",
"cb",
".",
"nextPC",
"(",
")",
"\n",
"if",
"ent",
",",
"ok",
":=",
"f",
".",
"ents"... | // put creates a flow control point for the next PC in the code buffer.
// This should be done before pushing the instruction into the code buffer. | [
"put",
"creates",
"a",
"flow",
"control",
"point",
"for",
"the",
"next",
"PC",
"in",
"the",
"code",
"buffer",
".",
"This",
"should",
"be",
"done",
"before",
"pushing",
"the",
"instruction",
"into",
"the",
"code",
"buffer",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L95-L101 |
17,918 | sbinet/go-eval | stmt.go | put1 | func (f *flowBuf) put1(cond bool, jumpPC *uint) {
f.put(cond, false, []*uint{jumpPC})
} | go | func (f *flowBuf) put1(cond bool, jumpPC *uint) {
f.put(cond, false, []*uint{jumpPC})
} | [
"func",
"(",
"f",
"*",
"flowBuf",
")",
"put1",
"(",
"cond",
"bool",
",",
"jumpPC",
"*",
"uint",
")",
"{",
"f",
".",
"put",
"(",
"cond",
",",
"false",
",",
"[",
"]",
"*",
"uint",
"{",
"jumpPC",
"}",
")",
"\n",
"}"
] | // put1 creates a flow control point at the next PC that jumps to one
// PC and, if cond is true, can also continue to the PC following the
// next PC. | [
"put1",
"creates",
"a",
"flow",
"control",
"point",
"at",
"the",
"next",
"PC",
"that",
"jumps",
"to",
"one",
"PC",
"and",
"if",
"cond",
"is",
"true",
"can",
"also",
"continue",
"to",
"the",
"PC",
"following",
"the",
"next",
"PC",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L110-L112 |
17,919 | sbinet/go-eval | stmt.go | putGoto | func (f *flowBuf) putGoto(pos token.Pos, target string, b *block) {
f.gotos[pos] = newFlowBlock(target, b)
} | go | func (f *flowBuf) putGoto(pos token.Pos, target string, b *block) {
f.gotos[pos] = newFlowBlock(target, b)
} | [
"func",
"(",
"f",
"*",
"flowBuf",
")",
"putGoto",
"(",
"pos",
"token",
".",
"Pos",
",",
"target",
"string",
",",
"b",
"*",
"block",
")",
"{",
"f",
".",
"gotos",
"[",
"pos",
"]",
"=",
"newFlowBlock",
"(",
"target",
",",
"b",
")",
"\n",
"}"
] | // putGoto captures the block at a goto statement. This should be
// called in addition to putting a flow control point. | [
"putGoto",
"captures",
"the",
"block",
"at",
"a",
"goto",
"statement",
".",
"This",
"should",
"be",
"called",
"in",
"addition",
"to",
"putting",
"a",
"flow",
"control",
"point",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L139-L141 |
17,920 | sbinet/go-eval | stmt.go | putLabel | func (f *flowBuf) putLabel(name string, b *block) {
f.labels[name] = newFlowBlock("", b)
} | go | func (f *flowBuf) putLabel(name string, b *block) {
f.labels[name] = newFlowBlock("", b)
} | [
"func",
"(",
"f",
"*",
"flowBuf",
")",
"putLabel",
"(",
"name",
"string",
",",
"b",
"*",
"block",
")",
"{",
"f",
".",
"labels",
"[",
"name",
"]",
"=",
"newFlowBlock",
"(",
"\"",
"\"",
",",
"b",
")",
"\n",
"}"
] | // putLabel captures the block at a label. | [
"putLabel",
"captures",
"the",
"block",
"at",
"a",
"label",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L144-L146 |
17,921 | sbinet/go-eval | stmt.go | reachesEnd | func (f *flowBuf) reachesEnd(pc uint) bool {
endPC := f.cb.nextPC()
if pc > endPC {
log.Panicf("Reached bad PC %d past end PC %d", pc, endPC)
}
for ; pc < endPC; pc++ {
ent, ok := f.ents[pc]
if !ok {
continue
}
if ent.visited {
return false
}
ent.visited = true
if ent.term {
return false... | go | func (f *flowBuf) reachesEnd(pc uint) bool {
endPC := f.cb.nextPC()
if pc > endPC {
log.Panicf("Reached bad PC %d past end PC %d", pc, endPC)
}
for ; pc < endPC; pc++ {
ent, ok := f.ents[pc]
if !ok {
continue
}
if ent.visited {
return false
}
ent.visited = true
if ent.term {
return false... | [
"func",
"(",
"f",
"*",
"flowBuf",
")",
"reachesEnd",
"(",
"pc",
"uint",
")",
"bool",
"{",
"endPC",
":=",
"f",
".",
"cb",
".",
"nextPC",
"(",
")",
"\n",
"if",
"pc",
">",
"endPC",
"{",
"log",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"pc",
",",
"end... | // reachesEnd returns true if the end of f's code buffer can be
// reached from the given program counter. Error reporting is the
// caller's responsibility. | [
"reachesEnd",
"returns",
"true",
"if",
"the",
"end",
"of",
"f",
"s",
"code",
"buffer",
"can",
"be",
"reached",
"from",
"the",
"given",
"program",
"counter",
".",
"Error",
"reporting",
"is",
"the",
"caller",
"s",
"responsibility",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L151-L187 |
17,922 | sbinet/go-eval | stmt.go | gotosObeyScopes | func (f *flowBuf) gotosObeyScopes(a *compiler) {
for pos, src := range f.gotos {
tgt := f.labels[src.target]
// The target block must be a parent of this block
numVars := src.numVars
b := src.block
for len(numVars) > 0 && b != tgt.block {
b = b.outer
numVars = numVars[1:]
}
if b != tgt.block {
... | go | func (f *flowBuf) gotosObeyScopes(a *compiler) {
for pos, src := range f.gotos {
tgt := f.labels[src.target]
// The target block must be a parent of this block
numVars := src.numVars
b := src.block
for len(numVars) > 0 && b != tgt.block {
b = b.outer
numVars = numVars[1:]
}
if b != tgt.block {
... | [
"func",
"(",
"f",
"*",
"flowBuf",
")",
"gotosObeyScopes",
"(",
"a",
"*",
"compiler",
")",
"{",
"for",
"pos",
",",
"src",
":=",
"range",
"f",
".",
"gotos",
"{",
"tgt",
":=",
"f",
".",
"labels",
"[",
"src",
".",
"target",
"]",
"\n\n",
"// The target ... | // gotosObeyScopes returns true if no goto statement causes any
// variables to come into scope that were not in scope at the point of
// the goto. Reports any errors using the given compiler. | [
"gotosObeyScopes",
"returns",
"true",
"if",
"no",
"goto",
"statement",
"causes",
"any",
"variables",
"to",
"come",
"into",
"scope",
"that",
"were",
"not",
"in",
"scope",
"at",
"the",
"point",
"of",
"the",
"goto",
".",
"Reports",
"any",
"errors",
"using",
"... | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L192-L219 |
17,923 | sbinet/go-eval | stmt.go | checkLabels | func (a *funcCompiler) checkLabels() {
nerr := a.numError()
for _, l := range a.labels {
if !l.resolved.IsValid() {
a.diagAt(l.used, "label %s not defined", l.name)
}
}
if nerr != a.numError() {
// Don't check scopes if we have unresolved labels
return
}
// Executing the "goto" statement must not caus... | go | func (a *funcCompiler) checkLabels() {
nerr := a.numError()
for _, l := range a.labels {
if !l.resolved.IsValid() {
a.diagAt(l.used, "label %s not defined", l.name)
}
}
if nerr != a.numError() {
// Don't check scopes if we have unresolved labels
return
}
// Executing the "goto" statement must not caus... | [
"func",
"(",
"a",
"*",
"funcCompiler",
")",
"checkLabels",
"(",
")",
"{",
"nerr",
":=",
"a",
".",
"numError",
"(",
")",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"a",
".",
"labels",
"{",
"if",
"!",
"l",
".",
"resolved",
".",
"IsValid",
"(",
")... | // Checks that labels were resolved and that all jumps obey scoping
// rules. Reports an error and set fc.err if any check fails. | [
"Checks",
"that",
"labels",
"were",
"resolved",
"and",
"that",
"all",
"jumps",
"obey",
"scoping",
"rules",
".",
"Reports",
"an",
"error",
"and",
"set",
"fc",
".",
"err",
"if",
"any",
"check",
"fails",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L1365-L1381 |
17,924 | sbinet/go-eval | stmt.go | srcImporter | func srcImporter(typesImporter types.Importer, path string) (pkg *types.Package, err error) {
return typesImporter.Import(path)
} | go | func srcImporter(typesImporter types.Importer, path string) (pkg *types.Package, err error) {
return typesImporter.Import(path)
} | [
"func",
"srcImporter",
"(",
"typesImporter",
"types",
".",
"Importer",
",",
"path",
"string",
")",
"(",
"pkg",
"*",
"types",
".",
"Package",
",",
"err",
"error",
")",
"{",
"return",
"typesImporter",
".",
"Import",
"(",
"path",
")",
"\n",
"}"
] | // srcImporter implements the ast.Importer signature. | [
"srcImporter",
"implements",
"the",
"ast",
".",
"Importer",
"signature",
"."
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/stmt.go#L1405-L1407 |
17,925 | sbinet/go-eval | compiler.go | newUniverse | func newUniverse() *universeScope {
sc := &universeScope{&Scope{nil, 0}, make(map[string]*Scope)}
sc.block = &block{
offset: 0,
scope: sc.Scope,
global: true,
defs: make(map[string]Def),
}
return sc
} | go | func newUniverse() *universeScope {
sc := &universeScope{&Scope{nil, 0}, make(map[string]*Scope)}
sc.block = &block{
offset: 0,
scope: sc.Scope,
global: true,
defs: make(map[string]Def),
}
return sc
} | [
"func",
"newUniverse",
"(",
")",
"*",
"universeScope",
"{",
"sc",
":=",
"&",
"universeScope",
"{",
"&",
"Scope",
"{",
"nil",
",",
"0",
"}",
",",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Scope",
")",
"}",
"\n",
"sc",
".",
"block",
"=",
"&",
... | // The universal scope | [
"The",
"universal",
"scope"
] | 34e015998e3222afb357e83084cdfada7b293ed0 | https://github.com/sbinet/go-eval/blob/34e015998e3222afb357e83084cdfada7b293ed0/compiler.go#L33-L42 |
17,926 | galeone/igor | igor_private.go | clear | func (db *Database) clear() {
db.rawRows = nil
db.tables = nil
db.joinTables = nil
db.models = nil
db.cteSelectValues = nil
db.cte = ""
db.selectFields = ""
db.updateCreateValues = nil
db.updateCreateFields = nil
db.whereValues = nil
db.whereFields = nil
db.order = ""
db.limit = 0
db.offset = 0
db.varCou... | go | func (db *Database) clear() {
db.rawRows = nil
db.tables = nil
db.joinTables = nil
db.models = nil
db.cteSelectValues = nil
db.cte = ""
db.selectFields = ""
db.updateCreateValues = nil
db.updateCreateFields = nil
db.whereValues = nil
db.whereFields = nil
db.order = ""
db.limit = 0
db.offset = 0
db.varCou... | [
"func",
"(",
"db",
"*",
"Database",
")",
"clear",
"(",
")",
"{",
"db",
".",
"rawRows",
"=",
"nil",
"\n",
"db",
".",
"tables",
"=",
"nil",
"\n",
"db",
".",
"joinTables",
"=",
"nil",
"\n",
"db",
".",
"models",
"=",
"nil",
"\n",
"db",
".",
"cteSel... | // clear is called at the end of every query, to clean up the db structure
// preserving the connection and the logger | [
"clear",
"is",
"called",
"at",
"the",
"end",
"of",
"every",
"query",
"to",
"clean",
"up",
"the",
"db",
"structure",
"preserving",
"the",
"connection",
"and",
"the",
"logger"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L165-L181 |
17,927 | galeone/igor | igor_private.go | printLog | func (db *Database) printLog(v interface{}) {
if db.logger != nil {
db.logger.Print(v)
}
} | go | func (db *Database) printLog(v interface{}) {
if db.logger != nil {
db.logger.Print(v)
}
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"printLog",
"(",
"v",
"interface",
"{",
"}",
")",
"{",
"if",
"db",
".",
"logger",
"!=",
"nil",
"{",
"db",
".",
"logger",
".",
"Print",
"(",
"v",
")",
"\n",
"}",
"\n",
"}"
] | // printLog uses db.log to update log | [
"printLog",
"uses",
"db",
".",
"log",
"to",
"update",
"log"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L184-L188 |
17,928 | galeone/igor | igor_private.go | panicLog | func (db *Database) panicLog(v interface{}) {
if db.logger != nil {
db.logger.Panic(v)
} else {
panic(v)
}
} | go | func (db *Database) panicLog(v interface{}) {
if db.logger != nil {
db.logger.Panic(v)
} else {
panic(v)
}
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"panicLog",
"(",
"v",
"interface",
"{",
"}",
")",
"{",
"if",
"db",
".",
"logger",
"!=",
"nil",
"{",
"db",
".",
"logger",
".",
"Panic",
"(",
"v",
")",
"\n",
"}",
"else",
"{",
"panic",
"(",
"v",
")",
"\n... | // panicLog uses db.log to update log and than it panics
// if db.log is nil, printLog panic using the panic method | [
"panicLog",
"uses",
"db",
".",
"log",
"to",
"update",
"log",
"and",
"than",
"it",
"panics",
"if",
"db",
".",
"log",
"is",
"nil",
"printLog",
"panic",
"using",
"the",
"panic",
"method"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L192-L198 |
17,929 | galeone/igor | igor_private.go | commonRawQuery | func (db *Database) commonRawQuery(query string, args ...interface{}) *sql.Stmt {
// Replace ? with $n
query = db.replaceMarks(query)
// Append args content to current values
db.whereValues = append(db.whereValues, args...)
db.printLog(query)
// Compile query
var stmt *sql.Stmt
var err error
if stmt, err = db... | go | func (db *Database) commonRawQuery(query string, args ...interface{}) *sql.Stmt {
// Replace ? with $n
query = db.replaceMarks(query)
// Append args content to current values
db.whereValues = append(db.whereValues, args...)
db.printLog(query)
// Compile query
var stmt *sql.Stmt
var err error
if stmt, err = db... | [
"func",
"(",
"db",
"*",
"Database",
")",
"commonRawQuery",
"(",
"query",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"sql",
".",
"Stmt",
"{",
"// Replace ? with $n",
"query",
"=",
"db",
".",
"replaceMarks",
"(",
"query",
")",
"\n",
"... | // commonRawQuery executes common operations when using raw queries
// returns the prepared statement | [
"commonRawQuery",
"executes",
"common",
"operations",
"when",
"using",
"raw",
"queries",
"returns",
"the",
"prepared",
"statement"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L214-L228 |
17,930 | galeone/igor | igor_private.go | namingConvention | func namingConvention(name string) string {
// first char is always upper case
var ucActual = true
var buffer bytes.Buffer
buffer.WriteRune(rune(name[0]))
for i := 1; i < len(name); i++ {
prevChar := rune(name[i-1])
actualChar := rune(name[i])
ucActual = unicode.IsUpper(actualChar)
if unicode.IsLower(prevC... | go | func namingConvention(name string) string {
// first char is always upper case
var ucActual = true
var buffer bytes.Buffer
buffer.WriteRune(rune(name[0]))
for i := 1; i < len(name); i++ {
prevChar := rune(name[i-1])
actualChar := rune(name[i])
ucActual = unicode.IsUpper(actualChar)
if unicode.IsLower(prevC... | [
"func",
"namingConvention",
"(",
"name",
"string",
")",
"string",
"{",
"// first char is always upper case",
"var",
"ucActual",
"=",
"true",
"\n",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"buffer",
".",
"WriteRune",
"(",
"rune",
"(",
"name",
"[",
"0",
... | // namingConvention returns the coversion of input name to a
// valid db entity that follows the convention | [
"namingConvention",
"returns",
"the",
"coversion",
"of",
"input",
"name",
"to",
"a",
"valid",
"db",
"entity",
"that",
"follows",
"the",
"convention"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L321-L337 |
17,931 | galeone/igor | igor_private.go | getFields | func getFields(s interface{}) (ret []reflect.StructField) {
val := reflect.Indirect(reflect.ValueOf(s))
// addIf adds filedType to ret if is not marked as `sql:"-"`
addIf := func(fieldType reflect.StructField) {
tag := strings.ToLower(fieldType.Tag.Get("sql"))
tagValue := strings.Split(tag, ",")
sort.Strings(t... | go | func getFields(s interface{}) (ret []reflect.StructField) {
val := reflect.Indirect(reflect.ValueOf(s))
// addIf adds filedType to ret if is not marked as `sql:"-"`
addIf := func(fieldType reflect.StructField) {
tag := strings.ToLower(fieldType.Tag.Get("sql"))
tagValue := strings.Split(tag, ",")
sort.Strings(t... | [
"func",
"getFields",
"(",
"s",
"interface",
"{",
"}",
")",
"(",
"ret",
"[",
"]",
"reflect",
".",
"StructField",
")",
"{",
"val",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"s",
")",
")",
"\n",
"// addIf adds filedType to ret i... | // getFields returns a slice of reflect.StructField that represents the exported struct Fields in s
// that are not excluded in sql generation | [
"getFields",
"returns",
"a",
"slice",
"of",
"reflect",
".",
"StructField",
"that",
"represents",
"the",
"exported",
"struct",
"Fields",
"in",
"s",
"that",
"are",
"not",
"excluded",
"in",
"sql",
"generation"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L365-L398 |
17,932 | galeone/igor | igor_private.go | isBlank | func isBlank(value reflect.Value) bool {
return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())
} | go | func isBlank(value reflect.Value) bool {
return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())
} | [
"func",
"isBlank",
"(",
"value",
"reflect",
".",
"Value",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"value",
".",
"Interface",
"(",
")",
",",
"reflect",
".",
"Zero",
"(",
"value",
".",
"Type",
"(",
")",
")",
".",
"Interface",
"(",... | // isBlank returns true if value is empty | [
"isBlank",
"returns",
"true",
"if",
"value",
"is",
"empty"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L401-L403 |
17,933 | galeone/igor | igor_private.go | buildSelect | func (db *Database) buildSelect() string {
if len(db.tables) == 0 {
db.panicLog("Please set a table with Model [ + Joins ]")
}
var query bytes.Buffer
query.WriteString(db.buildCTE())
// Select
var fields string
query.WriteString("SELECT ")
if len(db.selectFields) > 0 {
fields = db.selectFields
}
query.... | go | func (db *Database) buildSelect() string {
if len(db.tables) == 0 {
db.panicLog("Please set a table with Model [ + Joins ]")
}
var query bytes.Buffer
query.WriteString(db.buildCTE())
// Select
var fields string
query.WriteString("SELECT ")
if len(db.selectFields) > 0 {
fields = db.selectFields
}
query.... | [
"func",
"(",
"db",
"*",
"Database",
")",
"buildSelect",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"db",
".",
"tables",
")",
"==",
"0",
"{",
"db",
".",
"panicLog",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"query",
"bytes",
".",
"Buffer",
... | // buildSelect returns the generated SQL. Panics if it can't generate a query | [
"buildSelect",
"returns",
"the",
"generated",
"SQL",
".",
"Panics",
"if",
"it",
"can",
"t",
"generate",
"a",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L415-L470 |
17,934 | galeone/igor | igor_private.go | buildUpdate | func (db *Database) buildUpdate() string {
var query bytes.Buffer
query.WriteString(db.buildCTE())
query.WriteString("UPDATE ")
// Model only
if len(db.tables) != 1 {
db.panicLog("Please set a table with Model to Update")
}
query.WriteString(db.tables[0])
query.WriteString(" SET ")
updateSize := len(db.upd... | go | func (db *Database) buildUpdate() string {
var query bytes.Buffer
query.WriteString(db.buildCTE())
query.WriteString("UPDATE ")
// Model only
if len(db.tables) != 1 {
db.panicLog("Please set a table with Model to Update")
}
query.WriteString(db.tables[0])
query.WriteString(" SET ")
updateSize := len(db.upd... | [
"func",
"(",
"db",
"*",
"Database",
")",
"buildUpdate",
"(",
")",
"string",
"{",
"var",
"query",
"bytes",
".",
"Buffer",
"\n",
"query",
".",
"WriteString",
"(",
"db",
".",
"buildCTE",
"(",
")",
")",
"\n",
"query",
".",
"WriteString",
"(",
"\"",
"\"",... | // buildUpdate returns the generated SQL for the UPDATE statement. Panics if it can't generate a query | [
"buildUpdate",
"returns",
"the",
"generated",
"SQL",
"for",
"the",
"UPDATE",
"statement",
".",
"Panics",
"if",
"it",
"can",
"t",
"generate",
"a",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L473-L510 |
17,935 | galeone/igor | igor_private.go | buildCreate | func (db *Database) buildCreate() string {
var query bytes.Buffer
query.WriteString(db.buildCTE())
query.WriteString("INSERT INTO ")
// Model only
if len(db.tables) != 1 {
db.panicLog(fmt.Sprintf("Unable to infer table name for Create. Number of tables: %d", len(db.tables)))
}
// Table (
query.WriteString(db... | go | func (db *Database) buildCreate() string {
var query bytes.Buffer
query.WriteString(db.buildCTE())
query.WriteString("INSERT INTO ")
// Model only
if len(db.tables) != 1 {
db.panicLog(fmt.Sprintf("Unable to infer table name for Create. Number of tables: %d", len(db.tables)))
}
// Table (
query.WriteString(db... | [
"func",
"(",
"db",
"*",
"Database",
")",
"buildCreate",
"(",
")",
"string",
"{",
"var",
"query",
"bytes",
".",
"Buffer",
"\n",
"query",
".",
"WriteString",
"(",
"db",
".",
"buildCTE",
"(",
")",
")",
"\n",
"query",
".",
"WriteString",
"(",
"\"",
"\"",... | // buildCreate returns the generated SQL for the CREATE statement. Panics if it can't generate a query | [
"buildCreate",
"returns",
"the",
"generated",
"SQL",
"for",
"the",
"CREATE",
"statement",
".",
"Panics",
"if",
"it",
"can",
"t",
"generate",
"a",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L513-L551 |
17,936 | galeone/igor | igor_private.go | buildReturning | func (db *Database) buildReturning() string {
var query bytes.Buffer
query.WriteString(" RETURNING ")
query.WriteString(strings.Join(getSQLFields(db.models[0]), ","))
return query.String()
} | go | func (db *Database) buildReturning() string {
var query bytes.Buffer
query.WriteString(" RETURNING ")
query.WriteString(strings.Join(getSQLFields(db.models[0]), ","))
return query.String()
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"buildReturning",
"(",
")",
"string",
"{",
"var",
"query",
"bytes",
".",
"Buffer",
"\n",
"query",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"query",
".",
"WriteString",
"(",
"strings",
".",
"Join",
"(",
... | // buildReturning returns the RETURNING part of the query
// it explicits every fields in the current model.
// In that way we're able to easily Scan the results | [
"buildReturning",
"returns",
"the",
"RETURNING",
"part",
"of",
"the",
"query",
"it",
"explicits",
"every",
"fields",
"in",
"the",
"current",
"model",
".",
"In",
"that",
"way",
"we",
"re",
"able",
"to",
"easily",
"Scan",
"the",
"results"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L556-L561 |
17,937 | galeone/igor | igor_private.go | buildDelete | func (db *Database) buildDelete() string {
var query bytes.Buffer
query.WriteString(db.buildCTE())
query.WriteString("DELETE FROM ")
// Model only
if len(db.tables) != 1 {
db.panicLog("Unable to infer table name for Delete. Use Delete(model) or Model(model)")
}
query.WriteString(db.tables[0])
// Where (mand... | go | func (db *Database) buildDelete() string {
var query bytes.Buffer
query.WriteString(db.buildCTE())
query.WriteString("DELETE FROM ")
// Model only
if len(db.tables) != 1 {
db.panicLog("Unable to infer table name for Delete. Use Delete(model) or Model(model)")
}
query.WriteString(db.tables[0])
// Where (mand... | [
"func",
"(",
"db",
"*",
"Database",
")",
"buildDelete",
"(",
")",
"string",
"{",
"var",
"query",
"bytes",
".",
"Buffer",
"\n",
"query",
".",
"WriteString",
"(",
"db",
".",
"buildCTE",
"(",
")",
")",
"\n",
"query",
".",
"WriteString",
"(",
"\"",
"\"",... | // buildDelete returns the generated SQL for the DELETE statement. Panics if it can't geerate a query | [
"buildDelete",
"returns",
"the",
"generated",
"SQL",
"for",
"the",
"DELETE",
"statement",
".",
"Panics",
"if",
"it",
"can",
"t",
"geerate",
"a",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L570-L592 |
17,938 | galeone/igor | igor_private.go | buildWhere | func (db *Database) buildWhere() string {
var query bytes.Buffer
whereSize := len(db.whereFields)
if whereSize == 0 {
db.panicLog("Please add a Where condition with .Where")
}
query.WriteString(" WHERE ")
for j, clause := range db.whereFields {
if strings.Contains(clause, "$") {
query.WriteString(clause)... | go | func (db *Database) buildWhere() string {
var query bytes.Buffer
whereSize := len(db.whereFields)
if whereSize == 0 {
db.panicLog("Please add a Where condition with .Where")
}
query.WriteString(" WHERE ")
for j, clause := range db.whereFields {
if strings.Contains(clause, "$") {
query.WriteString(clause)... | [
"func",
"(",
"db",
"*",
"Database",
")",
"buildWhere",
"(",
")",
"string",
"{",
"var",
"query",
"bytes",
".",
"Buffer",
"\n",
"whereSize",
":=",
"len",
"(",
"db",
".",
"whereFields",
")",
"\n",
"if",
"whereSize",
"==",
"0",
"{",
"db",
".",
"panicLog"... | // buildWhere returns the generated SQL for the WHERE clause. Panics if the Where method hasn't been called
// The generated query uses the PostgreSQL placeholders for query parameters in compiled queries | [
"buildWhere",
"returns",
"the",
"generated",
"SQL",
"for",
"the",
"WHERE",
"clause",
".",
"Panics",
"if",
"the",
"Where",
"method",
"hasn",
"t",
"been",
"called",
"The",
"generated",
"query",
"uses",
"the",
"PostgreSQL",
"placeholders",
"for",
"query",
"parame... | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L596-L620 |
17,939 | galeone/igor | igor_private.go | clone | func (db *Database) clone() *Database {
clone := &Database{
connection: db.connection,
db: db.db,
rawRows: db.rawRows,
logger: db.logger,
cte: db.cte,
selectFields: db.selectFields,
order: db.order,
limit: db.limit,
offset:... | go | func (db *Database) clone() *Database {
clone := &Database{
connection: db.connection,
db: db.db,
rawRows: db.rawRows,
logger: db.logger,
cte: db.cte,
selectFields: db.selectFields,
order: db.order,
limit: db.limit,
offset:... | [
"func",
"(",
"db",
"*",
"Database",
")",
"clone",
"(",
")",
"*",
"Database",
"{",
"clone",
":=",
"&",
"Database",
"{",
"connection",
":",
"db",
".",
"connection",
",",
"db",
":",
"db",
".",
"db",
",",
"rawRows",
":",
"db",
".",
"rawRows",
",",
"l... | // clone clones the current Database in order to be thread safe | [
"clone",
"clones",
"the",
"current",
"Database",
"in",
"order",
"to",
"be",
"thread",
"safe"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor_private.go#L686-L727 |
17,940 | galeone/igor | notifications.go | Notify | func (db *Database) Notify(channel string, payload ...string) error {
pl := strings.Join(payload, ",")
if len(pl) > 0 {
return db.Exec("SELECT pg_notify(?, ?)", channel, pl)
}
return db.Exec("NOTIFY " + handleIdentifier(channel))
} | go | func (db *Database) Notify(channel string, payload ...string) error {
pl := strings.Join(payload, ",")
if len(pl) > 0 {
return db.Exec("SELECT pg_notify(?, ?)", channel, pl)
}
return db.Exec("NOTIFY " + handleIdentifier(channel))
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Notify",
"(",
"channel",
"string",
",",
"payload",
"...",
"string",
")",
"error",
"{",
"pl",
":=",
"strings",
".",
"Join",
"(",
"payload",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"pl",
")",
">",
"0"... | // Notify sends a notification on channel, optional payloads are joined together and comma separated | [
"Notify",
"sends",
"a",
"notification",
"on",
"channel",
"optional",
"payloads",
"are",
"joined",
"together",
"and",
"comma",
"separated"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/notifications.go#L95-L101 |
17,941 | galeone/igor | json.go | Scan | func (js *JSON) Scan(src interface{}) error {
if src == nil {
*js = make(JSON)
return nil
}
source, ok := src.([]byte)
if !ok {
return errors.New("Type assertion .([]byte) failed.")
}
if err := json.Unmarshal(source, js); err != nil {
return err
}
return nil
} | go | func (js *JSON) Scan(src interface{}) error {
if src == nil {
*js = make(JSON)
return nil
}
source, ok := src.([]byte)
if !ok {
return errors.New("Type assertion .([]byte) failed.")
}
if err := json.Unmarshal(source, js); err != nil {
return err
}
return nil
} | [
"func",
"(",
"js",
"*",
"JSON",
")",
"Scan",
"(",
"src",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"src",
"==",
"nil",
"{",
"*",
"js",
"=",
"make",
"(",
"JSON",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"source",
",",
"ok",
":=",
"sr... | // Scan implements sql.Scanner interface | [
"Scan",
"implements",
"sql",
".",
"Scanner",
"interface"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/json.go#L36-L50 |
17,942 | galeone/igor | igor.go | Connect | func Connect(connectionString string) (*Database, error) {
var e error
db := new(Database)
if db.db, e = sql.Open("postgres", connectionString); e != nil {
return nil, e
}
// Ping the database to see if the connection is real
if e = db.DB().Ping(); e != nil {
return nil, errors.New("Connection failed. Unable... | go | func Connect(connectionString string) (*Database, error) {
var e error
db := new(Database)
if db.db, e = sql.Open("postgres", connectionString); e != nil {
return nil, e
}
// Ping the database to see if the connection is real
if e = db.DB().Ping(); e != nil {
return nil, errors.New("Connection failed. Unable... | [
"func",
"Connect",
"(",
"connectionString",
"string",
")",
"(",
"*",
"Database",
",",
"error",
")",
"{",
"var",
"e",
"error",
"\n",
"db",
":=",
"new",
"(",
"Database",
")",
"\n",
"if",
"db",
".",
"db",
",",
"e",
"=",
"sql",
".",
"Open",
"(",
"\""... | // Connect opens the connection to PostgreSQL using connectionString | [
"Connect",
"opens",
"the",
"connection",
"to",
"PostgreSQL",
"using",
"connectionString"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L53-L68 |
17,943 | galeone/igor | igor.go | Log | func (db *Database) Log(logger *log.Logger) *Database {
db.logger = logger
return db
} | go | func (db *Database) Log(logger *log.Logger) *Database {
db.logger = logger
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Log",
"(",
"logger",
"*",
"log",
".",
"Logger",
")",
"*",
"Database",
"{",
"db",
".",
"logger",
"=",
"logger",
"\n",
"return",
"db",
"\n",
"}"
] | // Log sets the query logger | [
"Log",
"sets",
"the",
"query",
"logger"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L71-L74 |
17,944 | galeone/igor | igor.go | Model | func (db *Database) Model(model DBModel) *Database {
db = db.clone()
db.tables = append(db.tables, handleIdentifier(model.TableName()))
db.models = append(db.models, model)
return db
} | go | func (db *Database) Model(model DBModel) *Database {
db = db.clone()
db.tables = append(db.tables, handleIdentifier(model.TableName()))
db.models = append(db.models, model)
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Model",
"(",
"model",
"DBModel",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"tables",
"=",
"append",
"(",
"db",
".",
"tables",
",",
"handleIdentifier",
"(",
"model"... | // Model sets the table name for the current query | [
"Model",
"sets",
"the",
"table",
"name",
"for",
"the",
"current",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L77-L82 |
17,945 | galeone/igor | igor.go | Joins | func (db *Database) Joins(joins string) *Database {
db = db.clone()
db.joinTables = append(db.joinTables, joins)
// we can't infer model from the join string (can contain everything)
return db
} | go | func (db *Database) Joins(joins string) *Database {
db = db.clone()
db.joinTables = append(db.joinTables, joins)
// we can't infer model from the join string (can contain everything)
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Joins",
"(",
"joins",
"string",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"joinTables",
"=",
"append",
"(",
"db",
".",
"joinTables",
",",
"joins",
")",
"\n",
"//... | // Joins append the join string to the current model | [
"Joins",
"append",
"the",
"join",
"string",
"to",
"the",
"current",
"model"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L85-L90 |
17,946 | galeone/igor | igor.go | Table | func (db *Database) Table(table string) *Database {
db = db.clone()
db.tables = append(db.tables, handleIdentifier(table))
return db
} | go | func (db *Database) Table(table string) *Database {
db = db.clone()
db.tables = append(db.tables, handleIdentifier(table))
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Table",
"(",
"table",
"string",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"tables",
"=",
"append",
"(",
"db",
".",
"tables",
",",
"handleIdentifier",
"(",
"table",... | // Table appends the table string to FROM. It has the same behavior of Model, but
// passing the tablename directly as a string | [
"Table",
"appends",
"the",
"table",
"string",
"to",
"FROM",
".",
"It",
"has",
"the",
"same",
"behavior",
"of",
"Model",
"but",
"passing",
"the",
"tablename",
"directly",
"as",
"a",
"string"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L94-L98 |
17,947 | galeone/igor | igor.go | Select | func (db *Database) Select(fields string, args ...interface{}) *Database {
db = db.clone()
db.selectFields += db.replaceMarks(fields)
db.cteSelectValues = append(db.cteSelectValues, args...)
return db
} | go | func (db *Database) Select(fields string, args ...interface{}) *Database {
db = db.clone()
db.selectFields += db.replaceMarks(fields)
db.cteSelectValues = append(db.cteSelectValues, args...)
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Select",
"(",
"fields",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"selectFields",
"+=",
"db",
".",
"replaceMar... | // Select sets the fields to retrieve. Appends fields to SELECT | [
"Select",
"sets",
"the",
"fields",
"to",
"retrieve",
".",
"Appends",
"fields",
"to",
"SELECT"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L101-L106 |
17,948 | galeone/igor | igor.go | CTE | func (db *Database) CTE(cte string, args ...interface{}) *Database {
db = db.clone()
db.cte += db.replaceMarks(cte)
db.cteSelectValues = append(db.cteSelectValues, args...)
return db
} | go | func (db *Database) CTE(cte string, args ...interface{}) *Database {
db = db.clone()
db.cte += db.replaceMarks(cte)
db.cteSelectValues = append(db.cteSelectValues, args...)
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"CTE",
"(",
"cte",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"cte",
"+=",
"db",
".",
"replaceMarks",
"(",
"... | // CTE defines a Common Table Expression. Parameters are allowed | [
"CTE",
"defines",
"a",
"Common",
"Table",
"Expression",
".",
"Parameters",
"are",
"allowed"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L109-L114 |
17,949 | galeone/igor | igor.go | Create | func (db *Database) Create(value DBModel) error {
defer func() {
if db.rawRows != nil {
db.rawRows.Close()
}
}()
db = db.clone()
return db.commonCreateUpdate(value, db.buildCreate)
} | go | func (db *Database) Create(value DBModel) error {
defer func() {
if db.rawRows != nil {
db.rawRows.Close()
}
}()
db = db.clone()
return db.commonCreateUpdate(value, db.buildCreate)
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Create",
"(",
"value",
"DBModel",
")",
"error",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"db",
".",
"rawRows",
"!=",
"nil",
"{",
"db",
".",
"rawRows",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}",
"("... | // Create creates a new row into the Database, of type value and with its fields | [
"Create",
"creates",
"a",
"new",
"row",
"into",
"the",
"Database",
"of",
"type",
"value",
"and",
"with",
"its",
"fields"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L164-L172 |
17,950 | galeone/igor | igor.go | First | func (db *Database) First(dest DBModel, key interface{}) error {
modelKey, _ := primaryKey(dest)
in := reflect.Indirect(reflect.ValueOf(dest))
in.FieldByName(modelKey).Set(reflect.Indirect(reflect.ValueOf(key)))
return db.Model(dest).Where(in.Interface()).Scan(dest)
} | go | func (db *Database) First(dest DBModel, key interface{}) error {
modelKey, _ := primaryKey(dest)
in := reflect.Indirect(reflect.ValueOf(dest))
in.FieldByName(modelKey).Set(reflect.Indirect(reflect.ValueOf(key)))
return db.Model(dest).Where(in.Interface()).Scan(dest)
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"First",
"(",
"dest",
"DBModel",
",",
"key",
"interface",
"{",
"}",
")",
"error",
"{",
"modelKey",
",",
"_",
":=",
"primaryKey",
"(",
"dest",
")",
"\n",
"in",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
... | // First Scans the result of the selection query of type model using the specified id
// Panics if key is not compatible with the primary key filed type or if the query formulation fails | [
"First",
"Scans",
"the",
"result",
"of",
"the",
"selection",
"query",
"of",
"type",
"model",
"using",
"the",
"specified",
"id",
"Panics",
"if",
"key",
"is",
"not",
"compatible",
"with",
"the",
"primary",
"key",
"filed",
"type",
"or",
"if",
"the",
"query",
... | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L202-L207 |
17,951 | galeone/igor | igor.go | Limit | func (db *Database) Limit(limit int) *Database {
db = db.clone()
db.limit = limit
return db
} | go | func (db *Database) Limit(limit int) *Database {
db = db.clone()
db.limit = limit
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Limit",
"(",
"limit",
"int",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"limit",
"=",
"limit",
"\n",
"return",
"db",
"\n",
"}"
] | // Limit sets the LIMIT value to the query | [
"Limit",
"sets",
"the",
"LIMIT",
"value",
"to",
"the",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L438-L442 |
17,952 | galeone/igor | igor.go | Offset | func (db *Database) Offset(offset int) *Database {
db = db.clone()
db.offset = offset
return db
} | go | func (db *Database) Offset(offset int) *Database {
db = db.clone()
db.offset = offset
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Offset",
"(",
"offset",
"int",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"offset",
"=",
"offset",
"\n",
"return",
"db",
"\n",
"}"
] | // Offset sets the OFFSET value to the query | [
"Offset",
"sets",
"the",
"OFFSET",
"value",
"to",
"the",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L445-L449 |
17,953 | galeone/igor | igor.go | Order | func (db *Database) Order(value string) *Database {
db = db.clone()
db.order = handleIdentifier(value)
return db
} | go | func (db *Database) Order(value string) *Database {
db = db.clone()
db.order = handleIdentifier(value)
return db
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"Order",
"(",
"value",
"string",
")",
"*",
"Database",
"{",
"db",
"=",
"db",
".",
"clone",
"(",
")",
"\n",
"db",
".",
"order",
"=",
"handleIdentifier",
"(",
"value",
")",
"\n",
"return",
"db",
"\n",
"}"
] | // Order sets the ORDER BY value to the query | [
"Order",
"sets",
"the",
"ORDER",
"BY",
"value",
"to",
"the",
"query"
] | 8553c8563c92ac5f94d02d70d00fa9df3e91bf3f | https://github.com/galeone/igor/blob/8553c8563c92ac5f94d02d70d00fa9df3e91bf3f/igor.go#L452-L456 |
17,954 | widuu/goini | conf.go | SetConfig | func SetConfig(filepath string) *Config {
c := new(Config)
c.filepath = filepath
return c
} | go | func SetConfig(filepath string) *Config {
c := new(Config)
c.filepath = filepath
return c
} | [
"func",
"SetConfig",
"(",
"filepath",
"string",
")",
"*",
"Config",
"{",
"c",
":=",
"new",
"(",
"Config",
")",
"\n",
"c",
".",
"filepath",
"=",
"filepath",
"\n\n",
"return",
"c",
"\n",
"}"
] | //Create an empty configuration file | [
"Create",
"an",
"empty",
"configuration",
"file"
] | 56a38bd2e09b9c1cbf849ab1404e74b33a9d9593 | https://github.com/widuu/goini/blob/56a38bd2e09b9c1cbf849ab1404e74b33a9d9593/conf.go#L26-L31 |
17,955 | widuu/goini | conf.go | GetValue | func (c *Config) GetValue(section, name string) string {
c.ReadList()
conf := c.ReadList()
for _, v := range conf {
for key, value := range v {
if key == section {
return value[name]
}
}
}
return "no value"
} | go | func (c *Config) GetValue(section, name string) string {
c.ReadList()
conf := c.ReadList()
for _, v := range conf {
for key, value := range v {
if key == section {
return value[name]
}
}
}
return "no value"
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetValue",
"(",
"section",
",",
"name",
"string",
")",
"string",
"{",
"c",
".",
"ReadList",
"(",
")",
"\n",
"conf",
":=",
"c",
".",
"ReadList",
"(",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"conf",
... | //To obtain corresponding value of the key values | [
"To",
"obtain",
"corresponding",
"value",
"of",
"the",
"key",
"values"
] | 56a38bd2e09b9c1cbf849ab1404e74b33a9d9593 | https://github.com/widuu/goini/blob/56a38bd2e09b9c1cbf849ab1404e74b33a9d9593/conf.go#L34-L45 |
17,956 | widuu/goini | conf.go | SetValue | func (c *Config) SetValue(section, key, value string) bool {
c.ReadList()
data := c.conflist
var ok bool
var index = make(map[int]bool)
var conf = make(map[string]map[string]string)
for i, v := range data {
_, ok = v[section]
index[i] = ok
}
i, ok := func(m map[int]bool) (i int, v bool) {
for i, v := ran... | go | func (c *Config) SetValue(section, key, value string) bool {
c.ReadList()
data := c.conflist
var ok bool
var index = make(map[int]bool)
var conf = make(map[string]map[string]string)
for i, v := range data {
_, ok = v[section]
index[i] = ok
}
i, ok := func(m map[int]bool) (i int, v bool) {
for i, v := ran... | [
"func",
"(",
"c",
"*",
"Config",
")",
"SetValue",
"(",
"section",
",",
"key",
",",
"value",
"string",
")",
"bool",
"{",
"c",
".",
"ReadList",
"(",
")",
"\n",
"data",
":=",
"c",
".",
"conflist",
"\n",
"var",
"ok",
"bool",
"\n",
"var",
"index",
"="... | //Set the corresponding value of the key value, if not add, if there is a key change | [
"Set",
"the",
"corresponding",
"value",
"of",
"the",
"key",
"value",
"if",
"not",
"add",
"if",
"there",
"is",
"a",
"key",
"change"
] | 56a38bd2e09b9c1cbf849ab1404e74b33a9d9593 | https://github.com/widuu/goini/blob/56a38bd2e09b9c1cbf849ab1404e74b33a9d9593/conf.go#L48-L79 |
17,957 | widuu/goini | conf.go | DeleteValue | func (c *Config) DeleteValue(section, name string) bool {
c.ReadList()
data := c.conflist
for i, v := range data {
for key, _ := range v {
if key == section {
delete(c.conflist[i][key], name)
return true
}
}
}
return false
} | go | func (c *Config) DeleteValue(section, name string) bool {
c.ReadList()
data := c.conflist
for i, v := range data {
for key, _ := range v {
if key == section {
delete(c.conflist[i][key], name)
return true
}
}
}
return false
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"DeleteValue",
"(",
"section",
",",
"name",
"string",
")",
"bool",
"{",
"c",
".",
"ReadList",
"(",
")",
"\n",
"data",
":=",
"c",
".",
"conflist",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"data",
"{",
"for",... | //Delete the corresponding key values | [
"Delete",
"the",
"corresponding",
"key",
"values"
] | 56a38bd2e09b9c1cbf849ab1404e74b33a9d9593 | https://github.com/widuu/goini/blob/56a38bd2e09b9c1cbf849ab1404e74b33a9d9593/conf.go#L82-L94 |
17,958 | widuu/goini | conf.go | ReadList | func (c *Config) ReadList() []map[string]map[string]string {
file, err := os.Open(c.filepath)
if err != nil {
CheckErr(err)
}
defer file.Close()
var data map[string]map[string]string
var section string
buf := bufio.NewReader(file)
for {
l, err := buf.ReadString('\n')
line := strings.TrimSpace(l)
if err... | go | func (c *Config) ReadList() []map[string]map[string]string {
file, err := os.Open(c.filepath)
if err != nil {
CheckErr(err)
}
defer file.Close()
var data map[string]map[string]string
var section string
buf := bufio.NewReader(file)
for {
l, err := buf.ReadString('\n')
line := strings.TrimSpace(l)
if err... | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadList",
"(",
")",
"[",
"]",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"c",
".",
"filepath",
")",
"\n",
"if",
"err",
"!=",
"... | //List all the configuration file | [
"List",
"all",
"the",
"configuration",
"file"
] | 56a38bd2e09b9c1cbf849ab1404e74b33a9d9593 | https://github.com/widuu/goini/blob/56a38bd2e09b9c1cbf849ab1404e74b33a9d9593/conf.go#L97-L140 |
17,959 | widuu/goini | conf.go | uniquappend | func (c *Config) uniquappend(conf string) bool {
for _, v := range c.conflist {
for k, _ := range v {
if k == conf {
return false
}
}
}
return true
} | go | func (c *Config) uniquappend(conf string) bool {
for _, v := range c.conflist {
for k, _ := range v {
if k == conf {
return false
}
}
}
return true
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"uniquappend",
"(",
"conf",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"c",
".",
"conflist",
"{",
"for",
"k",
",",
"_",
":=",
"range",
"v",
"{",
"if",
"k",
"==",
"conf",
"{",
"return",... | //Ban repeated appended to the slice method | [
"Ban",
"repeated",
"appended",
"to",
"the",
"slice",
"method"
] | 56a38bd2e09b9c1cbf849ab1404e74b33a9d9593 | https://github.com/widuu/goini/blob/56a38bd2e09b9c1cbf849ab1404e74b33a9d9593/conf.go#L150-L159 |
17,960 | gobuffalo/velvet | markdown_helper.go | markdownHelper | func markdownHelper(body string) template.HTML {
b := github_flavored_markdown.Markdown([]byte(body))
return template.HTML(b)
} | go | func markdownHelper(body string) template.HTML {
b := github_flavored_markdown.Markdown([]byte(body))
return template.HTML(b)
} | [
"func",
"markdownHelper",
"(",
"body",
"string",
")",
"template",
".",
"HTML",
"{",
"b",
":=",
"github_flavored_markdown",
".",
"Markdown",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
")",
"\n",
"return",
"template",
".",
"HTML",
"(",
"b",
")",
"\n",
"}"
... | // Markdown converts the string into HTML using GitHub flavored markdown. | [
"Markdown",
"converts",
"the",
"string",
"into",
"HTML",
"using",
"GitHub",
"flavored",
"markdown",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/markdown_helper.go#L10-L13 |
17,961 | gobuffalo/velvet | context.go | New | func (c *Context) New() *Context {
cc := NewContext()
cc.outer = c
return cc
} | go | func (c *Context) New() *Context {
cc := NewContext()
cc.outer = c
return cc
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"New",
"(",
")",
"*",
"Context",
"{",
"cc",
":=",
"NewContext",
"(",
")",
"\n",
"cc",
".",
"outer",
"=",
"c",
"\n",
"return",
"cc",
"\n",
"}"
] | // New context containing the current context. Values set on the new context
// will not be set onto the original context, however, the original context's
// values will be available to the new context. | [
"New",
"context",
"containing",
"the",
"current",
"context",
".",
"Values",
"set",
"on",
"the",
"new",
"context",
"will",
"not",
"be",
"set",
"onto",
"the",
"original",
"context",
"however",
"the",
"original",
"context",
"s",
"values",
"will",
"be",
"availab... | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/context.go#L32-L36 |
17,962 | gobuffalo/velvet | context.go | Set | func (c *Context) Set(key string, value interface{}) {
c.data[key] = value
} | go | func (c *Context) Set(key string, value interface{}) {
c.data[key] = value
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Set",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"data",
"[",
"key",
"]",
"=",
"value",
"\n",
"}"
] | // Set a value onto the context | [
"Set",
"a",
"value",
"onto",
"the",
"context"
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/context.go#L39-L41 |
17,963 | gobuffalo/velvet | context.go | Get | func (c *Context) Get(key string) interface{} {
if v, ok := c.data[key]; ok {
return v
}
if c.outer != nil {
return c.outer.Get(key)
}
return nil
} | go | func (c *Context) Get(key string) interface{} {
if v, ok := c.data[key]; ok {
return v
}
if c.outer != nil {
return c.outer.Get(key)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Get",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"if",
"v",
",",
"ok",
":=",
"c",
".",
"data",
"[",
"key",
"]",
";",
"ok",
"{",
"return",
"v",
"\n",
"}",
"\n",
"if",
"c",
".",
"outer",
"!=... | // Get a value from the context, or it's parent's context if one exists. | [
"Get",
"a",
"value",
"from",
"the",
"context",
"or",
"it",
"s",
"parent",
"s",
"context",
"if",
"one",
"exists",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/context.go#L44-L52 |
17,964 | gobuffalo/velvet | context.go | Has | func (c *Context) Has(key string) bool {
return c.Get(key) != nil
} | go | func (c *Context) Has(key string) bool {
return c.Get(key) != nil
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Has",
"(",
"key",
"string",
")",
"bool",
"{",
"return",
"c",
".",
"Get",
"(",
"key",
")",
"!=",
"nil",
"\n",
"}"
] | // Has checks the existence of the key in the context. | [
"Has",
"checks",
"the",
"existence",
"of",
"the",
"key",
"in",
"the",
"context",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/context.go#L55-L57 |
17,965 | gobuffalo/velvet | context.go | NewContextWith | func NewContextWith(data map[string]interface{}) *Context {
c := NewContext()
c.data = data
return c
} | go | func NewContextWith(data map[string]interface{}) *Context {
c := NewContext()
c.data = data
return c
} | [
"func",
"NewContextWith",
"(",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"Context",
"{",
"c",
":=",
"NewContext",
"(",
")",
"\n",
"c",
".",
"data",
"=",
"data",
"\n",
"return",
"c",
"\n",
"}"
] | // NewContextWith returns a fully formed context using the data
// provided. | [
"NewContextWith",
"returns",
"a",
"fully",
"formed",
"context",
"using",
"the",
"data",
"provided",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/context.go#L75-L79 |
17,966 | gobuffalo/velvet | helpers.go | BlockWith | func (h HelperContext) BlockWith(ctx *Context) (string, error) {
nev := newEvalVisitor(h.evalVisitor.template, ctx)
nev.blockParams = h.evalVisitor.blockParams
dd := nev.VisitProgram(h.evalVisitor.curBlock.Program)
switch tp := dd.(type) {
case string:
return tp, nil
case error:
return "", errors.WithStack(tp... | go | func (h HelperContext) BlockWith(ctx *Context) (string, error) {
nev := newEvalVisitor(h.evalVisitor.template, ctx)
nev.blockParams = h.evalVisitor.blockParams
dd := nev.VisitProgram(h.evalVisitor.curBlock.Program)
switch tp := dd.(type) {
case string:
return tp, nil
case error:
return "", errors.WithStack(tp... | [
"func",
"(",
"h",
"HelperContext",
")",
"BlockWith",
"(",
"ctx",
"*",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"nev",
":=",
"newEvalVisitor",
"(",
"h",
".",
"evalVisitor",
".",
"template",
",",
"ctx",
")",
"\n",
"nev",
".",
"blockParams",... | // BlockWith executes the block of template associated with
// the helper, think the block inside of an "if" or "each"
// statement. It takes a new context with which to evaluate
// the block. | [
"BlockWith",
"executes",
"the",
"block",
"of",
"template",
"associated",
"with",
"the",
"helper",
"think",
"the",
"block",
"inside",
"of",
"an",
"if",
"or",
"each",
"statement",
".",
"It",
"takes",
"a",
"new",
"context",
"with",
"which",
"to",
"evaluate",
... | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/helpers.go#L64-L78 |
17,967 | gobuffalo/velvet | helpers.go | toJSONHelper | func toJSONHelper(v interface{}) (template.HTML, error) {
b, err := json.Marshal(v)
if err != nil {
return "", errors.WithStack(err)
}
return template.HTML(b), nil
} | go | func toJSONHelper(v interface{}) (template.HTML, error) {
b, err := json.Marshal(v)
if err != nil {
return "", errors.WithStack(err)
}
return template.HTML(b), nil
} | [
"func",
"toJSONHelper",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"template",
".",
"HTML",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"e... | // toJSONHelper converts an interface into a string. | [
"toJSONHelper",
"converts",
"an",
"interface",
"into",
"a",
"string",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/helpers.go#L121-L127 |
17,968 | gobuffalo/velvet | velvet.go | BuffaloRenderer | func BuffaloRenderer(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error) {
t, err := Parse(input)
if err != nil {
return "", err
}
if helpers != nil {
t.Helpers.AddMany(helpers)
}
return t.Exec(NewContextWith(data))
} | go | func BuffaloRenderer(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error) {
t, err := Parse(input)
if err != nil {
return "", err
}
if helpers != nil {
t.Helpers.AddMany(helpers)
}
return t.Exec(NewContextWith(data))
} | [
"func",
"BuffaloRenderer",
"(",
"input",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"helpers",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"... | // BuffaloRenderer implements the render.TemplateEngine interface allowing velvet to be used as a template engine
// for Buffalo | [
"BuffaloRenderer",
"implements",
"the",
"render",
".",
"TemplateEngine",
"interface",
"allowing",
"velvet",
"to",
"be",
"used",
"as",
"a",
"template",
"engine",
"for",
"Buffalo"
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/velvet.go#L11-L20 |
17,969 | gobuffalo/velvet | velvet.go | Parse | func Parse(input string) (*Template, error) {
moot.Lock()
defer moot.Unlock()
if t, ok := cache[input]; ok {
return t, nil
}
t, err := NewTemplate(input)
if err == nil {
cache[input] = t
}
if err != nil {
return t, errors.WithStack(err)
}
return t, nil
} | go | func Parse(input string) (*Template, error) {
moot.Lock()
defer moot.Unlock()
if t, ok := cache[input]; ok {
return t, nil
}
t, err := NewTemplate(input)
if err == nil {
cache[input] = t
}
if err != nil {
return t, errors.WithStack(err)
}
return t, nil
} | [
"func",
"Parse",
"(",
"input",
"string",
")",
"(",
"*",
"Template",
",",
"error",
")",
"{",
"moot",
".",
"Lock",
"(",
")",
"\n",
"defer",
"moot",
".",
"Unlock",
"(",
")",
"\n",
"if",
"t",
",",
"ok",
":=",
"cache",
"[",
"input",
"]",
";",
"ok",
... | // Parse an input string and return a Template. | [
"Parse",
"an",
"input",
"string",
"and",
"return",
"a",
"Template",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/velvet.go#L26-L43 |
17,970 | gobuffalo/velvet | velvet.go | Render | func Render(input string, ctx *Context) (string, error) {
t, err := Parse(input)
if err != nil {
return "", errors.WithStack(err)
}
return t.Exec(ctx)
} | go | func Render(input string, ctx *Context) (string, error) {
t, err := Parse(input)
if err != nil {
return "", errors.WithStack(err)
}
return t.Exec(ctx)
} | [
"func",
"Render",
"(",
"input",
"string",
",",
"ctx",
"*",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"Parse",
"(",
"input",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
... | // Render a string using the given the context. | [
"Render",
"a",
"string",
"using",
"the",
"given",
"the",
"context",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/velvet.go#L46-L52 |
17,971 | gobuffalo/velvet | template.go | NewTemplate | func NewTemplate(input string) (*Template, error) {
hm, err := NewHelperMap()
if err != nil {
return nil, errors.WithStack(err)
}
t := &Template{
Input: input,
Helpers: hm,
}
err = t.Parse()
if err != nil {
return t, errors.WithStack(err)
}
return t, nil
} | go | func NewTemplate(input string) (*Template, error) {
hm, err := NewHelperMap()
if err != nil {
return nil, errors.WithStack(err)
}
t := &Template{
Input: input,
Helpers: hm,
}
err = t.Parse()
if err != nil {
return t, errors.WithStack(err)
}
return t, nil
} | [
"func",
"NewTemplate",
"(",
"input",
"string",
")",
"(",
"*",
"Template",
",",
"error",
")",
"{",
"hm",
",",
"err",
":=",
"NewHelperMap",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"WithStack",
"(",
"err",
"... | // NewTemplate from the input string. Adds all of the
// global helper functions from "velvet.Helpers". | [
"NewTemplate",
"from",
"the",
"input",
"string",
".",
"Adds",
"all",
"of",
"the",
"global",
"helper",
"functions",
"from",
"velvet",
".",
"Helpers",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/template.go#L19-L33 |
17,972 | gobuffalo/velvet | template.go | Exec | func (t *Template) Exec(ctx *Context) (string, error) {
err := t.Parse()
if err != nil {
return "", errors.WithStack(err)
}
v := newEvalVisitor(t, ctx)
r := t.program.Accept(v)
switch rp := r.(type) {
case string:
return rp, nil
case error:
return "", rp
case nil:
return "", nil
default:
return "", ... | go | func (t *Template) Exec(ctx *Context) (string, error) {
err := t.Parse()
if err != nil {
return "", errors.WithStack(err)
}
v := newEvalVisitor(t, ctx)
r := t.program.Accept(v)
switch rp := r.(type) {
case string:
return rp, nil
case error:
return "", rp
case nil:
return "", nil
default:
return "", ... | [
"func",
"(",
"t",
"*",
"Template",
")",
"Exec",
"(",
"ctx",
"*",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"t",
".",
"Parse",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"... | // Exec the template using the content and return the results | [
"Exec",
"the",
"template",
"using",
"the",
"content",
"and",
"return",
"the",
"results"
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/template.go#L51-L68 |
17,973 | gobuffalo/velvet | template.go | Clone | func (t *Template) Clone() *Template {
hm, _ := NewHelperMap()
hm.AddMany(t.Helpers.Helpers())
t2 := &Template{
Helpers: hm,
Input: t.Input,
program: t.program,
}
return t2
} | go | func (t *Template) Clone() *Template {
hm, _ := NewHelperMap()
hm.AddMany(t.Helpers.Helpers())
t2 := &Template{
Helpers: hm,
Input: t.Input,
program: t.program,
}
return t2
} | [
"func",
"(",
"t",
"*",
"Template",
")",
"Clone",
"(",
")",
"*",
"Template",
"{",
"hm",
",",
"_",
":=",
"NewHelperMap",
"(",
")",
"\n",
"hm",
".",
"AddMany",
"(",
"t",
".",
"Helpers",
".",
"Helpers",
"(",
")",
")",
"\n",
"t2",
":=",
"&",
"Templa... | // Clone a template. This is useful for defining helpers on per "instance" of the template. | [
"Clone",
"a",
"template",
".",
"This",
"is",
"useful",
"for",
"defining",
"helpers",
"on",
"per",
"instance",
"of",
"the",
"template",
"."
] | d97471bf5d8fd758ba0ecc7a085796b71ffc8957 | https://github.com/gobuffalo/velvet/blob/d97471bf5d8fd758ba0ecc7a085796b71ffc8957/template.go#L71-L80 |
17,974 | paked/messenger | messenger.go | New | func New(mo Options) *Messenger {
if mo.Mux == nil {
mo.Mux = http.NewServeMux()
}
m := &Messenger{
mux: mo.Mux,
token: mo.Token,
verify: mo.Verify,
appSecret: mo.AppSecret,
}
if mo.WebhookURL == "" {
mo.WebhookURL = "/"
}
m.verifyHandler = newVerifyHandler(mo.VerifyToken)
m.mux.Hand... | go | func New(mo Options) *Messenger {
if mo.Mux == nil {
mo.Mux = http.NewServeMux()
}
m := &Messenger{
mux: mo.Mux,
token: mo.Token,
verify: mo.Verify,
appSecret: mo.AppSecret,
}
if mo.WebhookURL == "" {
mo.WebhookURL = "/"
}
m.verifyHandler = newVerifyHandler(mo.VerifyToken)
m.mux.Hand... | [
"func",
"New",
"(",
"mo",
"Options",
")",
"*",
"Messenger",
"{",
"if",
"mo",
".",
"Mux",
"==",
"nil",
"{",
"mo",
".",
"Mux",
"=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"}",
"\n\n",
"m",
":=",
"&",
"Messenger",
"{",
"mux",
":",
"mo",
".",
... | // New creates a new Messenger. You pass in Options in order to affect settings. | [
"New",
"creates",
"a",
"new",
"Messenger",
".",
"You",
"pass",
"in",
"Options",
"in",
"order",
"to",
"affect",
"settings",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L86-L106 |
17,975 | paked/messenger | messenger.go | HandleMessage | func (m *Messenger) HandleMessage(f MessageHandler) {
m.messageHandlers = append(m.messageHandlers, f)
} | go | func (m *Messenger) HandleMessage(f MessageHandler) {
m.messageHandlers = append(m.messageHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandleMessage",
"(",
"f",
"MessageHandler",
")",
"{",
"m",
".",
"messageHandlers",
"=",
"append",
"(",
"m",
".",
"messageHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandleMessage adds a new MessageHandler to the Messenger which will be triggered
// when a message is received by the client. | [
"HandleMessage",
"adds",
"a",
"new",
"MessageHandler",
"to",
"the",
"Messenger",
"which",
"will",
"be",
"triggered",
"when",
"a",
"message",
"is",
"received",
"by",
"the",
"client",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L110-L112 |
17,976 | paked/messenger | messenger.go | HandleDelivery | func (m *Messenger) HandleDelivery(f DeliveryHandler) {
m.deliveryHandlers = append(m.deliveryHandlers, f)
} | go | func (m *Messenger) HandleDelivery(f DeliveryHandler) {
m.deliveryHandlers = append(m.deliveryHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandleDelivery",
"(",
"f",
"DeliveryHandler",
")",
"{",
"m",
".",
"deliveryHandlers",
"=",
"append",
"(",
"m",
".",
"deliveryHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandleDelivery adds a new DeliveryHandler to the Messenger which will be triggered
// when a previously sent message is delivered to the recipient. | [
"HandleDelivery",
"adds",
"a",
"new",
"DeliveryHandler",
"to",
"the",
"Messenger",
"which",
"will",
"be",
"triggered",
"when",
"a",
"previously",
"sent",
"message",
"is",
"delivered",
"to",
"the",
"recipient",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L116-L118 |
17,977 | paked/messenger | messenger.go | HandleOptIn | func (m *Messenger) HandleOptIn(f OptInHandler) {
m.optInHandlers = append(m.optInHandlers, f)
} | go | func (m *Messenger) HandleOptIn(f OptInHandler) {
m.optInHandlers = append(m.optInHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandleOptIn",
"(",
"f",
"OptInHandler",
")",
"{",
"m",
".",
"optInHandlers",
"=",
"append",
"(",
"m",
".",
"optInHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandleOptIn adds a new OptInHandler to the Messenger which will be triggered
// once a user opts in to communicate with the bot. | [
"HandleOptIn",
"adds",
"a",
"new",
"OptInHandler",
"to",
"the",
"Messenger",
"which",
"will",
"be",
"triggered",
"once",
"a",
"user",
"opts",
"in",
"to",
"communicate",
"with",
"the",
"bot",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L122-L124 |
17,978 | paked/messenger | messenger.go | HandleRead | func (m *Messenger) HandleRead(f ReadHandler) {
m.readHandlers = append(m.readHandlers, f)
} | go | func (m *Messenger) HandleRead(f ReadHandler) {
m.readHandlers = append(m.readHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandleRead",
"(",
"f",
"ReadHandler",
")",
"{",
"m",
".",
"readHandlers",
"=",
"append",
"(",
"m",
".",
"readHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandleRead adds a new DeliveryHandler to the Messenger which will be triggered
// when a previously sent message is read by the recipient. | [
"HandleRead",
"adds",
"a",
"new",
"DeliveryHandler",
"to",
"the",
"Messenger",
"which",
"will",
"be",
"triggered",
"when",
"a",
"previously",
"sent",
"message",
"is",
"read",
"by",
"the",
"recipient",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L128-L130 |
17,979 | paked/messenger | messenger.go | HandlePostBack | func (m *Messenger) HandlePostBack(f PostBackHandler) {
m.postBackHandlers = append(m.postBackHandlers, f)
} | go | func (m *Messenger) HandlePostBack(f PostBackHandler) {
m.postBackHandlers = append(m.postBackHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandlePostBack",
"(",
"f",
"PostBackHandler",
")",
"{",
"m",
".",
"postBackHandlers",
"=",
"append",
"(",
"m",
".",
"postBackHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandlePostBack adds a new PostBackHandler to the Messenger | [
"HandlePostBack",
"adds",
"a",
"new",
"PostBackHandler",
"to",
"the",
"Messenger"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L133-L135 |
17,980 | paked/messenger | messenger.go | HandleReferral | func (m *Messenger) HandleReferral(f ReferralHandler) {
m.referralHandlers = append(m.referralHandlers, f)
} | go | func (m *Messenger) HandleReferral(f ReferralHandler) {
m.referralHandlers = append(m.referralHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandleReferral",
"(",
"f",
"ReferralHandler",
")",
"{",
"m",
".",
"referralHandlers",
"=",
"append",
"(",
"m",
".",
"referralHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandleReferral adds a new ReferralHandler to the Messenger | [
"HandleReferral",
"adds",
"a",
"new",
"ReferralHandler",
"to",
"the",
"Messenger"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L138-L140 |
17,981 | paked/messenger | messenger.go | HandleAccountLinking | func (m *Messenger) HandleAccountLinking(f AccountLinkingHandler) {
m.accountLinkingHandlers = append(m.accountLinkingHandlers, f)
} | go | func (m *Messenger) HandleAccountLinking(f AccountLinkingHandler) {
m.accountLinkingHandlers = append(m.accountLinkingHandlers, f)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"HandleAccountLinking",
"(",
"f",
"AccountLinkingHandler",
")",
"{",
"m",
".",
"accountLinkingHandlers",
"=",
"append",
"(",
"m",
".",
"accountLinkingHandlers",
",",
"f",
")",
"\n",
"}"
] | // HandleAccountLinking adds a new AccountLinkingHandler to the Messenger | [
"HandleAccountLinking",
"adds",
"a",
"new",
"AccountLinkingHandler",
"to",
"the",
"Messenger"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L143-L145 |
17,982 | paked/messenger | messenger.go | GreetingSetting | func (m *Messenger) GreetingSetting(text string) error {
d := GreetingSetting{
SettingType: "greeting",
Greeting: GreetingInfo{
Text: text,
},
}
data, err := json.Marshal(d)
if err != nil {
return err
}
req, err := http.NewRequest("POST", SendSettingsURL, bytes.NewBuffer(data))
if err != nil {
ret... | go | func (m *Messenger) GreetingSetting(text string) error {
d := GreetingSetting{
SettingType: "greeting",
Greeting: GreetingInfo{
Text: text,
},
}
data, err := json.Marshal(d)
if err != nil {
return err
}
req, err := http.NewRequest("POST", SendSettingsURL, bytes.NewBuffer(data))
if err != nil {
ret... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"GreetingSetting",
"(",
"text",
"string",
")",
"error",
"{",
"d",
":=",
"GreetingSetting",
"{",
"SettingType",
":",
"\"",
"\"",
",",
"Greeting",
":",
"GreetingInfo",
"{",
"Text",
":",
"text",
",",
"}",
",",
"}",... | // GreetingSetting sends settings for greeting | [
"GreetingSetting",
"sends",
"settings",
"for",
"greeting"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L203-L233 |
17,983 | paked/messenger | messenger.go | CallToActionsSetting | func (m *Messenger) CallToActionsSetting(state string, actions []CallToActionsItem) error {
d := CallToActionsSetting{
SettingType: "call_to_actions",
ThreadState: state,
CallToActions: actions,
}
data, err := json.Marshal(d)
if err != nil {
return err
}
req, err := http.NewRequest("POST", SendSetti... | go | func (m *Messenger) CallToActionsSetting(state string, actions []CallToActionsItem) error {
d := CallToActionsSetting{
SettingType: "call_to_actions",
ThreadState: state,
CallToActions: actions,
}
data, err := json.Marshal(d)
if err != nil {
return err
}
req, err := http.NewRequest("POST", SendSetti... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"CallToActionsSetting",
"(",
"state",
"string",
",",
"actions",
"[",
"]",
"CallToActionsItem",
")",
"error",
"{",
"d",
":=",
"CallToActionsSetting",
"{",
"SettingType",
":",
"\"",
"\"",
",",
"ThreadState",
":",
"state... | // CallToActionsSetting sends settings for Get Started or Persistent Menu | [
"CallToActionsSetting",
"sends",
"settings",
"for",
"Get",
"Started",
"or",
"Persistent",
"Menu"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L236-L265 |
17,984 | paked/messenger | messenger.go | handle | func (m *Messenger) handle(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
m.verifyHandler(w, r)
return
}
var rec Receive
// consume a *copy* of the request body
body, _ := ioutil.ReadAll(r.Body)
r.Body = ioutil.NopCloser(bytes.NewBuffer(body))
err := json.Unmarshal(body, &rec)
if err !=... | go | func (m *Messenger) handle(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
m.verifyHandler(w, r)
return
}
var rec Receive
// consume a *copy* of the request body
body, _ := ioutil.ReadAll(r.Body)
r.Body = ioutil.NopCloser(bytes.NewBuffer(body))
err := json.Unmarshal(body, &rec)
if err !=... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"handle",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"m",
".",
"verifyHandler",
"(",
"w",
",",
"r",
")",
"\... | // handle is the internal HTTP handler for the webhooks. | [
"handle",
"is",
"the",
"internal",
"HTTP",
"handler",
"for",
"the",
"webhooks",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L268-L302 |
17,985 | paked/messenger | messenger.go | checkIntegrity | func (m *Messenger) checkIntegrity(r *http.Request) error {
if m.appSecret == "" {
return fmt.Errorf("missing app secret")
}
sigHeader := "X-Hub-Signature"
sig := strings.SplitN(r.Header.Get(sigHeader), "=", 2)
if len(sig) == 1 {
if sig[0] == "" {
return fmt.Errorf("missing %s header", sigHeader)
}
ret... | go | func (m *Messenger) checkIntegrity(r *http.Request) error {
if m.appSecret == "" {
return fmt.Errorf("missing app secret")
}
sigHeader := "X-Hub-Signature"
sig := strings.SplitN(r.Header.Get(sigHeader), "=", 2)
if len(sig) == 1 {
if sig[0] == "" {
return fmt.Errorf("missing %s header", sigHeader)
}
ret... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"checkIntegrity",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"if",
"m",
".",
"appSecret",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"sig... | // checkIntegrity checks the integrity of the requests received | [
"checkIntegrity",
"checks",
"the",
"integrity",
"of",
"the",
"requests",
"received"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L305-L338 |
17,986 | paked/messenger | messenger.go | dispatch | func (m *Messenger) dispatch(r Receive) {
for _, entry := range r.Entry {
for _, info := range entry.Messaging {
a := m.classify(info, entry)
if a == UnknownAction {
fmt.Println("Unknown action:", info)
continue
}
resp := &Response{
to: Recipient{info.Sender.ID},
token: m.token,
}
... | go | func (m *Messenger) dispatch(r Receive) {
for _, entry := range r.Entry {
for _, info := range entry.Messaging {
a := m.classify(info, entry)
if a == UnknownAction {
fmt.Println("Unknown action:", info)
continue
}
resp := &Response{
to: Recipient{info.Sender.ID},
token: m.token,
}
... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"dispatch",
"(",
"r",
"Receive",
")",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"r",
".",
"Entry",
"{",
"for",
"_",
",",
"info",
":=",
"range",
"entry",
".",
"Messaging",
"{",
"a",
":=",
"m",
".",
"c... | // dispatch triggers all of the relevant handlers when a webhook event is received. | [
"dispatch",
"triggers",
"all",
"of",
"the",
"relevant",
"handlers",
"when",
"a",
"webhook",
"event",
"is",
"received",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L341-L407 |
17,987 | paked/messenger | messenger.go | Response | func (m *Messenger) Response(to int64) *Response {
return &Response{
to: Recipient{to},
token: m.token,
}
} | go | func (m *Messenger) Response(to int64) *Response {
return &Response{
to: Recipient{to},
token: m.token,
}
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"Response",
"(",
"to",
"int64",
")",
"*",
"Response",
"{",
"return",
"&",
"Response",
"{",
"to",
":",
"Recipient",
"{",
"to",
"}",
",",
"token",
":",
"m",
".",
"token",
",",
"}",
"\n",
"}"
] | // Response returns new Response object | [
"Response",
"returns",
"new",
"Response",
"object"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L410-L415 |
17,988 | paked/messenger | messenger.go | Send | func (m *Messenger) Send(to Recipient, message string, messagingType MessagingType, tags ...string) error {
return m.SendWithReplies(to, message, nil, messagingType, tags...)
} | go | func (m *Messenger) Send(to Recipient, message string, messagingType MessagingType, tags ...string) error {
return m.SendWithReplies(to, message, nil, messagingType, tags...)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"Send",
"(",
"to",
"Recipient",
",",
"message",
"string",
",",
"messagingType",
"MessagingType",
",",
"tags",
"...",
"string",
")",
"error",
"{",
"return",
"m",
".",
"SendWithReplies",
"(",
"to",
",",
"message",
"... | // Send will send a textual message to a user. This user must have previously initiated a conversation with the bot. | [
"Send",
"will",
"send",
"a",
"textual",
"message",
"to",
"a",
"user",
".",
"This",
"user",
"must",
"have",
"previously",
"initiated",
"a",
"conversation",
"with",
"the",
"bot",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L418-L420 |
17,989 | paked/messenger | messenger.go | SendGeneralMessage | func (m *Messenger) SendGeneralMessage(to Recipient, elements *[]StructuredMessageElement, messagingType MessagingType, tags ...string) error {
r := &Response{
token: m.token,
to: to,
}
return r.GenericTemplate(elements, messagingType, tags...)
} | go | func (m *Messenger) SendGeneralMessage(to Recipient, elements *[]StructuredMessageElement, messagingType MessagingType, tags ...string) error {
r := &Response{
token: m.token,
to: to,
}
return r.GenericTemplate(elements, messagingType, tags...)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"SendGeneralMessage",
"(",
"to",
"Recipient",
",",
"elements",
"*",
"[",
"]",
"StructuredMessageElement",
",",
"messagingType",
"MessagingType",
",",
"tags",
"...",
"string",
")",
"error",
"{",
"r",
":=",
"&",
"Respon... | // SendGeneralMessage will send the GenericTemplate message | [
"SendGeneralMessage",
"will",
"send",
"the",
"GenericTemplate",
"message"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L423-L429 |
17,990 | paked/messenger | messenger.go | SendWithReplies | func (m *Messenger) SendWithReplies(to Recipient, message string, replies []QuickReply, messagingType MessagingType, tags ...string) error {
response := &Response{
token: m.token,
to: to,
}
return response.TextWithReplies(message, replies, messagingType, tags...)
} | go | func (m *Messenger) SendWithReplies(to Recipient, message string, replies []QuickReply, messagingType MessagingType, tags ...string) error {
response := &Response{
token: m.token,
to: to,
}
return response.TextWithReplies(message, replies, messagingType, tags...)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"SendWithReplies",
"(",
"to",
"Recipient",
",",
"message",
"string",
",",
"replies",
"[",
"]",
"QuickReply",
",",
"messagingType",
"MessagingType",
",",
"tags",
"...",
"string",
")",
"error",
"{",
"response",
":=",
... | // SendWithReplies sends a textual message to a user, but gives them the option of numerous quick response options. | [
"SendWithReplies",
"sends",
"a",
"textual",
"message",
"to",
"a",
"user",
"but",
"gives",
"them",
"the",
"option",
"of",
"numerous",
"quick",
"response",
"options",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L432-L439 |
17,991 | paked/messenger | messenger.go | Attachment | func (m *Messenger) Attachment(to Recipient, dataType AttachmentType, url string, messagingType MessagingType, tags ...string) error {
response := &Response{
token: m.token,
to: to,
}
return response.Attachment(dataType, url, messagingType, tags...)
} | go | func (m *Messenger) Attachment(to Recipient, dataType AttachmentType, url string, messagingType MessagingType, tags ...string) error {
response := &Response{
token: m.token,
to: to,
}
return response.Attachment(dataType, url, messagingType, tags...)
} | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"Attachment",
"(",
"to",
"Recipient",
",",
"dataType",
"AttachmentType",
",",
"url",
"string",
",",
"messagingType",
"MessagingType",
",",
"tags",
"...",
"string",
")",
"error",
"{",
"response",
":=",
"&",
"Response",... | // Attachment sends an image, sound, video or a regular file to a given recipient. | [
"Attachment",
"sends",
"an",
"image",
"sound",
"video",
"or",
"a",
"regular",
"file",
"to",
"a",
"given",
"recipient",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L442-L449 |
17,992 | paked/messenger | messenger.go | EnableChatExtension | func (m *Messenger) EnableChatExtension(homeURL HomeURL) error {
wrap := map[string]interface{}{
"home_url": homeURL,
}
data, err := json.Marshal(wrap)
if err != nil {
return err
}
req, err := http.NewRequest("POST", MessengerProfileURL, bytes.NewBuffer(data))
if err != nil {
return err
}
req.Header.Se... | go | func (m *Messenger) EnableChatExtension(homeURL HomeURL) error {
wrap := map[string]interface{}{
"home_url": homeURL,
}
data, err := json.Marshal(wrap)
if err != nil {
return err
}
req, err := http.NewRequest("POST", MessengerProfileURL, bytes.NewBuffer(data))
if err != nil {
return err
}
req.Header.Se... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"EnableChatExtension",
"(",
"homeURL",
"HomeURL",
")",
"error",
"{",
"wrap",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"homeURL",
",",
"}",
"\n",
"data",
",",
"err",
":=",
... | // EnableChatExtension set the homepage url required for a chat extension. | [
"EnableChatExtension",
"set",
"the",
"homepage",
"url",
"required",
"for",
"a",
"chat",
"extension",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L452-L478 |
17,993 | paked/messenger | messenger.go | classify | func (m *Messenger) classify(info MessageInfo, e Entry) Action {
if info.Message != nil {
return TextAction
} else if info.Delivery != nil {
return DeliveryAction
} else if info.Read != nil {
return ReadAction
} else if info.PostBack != nil {
return PostBackAction
} else if info.OptIn != nil {
return Opt... | go | func (m *Messenger) classify(info MessageInfo, e Entry) Action {
if info.Message != nil {
return TextAction
} else if info.Delivery != nil {
return DeliveryAction
} else if info.Read != nil {
return ReadAction
} else if info.PostBack != nil {
return PostBackAction
} else if info.OptIn != nil {
return Opt... | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"classify",
"(",
"info",
"MessageInfo",
",",
"e",
"Entry",
")",
"Action",
"{",
"if",
"info",
".",
"Message",
"!=",
"nil",
"{",
"return",
"TextAction",
"\n",
"}",
"else",
"if",
"info",
".",
"Delivery",
"!=",
"n... | // classify determines what type of message a webhook event is. | [
"classify",
"determines",
"what",
"type",
"of",
"message",
"a",
"webhook",
"event",
"is",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L481-L498 |
17,994 | paked/messenger | messenger.go | newVerifyHandler | func newVerifyHandler(token string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if r.FormValue("hub.verify_token") == token {
fmt.Fprintln(w, r.FormValue("hub.challenge"))
return
}
fmt.Fprintln(w, "Incorrect verify token.")
}
} | go | func newVerifyHandler(token string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if r.FormValue("hub.verify_token") == token {
fmt.Fprintln(w, r.FormValue("hub.challenge"))
return
}
fmt.Fprintln(w, "Incorrect verify token.")
}
} | [
"func",
"newVerifyHandler",
"(",
"token",
"string",
")",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"return",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",... | // newVerifyHandler returns a function which can be used to handle webhook verification | [
"newVerifyHandler",
"returns",
"a",
"function",
"which",
"can",
"be",
"used",
"to",
"handle",
"webhook",
"verification"
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/messenger.go#L501-L509 |
17,995 | paked/messenger | examples/linked-account/main.go | loginButton | func loginButton(r *messenger.Response) error {
buttons := &[]messenger.StructuredMessageButton{
{
Type: "account_link",
URL: "https://" + path.Join(*publicHost, loginPath),
},
}
return r.ButtonTemplate("Link your account.", buttons, messenger.ResponseType)
} | go | func loginButton(r *messenger.Response) error {
buttons := &[]messenger.StructuredMessageButton{
{
Type: "account_link",
URL: "https://" + path.Join(*publicHost, loginPath),
},
}
return r.ButtonTemplate("Link your account.", buttons, messenger.ResponseType)
} | [
"func",
"loginButton",
"(",
"r",
"*",
"messenger",
".",
"Response",
")",
"error",
"{",
"buttons",
":=",
"&",
"[",
"]",
"messenger",
".",
"StructuredMessageButton",
"{",
"{",
"Type",
":",
"\"",
"\"",
",",
"URL",
":",
"\"",
"\"",
"+",
"path",
".",
"Joi... | // loginButton will present to the user a button that can be used to
// start the account linking process. | [
"loginButton",
"will",
"present",
"to",
"the",
"user",
"a",
"button",
"that",
"can",
"be",
"used",
"to",
"start",
"the",
"account",
"linking",
"process",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/examples/linked-account/main.go#L113-L121 |
17,996 | paked/messenger | examples/linked-account/main.go | logoutButton | func logoutButton(r *messenger.Response) error {
buttons := &[]messenger.StructuredMessageButton{
{
Type: "account_unlink",
},
}
return r.ButtonTemplate("Unlink your account.", buttons, messenger.ResponseType)
} | go | func logoutButton(r *messenger.Response) error {
buttons := &[]messenger.StructuredMessageButton{
{
Type: "account_unlink",
},
}
return r.ButtonTemplate("Unlink your account.", buttons, messenger.ResponseType)
} | [
"func",
"logoutButton",
"(",
"r",
"*",
"messenger",
".",
"Response",
")",
"error",
"{",
"buttons",
":=",
"&",
"[",
"]",
"messenger",
".",
"StructuredMessageButton",
"{",
"{",
"Type",
":",
"\"",
"\"",
",",
"}",
",",
"}",
"\n",
"return",
"r",
".",
"But... | // logoutButton show to the user a button that can be used to start
// the process of unlinking an account. | [
"logoutButton",
"show",
"to",
"the",
"user",
"a",
"button",
"that",
"can",
"be",
"used",
"to",
"start",
"the",
"process",
"of",
"unlinking",
"an",
"account",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/examples/linked-account/main.go#L125-L132 |
17,997 | paked/messenger | examples/linked-account/main.go | greeting | func greeting(p messenger.Profile, r *messenger.Response) error {
return r.Text(fmt.Sprintf("Hello, %v!", p.FirstName), messenger.ResponseType)
} | go | func greeting(p messenger.Profile, r *messenger.Response) error {
return r.Text(fmt.Sprintf("Hello, %v!", p.FirstName), messenger.ResponseType)
} | [
"func",
"greeting",
"(",
"p",
"messenger",
".",
"Profile",
",",
"r",
"*",
"messenger",
".",
"Response",
")",
"error",
"{",
"return",
"r",
".",
"Text",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
".",
"FirstName",
")",
",",
"messenger",
"... | // greeting salutes the user. | [
"greeting",
"salutes",
"the",
"user",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/examples/linked-account/main.go#L135-L137 |
17,998 | paked/messenger | examples/linked-account/main.go | help | func help(p messenger.Profile, r *messenger.Response) error {
text := fmt.Sprintf(
"%s, looking for actions to do? Here is what I understand.",
p.FirstName,
)
replies := []messenger.QuickReply{
{
ContentType: "text",
Title: "Login",
},
{
ContentType: "text",
Title: "Logout",
},
... | go | func help(p messenger.Profile, r *messenger.Response) error {
text := fmt.Sprintf(
"%s, looking for actions to do? Here is what I understand.",
p.FirstName,
)
replies := []messenger.QuickReply{
{
ContentType: "text",
Title: "Login",
},
{
ContentType: "text",
Title: "Logout",
},
... | [
"func",
"help",
"(",
"p",
"messenger",
".",
"Profile",
",",
"r",
"*",
"messenger",
".",
"Response",
")",
"error",
"{",
"text",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
".",
"FirstName",
",",
")",
"\n\n",
"replies",
":=",
"[",
"]",
... | // help displays possibles actions to the user. | [
"help",
"displays",
"possibles",
"actions",
"to",
"the",
"user",
"."
] | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/examples/linked-account/main.go#L140-L158 |
17,999 | paked/messenger | examples/linked-account/main.go | loginForm | func loginForm(w http.ResponseWriter, r *http.Request) {
values := r.URL.Query()
linkingToken := values.Get("account_linking_token")
redirectURI := values.Get("redirect_uri")
fmt.Fprint(w, templateLogin(loginPath, linkingToken, redirectURI, false))
} | go | func loginForm(w http.ResponseWriter, r *http.Request) {
values := r.URL.Query()
linkingToken := values.Get("account_linking_token")
redirectURI := values.Get("redirect_uri")
fmt.Fprint(w, templateLogin(loginPath, linkingToken, redirectURI, false))
} | [
"func",
"loginForm",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"values",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
"\n",
"linkingToken",
":=",
"values",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
... | // loginForm is the endpoint responsible to displays a login
// form. During the account linking process, after clicking on the
// login button, users are directed to this form where they are
// supposed to sign into their account. When the form is submitted,
// credentials are sent to the login endpoint. | [
"loginForm",
"is",
"the",
"endpoint",
"responsible",
"to",
"displays",
"a",
"login",
"form",
".",
"During",
"the",
"account",
"linking",
"process",
"after",
"clicking",
"on",
"the",
"login",
"button",
"users",
"are",
"directed",
"to",
"this",
"form",
"where",
... | 841714601c8a2d693f15fc70e74aa72af4a117a2 | https://github.com/paked/messenger/blob/841714601c8a2d693f15fc70e74aa72af4a117a2/examples/linked-account/main.go#L165-L170 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.