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
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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...
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...
[ "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
bxcodec/faker
datetime.go
DayOfMonth
func (d DateTime) DayOfMonth(v reflect.Value) (interface{}, error) { return d.dayOfMonth(), nil }
go
func (d DateTime) DayOfMonth(v reflect.Value) (interface{}, error) { return d.dayOfMonth(), nil }
[ "func", "(", "d", "DateTime", ")", "DayOfMonth", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "dayOfMonth", "(", ")", ",", "nil", "\n", "}" ]
// DayOfMonth formats DateTime using example DayOfMonth const
[ "DayOfMonth", "formats", "DateTime", "using", "example", "DayOfMonth", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L748-L750
train
bxcodec/faker
datetime.go
Timestamp
func (d DateTime) Timestamp(v reflect.Value) (interface{}, error) { return d.timestamp(), nil }
go
func (d DateTime) Timestamp(v reflect.Value) (interface{}, error) { return d.timestamp(), nil }
[ "func", "(", "d", "DateTime", ")", "Timestamp", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "timestamp", "(", ")", ",", "nil", "\n", "}" ]
// Timestamp formats DateTime using example Timestamp const
[ "Timestamp", "formats", "DateTime", "using", "example", "Timestamp", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L763-L765
train
bxcodec/faker
datetime.go
Century
func (d DateTime) Century(v reflect.Value) (interface{}, error) { return d.century(), nil }
go
func (d DateTime) Century(v reflect.Value) (interface{}, error) { return d.century(), nil }
[ "func", "(", "d", "DateTime", ")", "Century", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "century", "(", ")", ",", "nil", "\n", "}" ]
// Century returns a random century
[ "Century", "returns", "a", "random", "century" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L778-L780
train
bxcodec/faker
datetime.go
TimeZone
func (d DateTime) TimeZone(v reflect.Value) (interface{}, error) { return d.timezone(), nil }
go
func (d DateTime) TimeZone(v reflect.Value) (interface{}, error) { return d.timezone(), nil }
[ "func", "(", "d", "DateTime", ")", "TimeZone", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "timezone", "(", ")", ",", "nil", "\n", "}" ]
// TimeZone returns a random timezone
[ "TimeZone", "returns", "a", "random", "timezone" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L793-L795
train
bxcodec/faker
datetime.go
TimePeriod
func (d DateTime) TimePeriod(v reflect.Value) (interface{}, error) { return d.period(), nil }
go
func (d DateTime) TimePeriod(v reflect.Value) (interface{}, error) { return d.period(), nil }
[ "func", "(", "d", "DateTime", ")", "TimePeriod", "(", "v", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "d", ".", "period", "(", ")", ",", "nil", "\n", "}" ]
// TimePeriod formats DateTime using example TimePeriod const
[ "TimePeriod", "formats", "DateTime", "using", "example", "TimePeriod", "const" ]
342a24f52a104690266c76399570254ec476d42c
https://github.com/bxcodec/faker/blob/342a24f52a104690266c76399570254ec476d42c/datetime.go#L808-L810
train
bugsnag/bugsnag-go
bugsnag.go
Configure
func Configure(config Configuration) { Config.update(&config) updateSessionConfig() // Only do once in case the user overrides the default panichandler, and // configures multiple times. panicHandlerOnce.Do(Config.PanicHandler) }
go
func Configure(config Configuration) { Config.update(&config) updateSessionConfig() // Only do once in case the user overrides the default panichandler, and // configures multiple times. panicHandlerOnce.Do(Config.PanicHandler) }
[ "func", "Configure", "(", "config", "Configuration", ")", "{", "Config", ".", "update", "(", "&", "config", ")", "\n", "updateSessionConfig", "(", ")", "\n", "// Only do once in case the user overrides the default panichandler, and", "// configures multiple times.", "panicH...
// Configure Bugsnag. The only required setting is the APIKey, which can be // obtained by clicking on "Settings" in your Bugsnag dashboard. This function // is also responsible for installing the global panic handler, so it should be // called as early as possible in your initialization process.
[ "Configure", "Bugsnag", ".", "The", "only", "required", "setting", "is", "the", "APIKey", "which", "can", "be", "obtained", "by", "clicking", "on", "Settings", "in", "your", "Bugsnag", "dashboard", ".", "This", "function", "is", "also", "responsible", "for", ...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/bugsnag.go#L45-L51
train
bugsnag/bugsnag-go
bugsnag.go
StartSession
func StartSession(ctx context.Context) context.Context { sessionTrackerOnce.Do(startSessionTracking) return sessionTracker.StartSession(ctx) }
go
func StartSession(ctx context.Context) context.Context { sessionTrackerOnce.Do(startSessionTracking) return sessionTracker.StartSession(ctx) }
[ "func", "StartSession", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "sessionTrackerOnce", ".", "Do", "(", "startSessionTracking", ")", "\n", "return", "sessionTracker", ".", "StartSession", "(", "ctx", ")", "\n", "}" ]
// StartSession creates new context from the context.Context instance with // Bugsnag session data attached. Will start the session tracker if not already // started
[ "StartSession", "creates", "new", "context", "from", "the", "context", ".", "Context", "instance", "with", "Bugsnag", "session", "data", "attached", ".", "Will", "start", "the", "session", "tracker", "if", "not", "already", "started" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/bugsnag.go#L56-L59
train
bugsnag/bugsnag-go
bugsnag.go
Handler
func Handler(h http.Handler, rawData ...interface{}) http.Handler { notifier := New(rawData...) if h == nil { h = http.DefaultServeMux } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { request := r // Record a session if auto notify session is enabled ctx := r.Context() if Config....
go
func Handler(h http.Handler, rawData ...interface{}) http.Handler { notifier := New(rawData...) if h == nil { h = http.DefaultServeMux } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { request := r // Record a session if auto notify session is enabled ctx := r.Context() if Config....
[ "func", "Handler", "(", "h", "http", ".", "Handler", ",", "rawData", "...", "interface", "{", "}", ")", "http", ".", "Handler", "{", "notifier", ":=", "New", "(", "rawData", "...", ")", "\n", "if", "h", "==", "nil", "{", "h", "=", "http", ".", "D...
// Handler creates an http Handler that notifies Bugsnag any panics that // happen. It then repanics so that the default http Server panic handler can // handle the panic too. The rawData is used to send extra information along // with any panics that are handled this way.
[ "Handler", "creates", "an", "http", "Handler", "that", "notifies", "Bugsnag", "any", "panics", "that", "happen", ".", "It", "then", "repanics", "so", "that", "the", "default", "http", "Server", "panic", "handler", "can", "handle", "the", "panic", "too", ".",...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/bugsnag.go#L162-L181
train
bugsnag/bugsnag-go
sessions/tracker.go
NewSessionTracker
func NewSessionTracker(config *SessionTrackingConfiguration) SessionTracker { publisher := publisher{ config: config, client: &http.Client{Transport: config.Transport}, } st := sessionTracker{ sessionChannel: make(chan *Session, 1), sessions: []*Session{}, config: config, publisher: &p...
go
func NewSessionTracker(config *SessionTrackingConfiguration) SessionTracker { publisher := publisher{ config: config, client: &http.Client{Transport: config.Transport}, } st := sessionTracker{ sessionChannel: make(chan *Session, 1), sessions: []*Session{}, config: config, publisher: &p...
[ "func", "NewSessionTracker", "(", "config", "*", "SessionTrackingConfiguration", ")", "SessionTracker", "{", "publisher", ":=", "publisher", "{", "config", ":", "config", ",", "client", ":", "&", "http", ".", "Client", "{", "Transport", ":", "config", ".", "Tr...
// NewSessionTracker creates a new SessionTracker based on the provided config,
[ "NewSessionTracker", "creates", "a", "new", "SessionTracker", "based", "on", "the", "provided", "config" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/sessions/tracker.go#L38-L51
train
bugsnag/bugsnag-go
sessions/tracker.go
IncrementEventCountAndGetSession
func IncrementEventCountAndGetSession(ctx context.Context, unhandled bool) *Session { if s := ctx.Value(contextSessionKey); s != nil { if session, ok := s.(*Session); ok && !session.StartedAt.IsZero() { // It is not just getting back a default value ec := session.EventCounts if unhandled { ec.Unhandled+...
go
func IncrementEventCountAndGetSession(ctx context.Context, unhandled bool) *Session { if s := ctx.Value(contextSessionKey); s != nil { if session, ok := s.(*Session); ok && !session.StartedAt.IsZero() { // It is not just getting back a default value ec := session.EventCounts if unhandled { ec.Unhandled+...
[ "func", "IncrementEventCountAndGetSession", "(", "ctx", "context", ".", "Context", ",", "unhandled", "bool", ")", "*", "Session", "{", "if", "s", ":=", "ctx", ".", "Value", "(", "contextSessionKey", ")", ";", "s", "!=", "nil", "{", "if", "session", ",", ...
// IncrementEventCountAndGetSession extracts a Bugsnag session from the given // context and increments the event count of unhandled or handled events and // returns the session
[ "IncrementEventCountAndGetSession", "extracts", "a", "Bugsnag", "session", "from", "the", "given", "context", "and", "increments", "the", "event", "count", "of", "unhandled", "or", "handled", "events", "and", "returns", "the", "session" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/sessions/tracker.go#L56-L70
train
bugsnag/bugsnag-go
sessions/payload.go
makeSessionPayload
func makeSessionPayload(sessions []*Session, config *SessionTrackingConfiguration) *sessionPayload { releaseStage := config.ReleaseStage if releaseStage == "" { releaseStage = "production" } hostname := config.Hostname if hostname == "" { hostname = device.GetHostname() } return &sessionPayload{ Notifier:...
go
func makeSessionPayload(sessions []*Session, config *SessionTrackingConfiguration) *sessionPayload { releaseStage := config.ReleaseStage if releaseStage == "" { releaseStage = "production" } hostname := config.Hostname if hostname == "" { hostname = device.GetHostname() } return &sessionPayload{ Notifier:...
[ "func", "makeSessionPayload", "(", "sessions", "[", "]", "*", "Session", ",", "config", "*", "SessionTrackingConfiguration", ")", "*", "sessionPayload", "{", "releaseStage", ":=", "config", ".", "ReleaseStage", "\n", "if", "releaseStage", "==", "\"", "\"", "{", ...
// makeSessionPayload creates a sessionPayload based off of the given sessions and config
[ "makeSessionPayload", "creates", "a", "sessionPayload", "based", "off", "of", "the", "given", "sessions", "and", "config" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/sessions/payload.go#L45-L78
train
bugsnag/bugsnag-go
headers/prefixed.go
PrefixedHeaders
func PrefixedHeaders(apiKey, payloadVersion string) map[string]string { return map[string]string{ "Content-Type": "application/json", "Bugsnag-Api-Key": apiKey, "Bugsnag-Payload-Version": payloadVersion, "Bugsnag-Sent-At": time.Now().UTC().Format(time.RFC3339), } }
go
func PrefixedHeaders(apiKey, payloadVersion string) map[string]string { return map[string]string{ "Content-Type": "application/json", "Bugsnag-Api-Key": apiKey, "Bugsnag-Payload-Version": payloadVersion, "Bugsnag-Sent-At": time.Now().UTC().Format(time.RFC3339), } }
[ "func", "PrefixedHeaders", "(", "apiKey", ",", "payloadVersion", "string", ")", "map", "[", "string", "]", "string", "{", "return", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "\"", "\"", ",", "\"", "\"", ":", "apiKey", ",", "\"", "\""...
//PrefixedHeaders returns a map of Content-Type and the 'Bugsnag-' headers for //API key, payload version, and the time at which the request is being sent.
[ "PrefixedHeaders", "returns", "a", "map", "of", "Content", "-", "Type", "and", "the", "Bugsnag", "-", "headers", "for", "API", "key", "payload", "version", "and", "the", "time", "at", "which", "the", "request", "is", "being", "sent", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/headers/prefixed.go#L7-L14
train
bugsnag/bugsnag-go
middleware.go
OnBeforeNotify
func (stack *middlewareStack) OnBeforeNotify(middleware beforeFunc) { stack.before = append(stack.before, middleware) }
go
func (stack *middlewareStack) OnBeforeNotify(middleware beforeFunc) { stack.before = append(stack.before, middleware) }
[ "func", "(", "stack", "*", "middlewareStack", ")", "OnBeforeNotify", "(", "middleware", "beforeFunc", ")", "{", "stack", ".", "before", "=", "append", "(", "stack", ".", "before", ",", "middleware", ")", "\n", "}" ]
// AddMiddleware adds a new middleware to the outside of the existing ones, // when the middlewareStack is Run it will be run before all middleware that // have been added before.
[ "AddMiddleware", "adds", "a", "new", "middleware", "to", "the", "outside", "of", "the", "existing", "ones", "when", "the", "middlewareStack", "is", "Run", "it", "will", "be", "run", "before", "all", "middleware", "that", "have", "been", "added", "before", "....
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/middleware.go#L21-L23
train
bugsnag/bugsnag-go
middleware.go
Run
func (stack *middlewareStack) Run(event *Event, config *Configuration, next func() error) error { // run all the before filters in reverse order for i := range stack.before { before := stack.before[len(stack.before)-i-1] severity := event.Severity err := stack.runBeforeFilter(before, event, config) if err !=...
go
func (stack *middlewareStack) Run(event *Event, config *Configuration, next func() error) error { // run all the before filters in reverse order for i := range stack.before { before := stack.before[len(stack.before)-i-1] severity := event.Severity err := stack.runBeforeFilter(before, event, config) if err !=...
[ "func", "(", "stack", "*", "middlewareStack", ")", "Run", "(", "event", "*", "Event", ",", "config", "*", "Configuration", ",", "next", "func", "(", ")", "error", ")", "error", "{", "// run all the before filters in reverse order", "for", "i", ":=", "range", ...
// Run causes all the middleware to be run. If they all permit it the next callback // will be called with all the middleware on the stack.
[ "Run", "causes", "all", "the", "middleware", "to", "be", "run", ".", "If", "they", "all", "permit", "it", "the", "next", "callback", "will", "be", "called", "with", "all", "the", "middleware", "on", "the", "stack", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/middleware.go#L27-L43
train
bugsnag/bugsnag-go
middleware.go
httpRequestMiddleware
func httpRequestMiddleware(event *Event, config *Configuration) error { for _, datum := range event.RawData { if request, ok := datum.(*http.Request); ok { event.MetaData.Update(MetaData{ "request": { "params": request.URL.Query(), }, }) } } return nil }
go
func httpRequestMiddleware(event *Event, config *Configuration) error { for _, datum := range event.RawData { if request, ok := datum.(*http.Request); ok { event.MetaData.Update(MetaData{ "request": { "params": request.URL.Query(), }, }) } } return nil }
[ "func", "httpRequestMiddleware", "(", "event", "*", "Event", ",", "config", "*", "Configuration", ")", "error", "{", "for", "_", ",", "datum", ":=", "range", "event", ".", "RawData", "{", "if", "request", ",", "ok", ":=", "datum", ".", "(", "*", "http"...
// httpRequestMiddleware is added OnBeforeNotify by default. It takes information // from an http.Request passed in as rawData, and adds it to the Event. You can // use this as a template for writing your own Middleware.
[ "httpRequestMiddleware", "is", "added", "OnBeforeNotify", "by", "default", ".", "It", "takes", "information", "from", "an", "http", ".", "Request", "passed", "in", "as", "rawData", "and", "adds", "it", "to", "the", "Event", ".", "You", "can", "use", "this", ...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/middleware.go#L63-L74
train
bugsnag/bugsnag-go
negroni/bugsnagnegroni.go
AutoNotify
func AutoNotify(rawData ...interface{}) negroni.Handler { updateGlobalConfig(rawData...) state := bugsnag.HandledState{ SeverityReason: bugsnag.SeverityReasonUnhandledMiddlewareError, OriginalSeverity: bugsnag.SeverityError, Unhandled: true, Framework: FrameworkName, } rawData = append(rawDa...
go
func AutoNotify(rawData ...interface{}) negroni.Handler { updateGlobalConfig(rawData...) state := bugsnag.HandledState{ SeverityReason: bugsnag.SeverityReasonUnhandledMiddlewareError, OriginalSeverity: bugsnag.SeverityError, Unhandled: true, Framework: FrameworkName, } rawData = append(rawDa...
[ "func", "AutoNotify", "(", "rawData", "...", "interface", "{", "}", ")", "negroni", ".", "Handler", "{", "updateGlobalConfig", "(", "rawData", "...", ")", "\n", "state", ":=", "bugsnag", ".", "HandledState", "{", "SeverityReason", ":", "bugsnag", ".", "Sever...
// AutoNotify sends any panics to bugsnag, and then re-raises them.
[ "AutoNotify", "sends", "any", "panics", "to", "bugsnag", "and", "then", "re", "-", "raises", "them", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/negroni/bugsnagnegroni.go#L18-L28
train
bugsnag/bugsnag-go
sessions/publisher.go
publish
func (p *publisher) publish(sessions []*Session) error { if p.config.Endpoint == "" { // Session tracking is disabled, likely because the notify endpoint was // changed without changing the sessions endpoint // We've already logged a warning in this case, so no need to spam the // log every minute return nil...
go
func (p *publisher) publish(sessions []*Session) error { if p.config.Endpoint == "" { // Session tracking is disabled, likely because the notify endpoint was // changed without changing the sessions endpoint // We've already logged a warning in this case, so no need to spam the // log every minute return nil...
[ "func", "(", "p", "*", "publisher", ")", "publish", "(", "sessions", "[", "]", "*", "Session", ")", "error", "{", "if", "p", ".", "config", ".", "Endpoint", "==", "\"", "\"", "{", "// Session tracking is disabled, likely because the notify endpoint was", "// cha...
// publish builds a payload from the given sessions and publishes them to the // session server. Returns any errors that happened as part of publishing.
[ "publish", "builds", "a", "payload", "from", "the", "given", "sessions", "and", "publishes", "them", "to", "the", "session", "server", ".", "Returns", "any", "errors", "that", "happened", "as", "part", "of", "publishing", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/sessions/publisher.go#L31-L78
train
bugsnag/bugsnag-go
sessions/startup.go
SendStartupSession
func SendStartupSession(config *SessionTrackingConfiguration) context.Context { ctx := context.Background() session := newSession() if !config.IsAutoCaptureSessions() || isApplicationProcess() { return ctx } publisher := &publisher{ config: config, client: &http.Client{Transport: config.Transport}, } go pu...
go
func SendStartupSession(config *SessionTrackingConfiguration) context.Context { ctx := context.Background() session := newSession() if !config.IsAutoCaptureSessions() || isApplicationProcess() { return ctx } publisher := &publisher{ config: config, client: &http.Client{Transport: config.Transport}, } go pu...
[ "func", "SendStartupSession", "(", "config", "*", "SessionTrackingConfiguration", ")", "context", ".", "Context", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "session", ":=", "newSession", "(", ")", "\n", "if", "!", "config", ".", "IsAuto...
// SendStartupSession is called by Bugsnag on startup, which will send a // session to Bugsnag and return a context to represent the session of the main // goroutine. This is the session associated with any fatal panics that are // caught by panicwrap.
[ "SendStartupSession", "is", "called", "by", "Bugsnag", "on", "startup", "which", "will", "send", "a", "session", "to", "Bugsnag", "and", "return", "a", "context", "to", "represent", "the", "session", "of", "the", "main", "goroutine", ".", "This", "is", "the"...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/sessions/startup.go#L15-L27
train
bugsnag/bugsnag-go
metadata.go
Update
func (meta MetaData) Update(other MetaData) { for name, tab := range other { if meta[name] == nil { meta[name] = make(map[string]interface{}) } for key, value := range tab { meta[name][key] = value } } }
go
func (meta MetaData) Update(other MetaData) { for name, tab := range other { if meta[name] == nil { meta[name] = make(map[string]interface{}) } for key, value := range tab { meta[name][key] = value } } }
[ "func", "(", "meta", "MetaData", ")", "Update", "(", "other", "MetaData", ")", "{", "for", "name", ",", "tab", ":=", "range", "other", "{", "if", "meta", "[", "name", "]", "==", "nil", "{", "meta", "[", "name", "]", "=", "make", "(", "map", "[", ...
// Update the meta-data with more information. Tabs are merged together such // that unique keys from both sides are preserved, and duplicate keys end up // with the provided values.
[ "Update", "the", "meta", "-", "data", "with", "more", "information", ".", "Tabs", "are", "merged", "together", "such", "that", "unique", "keys", "from", "both", "sides", "are", "preserved", "and", "duplicate", "keys", "end", "up", "with", "the", "provided", ...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/metadata.go#L17-L28
train
bugsnag/bugsnag-go
metadata.go
Add
func (meta MetaData) Add(tab string, key string, value interface{}) { if meta[tab] == nil { meta[tab] = make(map[string]interface{}) } meta[tab][key] = value }
go
func (meta MetaData) Add(tab string, key string, value interface{}) { if meta[tab] == nil { meta[tab] = make(map[string]interface{}) } meta[tab][key] = value }
[ "func", "(", "meta", "MetaData", ")", "Add", "(", "tab", "string", ",", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "meta", "[", "tab", "]", "==", "nil", "{", "meta", "[", "tab", "]", "=", "make", "(", "map", "[", "str...
// Add creates a tab of Bugsnag meta-data. // If the tab doesn't yet exist it will be created. // If the key already exists, it will be overwritten.
[ "Add", "creates", "a", "tab", "of", "Bugsnag", "meta", "-", "data", ".", "If", "the", "tab", "doesn", "t", "yet", "exist", "it", "will", "be", "created", ".", "If", "the", "key", "already", "exists", "it", "will", "be", "overwritten", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/metadata.go#L33-L39
train
bugsnag/bugsnag-go
metadata.go
AddStruct
func (meta MetaData) AddStruct(tab string, obj interface{}) { val := sanitizer{}.Sanitize(obj) content, ok := val.(map[string]interface{}) if ok { meta[tab] = content } else { // Wasn't a struct meta.Add("Extra data", tab, obj) } }
go
func (meta MetaData) AddStruct(tab string, obj interface{}) { val := sanitizer{}.Sanitize(obj) content, ok := val.(map[string]interface{}) if ok { meta[tab] = content } else { // Wasn't a struct meta.Add("Extra data", tab, obj) } }
[ "func", "(", "meta", "MetaData", ")", "AddStruct", "(", "tab", "string", ",", "obj", "interface", "{", "}", ")", "{", "val", ":=", "sanitizer", "{", "}", ".", "Sanitize", "(", "obj", ")", "\n", "content", ",", "ok", ":=", "val", ".", "(", "map", ...
// AddStruct creates a tab of Bugsnag meta-data. // The struct will be converted to an Object using the // reflect library so any private fields will not be exported. // As a safety measure, if you pass a non-struct the value will be // sent to Bugsnag under the "Extra data" tab.
[ "AddStruct", "creates", "a", "tab", "of", "Bugsnag", "meta", "-", "data", ".", "The", "struct", "will", "be", "converted", "to", "an", "Object", "using", "the", "reflect", "library", "so", "any", "private", "fields", "will", "not", "be", "exported", ".", ...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/metadata.go#L46-L56
train
bugsnag/bugsnag-go
metadata.go
sanitize
func (meta MetaData) sanitize(filters []string) interface{} { return sanitizer{ Filters: filters, Seen: make([]interface{}, 0), }.Sanitize(meta) }
go
func (meta MetaData) sanitize(filters []string) interface{} { return sanitizer{ Filters: filters, Seen: make([]interface{}, 0), }.Sanitize(meta) }
[ "func", "(", "meta", "MetaData", ")", "sanitize", "(", "filters", "[", "]", "string", ")", "interface", "{", "}", "{", "return", "sanitizer", "{", "Filters", ":", "filters", ",", "Seen", ":", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ...
// Remove any values from meta-data that have keys matching the filters, // and any that are recursive data-structures
[ "Remove", "any", "values", "from", "meta", "-", "data", "that", "have", "keys", "matching", "the", "filters", "and", "any", "that", "are", "recursive", "data", "-", "structures" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/metadata.go#L60-L66
train
bugsnag/bugsnag-go
features/fixtures/net_http/main.go
recoverWrap
func recoverWrap(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { r := recover() if r != nil { http.Error(w, "", http.StatusInternalServerError) } }() h.ServeHTTP(w, r) }) }
go
func recoverWrap(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { r := recover() if r != nil { http.Error(w, "", http.StatusInternalServerError) } }() h.ServeHTTP(w, r) }) }
[ "func", "recoverWrap", "(", "h", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "defer", "func", "...
// Simple wrapper to send internal server error on panics
[ "Simple", "wrapper", "to", "send", "internal", "server", "error", "on", "panics" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/features/fixtures/net_http/main.go#L31-L41
train
bugsnag/bugsnag-go
request_extractor.go
AttachRequestData
func AttachRequestData(ctx context.Context, r *http.Request) context.Context { return context.WithValue(ctx, requestContextKey, r) }
go
func AttachRequestData(ctx context.Context, r *http.Request) context.Context { return context.WithValue(ctx, requestContextKey, r) }
[ "func", "AttachRequestData", "(", "ctx", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "requestContextKey", ",", "r", ")", "\n", "}" ]
// AttachRequestData returns a child of the given context with the request // object attached for later extraction by the notifier in order to // automatically record request data
[ "AttachRequestData", "returns", "a", "child", "of", "the", "given", "context", "with", "the", "request", "object", "attached", "for", "later", "extraction", "by", "the", "notifier", "in", "order", "to", "automatically", "record", "request", "data" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/request_extractor.go#L16-L18
train
bugsnag/bugsnag-go
request_extractor.go
extractRequestInfo
func extractRequestInfo(ctx context.Context) (*RequestJSON, *http.Request) { if req := getRequestIfPresent(ctx); req != nil { return extractRequestInfoFromReq(req), req } return nil, nil }
go
func extractRequestInfo(ctx context.Context) (*RequestJSON, *http.Request) { if req := getRequestIfPresent(ctx); req != nil { return extractRequestInfoFromReq(req), req } return nil, nil }
[ "func", "extractRequestInfo", "(", "ctx", "context", ".", "Context", ")", "(", "*", "RequestJSON", ",", "*", "http", ".", "Request", ")", "{", "if", "req", ":=", "getRequestIfPresent", "(", "ctx", ")", ";", "req", "!=", "nil", "{", "return", "extractRequ...
// extractRequestInfo looks for the request object that the notifier // automatically attaches to the context when using any of the supported // frameworks or bugsnag.HandlerFunc or bugsnag.Handler, and returns sub-object // supported by the notify API.
[ "extractRequestInfo", "looks", "for", "the", "request", "object", "that", "the", "notifier", "automatically", "attaches", "to", "the", "context", "when", "using", "any", "of", "the", "supported", "frameworks", "or", "bugsnag", ".", "HandlerFunc", "or", "bugsnag", ...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/request_extractor.go#L24-L29
train
bugsnag/bugsnag-go
request_extractor.go
extractRequestInfoFromReq
func extractRequestInfoFromReq(req *http.Request) *RequestJSON { proto := "http://" if req.TLS != nil { proto = "https://" } return &RequestJSON{ ClientIP: req.RemoteAddr, HTTPMethod: req.Method, URL: proto + req.Host + req.RequestURI, Referer: req.Referer(), Headers: parseRequestHeaders(...
go
func extractRequestInfoFromReq(req *http.Request) *RequestJSON { proto := "http://" if req.TLS != nil { proto = "https://" } return &RequestJSON{ ClientIP: req.RemoteAddr, HTTPMethod: req.Method, URL: proto + req.Host + req.RequestURI, Referer: req.Referer(), Headers: parseRequestHeaders(...
[ "func", "extractRequestInfoFromReq", "(", "req", "*", "http", ".", "Request", ")", "*", "RequestJSON", "{", "proto", ":=", "\"", "\"", "\n", "if", "req", ".", "TLS", "!=", "nil", "{", "proto", "=", "\"", "\"", "\n", "}", "\n", "return", "&", "Request...
// extractRequestInfoFromReq extracts the request information the notify API // understands from the given HTTP request. Returns the sub-object supported by // the notify API.
[ "extractRequestInfoFromReq", "extracts", "the", "request", "information", "the", "notify", "API", "understands", "from", "the", "given", "HTTP", "request", ".", "Returns", "the", "sub", "-", "object", "supported", "by", "the", "notify", "API", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/request_extractor.go#L34-L46
train
bugsnag/bugsnag-go
notifier.go
New
func New(rawData ...interface{}) *Notifier { config := Config.clone() for i, datum := range rawData { if c, ok := datum.(Configuration); ok { config.update(&c) rawData[i] = nil } } return &Notifier{ Config: config, RawData: rawData, } }
go
func New(rawData ...interface{}) *Notifier { config := Config.clone() for i, datum := range rawData { if c, ok := datum.(Configuration); ok { config.update(&c) rawData[i] = nil } } return &Notifier{ Config: config, RawData: rawData, } }
[ "func", "New", "(", "rawData", "...", "interface", "{", "}", ")", "*", "Notifier", "{", "config", ":=", "Config", ".", "clone", "(", ")", "\n", "for", "i", ",", "datum", ":=", "range", "rawData", "{", "if", "c", ",", "ok", ":=", "datum", ".", "("...
// New creates a new notifier. // You can pass an instance of bugsnag.Configuration in rawData to change the configuration. // Other values of rawData will be passed to Notify.
[ "New", "creates", "a", "new", "notifier", ".", "You", "can", "pass", "an", "instance", "of", "bugsnag", ".", "Configuration", "in", "rawData", "to", "change", "the", "configuration", ".", "Other", "values", "of", "rawData", "will", "be", "passed", "to", "N...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/notifier.go#L18-L31
train
bugsnag/bugsnag-go
notifier.go
getDefaultSeverity
func (notifier *Notifier) getDefaultSeverity(rawData []interface{}, s severity) severity { allData := append(notifier.RawData, rawData...) for _, datum := range allData { if _, ok := datum.(severity); ok { return datum.(severity) } } for _, datum := range allData { if _, ok := datum.(HandledState); ok { ...
go
func (notifier *Notifier) getDefaultSeverity(rawData []interface{}, s severity) severity { allData := append(notifier.RawData, rawData...) for _, datum := range allData { if _, ok := datum.(severity); ok { return datum.(severity) } } for _, datum := range allData { if _, ok := datum.(HandledState); ok { ...
[ "func", "(", "notifier", "*", "Notifier", ")", "getDefaultSeverity", "(", "rawData", "[", "]", "interface", "{", "}", ",", "s", "severity", ")", "severity", "{", "allData", ":=", "append", "(", "notifier", ".", "RawData", ",", "rawData", "...", ")", "\n"...
// Get defined severity from raw data or a fallback value
[ "Get", "defined", "severity", "from", "raw", "data", "or", "a", "fallback", "value" ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/notifier.go#L125-L140
train
bugsnag/bugsnag-go
sessions/config.go
Update
func (c *SessionTrackingConfiguration) Update(config *SessionTrackingConfiguration) { c.mutex.Lock() defer c.mutex.Unlock() if config.PublishInterval != 0 { c.PublishInterval = config.PublishInterval } if config.APIKey != "" { c.APIKey = config.APIKey } if config.Endpoint != "" { c.Endpoint = config.Endpoi...
go
func (c *SessionTrackingConfiguration) Update(config *SessionTrackingConfiguration) { c.mutex.Lock() defer c.mutex.Unlock() if config.PublishInterval != 0 { c.PublishInterval = config.PublishInterval } if config.APIKey != "" { c.APIKey = config.APIKey } if config.Endpoint != "" { c.Endpoint = config.Endpoi...
[ "func", "(", "c", "*", "SessionTrackingConfiguration", ")", "Update", "(", "config", "*", "SessionTrackingConfiguration", ")", "{", "c", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mutex", ".", "Unlock", "(", ")", "\n", "if", "config",...
// Update modifies the values inside the receiver to match the non-default properties of the given config. // Existing properties will not be cleared when given empty fields.
[ "Update", "modifies", "the", "values", "inside", "the", "receiver", "to", "match", "the", "non", "-", "default", "properties", "of", "the", "given", "config", ".", "Existing", "properties", "will", "not", "be", "cleared", "when", "given", "empty", "fields", ...
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/sessions/config.go#L65-L104
train
bugsnag/bugsnag-go
errors/stackframe.go
NewStackFrame
func NewStackFrame(pc uintptr) (frame StackFrame) { frame = StackFrame{ProgramCounter: pc} if frame.Func() == nil { return } frame.Package, frame.Name = packageAndName(frame.Func()) // pc -1 because the program counters we use are usually return addresses, // and we want to show the line that corresponds to t...
go
func NewStackFrame(pc uintptr) (frame StackFrame) { frame = StackFrame{ProgramCounter: pc} if frame.Func() == nil { return } frame.Package, frame.Name = packageAndName(frame.Func()) // pc -1 because the program counters we use are usually return addresses, // and we want to show the line that corresponds to t...
[ "func", "NewStackFrame", "(", "pc", "uintptr", ")", "(", "frame", "StackFrame", ")", "{", "frame", "=", "StackFrame", "{", "ProgramCounter", ":", "pc", "}", "\n", "if", "frame", ".", "Func", "(", ")", "==", "nil", "{", "return", "\n", "}", "\n", "fra...
// NewStackFrame popoulates a stack frame object from the program counter.
[ "NewStackFrame", "popoulates", "a", "stack", "frame", "object", "from", "the", "program", "counter", "." ]
f13f7c670be1c2f2799481ca164a3e81d36e138f
https://github.com/bugsnag/bugsnag-go/blob/f13f7c670be1c2f2799481ca164a3e81d36e138f/errors/stackframe.go#L22-L35
train
francoispqt/gojay
encode_number_uint.go
EncodeUint64
func (enc *Encoder) EncodeUint64(n uint64) error { if enc.isPooled == 1 { panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder")) } _, _ = enc.encodeUint64(n) _, err := enc.Write() if err != nil { return err } return nil }
go
func (enc *Encoder) EncodeUint64(n uint64) error { if enc.isPooled == 1 { panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder")) } _, _ = enc.encodeUint64(n) _, err := enc.Write() if err != nil { return err } return nil }
[ "func", "(", "enc", "*", "Encoder", ")", "EncodeUint64", "(", "n", "uint64", ")", "error", "{", "if", "enc", ".", "isPooled", "==", "1", "{", "panic", "(", "InvalidUsagePooledEncoderError", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "_", ",", "_", ...
// EncodeUint64 encodes an int64 to JSON
[ "EncodeUint64", "encodes", "an", "int64", "to", "JSON" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L6-L16
train
francoispqt/gojay
encode_number_uint.go
encodeUint64
func (enc *Encoder) encodeUint64(n uint64) ([]byte, error) { enc.buf = strconv.AppendUint(enc.buf, n, 10) return enc.buf, nil }
go
func (enc *Encoder) encodeUint64(n uint64) ([]byte, error) { enc.buf = strconv.AppendUint(enc.buf, n, 10) return enc.buf, nil }
[ "func", "(", "enc", "*", "Encoder", ")", "encodeUint64", "(", "n", "uint64", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "enc", ".", "buf", "=", "strconv", ".", "AppendUint", "(", "enc", ".", "buf", ",", "n", ",", "10", ")", "\n", "retu...
// encodeUint64 encodes an int to JSON
[ "encodeUint64", "encodes", "an", "int", "to", "JSON" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L19-L22
train
francoispqt/gojay
encode_number_uint.go
AddUint64Key
func (enc *Encoder) AddUint64Key(key string, v uint64) { enc.Uint64Key(key, v) }
go
func (enc *Encoder) AddUint64Key(key string, v uint64) { enc.Uint64Key(key, v) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint64Key", "(", "key", "string", ",", "v", "uint64", ")", "{", "enc", ".", "Uint64Key", "(", "key", ",", "v", ")", "\n", "}" ]
// AddUint64Key adds an int to be encoded, must be used inside an object as it will encode a key
[ "AddUint64Key", "adds", "an", "int", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L81-L83
train
francoispqt/gojay
encode_number_uint.go
AddUint64KeyOmitEmpty
func (enc *Encoder) AddUint64KeyOmitEmpty(key string, v uint64) { enc.Uint64KeyOmitEmpty(key, v) }
go
func (enc *Encoder) AddUint64KeyOmitEmpty(key string, v uint64) { enc.Uint64KeyOmitEmpty(key, v) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint64KeyOmitEmpty", "(", "key", "string", ",", "v", "uint64", ")", "{", "enc", ".", "Uint64KeyOmitEmpty", "(", "key", ",", "v", ")", "\n", "}" ]
// AddUint64KeyOmitEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "AddUint64KeyOmitEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L87-L89
train
francoispqt/gojay
encode_number_uint.go
AddUint64KeyNullEmpty
func (enc *Encoder) AddUint64KeyNullEmpty(key string, v uint64) { enc.Uint64KeyNullEmpty(key, v) }
go
func (enc *Encoder) AddUint64KeyNullEmpty(key string, v uint64) { enc.Uint64KeyNullEmpty(key, v) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint64KeyNullEmpty", "(", "key", "string", ",", "v", "uint64", ")", "{", "enc", ".", "Uint64KeyNullEmpty", "(", "key", ",", "v", ")", "\n", "}" ]
// AddUint64KeyNullEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "AddUint64KeyNullEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L93-L95
train
francoispqt/gojay
encode_number_uint.go
Uint64Key
func (enc *Encoder) Uint64Key(key string, v uint64) { if enc.hasKeys { if !enc.keyExists(key) { return } } enc.grow(10 + len(key)) r := enc.getPreviousRune() if r != '{' { enc.writeByte(',') } enc.writeByte('"') enc.writeStringEscape(key) enc.writeBytes(objKey) enc.buf = strconv.AppendUint(enc.buf, v...
go
func (enc *Encoder) Uint64Key(key string, v uint64) { if enc.hasKeys { if !enc.keyExists(key) { return } } enc.grow(10 + len(key)) r := enc.getPreviousRune() if r != '{' { enc.writeByte(',') } enc.writeByte('"') enc.writeStringEscape(key) enc.writeBytes(objKey) enc.buf = strconv.AppendUint(enc.buf, v...
[ "func", "(", "enc", "*", "Encoder", ")", "Uint64Key", "(", "key", "string", ",", "v", "uint64", ")", "{", "if", "enc", ".", "hasKeys", "{", "if", "!", "enc", ".", "keyExists", "(", "key", ")", "{", "return", "\n", "}", "\n", "}", "\n", "enc", "...
// Uint64Key adds an int to be encoded, must be used inside an object as it will encode a key
[ "Uint64Key", "adds", "an", "int", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L98-L113
train
francoispqt/gojay
encode_number_uint.go
AddUint32Key
func (enc *Encoder) AddUint32Key(key string, v uint32) { enc.Uint64Key(key, uint64(v)) }
go
func (enc *Encoder) AddUint32Key(key string, v uint32) { enc.Uint64Key(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint32Key", "(", "key", "string", ",", "v", "uint32", ")", "{", "enc", ".", "Uint64Key", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// AddUint32Key adds an int to be encoded, must be used inside an object as it will encode a key
[ "AddUint32Key", "adds", "an", "int", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L195-L197
train
francoispqt/gojay
encode_number_uint.go
AddUint32KeyOmitEmpty
func (enc *Encoder) AddUint32KeyOmitEmpty(key string, v uint32) { enc.Uint64KeyOmitEmpty(key, uint64(v)) }
go
func (enc *Encoder) AddUint32KeyOmitEmpty(key string, v uint32) { enc.Uint64KeyOmitEmpty(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint32KeyOmitEmpty", "(", "key", "string", ",", "v", "uint32", ")", "{", "enc", ".", "Uint64KeyOmitEmpty", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// AddUint32KeyOmitEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "AddUint32KeyOmitEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L201-L203
train
francoispqt/gojay
encode_number_uint.go
AddUint32KeyNullEmpty
func (enc *Encoder) AddUint32KeyNullEmpty(key string, v uint32) { enc.Uint64KeyNullEmpty(key, uint64(v)) }
go
func (enc *Encoder) AddUint32KeyNullEmpty(key string, v uint32) { enc.Uint64KeyNullEmpty(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint32KeyNullEmpty", "(", "key", "string", ",", "v", "uint32", ")", "{", "enc", ".", "Uint64KeyNullEmpty", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// AddUint32KeyNullEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "AddUint32KeyNullEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L207-L209
train
francoispqt/gojay
encode_number_uint.go
Uint16Key
func (enc *Encoder) Uint16Key(key string, v uint16) { enc.Uint64Key(key, uint64(v)) }
go
func (enc *Encoder) Uint16Key(key string, v uint16) { enc.Uint64Key(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "Uint16Key", "(", "key", "string", ",", "v", "uint16", ")", "{", "enc", ".", "Uint64Key", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// Uint16Key adds an int to be encoded, must be used inside an object as it will encode a key
[ "Uint16Key", "adds", "an", "int", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L280-L282
train
francoispqt/gojay
encode_number_uint.go
Uint16KeyOmitEmpty
func (enc *Encoder) Uint16KeyOmitEmpty(key string, v uint16) { enc.Uint64KeyOmitEmpty(key, uint64(v)) }
go
func (enc *Encoder) Uint16KeyOmitEmpty(key string, v uint16) { enc.Uint64KeyOmitEmpty(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "Uint16KeyOmitEmpty", "(", "key", "string", ",", "v", "uint16", ")", "{", "enc", ".", "Uint64KeyOmitEmpty", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// Uint16KeyOmitEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "Uint16KeyOmitEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L286-L288
train
francoispqt/gojay
encode_number_uint.go
Uint16KeyNullEmpty
func (enc *Encoder) Uint16KeyNullEmpty(key string, v uint16) { enc.Uint64KeyNullEmpty(key, uint64(v)) }
go
func (enc *Encoder) Uint16KeyNullEmpty(key string, v uint16) { enc.Uint64KeyNullEmpty(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "Uint16KeyNullEmpty", "(", "key", "string", ",", "v", "uint16", ")", "{", "enc", ".", "Uint64KeyNullEmpty", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// Uint16KeyNullEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "Uint16KeyNullEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L292-L294
train
francoispqt/gojay
encode_number_uint.go
AddUint8Key
func (enc *Encoder) AddUint8Key(key string, v uint8) { enc.Uint64Key(key, uint64(v)) }
go
func (enc *Encoder) AddUint8Key(key string, v uint8) { enc.Uint64Key(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint8Key", "(", "key", "string", ",", "v", "uint8", ")", "{", "enc", ".", "Uint64Key", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// AddUint8Key adds an int to be encoded, must be used inside an object as it will encode a key
[ "AddUint8Key", "adds", "an", "int", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L331-L333
train
francoispqt/gojay
encode_number_uint.go
AddUint8KeyOmitEmpty
func (enc *Encoder) AddUint8KeyOmitEmpty(key string, v uint8) { enc.Uint64KeyOmitEmpty(key, uint64(v)) }
go
func (enc *Encoder) AddUint8KeyOmitEmpty(key string, v uint8) { enc.Uint64KeyOmitEmpty(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint8KeyOmitEmpty", "(", "key", "string", ",", "v", "uint8", ")", "{", "enc", ".", "Uint64KeyOmitEmpty", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// AddUint8KeyOmitEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "AddUint8KeyOmitEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L337-L339
train
francoispqt/gojay
encode_number_uint.go
AddUint8KeyNullEmpty
func (enc *Encoder) AddUint8KeyNullEmpty(key string, v uint8) { enc.Uint64KeyNullEmpty(key, uint64(v)) }
go
func (enc *Encoder) AddUint8KeyNullEmpty(key string, v uint8) { enc.Uint64KeyNullEmpty(key, uint64(v)) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddUint8KeyNullEmpty", "(", "key", "string", ",", "v", "uint8", ")", "{", "enc", ".", "Uint64KeyNullEmpty", "(", "key", ",", "uint64", "(", "v", ")", ")", "\n", "}" ]
// AddUint8KeyNullEmpty adds an int to be encoded and skips it if its value is 0. // Must be used inside an object as it will encode a key.
[ "AddUint8KeyNullEmpty", "adds", "an", "int", "to", "be", "encoded", "and", "skips", "it", "if", "its", "value", "is", "0", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key", "." ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_uint.go#L343-L345
train
francoispqt/gojay
gojay/codegen/generator.go
Type
func (g *Generator) Type(typeName string) *toolbox.TypeInfo { return g.fileInfo.Type(typeName) }
go
func (g *Generator) Type(typeName string) *toolbox.TypeInfo { return g.fileInfo.Type(typeName) }
[ "func", "(", "g", "*", "Generator", ")", "Type", "(", "typeName", "string", ")", "*", "toolbox", ".", "TypeInfo", "{", "return", "g", ".", "fileInfo", ".", "Type", "(", "typeName", ")", "\n", "}" ]
// Returns the type from the the fileInfo
[ "Returns", "the", "type", "from", "the", "the", "fileInfo" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/gojay/codegen/generator.go#L34-L36
train
francoispqt/gojay
gojay/codegen/generator.go
init
func (g *Generator) init() { g.filedInit = []string{} g.imports = map[string]bool{} g.pooledObjects = map[string]string{} g.structTypes = map[string]string{} g.sliceTypes = map[string]string{} g.poolInit = map[string]string{} g.addImport(gojayPackage) // if we want pools, add the sync package right away if g.o...
go
func (g *Generator) init() { g.filedInit = []string{} g.imports = map[string]bool{} g.pooledObjects = map[string]string{} g.structTypes = map[string]string{} g.sliceTypes = map[string]string{} g.poolInit = map[string]string{} g.addImport(gojayPackage) // if we want pools, add the sync package right away if g.o...
[ "func", "(", "g", "*", "Generator", ")", "init", "(", ")", "{", "g", ".", "filedInit", "=", "[", "]", "string", "{", "}", "\n", "g", ".", "imports", "=", "map", "[", "string", "]", "bool", "{", "}", "\n", "g", ".", "pooledObjects", "=", "map", ...
// we initiate the variables containing the code to be generated
[ "we", "initiate", "the", "variables", "containing", "the", "code", "to", "be", "generated" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/gojay/codegen/generator.go#L44-L56
train
francoispqt/gojay
gojay/codegen/generator.go
NewGenerator
func NewGenerator(options *Options) *Generator { var g = &Generator{} // first we validate the flags if err := options.Validate(); err != nil { panic(err) } g.options = options // we initiate the values on the generator g.init() return g }
go
func NewGenerator(options *Options) *Generator { var g = &Generator{} // first we validate the flags if err := options.Validate(); err != nil { panic(err) } g.options = options // we initiate the values on the generator g.init() return g }
[ "func", "NewGenerator", "(", "options", "*", "Options", ")", "*", "Generator", "{", "var", "g", "=", "&", "Generator", "{", "}", "\n", "// first we validate the flags", "if", "err", ":=", "options", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{"...
// NewGenerator creates a new generator with the given options
[ "NewGenerator", "creates", "a", "new", "generator", "with", "the", "given", "options" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/gojay/codegen/generator.go#L59-L69
train
francoispqt/gojay
gojay/codegen/generator.go
Generate
func (g *Generator) Generate() error { // first we read the code from which we should find the types if err := g.readPackageCode(g.options.Source); err != nil { return err } // then we generate code for the types given for _, rootType := range g.options.Types { if err := g.generateStructCode(rootType); err !=...
go
func (g *Generator) Generate() error { // first we read the code from which we should find the types if err := g.readPackageCode(g.options.Source); err != nil { return err } // then we generate code for the types given for _, rootType := range g.options.Types { if err := g.generateStructCode(rootType); err !=...
[ "func", "(", "g", "*", "Generator", ")", "Generate", "(", ")", "error", "{", "// first we read the code from which we should find the types", "if", "err", ":=", "g", ".", "readPackageCode", "(", "g", ".", "options", ".", "Source", ")", ";", "err", "!=", "nil",...
// Generate generates the gojay implementation code
[ "Generate", "generates", "the", "gojay", "implementation", "code" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/gojay/codegen/generator.go#L72-L88
train
francoispqt/gojay
encode_string.go
EncodeString
func (enc *Encoder) EncodeString(s string) error { if enc.isPooled == 1 { panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder")) } _, _ = enc.encodeString(s) _, err := enc.Write() if err != nil { enc.err = err return err } return nil }
go
func (enc *Encoder) EncodeString(s string) error { if enc.isPooled == 1 { panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder")) } _, _ = enc.encodeString(s) _, err := enc.Write() if err != nil { enc.err = err return err } return nil }
[ "func", "(", "enc", "*", "Encoder", ")", "EncodeString", "(", "s", "string", ")", "error", "{", "if", "enc", ".", "isPooled", "==", "1", "{", "panic", "(", "InvalidUsagePooledEncoderError", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "_", ",", "_", ...
// EncodeString encodes a string to
[ "EncodeString", "encodes", "a", "string", "to" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L4-L15
train
francoispqt/gojay
encode_string.go
encodeString
func (enc *Encoder) encodeString(v string) ([]byte, error) { enc.writeByte('"') enc.writeStringEscape(v) enc.writeByte('"') return enc.buf, nil }
go
func (enc *Encoder) encodeString(v string) ([]byte, error) { enc.writeByte('"') enc.writeStringEscape(v) enc.writeByte('"') return enc.buf, nil }
[ "func", "(", "enc", "*", "Encoder", ")", "encodeString", "(", "v", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "enc", ".", "writeByte", "(", "'\"'", ")", "\n", "enc", ".", "writeStringEscape", "(", "v", ")", "\n", "enc", ".", "w...
// encodeString encodes a string to
[ "encodeString", "encodes", "a", "string", "to" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L18-L23
train
francoispqt/gojay
encode_string.go
AppendString
func (enc *Encoder) AppendString(v string) { enc.grow(len(v) + 2) enc.writeByte('"') enc.writeStringEscape(v) enc.writeByte('"') }
go
func (enc *Encoder) AppendString(v string) { enc.grow(len(v) + 2) enc.writeByte('"') enc.writeStringEscape(v) enc.writeByte('"') }
[ "func", "(", "enc", "*", "Encoder", ")", "AppendString", "(", "v", "string", ")", "{", "enc", ".", "grow", "(", "len", "(", "v", ")", "+", "2", ")", "\n", "enc", ".", "writeByte", "(", "'\"'", ")", "\n", "enc", ".", "writeStringEscape", "(", "v",...
// AppendString appends a string to the buffer
[ "AppendString", "appends", "a", "string", "to", "the", "buffer" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L26-L31
train
francoispqt/gojay
encode_string.go
AddStringKey
func (enc *Encoder) AddStringKey(key, v string) { enc.StringKey(key, v) }
go
func (enc *Encoder) AddStringKey(key, v string) { enc.StringKey(key, v) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddStringKey", "(", "key", ",", "v", "string", ")", "{", "enc", ".", "StringKey", "(", "key", ",", "v", ")", "\n", "}" ]
// AddStringKey adds a string to be encoded, must be used inside an object as it will encode a key
[ "AddStringKey", "adds", "a", "string", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L51-L53
train
francoispqt/gojay
encode_string.go
AddStringKeyOmitEmpty
func (enc *Encoder) AddStringKeyOmitEmpty(key, v string) { enc.StringKeyOmitEmpty(key, v) }
go
func (enc *Encoder) AddStringKeyOmitEmpty(key, v string) { enc.StringKeyOmitEmpty(key, v) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddStringKeyOmitEmpty", "(", "key", ",", "v", "string", ")", "{", "enc", ".", "StringKeyOmitEmpty", "(", "key", ",", "v", ")", "\n", "}" ]
// AddStringKeyOmitEmpty adds a string to be encoded or skips it if it is zero value. // Must be used inside an object as it will encode a key
[ "AddStringKeyOmitEmpty", "adds", "a", "string", "to", "be", "encoded", "or", "skips", "it", "if", "it", "is", "zero", "value", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L57-L59
train
francoispqt/gojay
encode_string.go
AddStringKeyNullEmpty
func (enc *Encoder) AddStringKeyNullEmpty(key, v string) { enc.StringKeyNullEmpty(key, v) }
go
func (enc *Encoder) AddStringKeyNullEmpty(key, v string) { enc.StringKeyNullEmpty(key, v) }
[ "func", "(", "enc", "*", "Encoder", ")", "AddStringKeyNullEmpty", "(", "key", ",", "v", "string", ")", "{", "enc", ".", "StringKeyNullEmpty", "(", "key", ",", "v", ")", "\n", "}" ]
// AddStringKeyNullEmpty adds a string to be encoded or skips it if it is zero value. // Must be used inside an object as it will encode a key
[ "AddStringKeyNullEmpty", "adds", "a", "string", "to", "be", "encoded", "or", "skips", "it", "if", "it", "is", "zero", "value", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L63-L65
train
francoispqt/gojay
encode_string.go
StringKey
func (enc *Encoder) StringKey(key, v string) { if enc.hasKeys { if !enc.keyExists(key) { return } } enc.grow(len(key) + len(v) + 5) r := enc.getPreviousRune() if r != '{' { enc.writeTwoBytes(',', '"') } else { enc.writeByte('"') } enc.writeStringEscape(key) enc.writeBytes(objKeyStr) enc.writeString...
go
func (enc *Encoder) StringKey(key, v string) { if enc.hasKeys { if !enc.keyExists(key) { return } } enc.grow(len(key) + len(v) + 5) r := enc.getPreviousRune() if r != '{' { enc.writeTwoBytes(',', '"') } else { enc.writeByte('"') } enc.writeStringEscape(key) enc.writeBytes(objKeyStr) enc.writeString...
[ "func", "(", "enc", "*", "Encoder", ")", "StringKey", "(", "key", ",", "v", "string", ")", "{", "if", "enc", ".", "hasKeys", "{", "if", "!", "enc", ".", "keyExists", "(", "key", ")", "{", "return", "\n", "}", "\n", "}", "\n", "enc", ".", "grow"...
// StringKey adds a string to be encoded, must be used inside an object as it will encode a key
[ "StringKey", "adds", "a", "string", "to", "be", "encoded", "must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L119-L136
train
francoispqt/gojay
encode_string.go
StringKeyNullEmpty
func (enc *Encoder) StringKeyNullEmpty(key, v string) { if enc.hasKeys { if !enc.keyExists(key) { return } } enc.grow(len(key) + len(v) + 5) r := enc.getPreviousRune() if r != '{' { enc.writeTwoBytes(',', '"') } else { enc.writeByte('"') } enc.writeStringEscape(key) enc.writeBytes(objKey) if v == "...
go
func (enc *Encoder) StringKeyNullEmpty(key, v string) { if enc.hasKeys { if !enc.keyExists(key) { return } } enc.grow(len(key) + len(v) + 5) r := enc.getPreviousRune() if r != '{' { enc.writeTwoBytes(',', '"') } else { enc.writeByte('"') } enc.writeStringEscape(key) enc.writeBytes(objKey) if v == "...
[ "func", "(", "enc", "*", "Encoder", ")", "StringKeyNullEmpty", "(", "key", ",", "v", "string", ")", "{", "if", "enc", ".", "hasKeys", "{", "if", "!", "enc", ".", "keyExists", "(", "key", ")", "{", "return", "\n", "}", "\n", "}", "\n", "enc", ".",...
// StringKeyNullEmpty adds a string to be encoded or skips it if it is zero value. // Must be used inside an object as it will encode a key
[ "StringKeyNullEmpty", "adds", "a", "string", "to", "be", "encoded", "or", "skips", "it", "if", "it", "is", "zero", "value", ".", "Must", "be", "used", "inside", "an", "object", "as", "it", "will", "encode", "a", "key" ]
e46791d21b5e950e35a725e34cbee72354cc7d10
https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_string.go#L164-L186
train