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
18,900
scylladb/gocqlx
qb/cmp.go
Gt
func Gt(column string) Cmp { return Cmp{ op: gt, column: column, value: param(column), } }
go
func Gt(column string) Cmp { return Cmp{ op: gt, column: column, value: param(column), } }
[ "func", "Gt", "(", "column", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "gt", ",", "column", ":", "column", ",", "value", ":", "param", "(", "column", ")", ",", "}", "\n", "}" ]
// Gt produces column>?.
[ "Gt", "produces", "column", ">", "?", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L169-L175
18,901
scylladb/gocqlx
qb/cmp.go
GtNamed
func GtNamed(column, name string) Cmp { return Cmp{ op: gt, column: column, value: param(name), } }
go
func GtNamed(column, name string) Cmp { return Cmp{ op: gt, column: column, value: param(name), } }
[ "func", "GtNamed", "(", "column", ",", "name", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "gt", ",", "column", ":", "column", ",", "value", ":", "param", "(", "name", ")", ",", "}", "\n", "}" ]
// GtNamed produces column>? with a custom parameter name.
[ "GtNamed", "produces", "column", ">", "?", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L178-L184
18,902
scylladb/gocqlx
qb/cmp.go
GtLit
func GtLit(column, literal string) Cmp { return Cmp{ op: gt, column: column, value: lit(literal), } }
go
func GtLit(column, literal string) Cmp { return Cmp{ op: gt, column: column, value: lit(literal), } }
[ "func", "GtLit", "(", "column", ",", "literal", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "gt", ",", "column", ":", "column", ",", "value", ":", "lit", "(", "literal", ")", ",", "}", "\n", "}" ]
// GtLit produces column>literal and does not add a parameter to the query.
[ "GtLit", "produces", "column", ">", "literal", "and", "does", "not", "add", "a", "parameter", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L187-L193
18,903
scylladb/gocqlx
qb/cmp.go
GtOrEq
func GtOrEq(column string) Cmp { return Cmp{ op: geq, column: column, value: param(column), } }
go
func GtOrEq(column string) Cmp { return Cmp{ op: geq, column: column, value: param(column), } }
[ "func", "GtOrEq", "(", "column", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "geq", ",", "column", ":", "column", ",", "value", ":", "param", "(", "column", ")", ",", "}", "\n", "}" ]
// GtOrEq produces column>=?.
[ "GtOrEq", "produces", "column", ">", "=", "?", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L205-L211
18,904
scylladb/gocqlx
qb/cmp.go
GtOrEqNamed
func GtOrEqNamed(column, name string) Cmp { return Cmp{ op: geq, column: column, value: param(name), } }
go
func GtOrEqNamed(column, name string) Cmp { return Cmp{ op: geq, column: column, value: param(name), } }
[ "func", "GtOrEqNamed", "(", "column", ",", "name", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "geq", ",", "column", ":", "column", ",", "value", ":", "param", "(", "name", ")", ",", "}", "\n", "}" ]
// GtOrEqNamed produces column>=? with a custom parameter name.
[ "GtOrEqNamed", "produces", "column", ">", "=", "?", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L214-L220
18,905
scylladb/gocqlx
qb/cmp.go
GtOrEqLit
func GtOrEqLit(column, literal string) Cmp { return Cmp{ op: geq, column: column, value: lit(literal), } }
go
func GtOrEqLit(column, literal string) Cmp { return Cmp{ op: geq, column: column, value: lit(literal), } }
[ "func", "GtOrEqLit", "(", "column", ",", "literal", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "geq", ",", "column", ":", "column", ",", "value", ":", "lit", "(", "literal", ")", ",", "}", "\n", "}" ]
// GtOrEqLit produces column>=literal and does not add a parameter to the query.
[ "GtOrEqLit", "produces", "column", ">", "=", "literal", "and", "does", "not", "add", "a", "parameter", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L223-L229
18,906
scylladb/gocqlx
qb/cmp.go
In
func In(column string) Cmp { return Cmp{ op: in, column: column, value: param(column), } }
go
func In(column string) Cmp { return Cmp{ op: in, column: column, value: param(column), } }
[ "func", "In", "(", "column", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "in", ",", "column", ":", "column", ",", "value", ":", "param", "(", "column", ")", ",", "}", "\n", "}" ]
// In produces column IN ?.
[ "In", "produces", "column", "IN", "?", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L241-L247
18,907
scylladb/gocqlx
qb/cmp.go
InNamed
func InNamed(column, name string) Cmp { return Cmp{ op: in, column: column, value: param(name), } }
go
func InNamed(column, name string) Cmp { return Cmp{ op: in, column: column, value: param(name), } }
[ "func", "InNamed", "(", "column", ",", "name", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "in", ",", "column", ":", "column", ",", "value", ":", "param", "(", "name", ")", ",", "}", "\n", "}" ]
// InNamed produces column IN ? with a custom parameter name.
[ "InNamed", "produces", "column", "IN", "?", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L250-L256
18,908
scylladb/gocqlx
qb/cmp.go
InLit
func InLit(column, literal string) Cmp { return Cmp{ op: in, column: column, value: lit(literal), } }
go
func InLit(column, literal string) Cmp { return Cmp{ op: in, column: column, value: lit(literal), } }
[ "func", "InLit", "(", "column", ",", "literal", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "in", ",", "column", ":", "column", ",", "value", ":", "lit", "(", "literal", ")", ",", "}", "\n", "}" ]
// InLit produces column IN literal and does not add a parameter to the query.
[ "InLit", "produces", "column", "IN", "literal", "and", "does", "not", "add", "a", "parameter", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L259-L265
18,909
scylladb/gocqlx
qb/cmp.go
Contains
func Contains(column string) Cmp { return Cmp{ op: cnt, column: column, value: param(column), } }
go
func Contains(column string) Cmp { return Cmp{ op: cnt, column: column, value: param(column), } }
[ "func", "Contains", "(", "column", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "cnt", ",", "column", ":", "column", ",", "value", ":", "param", "(", "column", ")", ",", "}", "\n", "}" ]
// Contains produces column CONTAINS ?.
[ "Contains", "produces", "column", "CONTAINS", "?", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L268-L274
18,910
scylladb/gocqlx
qb/cmp.go
ContainsKey
func ContainsKey(column string) Cmp { return Cmp{ op: cntKey, column: column, value: param(column), } }
go
func ContainsKey(column string) Cmp { return Cmp{ op: cntKey, column: column, value: param(column), } }
[ "func", "ContainsKey", "(", "column", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "cntKey", ",", "column", ":", "column", ",", "value", ":", "param", "(", "column", ")", ",", "}", "\n", "}" ]
// ContainsKey produces column CONTAINS KEY ?.
[ "ContainsKey", "produces", "column", "CONTAINS", "KEY", "?", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L277-L283
18,911
scylladb/gocqlx
qb/cmp.go
ContainsNamed
func ContainsNamed(column, name string) Cmp { return Cmp{ op: cnt, column: column, value: param(name), } }
go
func ContainsNamed(column, name string) Cmp { return Cmp{ op: cnt, column: column, value: param(name), } }
[ "func", "ContainsNamed", "(", "column", ",", "name", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "cnt", ",", "column", ":", "column", ",", "value", ":", "param", "(", "name", ")", ",", "}", "\n", "}" ]
// ContainsNamed produces column CONTAINS ? with a custom parameter name.
[ "ContainsNamed", "produces", "column", "CONTAINS", "?", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L286-L292
18,912
scylladb/gocqlx
qb/cmp.go
ContainsKeyNamed
func ContainsKeyNamed(column, name string) Cmp { return Cmp{ op: cntKey, column: column, value: param(name), } }
go
func ContainsKeyNamed(column, name string) Cmp { return Cmp{ op: cntKey, column: column, value: param(name), } }
[ "func", "ContainsKeyNamed", "(", "column", ",", "name", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "cntKey", ",", "column", ":", "column", ",", "value", ":", "param", "(", "name", ")", ",", "}", "\n", "}" ]
// ContainsKeyNamed produces column CONTAINS KEY ? with a custom parameter name.
[ "ContainsKeyNamed", "produces", "column", "CONTAINS", "KEY", "?", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L295-L301
18,913
scylladb/gocqlx
qb/cmp.go
ContainsLit
func ContainsLit(column, literal string) Cmp { return Cmp{ op: cnt, column: column, value: lit(literal), } }
go
func ContainsLit(column, literal string) Cmp { return Cmp{ op: cnt, column: column, value: lit(literal), } }
[ "func", "ContainsLit", "(", "column", ",", "literal", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "cnt", ",", "column", ":", "column", ",", "value", ":", "lit", "(", "literal", ")", ",", "}", "\n", "}" ]
// ContainsLit produces column CONTAINS literal and does not add a parameter to the query.
[ "ContainsLit", "produces", "column", "CONTAINS", "literal", "and", "does", "not", "add", "a", "parameter", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L304-L310
18,914
scylladb/gocqlx
qb/cmp.go
Like
func Like(column string) Cmp { return Cmp{ op: like, column: column, value: param(column), } }
go
func Like(column string) Cmp { return Cmp{ op: like, column: column, value: param(column), } }
[ "func", "Like", "(", "column", "string", ")", "Cmp", "{", "return", "Cmp", "{", "op", ":", "like", ",", "column", ":", "column", ",", "value", ":", "param", "(", "column", ")", ",", "}", "\n", "}" ]
// Like produces column LIKE ?.
[ "Like", "produces", "column", "LIKE", "?", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/cmp.go#L313-L319
18,915
scylladb/gocqlx
qb/select.go
From
func (b *SelectBuilder) From(table string) *SelectBuilder { b.table = table return b }
go
func (b *SelectBuilder) From(table string) *SelectBuilder { b.table = table return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "From", "(", "table", "string", ")", "*", "SelectBuilder", "{", "b", ".", "table", "=", "table", "\n", "return", "b", "\n", "}" ]
// From sets the table to be selected from.
[ "From", "sets", "the", "table", "to", "be", "selected", "from", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L111-L114
18,916
scylladb/gocqlx
qb/select.go
Columns
func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder { b.columns = append(b.columns, columns...) return b }
go
func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder { b.columns = append(b.columns, columns...) return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "Columns", "(", "columns", "...", "string", ")", "*", "SelectBuilder", "{", "b", ".", "columns", "=", "append", "(", "b", ".", "columns", ",", "columns", "...", ")", "\n", "return", "b", "\n", "}" ]
// Columns adds result columns to the query.
[ "Columns", "adds", "result", "columns", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L117-L120
18,917
scylladb/gocqlx
qb/select.go
Distinct
func (b *SelectBuilder) Distinct(columns ...string) *SelectBuilder { b.distinct = append(b.distinct, columns...) return b }
go
func (b *SelectBuilder) Distinct(columns ...string) *SelectBuilder { b.distinct = append(b.distinct, columns...) return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "Distinct", "(", "columns", "...", "string", ")", "*", "SelectBuilder", "{", "b", ".", "distinct", "=", "append", "(", "b", ".", "distinct", ",", "columns", "...", ")", "\n", "return", "b", "\n", "}" ]
// Distinct sets DISTINCT clause on the query.
[ "Distinct", "sets", "DISTINCT", "clause", "on", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L128-L131
18,918
scylladb/gocqlx
qb/select.go
GroupBy
func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder { b.groupBy = append(b.groupBy, columns...) return b }
go
func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder { b.groupBy = append(b.groupBy, columns...) return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "GroupBy", "(", "columns", "...", "string", ")", "*", "SelectBuilder", "{", "b", ".", "groupBy", "=", "append", "(", "b", ".", "groupBy", ",", "columns", "...", ")", "\n", "return", "b", "\n", "}" ]
// GroupBy sets GROUP BY clause on the query. Columns must be a primary key, // this will automatically add the the columns as first selectors.
[ "GroupBy", "sets", "GROUP", "BY", "clause", "on", "the", "query", ".", "Columns", "must", "be", "a", "primary", "key", "this", "will", "automatically", "add", "the", "the", "columns", "as", "first", "selectors", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L142-L145
18,919
scylladb/gocqlx
qb/select.go
OrderBy
func (b *SelectBuilder) OrderBy(column string, o Order) *SelectBuilder { b.orderBy = append(b.orderBy, column+" "+o.String()) return b }
go
func (b *SelectBuilder) OrderBy(column string, o Order) *SelectBuilder { b.orderBy = append(b.orderBy, column+" "+o.String()) return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "OrderBy", "(", "column", "string", ",", "o", "Order", ")", "*", "SelectBuilder", "{", "b", ".", "orderBy", "=", "append", "(", "b", ".", "orderBy", ",", "column", "+", "\"", "\"", "+", "o", ".", "String...
// OrderBy sets ORDER BY clause on the query.
[ "OrderBy", "sets", "ORDER", "BY", "clause", "on", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L148-L151
18,920
scylladb/gocqlx
qb/select.go
Limit
func (b *SelectBuilder) Limit(limit uint) *SelectBuilder { b.limit = limit return b }
go
func (b *SelectBuilder) Limit(limit uint) *SelectBuilder { b.limit = limit return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "Limit", "(", "limit", "uint", ")", "*", "SelectBuilder", "{", "b", ".", "limit", "=", "limit", "\n", "return", "b", "\n", "}" ]
// Limit sets a LIMIT clause on the query.
[ "Limit", "sets", "a", "LIMIT", "clause", "on", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L154-L157
18,921
scylladb/gocqlx
qb/select.go
LimitPerPartition
func (b *SelectBuilder) LimitPerPartition(limit uint) *SelectBuilder { b.limitPerPartition = limit return b }
go
func (b *SelectBuilder) LimitPerPartition(limit uint) *SelectBuilder { b.limitPerPartition = limit return b }
[ "func", "(", "b", "*", "SelectBuilder", ")", "LimitPerPartition", "(", "limit", "uint", ")", "*", "SelectBuilder", "{", "b", ".", "limitPerPartition", "=", "limit", "\n", "return", "b", "\n", "}" ]
// LimitPerPartition sets a PER PARTITION LIMIT clause on the query.
[ "LimitPerPartition", "sets", "a", "PER", "PARTITION", "LIMIT", "clause", "on", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/select.go#L160-L163
18,922
scylladb/gocqlx
qb/func.go
Fn
func Fn(name string, paramNames ...string) *Func { return &Func{ Name: name, ParamNames: paramNames, } }
go
func Fn(name string, paramNames ...string) *Func { return &Func{ Name: name, ParamNames: paramNames, } }
[ "func", "Fn", "(", "name", "string", ",", "paramNames", "...", "string", ")", "*", "Func", "{", "return", "&", "Func", "{", "Name", ":", "name", ",", "ParamNames", ":", "paramNames", ",", "}", "\n", "}" ]
// Fn creates Func.
[ "Fn", "creates", "Func", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/func.go#L31-L36
18,923
scylladb/gocqlx
migrate/migrate.go
List
func List(ctx context.Context, session *gocql.Session) ([]*Info, error) { if err := ensureInfoTable(ctx, session); err != nil { return nil, err } var v []*Info err := gocqlx.Select(&v, session.Query(selectInfo).WithContext(ctx)) if err == gocql.ErrNotFound { return nil, nil } sort.Slice(v, func(i, j int) bool { return v[i].Name < v[j].Name }) return v, err }
go
func List(ctx context.Context, session *gocql.Session) ([]*Info, error) { if err := ensureInfoTable(ctx, session); err != nil { return nil, err } var v []*Info err := gocqlx.Select(&v, session.Query(selectInfo).WithContext(ctx)) if err == gocql.ErrNotFound { return nil, nil } sort.Slice(v, func(i, j int) bool { return v[i].Name < v[j].Name }) return v, err }
[ "func", "List", "(", "ctx", "context", ".", "Context", ",", "session", "*", "gocql", ".", "Session", ")", "(", "[", "]", "*", "Info", ",", "error", ")", "{", "if", "err", ":=", "ensureInfoTable", "(", "ctx", ",", "session", ")", ";", "err", "!=", ...
// List provides a listing of applied migrations.
[ "List", "provides", "a", "listing", "of", "applied", "migrations", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/migrate/migrate.go#L47-L63
18,924
scylladb/gocqlx
migrate/migrate.go
Migrate
func Migrate(ctx context.Context, session *gocql.Session, dir string) error { // get database migrations dbm, err := List(ctx, session) if err != nil { return fmt.Errorf("failed to list migrations: %s", err) } // get file migrations fm, err := filepath.Glob(filepath.Join(dir, "*.cql")) if err != nil { return fmt.Errorf("failed to list migrations in %q: %s", dir, err) } if len(fm) == 0 { return fmt.Errorf("no migration files found in %q", dir) } sort.Strings(fm) // verify migrations if len(dbm) > len(fm) { return fmt.Errorf("database is ahead of %q", dir) } for i := 0; i < len(dbm); i++ { if dbm[i].Name != filepath.Base(fm[i]) { fmt.Println(dbm[i].Name, filepath.Base(fm[i]), i) return errors.New("inconsistent migrations") } c, err := fileChecksum(fm[i]) if err != nil { return fmt.Errorf("failed to calculate checksum for %q: %s", fm[i], err) } if dbm[i].Checksum != c { return fmt.Errorf("file %q was tempered with, expected md5 %s", fm[i], dbm[i].Checksum) } } // apply migrations if len(dbm) > 0 { last := len(dbm) - 1 if err := applyMigration(ctx, session, fm[last], dbm[last].Done); err != nil { return fmt.Errorf("failed to apply migration %q: %s", fm[last], err) } } for i := len(dbm); i < len(fm); i++ { if err := applyMigration(ctx, session, fm[i], 0); err != nil { return fmt.Errorf("failed to apply migration %q: %s", fm[i], err) } } return nil }
go
func Migrate(ctx context.Context, session *gocql.Session, dir string) error { // get database migrations dbm, err := List(ctx, session) if err != nil { return fmt.Errorf("failed to list migrations: %s", err) } // get file migrations fm, err := filepath.Glob(filepath.Join(dir, "*.cql")) if err != nil { return fmt.Errorf("failed to list migrations in %q: %s", dir, err) } if len(fm) == 0 { return fmt.Errorf("no migration files found in %q", dir) } sort.Strings(fm) // verify migrations if len(dbm) > len(fm) { return fmt.Errorf("database is ahead of %q", dir) } for i := 0; i < len(dbm); i++ { if dbm[i].Name != filepath.Base(fm[i]) { fmt.Println(dbm[i].Name, filepath.Base(fm[i]), i) return errors.New("inconsistent migrations") } c, err := fileChecksum(fm[i]) if err != nil { return fmt.Errorf("failed to calculate checksum for %q: %s", fm[i], err) } if dbm[i].Checksum != c { return fmt.Errorf("file %q was tempered with, expected md5 %s", fm[i], dbm[i].Checksum) } } // apply migrations if len(dbm) > 0 { last := len(dbm) - 1 if err := applyMigration(ctx, session, fm[last], dbm[last].Done); err != nil { return fmt.Errorf("failed to apply migration %q: %s", fm[last], err) } } for i := len(dbm); i < len(fm); i++ { if err := applyMigration(ctx, session, fm[i], 0); err != nil { return fmt.Errorf("failed to apply migration %q: %s", fm[i], err) } } return nil }
[ "func", "Migrate", "(", "ctx", "context", ".", "Context", ",", "session", "*", "gocql", ".", "Session", ",", "dir", "string", ")", "error", "{", "// get database migrations", "dbm", ",", "err", ":=", "List", "(", "ctx", ",", "session", ")", "\n", "if", ...
// Migrate reads the cql files from a directory and applies required migrations.
[ "Migrate", "reads", "the", "cql", "files", "from", "a", "directory", "and", "applies", "required", "migrations", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/migrate/migrate.go#L70-L121
18,925
scylladb/gocqlx
table/table.go
New
func New(m Metadata) *Table { t := &Table{ metadata: m, } // prepare primary and partition key comparators t.primaryKeyCmp = make([]qb.Cmp, 0, len(m.PartKey)+len(m.SortKey)) for _, k := range m.PartKey { t.primaryKeyCmp = append(t.primaryKeyCmp, qb.Eq(k)) } for _, k := range m.SortKey { t.primaryKeyCmp = append(t.primaryKeyCmp, qb.Eq(k)) } t.partKeyCmp = t.primaryKeyCmp[:len(t.metadata.PartKey)] // prepare get stmt t.get.stmt, t.get.names = qb.Select(m.Name).Where(t.primaryKeyCmp...).ToCql() // prepare select stmt t.sel.stmt, t.sel.names = qb.Select(m.Name).Where(t.partKeyCmp...).ToCql() // prepare insert stmt t.insert.stmt, t.insert.names = qb.Insert(m.Name).Columns(m.Columns...).ToCql() return t }
go
func New(m Metadata) *Table { t := &Table{ metadata: m, } // prepare primary and partition key comparators t.primaryKeyCmp = make([]qb.Cmp, 0, len(m.PartKey)+len(m.SortKey)) for _, k := range m.PartKey { t.primaryKeyCmp = append(t.primaryKeyCmp, qb.Eq(k)) } for _, k := range m.SortKey { t.primaryKeyCmp = append(t.primaryKeyCmp, qb.Eq(k)) } t.partKeyCmp = t.primaryKeyCmp[:len(t.metadata.PartKey)] // prepare get stmt t.get.stmt, t.get.names = qb.Select(m.Name).Where(t.primaryKeyCmp...).ToCql() // prepare select stmt t.sel.stmt, t.sel.names = qb.Select(m.Name).Where(t.partKeyCmp...).ToCql() // prepare insert stmt t.insert.stmt, t.insert.names = qb.Insert(m.Name).Columns(m.Columns...).ToCql() return t }
[ "func", "New", "(", "m", "Metadata", ")", "*", "Table", "{", "t", ":=", "&", "Table", "{", "metadata", ":", "m", ",", "}", "\n\n", "// prepare primary and partition key comparators", "t", ".", "primaryKeyCmp", "=", "make", "(", "[", "]", "qb", ".", "Cmp"...
// New creates new Table based on table schema read from Metadata.
[ "New", "creates", "new", "Table", "based", "on", "table", "schema", "read", "from", "Metadata", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L35-L58
18,926
scylladb/gocqlx
table/table.go
Get
func (t *Table) Get(columns ...string) (stmt string, names []string) { if len(columns) == 0 { return t.get.stmt, t.get.names } return qb.Select(t.metadata.Name). Columns(columns...). Where(t.primaryKeyCmp...). ToCql() }
go
func (t *Table) Get(columns ...string) (stmt string, names []string) { if len(columns) == 0 { return t.get.stmt, t.get.names } return qb.Select(t.metadata.Name). Columns(columns...). Where(t.primaryKeyCmp...). ToCql() }
[ "func", "(", "t", "*", "Table", ")", "Get", "(", "columns", "...", "string", ")", "(", "stmt", "string", ",", "names", "[", "]", "string", ")", "{", "if", "len", "(", "columns", ")", "==", "0", "{", "return", "t", ".", "get", ".", "stmt", ",", ...
// Get returns select by primary key statement.
[ "Get", "returns", "select", "by", "primary", "key", "statement", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L71-L80
18,927
scylladb/gocqlx
table/table.go
Select
func (t *Table) Select(columns ...string) (stmt string, names []string) { if len(columns) == 0 { return t.sel.stmt, t.sel.names } return qb.Select(t.metadata.Name). Columns(columns...). Where(t.primaryKeyCmp[0:len(t.metadata.PartKey)]...). ToCql() }
go
func (t *Table) Select(columns ...string) (stmt string, names []string) { if len(columns) == 0 { return t.sel.stmt, t.sel.names } return qb.Select(t.metadata.Name). Columns(columns...). Where(t.primaryKeyCmp[0:len(t.metadata.PartKey)]...). ToCql() }
[ "func", "(", "t", "*", "Table", ")", "Select", "(", "columns", "...", "string", ")", "(", "stmt", "string", ",", "names", "[", "]", "string", ")", "{", "if", "len", "(", "columns", ")", "==", "0", "{", "return", "t", ".", "sel", ".", "stmt", ",...
// Select returns select by partition key statement.
[ "Select", "returns", "select", "by", "partition", "key", "statement", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L83-L92
18,928
scylladb/gocqlx
table/table.go
SelectBuilder
func (t *Table) SelectBuilder(columns ...string) *qb.SelectBuilder { return qb.Select(t.metadata.Name).Columns(columns...).Where(t.partKeyCmp...) }
go
func (t *Table) SelectBuilder(columns ...string) *qb.SelectBuilder { return qb.Select(t.metadata.Name).Columns(columns...).Where(t.partKeyCmp...) }
[ "func", "(", "t", "*", "Table", ")", "SelectBuilder", "(", "columns", "...", "string", ")", "*", "qb", ".", "SelectBuilder", "{", "return", "qb", ".", "Select", "(", "t", ".", "metadata", ".", "Name", ")", ".", "Columns", "(", "columns", "...", ")", ...
// SelectBuilder returns a builder initialised to select by partition key // statement.
[ "SelectBuilder", "returns", "a", "builder", "initialised", "to", "select", "by", "partition", "key", "statement", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L96-L98
18,929
scylladb/gocqlx
table/table.go
Insert
func (t *Table) Insert() (stmt string, names []string) { return t.insert.stmt, t.insert.names }
go
func (t *Table) Insert() (stmt string, names []string) { return t.insert.stmt, t.insert.names }
[ "func", "(", "t", "*", "Table", ")", "Insert", "(", ")", "(", "stmt", "string", ",", "names", "[", "]", "string", ")", "{", "return", "t", ".", "insert", ".", "stmt", ",", "t", ".", "insert", ".", "names", "\n", "}" ]
// Insert returns insert all columns statement.
[ "Insert", "returns", "insert", "all", "columns", "statement", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L101-L103
18,930
scylladb/gocqlx
table/table.go
Update
func (t *Table) Update(columns ...string) (stmt string, names []string) { return qb.Update(t.metadata.Name).Set(columns...).Where(t.primaryKeyCmp...).ToCql() }
go
func (t *Table) Update(columns ...string) (stmt string, names []string) { return qb.Update(t.metadata.Name).Set(columns...).Where(t.primaryKeyCmp...).ToCql() }
[ "func", "(", "t", "*", "Table", ")", "Update", "(", "columns", "...", "string", ")", "(", "stmt", "string", ",", "names", "[", "]", "string", ")", "{", "return", "qb", ".", "Update", "(", "t", ".", "metadata", ".", "Name", ")", ".", "Set", "(", ...
// Update returns update by primary key statement.
[ "Update", "returns", "update", "by", "primary", "key", "statement", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L106-L108
18,931
scylladb/gocqlx
table/table.go
Delete
func (t *Table) Delete(columns ...string) (stmt string, names []string) { return qb.Delete(t.metadata.Name).Columns(columns...).Where(t.primaryKeyCmp...).ToCql() }
go
func (t *Table) Delete(columns ...string) (stmt string, names []string) { return qb.Delete(t.metadata.Name).Columns(columns...).Where(t.primaryKeyCmp...).ToCql() }
[ "func", "(", "t", "*", "Table", ")", "Delete", "(", "columns", "...", "string", ")", "(", "stmt", "string", ",", "names", "[", "]", "string", ")", "{", "return", "qb", ".", "Delete", "(", "t", ".", "metadata", ".", "Name", ")", ".", "Columns", "(...
// Delete returns delete by primary key statement.
[ "Delete", "returns", "delete", "by", "primary", "key", "statement", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/table/table.go#L111-L113
18,932
scylladb/gocqlx
qb/delete.go
From
func (b *DeleteBuilder) From(table string) *DeleteBuilder { b.table = table return b }
go
func (b *DeleteBuilder) From(table string) *DeleteBuilder { b.table = table return b }
[ "func", "(", "b", "*", "DeleteBuilder", ")", "From", "(", "table", "string", ")", "*", "DeleteBuilder", "{", "b", ".", "table", "=", "table", "\n", "return", "b", "\n", "}" ]
// From sets the table to be deleted from.
[ "From", "sets", "the", "table", "to", "be", "deleted", "from", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/delete.go#L58-L61
18,933
scylladb/gocqlx
qb/delete.go
Columns
func (b *DeleteBuilder) Columns(columns ...string) *DeleteBuilder { b.columns = append(b.columns, columns...) return b }
go
func (b *DeleteBuilder) Columns(columns ...string) *DeleteBuilder { b.columns = append(b.columns, columns...) return b }
[ "func", "(", "b", "*", "DeleteBuilder", ")", "Columns", "(", "columns", "...", "string", ")", "*", "DeleteBuilder", "{", "b", ".", "columns", "=", "append", "(", "b", ".", "columns", ",", "columns", "...", ")", "\n", "return", "b", "\n", "}" ]
// Columns adds delete columns to the query.
[ "Columns", "adds", "delete", "columns", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/delete.go#L64-L67
18,934
scylladb/gocqlx
gocqlx.go
structOnlyError
func structOnlyError(t reflect.Type) error { isStruct := t.Kind() == reflect.Struct isScanner := reflect.PtrTo(t).Implements(_unmarshallerInterface) if !isStruct { return fmt.Errorf("expected %s but got %s", reflect.Struct, t.Kind()) } if isScanner { return fmt.Errorf("structscan expects a struct dest but the provided struct type %s implements unmarshaler", t.Name()) } return fmt.Errorf("expected a struct, but struct %s has no exported fields", t.Name()) }
go
func structOnlyError(t reflect.Type) error { isStruct := t.Kind() == reflect.Struct isScanner := reflect.PtrTo(t).Implements(_unmarshallerInterface) if !isStruct { return fmt.Errorf("expected %s but got %s", reflect.Struct, t.Kind()) } if isScanner { return fmt.Errorf("structscan expects a struct dest but the provided struct type %s implements unmarshaler", t.Name()) } return fmt.Errorf("expected a struct, but struct %s has no exported fields", t.Name()) }
[ "func", "structOnlyError", "(", "t", "reflect", ".", "Type", ")", "error", "{", "isStruct", ":=", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Struct", "\n", "isScanner", ":=", "reflect", ".", "PtrTo", "(", "t", ")", ".", "Implements", "(", "_u...
// structOnlyError returns an error appropriate for type when a non-scannable // struct is expected but something else is given
[ "structOnlyError", "returns", "an", "error", "appropriate", "for", "type", "when", "a", "non", "-", "scannable", "struct", "is", "expected", "but", "something", "else", "is", "given" ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/gocqlx.go#L18-L28
18,935
scylladb/gocqlx
gocqlx.go
fieldsByTraversal
func fieldsByTraversal(v reflect.Value, traversals [][]int, values []interface{}, ptrs bool) error { v = reflect.Indirect(v) if v.Kind() != reflect.Struct { return errors.New("argument not a struct") } for i, traversal := range traversals { if len(traversal) == 0 { continue } f := reflectx.FieldByIndexes(v, traversal) if ptrs { values[i] = f.Addr().Interface() } else { values[i] = f.Interface() } } return nil }
go
func fieldsByTraversal(v reflect.Value, traversals [][]int, values []interface{}, ptrs bool) error { v = reflect.Indirect(v) if v.Kind() != reflect.Struct { return errors.New("argument not a struct") } for i, traversal := range traversals { if len(traversal) == 0 { continue } f := reflectx.FieldByIndexes(v, traversal) if ptrs { values[i] = f.Addr().Interface() } else { values[i] = f.Interface() } } return nil }
[ "func", "fieldsByTraversal", "(", "v", "reflect", ".", "Value", ",", "traversals", "[", "]", "[", "]", "int", ",", "values", "[", "]", "interface", "{", "}", ",", "ptrs", "bool", ")", "error", "{", "v", "=", "reflect", ".", "Indirect", "(", "v", ")...
// fieldsByName fills a values interface with fields from the passed value based // on the traversals in int. If ptrs is true, return addresses instead of values. // We write this instead of using FieldsByName to save allocations and map lookups // when iterating over many rows. Empty traversals will get an interface pointer. // Because of the necessity of requesting ptrs or values, it's considered a bit too // specialized for inclusion in reflectx itself.
[ "fieldsByName", "fills", "a", "values", "interface", "with", "fields", "from", "the", "passed", "value", "based", "on", "the", "traversals", "in", "int", ".", "If", "ptrs", "is", "true", "return", "addresses", "instead", "of", "values", ".", "We", "write", ...
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/gocqlx.go#L68-L86
18,936
scylladb/gocqlx
qb/insert.go
Into
func (b *InsertBuilder) Into(table string) *InsertBuilder { b.table = table return b }
go
func (b *InsertBuilder) Into(table string) *InsertBuilder { b.table = table return b }
[ "func", "(", "b", "*", "InsertBuilder", ")", "Into", "(", "table", "string", ")", "*", "InsertBuilder", "{", "b", ".", "table", "=", "table", "\n", "return", "b", "\n", "}" ]
// Into sets the INTO clause of the query.
[ "Into", "sets", "the", "INTO", "clause", "of", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/insert.go#L74-L77
18,937
scylladb/gocqlx
qb/insert.go
Columns
func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder { for _, c := range columns { b.columns = append(b.columns, initializer{ column: c, value: param(c), }) } return b }
go
func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder { for _, c := range columns { b.columns = append(b.columns, initializer{ column: c, value: param(c), }) } return b }
[ "func", "(", "b", "*", "InsertBuilder", ")", "Columns", "(", "columns", "...", "string", ")", "*", "InsertBuilder", "{", "for", "_", ",", "c", ":=", "range", "columns", "{", "b", ".", "columns", "=", "append", "(", "b", ".", "columns", ",", "initiali...
// Columns adds insert columns to the query.
[ "Columns", "adds", "insert", "columns", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/insert.go#L80-L88
18,938
scylladb/gocqlx
qb/insert.go
NamedColumn
func (b *InsertBuilder) NamedColumn(column, name string) *InsertBuilder { b.columns = append(b.columns, initializer{ column: column, value: param(name), }) return b }
go
func (b *InsertBuilder) NamedColumn(column, name string) *InsertBuilder { b.columns = append(b.columns, initializer{ column: column, value: param(name), }) return b }
[ "func", "(", "b", "*", "InsertBuilder", ")", "NamedColumn", "(", "column", ",", "name", "string", ")", "*", "InsertBuilder", "{", "b", ".", "columns", "=", "append", "(", "b", ".", "columns", ",", "initializer", "{", "column", ":", "column", ",", "valu...
// NamedColumn adds an insert column with a custom parameter name.
[ "NamedColumn", "adds", "an", "insert", "column", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/insert.go#L91-L97
18,939
scylladb/gocqlx
qb/insert.go
LitColumn
func (b *InsertBuilder) LitColumn(column, literal string) *InsertBuilder { b.columns = append(b.columns, initializer{ column: column, value: lit(literal), }) return b }
go
func (b *InsertBuilder) LitColumn(column, literal string) *InsertBuilder { b.columns = append(b.columns, initializer{ column: column, value: lit(literal), }) return b }
[ "func", "(", "b", "*", "InsertBuilder", ")", "LitColumn", "(", "column", ",", "literal", "string", ")", "*", "InsertBuilder", "{", "b", ".", "columns", "=", "append", "(", "b", ".", "columns", ",", "initializer", "{", "column", ":", "column", ",", "val...
// LitColumn adds an insert column with a literal value to the query.
[ "LitColumn", "adds", "an", "insert", "column", "with", "a", "literal", "value", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/insert.go#L100-L106
18,940
scylladb/gocqlx
qb/insert.go
FuncColumn
func (b *InsertBuilder) FuncColumn(column string, fn *Func) *InsertBuilder { b.columns = append(b.columns, initializer{ column: column, value: fn, }) return b }
go
func (b *InsertBuilder) FuncColumn(column string, fn *Func) *InsertBuilder { b.columns = append(b.columns, initializer{ column: column, value: fn, }) return b }
[ "func", "(", "b", "*", "InsertBuilder", ")", "FuncColumn", "(", "column", "string", ",", "fn", "*", "Func", ")", "*", "InsertBuilder", "{", "b", ".", "columns", "=", "append", "(", "b", ".", "columns", ",", "initializer", "{", "column", ":", "column", ...
// FuncColumn adds an insert column initialized by evaluating a CQL function.
[ "FuncColumn", "adds", "an", "insert", "column", "initialized", "by", "evaluating", "a", "CQL", "function", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/insert.go#L109-L115
18,941
scylladb/gocqlx
qb/batch.go
Add
func (b *BatchBuilder) Add(builder Builder) *BatchBuilder { return b.AddStmt(builder.ToCql()) }
go
func (b *BatchBuilder) Add(builder Builder) *BatchBuilder { return b.AddStmt(builder.ToCql()) }
[ "func", "(", "b", "*", "BatchBuilder", ")", "Add", "(", "builder", "Builder", ")", "*", "BatchBuilder", "{", "return", "b", ".", "AddStmt", "(", "builder", ".", "ToCql", "(", ")", ")", "\n", "}" ]
// Add builds the builder and adds the statement to the batch.
[ "Add", "builds", "the", "builder", "and", "adds", "the", "statement", "to", "the", "batch", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/batch.go#L59-L61
18,942
scylladb/gocqlx
qb/batch.go
AddStmt
func (b *BatchBuilder) AddStmt(stmt string, names []string) *BatchBuilder { b.stmts = append(b.stmts, stmt) b.names = append(b.names, names...) return b }
go
func (b *BatchBuilder) AddStmt(stmt string, names []string) *BatchBuilder { b.stmts = append(b.stmts, stmt) b.names = append(b.names, names...) return b }
[ "func", "(", "b", "*", "BatchBuilder", ")", "AddStmt", "(", "stmt", "string", ",", "names", "[", "]", "string", ")", "*", "BatchBuilder", "{", "b", ".", "stmts", "=", "append", "(", "b", ".", "stmts", ",", "stmt", ")", "\n", "b", ".", "names", "=...
// AddStmt adds statement to the batch.
[ "AddStmt", "adds", "statement", "to", "the", "batch", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/batch.go#L64-L68
18,943
scylladb/gocqlx
qb/batch.go
AddWithPrefix
func (b *BatchBuilder) AddWithPrefix(prefix string, builder Builder) *BatchBuilder { stmt, names := builder.ToCql() return b.AddStmtWithPrefix(prefix, stmt, names) }
go
func (b *BatchBuilder) AddWithPrefix(prefix string, builder Builder) *BatchBuilder { stmt, names := builder.ToCql() return b.AddStmtWithPrefix(prefix, stmt, names) }
[ "func", "(", "b", "*", "BatchBuilder", ")", "AddWithPrefix", "(", "prefix", "string", ",", "builder", "Builder", ")", "*", "BatchBuilder", "{", "stmt", ",", "names", ":=", "builder", ".", "ToCql", "(", ")", "\n", "return", "b", ".", "AddStmtWithPrefix", ...
// AddWithPrefix builds the builder and adds the statement to the batch. Names // are prefixed with the prefix + ".".
[ "AddWithPrefix", "builds", "the", "builder", "and", "adds", "the", "statement", "to", "the", "batch", ".", "Names", "are", "prefixed", "with", "the", "prefix", "+", ".", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/batch.go#L72-L75
18,944
scylladb/gocqlx
qb/batch.go
AddStmtWithPrefix
func (b *BatchBuilder) AddStmtWithPrefix(prefix string, stmt string, names []string) *BatchBuilder { b.stmts = append(b.stmts, stmt) for _, name := range names { if prefix != "" { name = fmt.Sprint(prefix, ".", name) } b.names = append(b.names, name) } return b }
go
func (b *BatchBuilder) AddStmtWithPrefix(prefix string, stmt string, names []string) *BatchBuilder { b.stmts = append(b.stmts, stmt) for _, name := range names { if prefix != "" { name = fmt.Sprint(prefix, ".", name) } b.names = append(b.names, name) } return b }
[ "func", "(", "b", "*", "BatchBuilder", ")", "AddStmtWithPrefix", "(", "prefix", "string", ",", "stmt", "string", ",", "names", "[", "]", "string", ")", "*", "BatchBuilder", "{", "b", ".", "stmts", "=", "append", "(", "b", ".", "stmts", ",", "stmt", "...
// AddStmtWithPrefix adds statement to the batch. Names are prefixed with // the prefix + ".".
[ "AddStmtWithPrefix", "adds", "statement", "to", "the", "batch", ".", "Names", "are", "prefixed", "with", "the", "prefix", "+", ".", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/batch.go#L79-L88
18,945
cespare/reflex
backlog.go
Add
func (b *UnifiedBacklog) Add(path string) { if b.empty { b.s = path b.empty = false } }
go
func (b *UnifiedBacklog) Add(path string) { if b.empty { b.s = path b.empty = false } }
[ "func", "(", "b", "*", "UnifiedBacklog", ")", "Add", "(", "path", "string", ")", "{", "if", "b", ".", "empty", "{", "b", ".", "s", "=", "path", "\n", "b", ".", "empty", "=", "false", "\n", "}", "\n", "}" ]
// Add adds path to b if there is not a path there currently. // Otherwise it discards it.
[ "Add", "adds", "path", "to", "b", "if", "there", "is", "not", "a", "path", "there", "currently", ".", "Otherwise", "it", "discards", "it", "." ]
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/backlog.go#L30-L35
18,946
cespare/reflex
backlog.go
RemoveOne
func (b *UnifiedBacklog) RemoveOne() bool { if b.empty { panic("RemoveOne() called on empty backlog") } b.empty = true b.s = "" return true }
go
func (b *UnifiedBacklog) RemoveOne() bool { if b.empty { panic("RemoveOne() called on empty backlog") } b.empty = true b.s = "" return true }
[ "func", "(", "b", "*", "UnifiedBacklog", ")", "RemoveOne", "(", ")", "bool", "{", "if", "b", ".", "empty", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "b", ".", "empty", "=", "true", "\n", "b", ".", "s", "=", "\"", "\"", "\n", "retur...
// RemoveOne removes the path in b.
[ "RemoveOne", "removes", "the", "path", "in", "b", "." ]
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/backlog.go#L46-L53
18,947
cespare/reflex
backlog.go
Add
func (b *UniqueFilesBacklog) Add(path string) { defer func() { b.empty = false }() if b.empty { b.next = path return } if path == b.next { return } b.rest[path] = struct{}{} }
go
func (b *UniqueFilesBacklog) Add(path string) { defer func() { b.empty = false }() if b.empty { b.next = path return } if path == b.next { return } b.rest[path] = struct{}{} }
[ "func", "(", "b", "*", "UniqueFilesBacklog", ")", "Add", "(", "path", "string", ")", "{", "defer", "func", "(", ")", "{", "b", ".", "empty", "=", "false", "}", "(", ")", "\n", "if", "b", ".", "empty", "{", "b", ".", "next", "=", "path", "\n", ...
// Add adds path to the set of files in b.
[ "Add", "adds", "path", "to", "the", "set", "of", "files", "in", "b", "." ]
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/backlog.go#L71-L81
18,948
cespare/reflex
config.go
ReadConfigs
func ReadConfigs(path string) ([]*Config, error) { var r io.Reader name := path if path == "-" { r = os.Stdin name = "standard input" } else { f, err := os.Open(flagConf) if err != nil { return nil, err } defer f.Close() r = f } return readConfigsFromReader(r, name) }
go
func ReadConfigs(path string) ([]*Config, error) { var r io.Reader name := path if path == "-" { r = os.Stdin name = "standard input" } else { f, err := os.Open(flagConf) if err != nil { return nil, err } defer f.Close() r = f } return readConfigsFromReader(r, name) }
[ "func", "ReadConfigs", "(", "path", "string", ")", "(", "[", "]", "*", "Config", ",", "error", ")", "{", "var", "r", "io", ".", "Reader", "\n", "name", ":=", "path", "\n", "if", "path", "==", "\"", "\"", "{", "r", "=", "os", ".", "Stdin", "\n",...
// ReadConfigs reads configurations from either a file or, as a special case, // stdin if "-" is given for path.
[ "ReadConfigs", "reads", "configurations", "from", "either", "a", "file", "or", "as", "a", "special", "case", "stdin", "if", "-", "is", "given", "for", "path", "." ]
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/config.go#L60-L75
18,949
cespare/reflex
watch.go
watch
func watch(root string, watcher *fsnotify.Watcher, names chan<- string, done chan<- error, reflexes []*Reflex) { if err := filepath.Walk(root, walker(watcher, reflexes)); err != nil { infoPrintf(-1, "Error while walking path %s: %s", root, err) } for { select { case e := <-watcher.Events: if verbose { infoPrintln(-1, "fsnotify event:", e) } stat, err := os.Stat(e.Name) if err != nil { continue } path := normalize(e.Name, stat.IsDir()) if e.Op&chmodMask == 0 { continue } names <- path if e.Op&fsnotify.Create > 0 && stat.IsDir() { if err := filepath.Walk(path, walker(watcher, reflexes)); err != nil { infoPrintf(-1, "Error while walking path %s: %s", path, err) } } // TODO: Cannot currently remove fsnotify watches // recursively, or for deleted files. See: // https://github.com/cespare/reflex/issues/13 // https://github.com/go-fsnotify/fsnotify/issues/40 // https://github.com/go-fsnotify/fsnotify/issues/41 case err := <-watcher.Errors: done <- err return } } }
go
func watch(root string, watcher *fsnotify.Watcher, names chan<- string, done chan<- error, reflexes []*Reflex) { if err := filepath.Walk(root, walker(watcher, reflexes)); err != nil { infoPrintf(-1, "Error while walking path %s: %s", root, err) } for { select { case e := <-watcher.Events: if verbose { infoPrintln(-1, "fsnotify event:", e) } stat, err := os.Stat(e.Name) if err != nil { continue } path := normalize(e.Name, stat.IsDir()) if e.Op&chmodMask == 0 { continue } names <- path if e.Op&fsnotify.Create > 0 && stat.IsDir() { if err := filepath.Walk(path, walker(watcher, reflexes)); err != nil { infoPrintf(-1, "Error while walking path %s: %s", path, err) } } // TODO: Cannot currently remove fsnotify watches // recursively, or for deleted files. See: // https://github.com/cespare/reflex/issues/13 // https://github.com/go-fsnotify/fsnotify/issues/40 // https://github.com/go-fsnotify/fsnotify/issues/41 case err := <-watcher.Errors: done <- err return } } }
[ "func", "watch", "(", "root", "string", ",", "watcher", "*", "fsnotify", ".", "Watcher", ",", "names", "chan", "<-", "string", ",", "done", "chan", "<-", "error", ",", "reflexes", "[", "]", "*", "Reflex", ")", "{", "if", "err", ":=", "filepath", ".",...
// watch recursively watches changes in root and reports the filenames to names. // It sends an error on the done chan. // As an optimization, any dirs we encounter that meet the ExcludePrefix // criteria of all reflexes can be ignored.
[ "watch", "recursively", "watches", "changes", "in", "root", "and", "reports", "the", "filenames", "to", "names", ".", "It", "sends", "an", "error", "on", "the", "done", "chan", ".", "As", "an", "optimization", "any", "dirs", "we", "encounter", "that", "mee...
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/watch.go#L17-L52
18,950
cespare/reflex
reflex.go
NewReflex
func NewReflex(c *Config) (*Reflex, error) { matcher, err := ParseMatchers(c.regexes, c.inverseRegexes, c.globs, c.inverseGlobs) if err != nil { return nil, fmt.Errorf("error parsing glob/regex: %s", err) } if !c.allFiles { matcher = multiMatcher{defaultExcludeMatcher, matcher} } if len(c.command) == 0 { return nil, errors.New("must give command to execute") } if c.subSymbol == "" { return nil, errors.New("substitution symbol must be non-empty") } substitution := false for _, part := range c.command { if strings.Contains(part, c.subSymbol) { substitution = true break } } var backlog Backlog if substitution { if c.startService { return nil, errors.New("using --start-service does not work with a command that has a substitution symbol") } backlog = NewUniqueFilesBacklog() } else { backlog = NewUnifiedBacklog() } if c.onlyFiles && c.onlyDirs { return nil, errors.New("cannot specify both --only-files and --only-dirs") } if c.shutdownTimeout <= 0 { return nil, errors.New("shutdown timeout cannot be <= 0") } reflex := &Reflex{ id: reflexID, source: c.source, startService: c.startService, backlog: backlog, matcher: matcher, onlyFiles: c.onlyFiles, onlyDirs: c.onlyDirs, command: c.command, subSymbol: c.subSymbol, done: make(chan struct{}), timeout: c.shutdownTimeout, mu: &sync.Mutex{}, } reflexID++ return reflex, nil }
go
func NewReflex(c *Config) (*Reflex, error) { matcher, err := ParseMatchers(c.regexes, c.inverseRegexes, c.globs, c.inverseGlobs) if err != nil { return nil, fmt.Errorf("error parsing glob/regex: %s", err) } if !c.allFiles { matcher = multiMatcher{defaultExcludeMatcher, matcher} } if len(c.command) == 0 { return nil, errors.New("must give command to execute") } if c.subSymbol == "" { return nil, errors.New("substitution symbol must be non-empty") } substitution := false for _, part := range c.command { if strings.Contains(part, c.subSymbol) { substitution = true break } } var backlog Backlog if substitution { if c.startService { return nil, errors.New("using --start-service does not work with a command that has a substitution symbol") } backlog = NewUniqueFilesBacklog() } else { backlog = NewUnifiedBacklog() } if c.onlyFiles && c.onlyDirs { return nil, errors.New("cannot specify both --only-files and --only-dirs") } if c.shutdownTimeout <= 0 { return nil, errors.New("shutdown timeout cannot be <= 0") } reflex := &Reflex{ id: reflexID, source: c.source, startService: c.startService, backlog: backlog, matcher: matcher, onlyFiles: c.onlyFiles, onlyDirs: c.onlyDirs, command: c.command, subSymbol: c.subSymbol, done: make(chan struct{}), timeout: c.shutdownTimeout, mu: &sync.Mutex{}, } reflexID++ return reflex, nil }
[ "func", "NewReflex", "(", "c", "*", "Config", ")", "(", "*", "Reflex", ",", "error", ")", "{", "matcher", ",", "err", ":=", "ParseMatchers", "(", "c", ".", "regexes", ",", "c", ".", "inverseRegexes", ",", "c", ".", "globs", ",", "c", ".", "inverseG...
// NewReflex prepares a Reflex from a Config, with sanity checking.
[ "NewReflex", "prepares", "a", "Reflex", "from", "a", "Config", "with", "sanity", "checking", "." ]
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/reflex.go#L43-L102
18,951
cespare/reflex
reflex.go
runCommand
func (r *Reflex) runCommand(name string, stdout chan<- OutMsg) { command := replaceSubSymbol(r.command, r.subSymbol, name) cmd := exec.Command(command[0], command[1:]...) r.cmd = cmd if flagSequential { seqCommands.Lock() } tty, err := pty.Start(cmd) if err != nil { infoPrintln(r.id, err) return } r.tty = tty // Handle pty size. chResize := make(chan os.Signal, 1) signal.Notify(chResize, syscall.SIGWINCH) go func() { for range chResize { // Intentionally ignore errors in case stdout is not a tty pty.InheritSize(os.Stdout, tty) } }() chResize <- syscall.SIGWINCH // Initial resize. go func() { scanner := bufio.NewScanner(tty) for scanner.Scan() { stdout <- OutMsg{r.id, scanner.Text()} } // Intentionally ignoring scanner.Err() for now. Unfortunately, // the pty returns a read error when the child dies naturally, // so I'm just going to ignore errors here unless I can find a // better way to handle it. }() r.mu.Lock() r.running = true r.mu.Unlock() go func() { err := cmd.Wait() if !r.Killed() && err != nil { stdout <- OutMsg{r.id, fmt.Sprintf("(error exit: %s)", err)} } r.done <- struct{}{} signal.Stop(chResize) close(chResize) if flagSequential { seqCommands.Unlock() } }() }
go
func (r *Reflex) runCommand(name string, stdout chan<- OutMsg) { command := replaceSubSymbol(r.command, r.subSymbol, name) cmd := exec.Command(command[0], command[1:]...) r.cmd = cmd if flagSequential { seqCommands.Lock() } tty, err := pty.Start(cmd) if err != nil { infoPrintln(r.id, err) return } r.tty = tty // Handle pty size. chResize := make(chan os.Signal, 1) signal.Notify(chResize, syscall.SIGWINCH) go func() { for range chResize { // Intentionally ignore errors in case stdout is not a tty pty.InheritSize(os.Stdout, tty) } }() chResize <- syscall.SIGWINCH // Initial resize. go func() { scanner := bufio.NewScanner(tty) for scanner.Scan() { stdout <- OutMsg{r.id, scanner.Text()} } // Intentionally ignoring scanner.Err() for now. Unfortunately, // the pty returns a read error when the child dies naturally, // so I'm just going to ignore errors here unless I can find a // better way to handle it. }() r.mu.Lock() r.running = true r.mu.Unlock() go func() { err := cmd.Wait() if !r.Killed() && err != nil { stdout <- OutMsg{r.id, fmt.Sprintf("(error exit: %s)", err)} } r.done <- struct{}{} signal.Stop(chResize) close(chResize) if flagSequential { seqCommands.Unlock() } }() }
[ "func", "(", "r", "*", "Reflex", ")", "runCommand", "(", "name", "string", ",", "stdout", "chan", "<-", "OutMsg", ")", "{", "command", ":=", "replaceSubSymbol", "(", "r", ".", "command", ",", "r", ".", "subSymbol", ",", "name", ")", "\n", "cmd", ":="...
// runCommand runs the given Command. All output is passed line-by-line to the // stdout channel.
[ "runCommand", "runs", "the", "given", "Command", ".", "All", "output", "is", "passed", "line", "-", "by", "-", "line", "to", "the", "stdout", "channel", "." ]
e1e64e8a6dd7552a6e8f616474c91d4d089eada6
https://github.com/cespare/reflex/blob/e1e64e8a6dd7552a6e8f616474c91d4d089eada6/reflex.go#L261-L316
18,952
bxcodec/faker
support/slice/helpers.go
Contains
func Contains(slice []string, item string) bool { set := make(map[string]struct{}, len(slice)) for _, s := range slice { set[s] = struct{}{} } _, ok := set[item] return ok }
go
func Contains(slice []string, item string) bool { set := make(map[string]struct{}, len(slice)) for _, s := range slice { set[s] = struct{}{} } _, ok := set[item] return ok }
[ "func", "Contains", "(", "slice", "[", "]", "string", ",", "item", "string", ")", "bool", "{", "set", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "len", "(", "slice", ")", ")", "\n", "for", "_", ",", "s", ":=", "range...
// Contains Check item in slice string type
[ "Contains", "Check", "item", "in", "slice", "string", "type" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/support/slice/helpers.go#L8-L16
18,953
bxcodec/faker
support/slice/helpers.go
IntToString
func IntToString(intSl []int) (str []string) { for i := range intSl { number := intSl[i] text := strconv.Itoa(number) str = append(str, text) } return str }
go
func IntToString(intSl []int) (str []string) { for i := range intSl { number := intSl[i] text := strconv.Itoa(number) str = append(str, text) } return str }
[ "func", "IntToString", "(", "intSl", "[", "]", "int", ")", "(", "str", "[", "]", "string", ")", "{", "for", "i", ":=", "range", "intSl", "{", "number", ":=", "intSl", "[", "i", "]", "\n", "text", ":=", "strconv", ".", "Itoa", "(", "number", ")", ...
// IntToString Convert slice int to slice string
[ "IntToString", "Convert", "slice", "int", "to", "slice", "string" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/support/slice/helpers.go#L19-L26
18,954
bxcodec/faker
price.go
GetPrice
func GetPrice() Money { mu.Lock() defer mu.Unlock() if pri == nil { pri = &Price{} } return pri }
go
func GetPrice() Money { mu.Lock() defer mu.Unlock() if pri == nil { pri = &Price{} } return pri }
[ "func", "GetPrice", "(", ")", "Money", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "pri", "==", "nil", "{", "pri", "=", "&", "Price", "{", "}", "\n", "}", "\n", "return", "pri", "\n", "}" ]
// GetPrice returns a new Money interface of Price struct
[ "GetPrice", "returns", "a", "new", "Money", "interface", "of", "Price", "struct" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/price.go#L48-L56
18,955
bxcodec/faker
price.go
Currency
func (p Price) Currency(v reflect.Value) (interface{}, error) { return p.currency(), nil }
go
func (p Price) Currency(v reflect.Value) (interface{}, error) { return p.currency(), nil }
[ "func", "(", "p", "Price", ")", "Currency", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "currency", "(", ")", ",", "nil", "\n", "}" ]
// Currency returns a random currency from currencies
[ "Currency", "returns", "a", "random", "currency", "from", "currencies" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/price.go#L68-L70
18,956
bxcodec/faker
price.go
AmountWithCurrency
func (p Price) AmountWithCurrency(v reflect.Value) (interface{}, error) { return p.amountwithcurrency(), nil }
go
func (p Price) AmountWithCurrency(v reflect.Value) (interface{}, error) { return p.amountwithcurrency(), nil }
[ "func", "(", "p", "Price", ")", "AmountWithCurrency", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "amountwithcurrency", "(", ")", ",", "nil", "\n", "}" ]
// AmountWithCurrency combines both price and currency together
[ "AmountWithCurrency", "combines", "both", "price", "and", "currency", "together" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/price.go#L101-L103
18,957
bxcodec/faker
price.go
precision
func precision(val float64, pre int) float64 { div := math.Pow10(pre) return float64(int64(val*div)) / div }
go
func precision(val float64, pre int) float64 { div := math.Pow10(pre) return float64(int64(val*div)) / div }
[ "func", "precision", "(", "val", "float64", ",", "pre", "int", ")", "float64", "{", "div", ":=", "math", ".", "Pow10", "(", "pre", ")", "\n", "return", "float64", "(", "int64", "(", "val", "*", "div", ")", ")", "/", "div", "\n", "}" ]
// precision | a helper function to set precision of price
[ "precision", "|", "a", "helper", "function", "to", "set", "precision", "of", "price" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/price.go#L112-L115
18,958
bxcodec/faker
lorem.go
GetLorem
func GetLorem() DataFaker { mu.Lock() defer mu.Unlock() if lorem == nil { lorem = &Lorem{} } return lorem }
go
func GetLorem() DataFaker { mu.Lock() defer mu.Unlock() if lorem == nil { lorem = &Lorem{} } return lorem }
[ "func", "GetLorem", "(", ")", "DataFaker", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "lorem", "==", "nil", "{", "lorem", "=", "&", "Lorem", "{", "}", "\n", "}", "\n", "return", "lorem", "\n", ...
// GetLorem returns a new DataFaker interface of Lorem struct
[ "GetLorem", "returns", "a", "new", "DataFaker", "interface", "of", "Lorem", "struct" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/lorem.go#L64-L72
18,959
bxcodec/faker
lorem.go
Word
func (l Lorem) Word(v reflect.Value) (interface{}, error) { return l.word(), nil }
go
func (l Lorem) Word(v reflect.Value) (interface{}, error) { return l.word(), nil }
[ "func", "(", "l", "Lorem", ")", "Word", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "l", ".", "word", "(", ")", ",", "nil", "\n", "}" ]
// Word returns a word from the wordList const
[ "Word", "returns", "a", "word", "from", "the", "wordList", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/lorem.go#L83-L85
18,960
bxcodec/faker
lorem.go
Sentence
func (l Lorem) Sentence(v reflect.Value) (interface{}, error) { sentence := l.sentence() return sentence, nil }
go
func (l Lorem) Sentence(v reflect.Value) (interface{}, error) { sentence := l.sentence() return sentence, nil }
[ "func", "(", "l", "Lorem", ")", "Sentence", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "sentence", ":=", "l", ".", "sentence", "(", ")", "\n", "return", "sentence", ",", "nil", "\n", "}" ]
// Sentence returns a sentence using the wordList const
[ "Sentence", "returns", "a", "sentence", "using", "the", "wordList", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/lorem.go#L111-L114
18,961
bxcodec/faker
lorem.go
Paragraph
func (l Lorem) Paragraph(v reflect.Value) (interface{}, error) { return l.paragraph(), nil }
go
func (l Lorem) Paragraph(v reflect.Value) (interface{}, error) { return l.paragraph(), nil }
[ "func", "(", "l", "Lorem", ")", "Paragraph", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "l", ".", "paragraph", "(", ")", ",", "nil", "\n", "}" ]
// Paragraph returns a series of sentences as a paragraph using the wordList const
[ "Paragraph", "returns", "a", "series", "of", "sentences", "as", "a", "paragraph", "using", "the", "wordList", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/lorem.go#L135-L137
18,962
bxcodec/faker
internet.go
GetNetworker
func GetNetworker() Networker { mu.Lock() defer mu.Unlock() if internet == nil { internet = &Internet{} } return internet }
go
func GetNetworker() Networker { mu.Lock() defer mu.Unlock() if internet == nil { internet = &Internet{} } return internet }
[ "func", "GetNetworker", "(", ")", "Networker", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "internet", "==", "nil", "{", "internet", "=", "&", "Internet", "{", "}", "\n", "}", "\n", "return", "inter...
// GetNetworker returns a new Networker interface of Internet
[ "GetNetworker", "returns", "a", "new", "Networker", "interface", "of", "Internet" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L29-L37
18,963
bxcodec/faker
internet.go
Email
func (internet Internet) Email(v reflect.Value) (interface{}, error) { return internet.email(), nil }
go
func (internet Internet) Email(v reflect.Value) (interface{}, error) { return internet.email(), nil }
[ "func", "(", "internet", "Internet", ")", "Email", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "email", "(", ")", ",", "nil", "\n", "}" ]
// Email generates random email id
[ "Email", "generates", "random", "email", "id" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L64-L66
18,964
bxcodec/faker
internet.go
MacAddress
func (internet Internet) MacAddress(v reflect.Value) (interface{}, error) { return internet.macAddress(), nil }
go
func (internet Internet) MacAddress(v reflect.Value) (interface{}, error) { return internet.macAddress(), nil }
[ "func", "(", "internet", "Internet", ")", "MacAddress", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "macAddress", "(", ")", ",", "nil", "\n", "}" ]
// MacAddress generates random MacAddress
[ "MacAddress", "generates", "random", "MacAddress" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L83-L85
18,965
bxcodec/faker
internet.go
DomainName
func (internet Internet) DomainName(v reflect.Value) (interface{}, error) { return internet.domainName(), nil }
go
func (internet Internet) DomainName(v reflect.Value) (interface{}, error) { return internet.domainName(), nil }
[ "func", "(", "internet", "Internet", ")", "DomainName", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "domainName", "(", ")", ",", "nil", "\n", "}" ]
// DomainName generates random domain name
[ "DomainName", "generates", "random", "domain", "name" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L98-L100
18,966
bxcodec/faker
internet.go
URL
func (internet Internet) URL(v reflect.Value) (interface{}, error) { return internet.url(), nil }
go
func (internet Internet) URL(v reflect.Value) (interface{}, error) { return internet.url(), nil }
[ "func", "(", "internet", "Internet", ")", "URL", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "url", "(", ")", ",", "nil", "\n", "}" ]
// URL generates random URL standardised in urlFormats const
[ "URL", "generates", "random", "URL", "standardised", "in", "urlFormats", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L118-L120
18,967
bxcodec/faker
internet.go
UserName
func (internet Internet) UserName(v reflect.Value) (interface{}, error) { return internet.username(), nil }
go
func (internet Internet) UserName(v reflect.Value) (interface{}, error) { return internet.username(), nil }
[ "func", "(", "internet", "Internet", ")", "UserName", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "username", "(", ")", ",", "nil", "\n", "}" ]
// UserName generates random username
[ "UserName", "generates", "random", "username" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L133-L135
18,968
bxcodec/faker
internet.go
IPv4
func (internet Internet) IPv4(v reflect.Value) (interface{}, error) { return internet.ipv4(), nil }
go
func (internet Internet) IPv4(v reflect.Value) (interface{}, error) { return internet.ipv4(), nil }
[ "func", "(", "internet", "Internet", ")", "IPv4", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "ipv4", "(", ")", ",", "nil", "\n", "}" ]
// IPv4 generates random IPv4 address
[ "IPv4", "generates", "random", "IPv4", "address" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L153-L155
18,969
bxcodec/faker
internet.go
IPv6
func (internet Internet) IPv6(v reflect.Value) (interface{}, error) { return internet.ipv6(), nil }
go
func (internet Internet) IPv6(v reflect.Value) (interface{}, error) { return internet.ipv6(), nil }
[ "func", "(", "internet", "Internet", ")", "IPv6", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "ipv6", "(", ")", ",", "nil", "\n", "}" ]
// IPv6 generates random IPv6 address
[ "IPv6", "generates", "random", "IPv6", "address" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L173-L175
18,970
bxcodec/faker
internet.go
Password
func (internet Internet) Password(v reflect.Value) (interface{}, error) { return internet.password(), nil }
go
func (internet Internet) Password(v reflect.Value) (interface{}, error) { return internet.password(), nil }
[ "func", "(", "internet", "Internet", ")", "Password", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "internet", ".", "password", "(", ")", ",", "nil", "\n", "}" ]
// Password returns a hashed password
[ "Password", "returns", "a", "hashed", "password" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/internet.go#L188-L190
18,971
bxcodec/faker
person.go
GetPerson
func GetPerson() Dowser { mu.Lock() defer mu.Unlock() if person == nil { person = &Person{} } return person }
go
func GetPerson() Dowser { mu.Lock() defer mu.Unlock() if person == nil { person = &Person{} } return person }
[ "func", "GetPerson", "(", ")", "Dowser", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "person", "==", "nil", "{", "person", "=", "&", "Person", "{", "}", "\n", "}", "\n", "return", "person", "\n", ...
// GetPerson returns a new Dowser interface of Person struct
[ "GetPerson", "returns", "a", "new", "Dowser", "interface", "of", "Person", "struct" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L112-L120
18,972
bxcodec/faker
person.go
TitleMale
func (p Person) TitleMale(v reflect.Value) (interface{}, error) { return p.titlemale(), nil }
go
func (p Person) TitleMale(v reflect.Value) (interface{}, error) { return p.titlemale(), nil }
[ "func", "(", "p", "Person", ")", "TitleMale", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "titlemale", "(", ")", ",", "nil", "\n", "}" ]
// TitleMale generates random titles for males
[ "TitleMale", "generates", "random", "titles", "for", "males" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L136-L138
18,973
bxcodec/faker
person.go
TitleFeMale
func (p Person) TitleFeMale(v reflect.Value) (interface{}, error) { return p.titleFemale(), nil }
go
func (p Person) TitleFeMale(v reflect.Value) (interface{}, error) { return p.titleFemale(), nil }
[ "func", "(", "p", "Person", ")", "TitleFeMale", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "titleFemale", "(", ")", ",", "nil", "\n", "}" ]
// TitleFeMale generates random titles for females
[ "TitleFeMale", "generates", "random", "titles", "for", "females" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L151-L153
18,974
bxcodec/faker
person.go
FirstName
func (p Person) FirstName(v reflect.Value) (interface{}, error) { return p.firstname(), nil }
go
func (p Person) FirstName(v reflect.Value) (interface{}, error) { return p.firstname(), nil }
[ "func", "(", "p", "Person", ")", "FirstName", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "firstname", "(", ")", ",", "nil", "\n", "}" ]
// FirstName retuns first names
[ "FirstName", "retuns", "first", "names" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L166-L168
18,975
bxcodec/faker
person.go
FirstNameMale
func (p Person) FirstNameMale(v reflect.Value) (interface{}, error) { return p.firstnamemale(), nil }
go
func (p Person) FirstNameMale(v reflect.Value) (interface{}, error) { return p.firstnamemale(), nil }
[ "func", "(", "p", "Person", ")", "FirstNameMale", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "firstnamemale", "(", ")", ",", "nil", "\n", "}" ]
// FirstNameMale retuns first names for males
[ "FirstNameMale", "retuns", "first", "names", "for", "males" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L181-L183
18,976
bxcodec/faker
person.go
FirstNameFemale
func (p Person) FirstNameFemale(v reflect.Value) (interface{}, error) { return p.firstnamefemale(), nil }
go
func (p Person) FirstNameFemale(v reflect.Value) (interface{}, error) { return p.firstnamefemale(), nil }
[ "func", "(", "p", "Person", ")", "FirstNameFemale", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "firstnamefemale", "(", ")", ",", "nil", "\n", "}" ]
// FirstNameFemale retuns first names for females
[ "FirstNameFemale", "retuns", "first", "names", "for", "females" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L196-L198
18,977
bxcodec/faker
person.go
LastName
func (p Person) LastName(v reflect.Value) (interface{}, error) { return p.lastname(), nil }
go
func (p Person) LastName(v reflect.Value) (interface{}, error) { return p.lastname(), nil }
[ "func", "(", "p", "Person", ")", "LastName", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "lastname", "(", ")", ",", "nil", "\n", "}" ]
// LastName returns last name
[ "LastName", "returns", "last", "name" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L211-L213
18,978
bxcodec/faker
person.go
Name
func (p Person) Name(v reflect.Value) (interface{}, error) { return p.name(), nil }
go
func (p Person) Name(v reflect.Value) (interface{}, error) { return p.name(), nil }
[ "func", "(", "p", "Person", ")", "Name", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "name", "(", ")", ",", "nil", "\n", "}" ]
// Name returns a random name
[ "Name", "returns", "a", "random", "name" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/person.go#L229-L231
18,979
bxcodec/faker
address.go
GetAddress
func GetAddress() Addresser { mu.Lock() defer mu.Unlock() if address == nil { address = &Address{} } return address }
go
func GetAddress() Addresser { mu.Lock() defer mu.Unlock() if address == nil { address = &Address{} } return address }
[ "func", "GetAddress", "(", ")", "Addresser", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "address", "==", "nil", "{", "address", "=", "&", "Address", "{", "}", "\n", "}", "\n", "return", "address", ...
// GetAddress returns a new Addresser interface of Address
[ "GetAddress", "returns", "a", "new", "Addresser", "interface", "of", "Address" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/address.go#L11-L19
18,980
bxcodec/faker
address.go
Latitude
func (i Address) Latitude(v reflect.Value) (interface{}, error) { kind := v.Kind() val := i.latitute() if kind == reflect.Float32 { return val, nil } return float64(val), nil }
go
func (i Address) Latitude(v reflect.Value) (interface{}, error) { kind := v.Kind() val := i.latitute() if kind == reflect.Float32 { return val, nil } return float64(val), nil }
[ "func", "(", "i", "Address", ")", "Latitude", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "kind", ":=", "v", ".", "Kind", "(", ")", "\n", "val", ":=", "i", ".", "latitute", "(", ")", "\n", "if", ...
// Latitude sets latitude of the address
[ "Latitude", "sets", "latitude", "of", "the", "address" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/address.go#L40-L47
18,981
bxcodec/faker
address.go
Longitude
func (i Address) Longitude(v reflect.Value) (interface{}, error) { kind := v.Kind() val := i.longitude() if kind == reflect.Float32 { return val, nil } return float64(val), nil }
go
func (i Address) Longitude(v reflect.Value) (interface{}, error) { kind := v.Kind() val := i.longitude() if kind == reflect.Float32 { return val, nil } return float64(val), nil }
[ "func", "(", "i", "Address", ")", "Longitude", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "kind", ":=", "v", ".", "Kind", "(", ")", "\n", "val", ":=", "i", ".", "longitude", "(", ")", "\n", "if",...
// Longitude sets longitude of the address
[ "Longitude", "sets", "longitude", "of", "the", "address" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/address.go#L54-L61
18,982
bxcodec/faker
faker.go
SetRandomStringLength
func SetRandomStringLength(size int) error { if size < 0 { return fmt.Errorf(ErrSmallerThanZero, size) } randomStringLen = size return nil }
go
func SetRandomStringLength(size int) error { if size < 0 { return fmt.Errorf(ErrSmallerThanZero, size) } randomStringLen = size return nil }
[ "func", "SetRandomStringLength", "(", "size", "int", ")", "error", "{", "if", "size", "<", "0", "{", "return", "fmt", ".", "Errorf", "(", "ErrSmallerThanZero", ",", "size", ")", "\n", "}", "\n", "randomStringLen", "=", "size", "\n", "return", "nil", "\n"...
// SetRandomStringLength sets a length for random string generation
[ "SetRandomStringLength", "sets", "a", "length", "for", "random", "string", "generation" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/faker.go#L218-L224
18,983
bxcodec/faker
faker.go
SetRandomMapAndSliceSize
func SetRandomMapAndSliceSize(size int) error { if size < 0 { return fmt.Errorf(ErrSmallerThanZero, size) } randomSize = size return nil }
go
func SetRandomMapAndSliceSize(size int) error { if size < 0 { return fmt.Errorf(ErrSmallerThanZero, size) } randomSize = size return nil }
[ "func", "SetRandomMapAndSliceSize", "(", "size", "int", ")", "error", "{", "if", "size", "<", "0", "{", "return", "fmt", ".", "Errorf", "(", "ErrSmallerThanZero", ",", "size", ")", "\n", "}", "\n", "randomSize", "=", "size", "\n", "return", "nil", "\n", ...
// SetRandomMapAndSliceSize sets the size for maps and slices for random generation.
[ "SetRandomMapAndSliceSize", "sets", "the", "size", "for", "maps", "and", "slices", "for", "random", "generation", "." ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/faker.go#L227-L233
18,984
bxcodec/faker
faker.go
SetRandomNumberBoundaries
func SetRandomNumberBoundaries(start, end int) error { if start > end { return errors.New(ErrStartValueBiggerThanEnd) } nBoundary = numberBoundary{start: start, end: end} return nil }
go
func SetRandomNumberBoundaries(start, end int) error { if start > end { return errors.New(ErrStartValueBiggerThanEnd) } nBoundary = numberBoundary{start: start, end: end} return nil }
[ "func", "SetRandomNumberBoundaries", "(", "start", ",", "end", "int", ")", "error", "{", "if", "start", ">", "end", "{", "return", "errors", ".", "New", "(", "ErrStartValueBiggerThanEnd", ")", "\n", "}", "\n", "nBoundary", "=", "numberBoundary", "{", "start"...
// SetRandomNumberBoundaries sets boundary for random number generation
[ "SetRandomNumberBoundaries", "sets", "boundary", "for", "random", "number", "generation" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/faker.go#L236-L242
18,985
bxcodec/faker
faker.go
FakeData
func FakeData(a interface{}) error { reflectType := reflect.TypeOf(a) if reflectType.Kind() != reflect.Ptr { return errors.New(ErrValueNotPtr) } if reflect.ValueOf(a).IsNil() { return fmt.Errorf(ErrNotSupportedPointer, reflectType.Elem().String()) } rval := reflect.ValueOf(a) finalValue, err := getValue(a) if err != nil { return err } rval.Elem().Set(finalValue.Elem().Convert(reflectType.Elem())) return nil }
go
func FakeData(a interface{}) error { reflectType := reflect.TypeOf(a) if reflectType.Kind() != reflect.Ptr { return errors.New(ErrValueNotPtr) } if reflect.ValueOf(a).IsNil() { return fmt.Errorf(ErrNotSupportedPointer, reflectType.Elem().String()) } rval := reflect.ValueOf(a) finalValue, err := getValue(a) if err != nil { return err } rval.Elem().Set(finalValue.Elem().Convert(reflectType.Elem())) return nil }
[ "func", "FakeData", "(", "a", "interface", "{", "}", ")", "error", "{", "reflectType", ":=", "reflect", ".", "TypeOf", "(", "a", ")", "\n\n", "if", "reflectType", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "return", "errors", ".", "New"...
// FakeData is the main function. Will generate a fake data based on your struct. You can use this for automation testing, or anything that need automated data. // You don't need to Create your own data for your testing.
[ "FakeData", "is", "the", "main", "function", ".", "Will", "generate", "a", "fake", "data", "based", "on", "your", "struct", ".", "You", "can", "use", "this", "for", "automation", "testing", "or", "anything", "that", "need", "automated", "data", ".", "You",...
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/faker.go#L246-L267
18,986
bxcodec/faker
faker.go
randomIntegerWithBoundary
func randomIntegerWithBoundary(boundary numberBoundary) int { return rand.Intn(boundary.end-boundary.start) + boundary.start }
go
func randomIntegerWithBoundary(boundary numberBoundary) int { return rand.Intn(boundary.end-boundary.start) + boundary.start }
[ "func", "randomIntegerWithBoundary", "(", "boundary", "numberBoundary", ")", "int", "{", "return", "rand", ".", "Intn", "(", "boundary", ".", "end", "-", "boundary", ".", "start", ")", "+", "boundary", ".", "start", "\n", "}" ]
// randomIntegerWithBoundary returns a random integer between input start and end boundary. [start, end)
[ "randomIntegerWithBoundary", "returns", "a", "random", "integer", "between", "input", "start", "and", "end", "boundary", ".", "[", "start", "end", ")" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/faker.go#L746-L748
18,987
bxcodec/faker
faker.go
randomInteger
func randomInteger() int { return rand.Intn(nBoundary.end-nBoundary.start) + nBoundary.start }
go
func randomInteger() int { return rand.Intn(nBoundary.end-nBoundary.start) + nBoundary.start }
[ "func", "randomInteger", "(", ")", "int", "{", "return", "rand", ".", "Intn", "(", "nBoundary", ".", "end", "-", "nBoundary", ".", "start", ")", "+", "nBoundary", ".", "start", "\n", "}" ]
// randomInteger returns a random integer between start and end boundary. [start, end)
[ "randomInteger", "returns", "a", "random", "integer", "between", "start", "and", "end", "boundary", ".", "[", "start", "end", ")" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/faker.go#L751-L753
18,988
bxcodec/faker
payment.go
GetPayment
func GetPayment() Render { mu.Lock() defer mu.Unlock() if pay == nil { pay = &Payment{} } return pay }
go
func GetPayment() Render { mu.Lock() defer mu.Unlock() if pay == nil { pay = &Payment{} } return pay }
[ "func", "GetPayment", "(", ")", "Render", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "pay", "==", "nil", "{", "pay", "=", "&", "Payment", "{", "}", "\n", "}", "\n", "return", "pay", "\n", "}" ]
// GetPayment returns a new Render interface of Payment struct
[ "GetPayment", "returns", "a", "new", "Render", "interface", "of", "Payment", "struct" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/payment.go#L35-L43
18,989
bxcodec/faker
payment.go
CreditCardNumber
func (p Payment) CreditCardNumber(v reflect.Value) (interface{}, error) { return p.ccnumber(), nil }
go
func (p Payment) CreditCardNumber(v reflect.Value) (interface{}, error) { return p.ccnumber(), nil }
[ "func", "(", "p", "Payment", ")", "CreditCardNumber", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "p", ".", "ccnumber", "(", ")", ",", "nil", "\n", "}" ]
// CreditCardNumber generated credit card number according to the card number rules
[ "CreditCardNumber", "generated", "credit", "card", "number", "according", "to", "the", "card", "number", "rules" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/payment.go#L99-L101
18,990
bxcodec/faker
phone.go
GetPhoner
func GetPhoner() Phoner { mu.Lock() defer mu.Unlock() if phone == nil { phone = &Phone{} } return phone }
go
func GetPhoner() Phoner { mu.Lock() defer mu.Unlock() if phone == nil { phone = &Phone{} } return phone }
[ "func", "GetPhoner", "(", ")", "Phoner", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "phone", "==", "nil", "{", "phone", "=", "&", "Phone", "{", "}", "\n", "}", "\n", "return", "phone", "\n", "}...
// GetPhoner serves as a constructor for Phoner interface
[ "GetPhoner", "serves", "as", "a", "constructor", "for", "Phoner", "interface" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/phone.go#L15-L23
18,991
bxcodec/faker
uuid.go
GetIdentifier
func GetIdentifier() Identifier { mu.Lock() defer mu.Unlock() if identifier == nil { identifier = &UUID{} } return identifier }
go
func GetIdentifier() Identifier { mu.Lock() defer mu.Unlock() if identifier == nil { identifier = &UUID{} } return identifier }
[ "func", "GetIdentifier", "(", ")", "Identifier", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "identifier", "==", "nil", "{", "identifier", "=", "&", "UUID", "{", "}", "\n", "}", "\n", "return", "ide...
// GetIdentifier returns a new Identifier
[ "GetIdentifier", "returns", "a", "new", "Identifier" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/uuid.go#L13-L21
18,992
bxcodec/faker
uuid.go
createUUID
func createUUID() ([]byte, error) { b := make([]byte, 16) _, err := io.ReadFull(rand.Reader, b) if err != nil { return b, err } // variant bits; see section 4.1.1 b[8] = b[8]&^0xc0 | 0x80 // version 4 (pseudo-random); see section 4.1.3 b[6] = b[6]&^0xf0 | 0x40 return b, nil }
go
func createUUID() ([]byte, error) { b := make([]byte, 16) _, err := io.ReadFull(rand.Reader, b) if err != nil { return b, err } // variant bits; see section 4.1.1 b[8] = b[8]&^0xc0 | 0x80 // version 4 (pseudo-random); see section 4.1.3 b[6] = b[6]&^0xf0 | 0x40 return b, nil }
[ "func", "createUUID", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "16", ")", "\n", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "rand", ".", "Reader", ",", "b", ")", "\n", "i...
// createUUID returns a 16 byte slice with random values
[ "createUUID", "returns", "a", "16", "byte", "slice", "with", "random", "values" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/uuid.go#L33-L44
18,993
bxcodec/faker
datetime.go
GetDateTimer
func GetDateTimer() DateTimer { mu.Lock() defer mu.Unlock() if date == nil { date = &DateTime{} } return date }
go
func GetDateTimer() DateTimer { mu.Lock() defer mu.Unlock() if date == nil { date = &DateTime{} } return date }
[ "func", "GetDateTimer", "(", ")", "DateTimer", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "date", "==", "nil", "{", "date", "=", "&", "DateTime", "{", "}", "\n", "}", "\n", "return", "date", "\n"...
// GetDateTimer returns a new DateTimer interface of DateTime
[ "GetDateTimer", "returns", "a", "new", "DateTimer", "interface", "of", "DateTime" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L626-L634
18,994
bxcodec/faker
datetime.go
UnixTime
func (d DateTime) UnixTime(v reflect.Value) (interface{}, error) { kind := v.Kind() var val int64 if kind == reflect.Int64 { val = d.unixtime() } else { val = 0 } return val, nil }
go
func (d DateTime) UnixTime(v reflect.Value) (interface{}, error) { kind := v.Kind() var val int64 if kind == reflect.Int64 { val = d.unixtime() } else { val = 0 } return val, nil }
[ "func", "(", "d", "DateTime", ")", "UnixTime", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "kind", ":=", "v", ".", "Kind", "(", ")", "\n", "var", "val", "int64", "\n", "if", "kind", "==", "reflect",...
// UnixTime get unix time
[ "UnixTime", "get", "unix", "time" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L650-L660
18,995
bxcodec/faker
datetime.go
Date
func (d DateTime) Date(v reflect.Value) (interface{}, error) { return d.date(), nil }
go
func (d DateTime) Date(v reflect.Value) (interface{}, error) { return d.date(), nil }
[ "func", "(", "d", "DateTime", ")", "Date", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "date", "(", ")", ",", "nil", "\n", "}" ]
// Date formats DateTime using example BaseDateFormat const
[ "Date", "formats", "DateTime", "using", "example", "BaseDateFormat", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L673-L675
18,996
bxcodec/faker
datetime.go
Time
func (d DateTime) Time(v reflect.Value) (interface{}, error) { return d.time(), nil }
go
func (d DateTime) Time(v reflect.Value) (interface{}, error) { return d.time(), nil }
[ "func", "(", "d", "DateTime", ")", "Time", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "time", "(", ")", ",", "nil", "\n", "}" ]
// Time formats DateTime using example Time const
[ "Time", "formats", "DateTime", "using", "example", "Time", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L688-L690
18,997
bxcodec/faker
datetime.go
MonthName
func (d DateTime) MonthName(v reflect.Value) (interface{}, error) { return d.monthName(), nil }
go
func (d DateTime) MonthName(v reflect.Value) (interface{}, error) { return d.monthName(), nil }
[ "func", "(", "d", "DateTime", ")", "MonthName", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "monthName", "(", ")", ",", "nil", "\n", "}" ]
// MonthName formats DateTime using example Month const
[ "MonthName", "formats", "DateTime", "using", "example", "Month", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L703-L705
18,998
bxcodec/faker
datetime.go
Year
func (d DateTime) Year(v reflect.Value) (interface{}, error) { return d.year(), nil }
go
func (d DateTime) Year(v reflect.Value) (interface{}, error) { return d.year(), nil }
[ "func", "(", "d", "DateTime", ")", "Year", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "year", "(", ")", ",", "nil", "\n", "}" ]
// Year formats DateTime using example Year const
[ "Year", "formats", "DateTime", "using", "example", "Year", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L718-L720
18,999
bxcodec/faker
datetime.go
DayOfWeek
func (d DateTime) DayOfWeek(v reflect.Value) (interface{}, error) { return d.dayOfWeek(), nil }
go
func (d DateTime) DayOfWeek(v reflect.Value) (interface{}, error) { return d.dayOfWeek(), nil }
[ "func", "(", "d", "DateTime", ")", "DayOfWeek", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "dayOfWeek", "(", ")", ",", "nil", "\n", "}" ]
// DayOfWeek formats DateTime using example Day const
[ "DayOfWeek", "formats", "DateTime", "using", "example", "Day", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L733-L735