id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
21,100
go-playground/validator
baked_in.go
isLongitude
func isLongitude(fl FieldLevel) bool { field := fl.Field() var v string switch field.Kind() { case reflect.String: v = field.String() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: v = strconv.FormatInt(field.Int(), 10) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.U...
go
func isLongitude(fl FieldLevel) bool { field := fl.Field() var v string switch field.Kind() { case reflect.String: v = field.String() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: v = strconv.FormatInt(field.Int(), 10) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.U...
[ "func", "isLongitude", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "var", "v", "string", "\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "String", ":", "v", "=", "fiel...
// IsLongitude is the validation function for validating if the field's value is a valid longitude coordinate.
[ "IsLongitude", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "longitude", "coordinate", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L314-L334
21,101
go-playground/validator
baked_in.go
isDataURI
func isDataURI(fl FieldLevel) bool { uri := strings.SplitN(fl.Field().String(), ",", 2) if len(uri) != 2 { return false } if !dataURIRegex.MatchString(uri[0]) { return false } return base64Regex.MatchString(uri[1]) }
go
func isDataURI(fl FieldLevel) bool { uri := strings.SplitN(fl.Field().String(), ",", 2) if len(uri) != 2 { return false } if !dataURIRegex.MatchString(uri[0]) { return false } return base64Regex.MatchString(uri[1]) }
[ "func", "isDataURI", "(", "fl", "FieldLevel", ")", "bool", "{", "uri", ":=", "strings", ".", "SplitN", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "\"", "\"", ",", "2", ")", "\n\n", "if", "len", "(", "uri", ")", "!=", "2", ...
// IsDataURI is the validation function for validating if the field's value is a valid data URI.
[ "IsDataURI", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "data", "URI", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L360-L373
21,102
go-playground/validator
baked_in.go
hasMultiByteCharacter
func hasMultiByteCharacter(fl FieldLevel) bool { field := fl.Field() if field.Len() == 0 { return true } return multibyteRegex.MatchString(field.String()) }
go
func hasMultiByteCharacter(fl FieldLevel) bool { field := fl.Field() if field.Len() == 0 { return true } return multibyteRegex.MatchString(field.String()) }
[ "func", "hasMultiByteCharacter", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "if", "field", ".", "Len", "(", ")", "==", "0", "{", "return", "true", "\n", "}", "\n\n", "return", "multibyteRegex", ".", ...
// HasMultiByteCharacter is the validation function for validating if the field's value has a multi byte character.
[ "HasMultiByteCharacter", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "has", "a", "multi", "byte", "character", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L376-L385
21,103
go-playground/validator
baked_in.go
isISBN13
func isISBN13(fl FieldLevel) bool { s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4) if !iSBN13Regex.MatchString(s) { return false } var checksum int32 var i int32 factor := []int32{1, 3} for i = 0; i < 12; i++ { checksum += factor[i%2] * int32(s[i]-'0') } return (in...
go
func isISBN13(fl FieldLevel) bool { s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4) if !iSBN13Regex.MatchString(s) { return false } var checksum int32 var i int32 factor := []int32{1, 3} for i = 0; i < 12; i++ { checksum += factor[i%2] * int32(s[i]-'0') } return (in...
[ "func", "isISBN13", "(", "fl", "FieldLevel", ")", "bool", "{", "s", ":=", "strings", ".", "Replace", "(", "strings", ".", "Replace", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "\"", "\"", ",", "\"", "\"", ",", "4", ")", ",...
// IsISBN13 is the validation function for validating if the field's value is a valid v13 ISBN.
[ "IsISBN13", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "v13", "ISBN", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L443-L461
21,104
go-playground/validator
baked_in.go
isISBN10
func isISBN10(fl FieldLevel) bool { s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3) if !iSBN10Regex.MatchString(s) { return false } var checksum int32 var i int32 for i = 0; i < 9; i++ { checksum += (i + 1) * int32(s[i]-'0') } if s[9] == 'X' { checksum += 10 * 10 }...
go
func isISBN10(fl FieldLevel) bool { s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3) if !iSBN10Regex.MatchString(s) { return false } var checksum int32 var i int32 for i = 0; i < 9; i++ { checksum += (i + 1) * int32(s[i]-'0') } if s[9] == 'X' { checksum += 10 * 10 }...
[ "func", "isISBN10", "(", "fl", "FieldLevel", ")", "bool", "{", "s", ":=", "strings", ".", "Replace", "(", "strings", ".", "Replace", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "\"", "\"", ",", "\"", "\"", ",", "3", ")", ",...
// IsISBN10 is the validation function for validating if the field's value is a valid v10 ISBN.
[ "IsISBN10", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "v10", "ISBN", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L464-L486
21,105
go-playground/validator
baked_in.go
isEthereumAddress
func isEthereumAddress(fl FieldLevel) bool { address := fl.Field().String() if !ethAddressRegex.MatchString(address) { return false } if ethaddressRegexUpper.MatchString(address) || ethAddressRegexLower.MatchString(address) { return true } // checksum validation is blocked by https://github.com/golang/cryp...
go
func isEthereumAddress(fl FieldLevel) bool { address := fl.Field().String() if !ethAddressRegex.MatchString(address) { return false } if ethaddressRegexUpper.MatchString(address) || ethAddressRegexLower.MatchString(address) { return true } // checksum validation is blocked by https://github.com/golang/cryp...
[ "func", "isEthereumAddress", "(", "fl", "FieldLevel", ")", "bool", "{", "address", ":=", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", "\n\n", "if", "!", "ethAddressRegex", ".", "MatchString", "(", "address", ")", "{", "return", "false", "\n", ...
// IsEthereumAddress is the validation function for validating if the field's value is a valid ethereum address based currently only on the format
[ "IsEthereumAddress", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "ethereum", "address", "based", "currently", "only", "on", "the", "format" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L489-L503
21,106
go-playground/validator
baked_in.go
isBitcoinAddress
func isBitcoinAddress(fl FieldLevel) bool { address := fl.Field().String() if !btcAddressRegex.MatchString(address) { return false } alphabet := []byte("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") decode := [25]byte{} for _, n := range []byte(address) { d := bytes.IndexByte(alphabet, n) ...
go
func isBitcoinAddress(fl FieldLevel) bool { address := fl.Field().String() if !btcAddressRegex.MatchString(address) { return false } alphabet := []byte("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") decode := [25]byte{} for _, n := range []byte(address) { d := bytes.IndexByte(alphabet, n) ...
[ "func", "isBitcoinAddress", "(", "fl", "FieldLevel", ")", "bool", "{", "address", ":=", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", "\n\n", "if", "!", "btcAddressRegex", ".", "MatchString", "(", "address", ")", "{", "return", "false", "\n", ...
// IsBitcoinAddress is the validation function for validating if the field's value is a valid btc address
[ "IsBitcoinAddress", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "btc", "address" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L506-L540
21,107
go-playground/validator
baked_in.go
isBitcoinBech32Address
func isBitcoinBech32Address(fl FieldLevel) bool { address := fl.Field().String() if !btcLowerAddressRegexBech32.MatchString(address) && !btcUpperAddressRegexBech32.MatchString(address) { return false } am := len(address) % 8 if am == 0 || am == 3 || am == 5 { return false } address = strings.ToLower(addr...
go
func isBitcoinBech32Address(fl FieldLevel) bool { address := fl.Field().String() if !btcLowerAddressRegexBech32.MatchString(address) && !btcUpperAddressRegexBech32.MatchString(address) { return false } am := len(address) % 8 if am == 0 || am == 3 || am == 5 { return false } address = strings.ToLower(addr...
[ "func", "isBitcoinBech32Address", "(", "fl", "FieldLevel", ")", "bool", "{", "address", ":=", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", "\n\n", "if", "!", "btcLowerAddressRegexBech32", ".", "MatchString", "(", "address", ")", "&&", "!", "btcUp...
// IsBitcoinBech32Address is the validation function for validating if the field's value is a valid bech32 btc address
[ "IsBitcoinBech32Address", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "valid", "bech32", "btc", "address" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L543-L620
21,108
go-playground/validator
baked_in.go
containsRune
func containsRune(fl FieldLevel) bool { r, _ := utf8.DecodeRuneInString(fl.Param()) return strings.ContainsRune(fl.Field().String(), r) }
go
func containsRune(fl FieldLevel) bool { r, _ := utf8.DecodeRuneInString(fl.Param()) return strings.ContainsRune(fl.Field().String(), r) }
[ "func", "containsRune", "(", "fl", "FieldLevel", ")", "bool", "{", "r", ",", "_", ":=", "utf8", ".", "DecodeRuneInString", "(", "fl", ".", "Param", "(", ")", ")", "\n\n", "return", "strings", ".", "ContainsRune", "(", "fl", ".", "Field", "(", ")", "....
// ContainsRune is the validation function for validating that the field's value contains the rune specified within the param.
[ "ContainsRune", "is", "the", "validation", "function", "for", "validating", "that", "the", "field", "s", "value", "contains", "the", "rune", "specified", "within", "the", "param", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L638-L643
21,109
go-playground/validator
baked_in.go
containsAny
func containsAny(fl FieldLevel) bool { return strings.ContainsAny(fl.Field().String(), fl.Param()) }
go
func containsAny(fl FieldLevel) bool { return strings.ContainsAny(fl.Field().String(), fl.Param()) }
[ "func", "containsAny", "(", "fl", "FieldLevel", ")", "bool", "{", "return", "strings", ".", "ContainsAny", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "fl", ".", "Param", "(", ")", ")", "\n", "}" ]
// ContainsAny is the validation function for validating that the field's value contains any of the characters specified within the param.
[ "ContainsAny", "is", "the", "validation", "function", "for", "validating", "that", "the", "field", "s", "value", "contains", "any", "of", "the", "characters", "specified", "within", "the", "param", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L646-L648
21,110
go-playground/validator
baked_in.go
contains
func contains(fl FieldLevel) bool { return strings.Contains(fl.Field().String(), fl.Param()) }
go
func contains(fl FieldLevel) bool { return strings.Contains(fl.Field().String(), fl.Param()) }
[ "func", "contains", "(", "fl", "FieldLevel", ")", "bool", "{", "return", "strings", ".", "Contains", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "fl", ".", "Param", "(", ")", ")", "\n", "}" ]
// Contains is the validation function for validating that the field's value contains the text specified within the param.
[ "Contains", "is", "the", "validation", "function", "for", "validating", "that", "the", "field", "s", "value", "contains", "the", "text", "specified", "within", "the", "param", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L651-L653
21,111
go-playground/validator
baked_in.go
startsWith
func startsWith(fl FieldLevel) bool { return strings.HasPrefix(fl.Field().String(), fl.Param()) }
go
func startsWith(fl FieldLevel) bool { return strings.HasPrefix(fl.Field().String(), fl.Param()) }
[ "func", "startsWith", "(", "fl", "FieldLevel", ")", "bool", "{", "return", "strings", ".", "HasPrefix", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "fl", ".", "Param", "(", ")", ")", "\n", "}" ]
// StartsWith is the validation function for validating that the field's value starts with the text specified within the param.
[ "StartsWith", "is", "the", "validation", "function", "for", "validating", "that", "the", "field", "s", "value", "starts", "with", "the", "text", "specified", "within", "the", "param", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L656-L658
21,112
go-playground/validator
baked_in.go
endsWith
func endsWith(fl FieldLevel) bool { return strings.HasSuffix(fl.Field().String(), fl.Param()) }
go
func endsWith(fl FieldLevel) bool { return strings.HasSuffix(fl.Field().String(), fl.Param()) }
[ "func", "endsWith", "(", "fl", "FieldLevel", ")", "bool", "{", "return", "strings", ".", "HasSuffix", "(", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ",", "fl", ".", "Param", "(", ")", ")", "\n", "}" ]
// EndsWith is the validation function for validating that the field's value ends with the text specified within the param.
[ "EndsWith", "is", "the", "validation", "function", "for", "validating", "that", "the", "field", "s", "value", "ends", "with", "the", "text", "specified", "within", "the", "param", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L661-L663
21,113
go-playground/validator
baked_in.go
fieldContains
func fieldContains(fl FieldLevel) bool { field := fl.Field() currentField, _, ok := fl.GetStructFieldOK() if !ok { return false } return strings.Contains(field.String(), currentField.String()) }
go
func fieldContains(fl FieldLevel) bool { field := fl.Field() currentField, _, ok := fl.GetStructFieldOK() if !ok { return false } return strings.Contains(field.String(), currentField.String()) }
[ "func", "fieldContains", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "currentField", ",", "_", ",", "ok", ":=", "fl", ".", "GetStructFieldOK", "(", ")", "\n\n", "if", "!", "ok", "{", "return", "fals...
// FieldContains is the validation function for validating if the current field's value contains the field specified by the param's value.
[ "FieldContains", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "contains", "the", "field", "specified", "by", "the", "param", "s", "value", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L666-L676
21,114
go-playground/validator
baked_in.go
fieldExcludes
func fieldExcludes(fl FieldLevel) bool { field := fl.Field() currentField, _, ok := fl.GetStructFieldOK() if !ok { return true } return !strings.Contains(field.String(), currentField.String()) }
go
func fieldExcludes(fl FieldLevel) bool { field := fl.Field() currentField, _, ok := fl.GetStructFieldOK() if !ok { return true } return !strings.Contains(field.String(), currentField.String()) }
[ "func", "fieldExcludes", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "currentField", ",", "_", ",", "ok", ":=", "fl", ".", "GetStructFieldOK", "(", ")", "\n", "if", "!", "ok", "{", "return", "true",...
// FieldExcludes is the validation function for validating if the current field's value excludes the field specified by the param's value.
[ "FieldExcludes", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "excludes", "the", "field", "specified", "by", "the", "param", "s", "value", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L679-L688
21,115
go-playground/validator
baked_in.go
isEqCrossStructField
func isEqCrossStructField(fl FieldLevel) bool { field := fl.Field() kind := field.Kind() topField, topKind, ok := fl.GetStructFieldOK() if !ok || topKind != kind { return false } switch kind { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return topField.Int() == field.Int(...
go
func isEqCrossStructField(fl FieldLevel) bool { field := fl.Field() kind := field.Kind() topField, topKind, ok := fl.GetStructFieldOK() if !ok || topKind != kind { return false } switch kind { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return topField.Int() == field.Int(...
[ "func", "isEqCrossStructField", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n", "kind", ":=", "field", ".", "Kind", "(", ")", "\n\n", "topField", ",", "topKind", ",", "ok", ":=", "fl", ".", "GetStructFieldO...
// IsEqCrossStructField is the validation function for validating that the current field's value is equal to the field, within a separate struct, specified by the param's value.
[ "IsEqCrossStructField", "is", "the", "validation", "function", "for", "validating", "that", "the", "current", "field", "s", "value", "is", "equal", "to", "the", "field", "within", "a", "separate", "struct", "specified", "by", "the", "param", "s", "value", "." ...
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L981-L1025
21,116
go-playground/validator
baked_in.go
isEq
func isEq(fl FieldLevel) bool { field := fl.Field() param := fl.Param() switch field.Kind() { case reflect.String: return field.String() == param case reflect.Slice, reflect.Map, reflect.Array: p := asInt(param) return int64(field.Len()) == p case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int3...
go
func isEq(fl FieldLevel) bool { field := fl.Field() param := fl.Param() switch field.Kind() { case reflect.String: return field.String() == param case reflect.Slice, reflect.Map, reflect.Array: p := asInt(param) return int64(field.Len()) == p case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int3...
[ "func", "isEq", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n", "param", ":=", "fl", ".", "Param", "(", ")", "\n\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "String", ":...
// IsEq is the validation function for validating if the current field's value is equal to the param's value.
[ "IsEq", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "equal", "to", "the", "param", "s", "value", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1076-L1108
21,117
go-playground/validator
baked_in.go
isURI
func isURI(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.String: s := field.String() // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195 // emulate browser and ...
go
func isURI(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.String: s := field.String() // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195 // emulate browser and ...
[ "func", "isURI", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "String", ":", "s", ":=", "field", ".", "String", "(", ")", "\...
// IsURI is the validation function for validating if the current field's value is a valid URI.
[ "IsURI", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "a", "valid", "URI", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1121-L1147
21,118
go-playground/validator
baked_in.go
isUrnRFC2141
func isUrnRFC2141(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.String: str := field.String() _, match := urn.Parse([]byte(str)) return match } panic(fmt.Sprintf("Bad field type %T", field.Interface())) }
go
func isUrnRFC2141(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.String: str := field.String() _, match := urn.Parse([]byte(str)) return match } panic(fmt.Sprintf("Bad field type %T", field.Interface())) }
[ "func", "isUrnRFC2141", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "String", ":", "str", ":=", "field", ".", "String", "(", ...
// isUrnRFC2141 is the validation function for validating if the current field's value is a valid URN as per RFC 2141.
[ "isUrnRFC2141", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "a", "valid", "URN", "as", "per", "RFC", "2141", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1184-L1199
21,119
go-playground/validator
baked_in.go
isFile
func isFile(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.String: fileInfo, err := os.Stat(field.String()) if err != nil { return false } return !fileInfo.IsDir() } panic(fmt.Sprintf("Bad field type %T", field.Interface())) }
go
func isFile(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.String: fileInfo, err := os.Stat(field.String()) if err != nil { return false } return !fileInfo.IsDir() } panic(fmt.Sprintf("Bad field type %T", field.Interface())) }
[ "func", "isFile", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "String", ":", "fileInfo", ",", "err", ":=", "os", ".", "Stat",...
// IsFile is the validation function for validating if the current field's value is a valid file path.
[ "IsFile", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "a", "valid", "file", "path", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1202-L1216
21,120
go-playground/validator
baked_in.go
isNumber
func isNumber(fl FieldLevel) bool { switch fl.Field().Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64: return true default: return numberRegex.Match...
go
func isNumber(fl FieldLevel) bool { switch fl.Field().Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64: return true default: return numberRegex.Match...
[ "func", "isNumber", "(", "fl", "FieldLevel", ")", "bool", "{", "switch", "fl", ".", "Field", "(", ")", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Int", ",", "reflect", ".", "Int8", ",", "reflect", ".", "Int16", ",", "reflect", ".", "Int32...
// IsNumber is the validation function for validating if the current field's value is a valid number.
[ "IsNumber", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "a", "valid", "number", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1254-L1261
21,121
go-playground/validator
baked_in.go
hasValue
func hasValue(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func: return !field.IsNil() default: if fl.(*validate).fldIsPointer && field.Interface() != nil { return true } return field.IsValid() &...
go
func hasValue(fl FieldLevel) bool { field := fl.Field() switch field.Kind() { case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func: return !field.IsNil() default: if fl.(*validate).fldIsPointer && field.Interface() != nil { return true } return field.IsValid() &...
[ "func", "hasValue", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Slice", ",", "reflect", ".", "Map", ",", "reflect", ".", "Pt...
// HasValue is the validation function for validating if the current field's value is not the default static value.
[ "HasValue", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "not", "the", "default", "static", "value", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1299-L1314
21,122
go-playground/validator
baked_in.go
isLte
func isLte(fl FieldLevel) bool { field := fl.Field() param := fl.Param() switch field.Kind() { case reflect.String: p := asInt(param) return int64(utf8.RuneCountInString(field.String())) <= p case reflect.Slice, reflect.Map, reflect.Array: p := asInt(param) return int64(field.Len()) <= p case refle...
go
func isLte(fl FieldLevel) bool { field := fl.Field() param := fl.Param() switch field.Kind() { case reflect.String: p := asInt(param) return int64(utf8.RuneCountInString(field.String())) <= p case reflect.Slice, reflect.Map, reflect.Array: p := asInt(param) return int64(field.Len()) <= p case refle...
[ "func", "isLte", "(", "fl", "FieldLevel", ")", "bool", "{", "field", ":=", "fl", ".", "Field", "(", ")", "\n", "param", ":=", "fl", ".", "Param", "(", ")", "\n\n", "switch", "field", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "String", "...
// IsLte is the validation function for validating if the current field's value is less than or equal to the param's value.
[ "IsLte", "is", "the", "validation", "function", "for", "validating", "if", "the", "current", "field", "s", "value", "is", "less", "than", "or", "equal", "to", "the", "param", "s", "value", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1637-L1681
21,123
go-playground/validator
baked_in.go
isTCP4AddrResolvable
func isTCP4AddrResolvable(fl FieldLevel) bool { if !isIP4Addr(fl) { return false } _, err := net.ResolveTCPAddr("tcp4", fl.Field().String()) return err == nil }
go
func isTCP4AddrResolvable(fl FieldLevel) bool { if !isIP4Addr(fl) { return false } _, err := net.ResolveTCPAddr("tcp4", fl.Field().String()) return err == nil }
[ "func", "isTCP4AddrResolvable", "(", "fl", "FieldLevel", ")", "bool", "{", "if", "!", "isIP4Addr", "(", "fl", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(", "\"", "\"", ",", "fl", ".", "Field...
// IsTCP4AddrResolvable is the validation function for validating if the field's value is a resolvable tcp4 address.
[ "IsTCP4AddrResolvable", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "resolvable", "tcp4", "address", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1733-L1741
21,124
go-playground/validator
baked_in.go
isUDPAddrResolvable
func isUDPAddrResolvable(fl FieldLevel) bool { if !isIP4Addr(fl) && !isIP6Addr(fl) { return false } _, err := net.ResolveUDPAddr("udp", fl.Field().String()) return err == nil }
go
func isUDPAddrResolvable(fl FieldLevel) bool { if !isIP4Addr(fl) && !isIP6Addr(fl) { return false } _, err := net.ResolveUDPAddr("udp", fl.Field().String()) return err == nil }
[ "func", "isUDPAddrResolvable", "(", "fl", "FieldLevel", ")", "bool", "{", "if", "!", "isIP4Addr", "(", "fl", ")", "&&", "!", "isIP6Addr", "(", "fl", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",", "err", ":=", "net", ".", "ResolveUDPAddr", ...
// IsUDPAddrResolvable is the validation function for validating if the field's value is a resolvable udp address.
[ "IsUDPAddrResolvable", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "resolvable", "udp", "address", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1792-L1801
21,125
go-playground/validator
baked_in.go
isIP4AddrResolvable
func isIP4AddrResolvable(fl FieldLevel) bool { if !isIPv4(fl) { return false } _, err := net.ResolveIPAddr("ip4", fl.Field().String()) return err == nil }
go
func isIP4AddrResolvable(fl FieldLevel) bool { if !isIPv4(fl) { return false } _, err := net.ResolveIPAddr("ip4", fl.Field().String()) return err == nil }
[ "func", "isIP4AddrResolvable", "(", "fl", "FieldLevel", ")", "bool", "{", "if", "!", "isIPv4", "(", "fl", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",", "err", ":=", "net", ".", "ResolveIPAddr", "(", "\"", "\"", ",", "fl", ".", "Field", ...
// IsIP4AddrResolvable is the validation function for validating if the field's value is a resolvable ip4 address.
[ "IsIP4AddrResolvable", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "resolvable", "ip4", "address", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1804-L1813
21,126
go-playground/validator
baked_in.go
isIP6AddrResolvable
func isIP6AddrResolvable(fl FieldLevel) bool { if !isIPv6(fl) { return false } _, err := net.ResolveIPAddr("ip6", fl.Field().String()) return err == nil }
go
func isIP6AddrResolvable(fl FieldLevel) bool { if !isIPv6(fl) { return false } _, err := net.ResolveIPAddr("ip6", fl.Field().String()) return err == nil }
[ "func", "isIP6AddrResolvable", "(", "fl", "FieldLevel", ")", "bool", "{", "if", "!", "isIPv6", "(", "fl", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",", "err", ":=", "net", ".", "ResolveIPAddr", "(", "\"", "\"", ",", "fl", ".", "Field", ...
// IsIP6AddrResolvable is the validation function for validating if the field's value is a resolvable ip6 address.
[ "IsIP6AddrResolvable", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "resolvable", "ip6", "address", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1816-L1825
21,127
go-playground/validator
baked_in.go
isIPAddrResolvable
func isIPAddrResolvable(fl FieldLevel) bool { if !isIP(fl) { return false } _, err := net.ResolveIPAddr("ip", fl.Field().String()) return err == nil }
go
func isIPAddrResolvable(fl FieldLevel) bool { if !isIP(fl) { return false } _, err := net.ResolveIPAddr("ip", fl.Field().String()) return err == nil }
[ "func", "isIPAddrResolvable", "(", "fl", "FieldLevel", ")", "bool", "{", "if", "!", "isIP", "(", "fl", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",", "err", ":=", "net", ".", "ResolveIPAddr", "(", "\"", "\"", ",", "fl", ".", "Field", "("...
// IsIPAddrResolvable is the validation function for validating if the field's value is a resolvable ip address.
[ "IsIPAddrResolvable", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "resolvable", "ip", "address", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1828-L1837
21,128
go-playground/validator
baked_in.go
isUnixAddrResolvable
func isUnixAddrResolvable(fl FieldLevel) bool { _, err := net.ResolveUnixAddr("unix", fl.Field().String()) return err == nil }
go
func isUnixAddrResolvable(fl FieldLevel) bool { _, err := net.ResolveUnixAddr("unix", fl.Field().String()) return err == nil }
[ "func", "isUnixAddrResolvable", "(", "fl", "FieldLevel", ")", "bool", "{", "_", ",", "err", ":=", "net", ".", "ResolveUnixAddr", "(", "\"", "\"", ",", "fl", ".", "Field", "(", ")", ".", "String", "(", ")", ")", "\n\n", "return", "err", "==", "nil", ...
// IsUnixAddrResolvable is the validation function for validating if the field's value is a resolvable unix address.
[ "IsUnixAddrResolvable", "is", "the", "validation", "function", "for", "validating", "if", "the", "field", "s", "value", "is", "a", "resolvable", "unix", "address", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/baked_in.go#L1840-L1845
21,129
go-playground/validator
util.go
extractTypeInternal
func (v *validate) extractTypeInternal(current reflect.Value, nullable bool) (reflect.Value, reflect.Kind, bool) { BEGIN: switch current.Kind() { case reflect.Ptr: nullable = true if current.IsNil() { return current, reflect.Ptr, nullable } current = current.Elem() goto BEGIN case reflect.Interface...
go
func (v *validate) extractTypeInternal(current reflect.Value, nullable bool) (reflect.Value, reflect.Kind, bool) { BEGIN: switch current.Kind() { case reflect.Ptr: nullable = true if current.IsNil() { return current, reflect.Ptr, nullable } current = current.Elem() goto BEGIN case reflect.Interface...
[ "func", "(", "v", "*", "validate", ")", "extractTypeInternal", "(", "current", "reflect", ".", "Value", ",", "nullable", "bool", ")", "(", "reflect", ".", "Value", ",", "reflect", ".", "Kind", ",", "bool", ")", "{", "BEGIN", ":", "switch", "current", "...
// extractTypeInternal gets the actual underlying type of field value. // It will dive into pointers, customTypes and return you the // underlying value and it's kind.
[ "extractTypeInternal", "gets", "the", "actual", "underlying", "type", "of", "field", "value", ".", "It", "will", "dive", "into", "pointers", "customTypes", "and", "return", "you", "the", "underlying", "value", "and", "it", "s", "kind", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/util.go#L12-L53
21,130
go-playground/validator
util.go
asInt
func asInt(param string) int64 { i, err := strconv.ParseInt(param, 0, 64) panicIf(err) return i }
go
func asInt(param string) int64 { i, err := strconv.ParseInt(param, 0, 64) panicIf(err) return i }
[ "func", "asInt", "(", "param", "string", ")", "int64", "{", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "param", ",", "0", ",", "64", ")", "\n", "panicIf", "(", "err", ")", "\n\n", "return", "i", "\n", "}" ]
// asInt returns the parameter as a int64 // or panics if it can't convert
[ "asInt", "returns", "the", "parameter", "as", "a", "int64", "or", "panics", "if", "it", "can", "t", "convert" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/util.go#L225-L231
21,131
go-playground/validator
util.go
asUint
func asUint(param string) uint64 { i, err := strconv.ParseUint(param, 0, 64) panicIf(err) return i }
go
func asUint(param string) uint64 { i, err := strconv.ParseUint(param, 0, 64) panicIf(err) return i }
[ "func", "asUint", "(", "param", "string", ")", "uint64", "{", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "param", ",", "0", ",", "64", ")", "\n", "panicIf", "(", "err", ")", "\n\n", "return", "i", "\n", "}" ]
// asUint returns the parameter as a uint64 // or panics if it can't convert
[ "asUint", "returns", "the", "parameter", "as", "a", "uint64", "or", "panics", "if", "it", "can", "t", "convert" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/util.go#L235-L241
21,132
go-playground/validator
util.go
asFloat
func asFloat(param string) float64 { i, err := strconv.ParseFloat(param, 64) panicIf(err) return i }
go
func asFloat(param string) float64 { i, err := strconv.ParseFloat(param, 64) panicIf(err) return i }
[ "func", "asFloat", "(", "param", "string", ")", "float64", "{", "i", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "param", ",", "64", ")", "\n", "panicIf", "(", "err", ")", "\n\n", "return", "i", "\n", "}" ]
// asFloat returns the parameter as a float64 // or panics if it can't convert
[ "asFloat", "returns", "the", "parameter", "as", "a", "float64", "or", "panics", "if", "it", "can", "t", "convert" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/util.go#L245-L251
21,133
go-playground/validator
validator_instance.go
New
func New() *Validate { tc := new(tagCache) tc.m.Store(make(map[string]*cTag)) sc := new(structCache) sc.m.Store(make(map[reflect.Type]*cStruct)) v := &Validate{ tagName: defaultTagName, aliases: make(map[string]string, len(bakedInAliases)), validations: make(map[string]FuncCtx, len(bakedInValidato...
go
func New() *Validate { tc := new(tagCache) tc.m.Store(make(map[string]*cTag)) sc := new(structCache) sc.m.Store(make(map[reflect.Type]*cStruct)) v := &Validate{ tagName: defaultTagName, aliases: make(map[string]string, len(bakedInAliases)), validations: make(map[string]FuncCtx, len(bakedInValidato...
[ "func", "New", "(", ")", "*", "Validate", "{", "tc", ":=", "new", "(", "tagCache", ")", "\n", "tc", ".", "m", ".", "Store", "(", "make", "(", "map", "[", "string", "]", "*", "cTag", ")", ")", "\n\n", "sc", ":=", "new", "(", "structCache", ")", ...
// New returns a new instance of 'validate' with sane defaults.
[ "New", "returns", "a", "new", "instance", "of", "validate", "with", "sane", "defaults", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/validator_instance.go#L75-L115
21,134
go-playground/validator
validator_instance.go
RegisterValidationCtx
func (v *Validate) RegisterValidationCtx(tag string, fn FuncCtx) error { return v.registerValidation(tag, fn, false) }
go
func (v *Validate) RegisterValidationCtx(tag string, fn FuncCtx) error { return v.registerValidation(tag, fn, false) }
[ "func", "(", "v", "*", "Validate", ")", "RegisterValidationCtx", "(", "tag", "string", ",", "fn", "FuncCtx", ")", "error", "{", "return", "v", ".", "registerValidation", "(", "tag", ",", "fn", ",", "false", ")", "\n", "}" ]
// RegisterValidationCtx does the same as RegisterValidation on accepts a FuncCtx validation // allowing context.Context validation support.
[ "RegisterValidationCtx", "does", "the", "same", "as", "RegisterValidation", "on", "accepts", "a", "FuncCtx", "validation", "allowing", "context", ".", "Context", "validation", "support", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/validator_instance.go#L149-L151
21,135
go-playground/validator
validator_instance.go
RegisterTranslation
func (v *Validate) RegisterTranslation(tag string, trans ut.Translator, registerFn RegisterTranslationsFunc, translationFn TranslationFunc) (err error) { if v.transTagFunc == nil { v.transTagFunc = make(map[ut.Translator]map[string]TranslationFunc) } if err = registerFn(trans); err != nil { return } m, ok :...
go
func (v *Validate) RegisterTranslation(tag string, trans ut.Translator, registerFn RegisterTranslationsFunc, translationFn TranslationFunc) (err error) { if v.transTagFunc == nil { v.transTagFunc = make(map[ut.Translator]map[string]TranslationFunc) } if err = registerFn(trans); err != nil { return } m, ok :...
[ "func", "(", "v", "*", "Validate", ")", "RegisterTranslation", "(", "tag", "string", ",", "trans", "ut", ".", "Translator", ",", "registerFn", "RegisterTranslationsFunc", ",", "translationFn", "TranslationFunc", ")", "(", "err", "error", ")", "{", "if", "v", ...
// RegisterTranslation registers translations against the provided tag.
[ "RegisterTranslation", "registers", "translations", "against", "the", "provided", "tag", "." ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/validator_instance.go#L236-L255
21,136
go-playground/validator
validator.go
validateStruct
func (v *validate) validateStruct(ctx context.Context, parent reflect.Value, current reflect.Value, typ reflect.Type, ns []byte, structNs []byte, ct *cTag) { cs, ok := v.v.structCache.Get(typ) if !ok { cs = v.v.extractStructCache(current, typ.Name()) } if len(ns) == 0 && len(cs.name) != 0 { ns = append(ns, c...
go
func (v *validate) validateStruct(ctx context.Context, parent reflect.Value, current reflect.Value, typ reflect.Type, ns []byte, structNs []byte, ct *cTag) { cs, ok := v.v.structCache.Get(typ) if !ok { cs = v.v.extractStructCache(current, typ.Name()) } if len(ns) == 0 && len(cs.name) != 0 { ns = append(ns, c...
[ "func", "(", "v", "*", "validate", ")", "validateStruct", "(", "ctx", "context", ".", "Context", ",", "parent", "reflect", ".", "Value", ",", "current", "reflect", ".", "Value", ",", "typ", "reflect", ".", "Type", ",", "ns", "[", "]", "byte", ",", "s...
// parent and current will be the same the first run of validateStruct
[ "parent", "and", "current", "will", "be", "the", "same", "the", "first", "run", "of", "validateStruct" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/validator.go#L33-L93
21,137
go-playground/validator
field_level.go
GetStructFieldOK
func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) { return v.getStructFieldOKInternal(v.slflParent, v.ct.param) }
go
func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) { return v.getStructFieldOKInternal(v.slflParent, v.ct.param) }
[ "func", "(", "v", "*", "validate", ")", "GetStructFieldOK", "(", ")", "(", "reflect", ".", "Value", ",", "reflect", ".", "Kind", ",", "bool", ")", "{", "return", "v", ".", "getStructFieldOKInternal", "(", "v", ".", "slflParent", ",", "v", ".", "ct", ...
// GetStructFieldOK returns Param returns param for validation against current field
[ "GetStructFieldOK", "returns", "Param", "returns", "param", "for", "validation", "against", "current", "field" ]
e25e66164b537d7b3161dfede38466880534e783
https://github.com/go-playground/validator/blob/e25e66164b537d7b3161dfede38466880534e783/field_level.go#L67-L69
21,138
muesli/beehive
api/resources/actions/actions.go
Register
func (r *ActionResource) Register(container *restful.Container, config smolder.APIConfig, context smolder.APIContextFactory) { r.Name = "ActionResource" r.TypeName = "action" r.Endpoint = "actions" r.Doc = "Manage actions" r.Config = config r.Context = context r.Init(container, r) }
go
func (r *ActionResource) Register(container *restful.Container, config smolder.APIConfig, context smolder.APIContextFactory) { r.Name = "ActionResource" r.TypeName = "action" r.Endpoint = "actions" r.Doc = "Manage actions" r.Config = config r.Context = context r.Init(container, r) }
[ "func", "(", "r", "*", "ActionResource", ")", "Register", "(", "container", "*", "restful", ".", "Container", ",", "config", "smolder", ".", "APIConfig", ",", "context", "smolder", ".", "APIContextFactory", ")", "{", "r", ".", "Name", "=", "\"", "\"", "\...
// Register this resource with the container to setup all the routes
[ "Register", "this", "resource", "with", "the", "container", "to", "setup", "all", "the", "routes" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions.go#L40-L50
21,139
muesli/beehive
api/resources/bees/bees.go
Validate
func (r *BeeResource) Validate(context smolder.APIContext, data interface{}, request *restful.Request) error { // ps := data.(*BeePostStruct) // FIXME return nil }
go
func (r *BeeResource) Validate(context smolder.APIContext, data interface{}, request *restful.Request) error { // ps := data.(*BeePostStruct) // FIXME return nil }
[ "func", "(", "r", "*", "BeeResource", ")", "Validate", "(", "context", "smolder", ".", "APIContext", ",", "data", "interface", "{", "}", ",", "request", "*", "restful", ".", "Request", ")", "error", "{", "//\tps := data.(*BeePostStruct)", "// FIXME", "return",...
// Validate checks an incoming request for data errors
[ "Validate", "checks", "an", "incoming", "request", "for", "data", "errors" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees.go#L65-L69
21,140
muesli/beehive
bees/bees.go
RegisterBee
func RegisterBee(bee BeeInterface) { log.Println("Worker bee ready:", bee.Name(), "-", bee.Description()) bees[bee.Name()] = &bee }
go
func RegisterBee(bee BeeInterface) { log.Println("Worker bee ready:", bee.Name(), "-", bee.Description()) bees[bee.Name()] = &bee }
[ "func", "RegisterBee", "(", "bee", "BeeInterface", ")", "{", "log", ".", "Println", "(", "\"", "\"", ",", "bee", ".", "Name", "(", ")", ",", "\"", "\"", ",", "bee", ".", "Description", "(", ")", ")", "\n\n", "bees", "[", "bee", ".", "Name", "(", ...
// RegisterBee gets called by Bees to register themselves.
[ "RegisterBee", "gets", "called", "by", "Bees", "to", "register", "themselves", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L99-L103
21,141
muesli/beehive
bees/bees.go
GetBee
func GetBee(identifier string) *BeeInterface { bee, ok := bees[identifier] if ok { return bee } return nil }
go
func GetBee(identifier string) *BeeInterface { bee, ok := bees[identifier] if ok { return bee } return nil }
[ "func", "GetBee", "(", "identifier", "string", ")", "*", "BeeInterface", "{", "bee", ",", "ok", ":=", "bees", "[", "identifier", "]", "\n", "if", "ok", "{", "return", "bee", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// GetBee returns a bee with a specific name.
[ "GetBee", "returns", "a", "bee", "with", "a", "specific", "name", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L106-L113
21,142
muesli/beehive
bees/bees.go
GetBees
func GetBees() []*BeeInterface { r := []*BeeInterface{} for _, bee := range bees { r = append(r, bee) } return r }
go
func GetBees() []*BeeInterface { r := []*BeeInterface{} for _, bee := range bees { r = append(r, bee) } return r }
[ "func", "GetBees", "(", ")", "[", "]", "*", "BeeInterface", "{", "r", ":=", "[", "]", "*", "BeeInterface", "{", "}", "\n", "for", "_", ",", "bee", ":=", "range", "bees", "{", "r", "=", "append", "(", "r", ",", "bee", ")", "\n", "}", "\n\n", "...
// GetBees returns all known bees.
[ "GetBees", "returns", "all", "known", "bees", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L116-L123
21,143
muesli/beehive
bees/bees.go
startBee
func startBee(bee *BeeInterface, fatals int) { if fatals >= 3 { log.Println("Terminating evil bee", (*bee).Name(), "after", fatals, "failed tries!") (*bee).Stop() return } (*bee).WaitGroup().Add(1) defer (*bee).WaitGroup().Done() defer func(bee *BeeInterface) { if e := recover(); e != nil { log.Printl...
go
func startBee(bee *BeeInterface, fatals int) { if fatals >= 3 { log.Println("Terminating evil bee", (*bee).Name(), "after", fatals, "failed tries!") (*bee).Stop() return } (*bee).WaitGroup().Add(1) defer (*bee).WaitGroup().Done() defer func(bee *BeeInterface) { if e := recover(); e != nil { log.Printl...
[ "func", "startBee", "(", "bee", "*", "BeeInterface", ",", "fatals", "int", ")", "{", "if", "fatals", ">=", "3", "{", "log", ".", "Println", "(", "\"", "\"", ",", "(", "*", "bee", ")", ".", "Name", "(", ")", ",", "\"", "\"", ",", "fatals", ",", ...
// startBee starts a bee and recovers from panics.
[ "startBee", "starts", "a", "bee", "and", "recovers", "from", "panics", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L126-L144
21,144
muesli/beehive
bees/bees.go
NewBeeInstance
func NewBeeInstance(bee BeeConfig) *BeeInterface { factory := GetFactory(bee.Class) if factory == nil { panic("Unknown bee-class in config file: " + bee.Class) } mod := (*factory).New(bee.Name, bee.Description, bee.Options) RegisterBee(mod) return &mod }
go
func NewBeeInstance(bee BeeConfig) *BeeInterface { factory := GetFactory(bee.Class) if factory == nil { panic("Unknown bee-class in config file: " + bee.Class) } mod := (*factory).New(bee.Name, bee.Description, bee.Options) RegisterBee(mod) return &mod }
[ "func", "NewBeeInstance", "(", "bee", "BeeConfig", ")", "*", "BeeInterface", "{", "factory", ":=", "GetFactory", "(", "bee", ".", "Class", ")", "\n", "if", "factory", "==", "nil", "{", "panic", "(", "\"", "\"", "+", "bee", ".", "Class", ")", "\n", "}...
// NewBeeInstance sets up a new Bee with supplied config.
[ "NewBeeInstance", "sets", "up", "a", "new", "Bee", "with", "supplied", "config", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L147-L156
21,145
muesli/beehive
bees/bees.go
StartBee
func StartBee(bee BeeConfig) *BeeInterface { b := NewBeeInstance(bee) (*b).Start() go func(mod *BeeInterface) { startBee(mod, 0) }(b) return b }
go
func StartBee(bee BeeConfig) *BeeInterface { b := NewBeeInstance(bee) (*b).Start() go func(mod *BeeInterface) { startBee(mod, 0) }(b) return b }
[ "func", "StartBee", "(", "bee", "BeeConfig", ")", "*", "BeeInterface", "{", "b", ":=", "NewBeeInstance", "(", "bee", ")", "\n\n", "(", "*", "b", ")", ".", "Start", "(", ")", "\n", "go", "func", "(", "mod", "*", "BeeInterface", ")", "{", "startBee", ...
// StartBee starts a bee.
[ "StartBee", "starts", "a", "bee", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L166-L175
21,146
muesli/beehive
bees/bees.go
StartBees
func StartBees(beeList []BeeConfig) { eventsIn = make(chan Event) go handleEvents() for _, bee := range beeList { StartBee(bee) } }
go
func StartBees(beeList []BeeConfig) { eventsIn = make(chan Event) go handleEvents() for _, bee := range beeList { StartBee(bee) } }
[ "func", "StartBees", "(", "beeList", "[", "]", "BeeConfig", ")", "{", "eventsIn", "=", "make", "(", "chan", "Event", ")", "\n", "go", "handleEvents", "(", ")", "\n\n", "for", "_", ",", "bee", ":=", "range", "beeList", "{", "StartBee", "(", "bee", ")"...
// StartBees starts all registered bees.
[ "StartBees", "starts", "all", "registered", "bees", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L178-L185
21,147
muesli/beehive
bees/bees.go
StopBees
func StopBees() { for _, bee := range bees { log.Println("Stopping bee:", (*bee).Name()) (*bee).Stop() } close(eventsIn) bees = make(map[string]*BeeInterface) }
go
func StopBees() { for _, bee := range bees { log.Println("Stopping bee:", (*bee).Name()) (*bee).Stop() } close(eventsIn) bees = make(map[string]*BeeInterface) }
[ "func", "StopBees", "(", ")", "{", "for", "_", ",", "bee", ":=", "range", "bees", "{", "log", ".", "Println", "(", "\"", "\"", ",", "(", "*", "bee", ")", ".", "Name", "(", ")", ")", "\n", "(", "*", "bee", ")", ".", "Stop", "(", ")", "\n", ...
// StopBees stops all bees gracefully.
[ "StopBees", "stops", "all", "bees", "gracefully", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L188-L196
21,148
muesli/beehive
bees/bees.go
RestartBee
func RestartBee(bee *BeeInterface) { (*bee).Stop() (*bee).SetSigChan(make(chan bool)) (*bee).Start() go func(mod *BeeInterface) { startBee(mod, 0) }(bee) }
go
func RestartBee(bee *BeeInterface) { (*bee).Stop() (*bee).SetSigChan(make(chan bool)) (*bee).Start() go func(mod *BeeInterface) { startBee(mod, 0) }(bee) }
[ "func", "RestartBee", "(", "bee", "*", "BeeInterface", ")", "{", "(", "*", "bee", ")", ".", "Stop", "(", ")", "\n\n", "(", "*", "bee", ")", ".", "SetSigChan", "(", "make", "(", "chan", "bool", ")", ")", "\n", "(", "*", "bee", ")", ".", "Start",...
// RestartBee restarts a Bee.
[ "RestartBee", "restarts", "a", "Bee", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L199-L207
21,149
muesli/beehive
bees/bees.go
NewBee
func NewBee(name, factoryName, description string, options []BeeOption) Bee { c := BeeConfig{ Name: name, Class: factoryName, Description: description, Options: options, } b := Bee{ config: c, SigChan: make(chan bool), waitGroup: &sync.WaitGroup{}, } return b }
go
func NewBee(name, factoryName, description string, options []BeeOption) Bee { c := BeeConfig{ Name: name, Class: factoryName, Description: description, Options: options, } b := Bee{ config: c, SigChan: make(chan bool), waitGroup: &sync.WaitGroup{}, } return b }
[ "func", "NewBee", "(", "name", ",", "factoryName", ",", "description", "string", ",", "options", "[", "]", "BeeOption", ")", "Bee", "{", "c", ":=", "BeeConfig", "{", "Name", ":", "name", ",", "Class", ":", "factoryName", ",", "Description", ":", "descrip...
// NewBee returns a new bee and sets up sig-channel & waitGroup.
[ "NewBee", "returns", "a", "new", "bee", "and", "sets", "up", "sig", "-", "channel", "&", "waitGroup", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L216-L230
21,150
muesli/beehive
bees/bees.go
Stop
func (bee *Bee) Stop() { if !bee.IsRunning() { return } log.Println(bee.Name(), "stopping gracefully!") close(bee.SigChan) bee.waitGroup.Wait() bee.Running = false log.Println(bee.Name(), "stopped gracefully!") }
go
func (bee *Bee) Stop() { if !bee.IsRunning() { return } log.Println(bee.Name(), "stopping gracefully!") close(bee.SigChan) bee.waitGroup.Wait() bee.Running = false log.Println(bee.Name(), "stopped gracefully!") }
[ "func", "(", "bee", "*", "Bee", ")", "Stop", "(", ")", "{", "if", "!", "bee", ".", "IsRunning", "(", ")", "{", "return", "\n", "}", "\n", "log", ".", "Println", "(", "bee", ".", "Name", "(", ")", ",", "\"", "\"", ")", "\n\n", "close", "(", ...
// Stop gracefully stops a Bee.
[ "Stop", "gracefully", "stops", "a", "Bee", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L301-L311
21,151
muesli/beehive
bees/bees.go
Logln
func (bee *Bee) Logln(args ...interface{}) { a := []interface{}{"[" + bee.Name() + "]:"} for _, v := range args { a = append(a, v) } log.Println(a...) Log(bee.Name(), fmt.Sprintln(args...), 0) }
go
func (bee *Bee) Logln(args ...interface{}) { a := []interface{}{"[" + bee.Name() + "]:"} for _, v := range args { a = append(a, v) } log.Println(a...) Log(bee.Name(), fmt.Sprintln(args...), 0) }
[ "func", "(", "bee", "*", "Bee", ")", "Logln", "(", "args", "...", "interface", "{", "}", ")", "{", "a", ":=", "[", "]", "interface", "{", "}", "{", "\"", "\"", "+", "bee", ".", "Name", "(", ")", "+", "\"", "\"", "}", "\n", "for", "_", ",", ...
// Logln logs args
[ "Logln", "logs", "args" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L334-L342
21,152
muesli/beehive
bees/bees.go
Logf
func (bee *Bee) Logf(format string, args ...interface{}) { s := fmt.Sprintf(format, args...) log.Printf("[%s]: %s", bee.Name(), s) Log(bee.Name(), s, 0) }
go
func (bee *Bee) Logf(format string, args ...interface{}) { s := fmt.Sprintf(format, args...) log.Printf("[%s]: %s", bee.Name(), s) Log(bee.Name(), s, 0) }
[ "func", "(", "bee", "*", "Bee", ")", "Logf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",...
// Logf logs a formatted string
[ "Logf", "logs", "a", "formatted", "string" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L345-L349
21,153
muesli/beehive
bees/bees.go
LogErrorf
func (bee *Bee) LogErrorf(format string, args ...interface{}) { s := fmt.Sprintf(format, args...) log.Errorf("[%s]: %s", bee.Name(), s) Log(bee.Name(), s, 1) }
go
func (bee *Bee) LogErrorf(format string, args ...interface{}) { s := fmt.Sprintf(format, args...) log.Errorf("[%s]: %s", bee.Name(), s) Log(bee.Name(), s, 1) }
[ "func", "(", "bee", "*", "Bee", ")", "LogErrorf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", "\n", "log", ".", "Errorf", "(", "\"", "\"",...
// LogErrorf logs a formatted error string
[ "LogErrorf", "logs", "a", "formatted", "error", "string" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L352-L356
21,154
muesli/beehive
bees/bees.go
LogFatal
func (bee *Bee) LogFatal(args ...interface{}) { a := []interface{}{"[" + bee.Name() + "]:"} for _, v := range args { a = append(a, v) } log.Panicln(a...) Log(bee.Name(), fmt.Sprintln(args...), 2) }
go
func (bee *Bee) LogFatal(args ...interface{}) { a := []interface{}{"[" + bee.Name() + "]:"} for _, v := range args { a = append(a, v) } log.Panicln(a...) Log(bee.Name(), fmt.Sprintln(args...), 2) }
[ "func", "(", "bee", "*", "Bee", ")", "LogFatal", "(", "args", "...", "interface", "{", "}", ")", "{", "a", ":=", "[", "]", "interface", "{", "}", "{", "\"", "\"", "+", "bee", ".", "Name", "(", ")", "+", "\"", "\"", "}", "\n", "for", "_", ",...
// LogFatal logs a fatal error
[ "LogFatal", "logs", "a", "fatal", "error" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/bees.go#L359-L366
21,155
muesli/beehive
bees/events.go
handleEvents
func handleEvents() { for { event, ok := <-eventsIn if !ok { log.Println() log.Println("Stopped event handler!") break } bee := GetBee(event.Bee) (*bee).LogEvent() log.Println() log.Println("Event received:", event.Bee, "/", event.Name, "-", GetEventDescriptor(&event).Description) for _, v :...
go
func handleEvents() { for { event, ok := <-eventsIn if !ok { log.Println() log.Println("Stopped event handler!") break } bee := GetBee(event.Bee) (*bee).LogEvent() log.Println() log.Println("Event received:", event.Bee, "/", event.Name, "-", GetEventDescriptor(&event).Description) for _, v :...
[ "func", "handleEvents", "(", ")", "{", "for", "{", "event", ",", "ok", ":=", "<-", "eventsIn", "\n", "if", "!", "ok", "{", "log", ".", "Println", "(", ")", "\n", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "break", "\n", "}", "\n\n", "be...
// handleEvents handles incoming events and executes matching Chains.
[ "handleEvents", "handles", "incoming", "events", "and", "executes", "matching", "Chains", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/events.go#L39-L67
21,156
muesli/beehive
filters/filters.go
GetFilter
func GetFilter(identifier string) *FilterInterface { filter, ok := filters[identifier] if ok { return filter } return nil }
go
func GetFilter(identifier string) *FilterInterface { filter, ok := filters[identifier] if ok { return filter } return nil }
[ "func", "GetFilter", "(", "identifier", "string", ")", "*", "FilterInterface", "{", "filter", ",", "ok", ":=", "filters", "[", "identifier", "]", "\n", "if", "ok", "{", "return", "filter", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// GetFilter returns a filter with a specific name
[ "GetFilter", "returns", "a", "filter", "with", "a", "specific", "name" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/filters/filters.go#L46-L53
21,157
muesli/beehive
api/resources/actions/actions_response.go
AddAction
func (r *ActionResponse) AddAction(action *bees.Action) { r.actions = append(r.actions, action) r.Actions = append(r.Actions, prepareActionResponse(r.Context, action)) }
go
func (r *ActionResponse) AddAction(action *bees.Action) { r.actions = append(r.actions, action) r.Actions = append(r.Actions, prepareActionResponse(r.Context, action)) }
[ "func", "(", "r", "*", "ActionResponse", ")", "AddAction", "(", "action", "*", "bees", ".", "Action", ")", "{", "r", ".", "actions", "=", "append", "(", "r", ".", "actions", ",", "action", ")", "\n", "r", ".", "Actions", "=", "append", "(", "r", ...
// AddAction adds a action to the response
[ "AddAction", "adds", "a", "action", "to", "the", "response" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/actions/actions_response.go#L53-L56
21,158
muesli/beehive
api/resources/logs/logs_response.go
AddLog
func (r *LogResponse) AddLog(log *bees.LogMessage) { r.logs = append(r.logs, log) r.Logs = append(r.Logs, prepareLogResponse(r.Context, log)) }
go
func (r *LogResponse) AddLog(log *bees.LogMessage) { r.logs = append(r.logs, log) r.Logs = append(r.Logs, prepareLogResponse(r.Context, log)) }
[ "func", "(", "r", "*", "LogResponse", ")", "AddLog", "(", "log", "*", "bees", ".", "LogMessage", ")", "{", "r", ".", "logs", "=", "append", "(", "r", ".", "logs", ",", "log", ")", "\n", "r", ".", "Logs", "=", "append", "(", "r", ".", "Logs", ...
// AddLog adds a log to the response
[ "AddLog", "adds", "a", "log", "to", "the", "response" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/logs/logs_response.go#L56-L59
21,159
muesli/beehive
bees/actions.go
GetAction
func GetAction(id string) *Action { for _, a := range actions { if a.ID == id { return &a } } return nil }
go
func GetAction(id string) *Action { for _, a := range actions { if a.ID == id { return &a } } return nil }
[ "func", "GetAction", "(", "id", "string", ")", "*", "Action", "{", "for", "_", ",", "a", ":=", "range", "actions", "{", "if", "a", ".", "ID", "==", "id", "{", "return", "&", "a", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// GetAction returns one action with a specific ID.
[ "GetAction", "returns", "one", "action", "with", "a", "specific", "ID", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/actions.go#L51-L59
21,160
muesli/beehive
bees/actions.go
execAction
func execAction(action Action, opts map[string]interface{}) bool { a := Action{ Bee: action.Bee, Name: action.Name, } for _, opt := range action.Options { ph := Placeholder{ Name: opt.Name, } switch opt.Value.(type) { case string: var value bytes.Buffer tmpl, err := template.New(action.Bee +...
go
func execAction(action Action, opts map[string]interface{}) bool { a := Action{ Bee: action.Bee, Name: action.Name, } for _, opt := range action.Options { ph := Placeholder{ Name: opt.Name, } switch opt.Value.(type) { case string: var value bytes.Buffer tmpl, err := template.New(action.Bee +...
[ "func", "execAction", "(", "action", "Action", ",", "opts", "map", "[", "string", "]", "interface", "{", "}", ")", "bool", "{", "a", ":=", "Action", "{", "Bee", ":", "action", ".", "Bee", ",", "Name", ":", "action", ".", "Name", ",", "}", "\n\n", ...
// execAction executes an action and map its ins & outs.
[ "execAction", "executes", "an", "action", "and", "map", "its", "ins", "&", "outs", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/actions.go#L67-L118
21,161
muesli/beehive
api/context/context.go
NewAPIContext
func (context *APIContext) NewAPIContext() smolder.APIContext { ctx := &APIContext{ Config: context.Config, } return ctx }
go
func (context *APIContext) NewAPIContext() smolder.APIContext { ctx := &APIContext{ Config: context.Config, } return ctx }
[ "func", "(", "context", "*", "APIContext", ")", "NewAPIContext", "(", ")", "smolder", ".", "APIContext", "{", "ctx", ":=", "&", "APIContext", "{", "Config", ":", "context", ".", "Config", ",", "}", "\n", "return", "ctx", "\n", "}" ]
// NewAPIContext returns a new polly context
[ "NewAPIContext", "returns", "a", "new", "polly", "context" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/context/context.go#L36-L41
21,162
muesli/beehive
bees/placeholders.go
SetValue
func (ph *Placeholders) SetValue(name string, _type string, value interface{}) { if ph.Value(name) == nil { p := Placeholder{ Name: name, Type: _type, Value: value, } *ph = append(*ph, p) } else { for i := 0; i < len(*ph); i++ { if (*ph)[i].Name == name { (*ph)[i].Type = _type (*ph)[i].V...
go
func (ph *Placeholders) SetValue(name string, _type string, value interface{}) { if ph.Value(name) == nil { p := Placeholder{ Name: name, Type: _type, Value: value, } *ph = append(*ph, p) } else { for i := 0; i < len(*ph); i++ { if (*ph)[i].Name == name { (*ph)[i].Type = _type (*ph)[i].V...
[ "func", "(", "ph", "*", "Placeholders", ")", "SetValue", "(", "name", "string", ",", "_type", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "ph", ".", "Value", "(", "name", ")", "==", "nil", "{", "p", ":=", "Placeholder", "{", "Nam...
// SetValue sets a value in the Placeholder slice.
[ "SetValue", "sets", "a", "value", "in", "the", "Placeholder", "slice", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L45-L61
21,163
muesli/beehive
bees/placeholders.go
Value
func (ph Placeholders) Value(name string) interface{} { for _, p := range ph { if p.Name == name { return p.Value } } return nil }
go
func (ph Placeholders) Value(name string) interface{} { for _, p := range ph { if p.Name == name { return p.Value } } return nil }
[ "func", "(", "ph", "Placeholders", ")", "Value", "(", "name", "string", ")", "interface", "{", "}", "{", "for", "_", ",", "p", ":=", "range", "ph", "{", "if", "p", ".", "Name", "==", "name", "{", "return", "p", ".", "Value", "\n", "}", "\n", "}...
// Value retrieves a value from a Placeholder slice.
[ "Value", "retrieves", "a", "value", "from", "a", "Placeholder", "slice", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L64-L72
21,164
muesli/beehive
bees/placeholders.go
Bind
func (ph Placeholders) Bind(name string, dst interface{}) error { v := ph.Value(name) if v == nil { return errors.New("Placeholder with name " + name + " not found") } return ConvertValue(v, dst) }
go
func (ph Placeholders) Bind(name string, dst interface{}) error { v := ph.Value(name) if v == nil { return errors.New("Placeholder with name " + name + " not found") } return ConvertValue(v, dst) }
[ "func", "(", "ph", "Placeholders", ")", "Bind", "(", "name", "string", ",", "dst", "interface", "{", "}", ")", "error", "{", "v", ":=", "ph", ".", "Value", "(", "name", ")", "\n", "if", "v", "==", "nil", "{", "return", "errors", ".", "New", "(", ...
// Bind a value from a Placeholder slice.
[ "Bind", "a", "value", "from", "a", "Placeholder", "slice", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/placeholders.go#L75-L82
21,165
muesli/beehive
bees/descriptors.go
GetActionDescriptor
func GetActionDescriptor(action *Action) ActionDescriptor { bee := GetBee(action.Bee) if bee == nil { panic("Bee " + action.Bee + " not registered") } factory := (*GetFactory((*bee).Namespace())) for _, ac := range factory.Actions() { if ac.Name == action.Name { return ac } } return ActionDescriptor{} ...
go
func GetActionDescriptor(action *Action) ActionDescriptor { bee := GetBee(action.Bee) if bee == nil { panic("Bee " + action.Bee + " not registered") } factory := (*GetFactory((*bee).Namespace())) for _, ac := range factory.Actions() { if ac.Name == action.Name { return ac } } return ActionDescriptor{} ...
[ "func", "GetActionDescriptor", "(", "action", "*", "Action", ")", "ActionDescriptor", "{", "bee", ":=", "GetBee", "(", "action", ".", "Bee", ")", "\n", "if", "bee", "==", "nil", "{", "panic", "(", "\"", "\"", "+", "action", ".", "Bee", "+", "\"", "\"...
// GetActionDescriptor returns the ActionDescriptor matching an action.
[ "GetActionDescriptor", "returns", "the", "ActionDescriptor", "matching", "an", "action", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/descriptors.go#L65-L78
21,166
muesli/beehive
bees/descriptors.go
GetEventDescriptor
func GetEventDescriptor(event *Event) EventDescriptor { bee := GetBee(event.Bee) if bee == nil { panic("Bee " + event.Bee + " not registered") } factory := (*GetFactory((*bee).Namespace())) for _, ev := range factory.Events() { if ev.Name == event.Name { return ev } } return EventDescriptor{} }
go
func GetEventDescriptor(event *Event) EventDescriptor { bee := GetBee(event.Bee) if bee == nil { panic("Bee " + event.Bee + " not registered") } factory := (*GetFactory((*bee).Namespace())) for _, ev := range factory.Events() { if ev.Name == event.Name { return ev } } return EventDescriptor{} }
[ "func", "GetEventDescriptor", "(", "event", "*", "Event", ")", "EventDescriptor", "{", "bee", ":=", "GetBee", "(", "event", ".", "Bee", ")", "\n", "if", "bee", "==", "nil", "{", "panic", "(", "\"", "\"", "+", "event", ".", "Bee", "+", "\"", "\"", "...
// GetEventDescriptor returns the EventDescriptor matching an event.
[ "GetEventDescriptor", "returns", "the", "EventDescriptor", "matching", "an", "event", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/descriptors.go#L81-L94
21,167
muesli/beehive
bees/ircbee/ircbeefactory.go
States
func (factory *IrcBeeFactory) States() []bees.StateDescriptor { opts := []bees.StateDescriptor{ { Name: "connected", Description: "Whether this bee is currently connected to IRC", Type: "bool", }, { Name: "channels", Description: "Which channels this bee is currently connected...
go
func (factory *IrcBeeFactory) States() []bees.StateDescriptor { opts := []bees.StateDescriptor{ { Name: "connected", Description: "Whether this bee is currently connected to IRC", Type: "bool", }, { Name: "channels", Description: "Which channels this bee is currently connected...
[ "func", "(", "factory", "*", "IrcBeeFactory", ")", "States", "(", ")", "[", "]", "bees", ".", "StateDescriptor", "{", "opts", ":=", "[", "]", "bees", ".", "StateDescriptor", "{", "{", "Name", ":", "\"", "\"", ",", "Description", ":", "\"", "\"", ",",...
// States returns the state values provided by this Bee.
[ "States", "returns", "the", "state", "values", "provided", "by", "this", "Bee", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/ircbeefactory.go#L105-L119
21,168
muesli/beehive
api/resources/chains/chains_response.go
AddChain
func (r *ChainResponse) AddChain(chain bees.Chain) { r.chains[chain.Name] = &chain }
go
func (r *ChainResponse) AddChain(chain bees.Chain) { r.chains[chain.Name] = &chain }
[ "func", "(", "r", "*", "ChainResponse", ")", "AddChain", "(", "chain", "bees", ".", "Chain", ")", "{", "r", ".", "chains", "[", "chain", ".", "Name", "]", "=", "&", "chain", "\n", "}" ]
// AddChain adds a chain to the response
[ "AddChain", "adds", "a", "chain", "to", "the", "response" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_response.go#L58-L60
21,169
muesli/beehive
bees/cronbee/cron/cronparser.go
checkValues
func (c *crontime) checkValues() { for _, sec := range c.second { if sec >= 60 || sec < 0 { log.Panicln("Cronbee: Your config seems messed up. Check the range of \"Second\".") } } for _, min := range c.second { if min >= 60 || min < 0 { log.Panicln("Cronbee: Your config seems messed up. Check the range ...
go
func (c *crontime) checkValues() { for _, sec := range c.second { if sec >= 60 || sec < 0 { log.Panicln("Cronbee: Your config seems messed up. Check the range of \"Second\".") } } for _, min := range c.second { if min >= 60 || min < 0 { log.Panicln("Cronbee: Your config seems messed up. Check the range ...
[ "func", "(", "c", "*", "crontime", ")", "checkValues", "(", ")", "{", "for", "_", ",", "sec", ":=", "range", "c", ".", "second", "{", "if", "sec", ">=", "60", "||", "sec", "<", "0", "{", "log", ".", "Panicln", "(", "\"", "\\\"", "\\\"", "\"", ...
// Look for obvious nonsense in the config.
[ "Look", "for", "obvious", "nonsense", "in", "the", "config", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/cronparser.go#L285-L321
21,170
muesli/beehive
bees/cronbee/cron/cronparser.go
valueRange
func valueRange(a, b, base int) []int { value := make([]int, absoluteOverBreakpoint(a, b, base)+1) i := 0 for ; a != b; a++ { if a == base { a = 0 } value[i] = a i++ } value[i] = a return value }
go
func valueRange(a, b, base int) []int { value := make([]int, absoluteOverBreakpoint(a, b, base)+1) i := 0 for ; a != b; a++ { if a == base { a = 0 } value[i] = a i++ } value[i] = a return value }
[ "func", "valueRange", "(", "a", ",", "b", ",", "base", "int", ")", "[", "]", "int", "{", "value", ":=", "make", "(", "[", "]", "int", ",", "absoluteOverBreakpoint", "(", "a", ",", "b", ",", "base", ")", "+", "1", ")", "\n", "i", ":=", "0", "\...
// Returns an array filled with all values between a and b considering // the base.
[ "Returns", "an", "array", "filled", "with", "all", "values", "between", "a", "and", "b", "considering", "the", "base", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/cronparser.go#L346-L358
21,171
muesli/beehive
bees/logs.go
NewLogMessage
func NewLogMessage(bee string, message string, messageType uint) LogMessage { return LogMessage{ ID: UUID(), Bee: bee, Message: message, MessageType: messageType, Timestamp: time.Now(), } }
go
func NewLogMessage(bee string, message string, messageType uint) LogMessage { return LogMessage{ ID: UUID(), Bee: bee, Message: message, MessageType: messageType, Timestamp: time.Now(), } }
[ "func", "NewLogMessage", "(", "bee", "string", ",", "message", "string", ",", "messageType", "uint", ")", "LogMessage", "{", "return", "LogMessage", "{", "ID", ":", "UUID", "(", ")", ",", "Bee", ":", "bee", ",", "Message", ":", "message", ",", "MessageTy...
// NewLogMessage returns a newly composed LogMessage
[ "NewLogMessage", "returns", "a", "newly", "composed", "LogMessage" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/logs.go#L52-L60
21,172
muesli/beehive
bees/logs.go
Log
func Log(bee string, message string, messageType uint) { logMutex.Lock() defer logMutex.Unlock() logs[bee] = append(logs[bee], NewLogMessage(bee, message, messageType)) }
go
func Log(bee string, message string, messageType uint) { logMutex.Lock() defer logMutex.Unlock() logs[bee] = append(logs[bee], NewLogMessage(bee, message, messageType)) }
[ "func", "Log", "(", "bee", "string", ",", "message", "string", ",", "messageType", "uint", ")", "{", "logMutex", ".", "Lock", "(", ")", "\n", "defer", "logMutex", ".", "Unlock", "(", ")", "\n\n", "logs", "[", "bee", "]", "=", "append", "(", "logs", ...
// Log adds a new LogMessage to the log
[ "Log", "adds", "a", "new", "LogMessage", "to", "the", "log" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/logs.go#L63-L68
21,173
muesli/beehive
bees/logs.go
GetLogs
func GetLogs(bee string) []LogMessage { r := []LogMessage{} logMutex.RLock() for b, ls := range logs { if len(bee) == 0 || bee == b { for _, l := range ls { r = append(r, l) } } } logMutex.RUnlock() sort.Sort(LogSorter(r)) return r }
go
func GetLogs(bee string) []LogMessage { r := []LogMessage{} logMutex.RLock() for b, ls := range logs { if len(bee) == 0 || bee == b { for _, l := range ls { r = append(r, l) } } } logMutex.RUnlock() sort.Sort(LogSorter(r)) return r }
[ "func", "GetLogs", "(", "bee", "string", ")", "[", "]", "LogMessage", "{", "r", ":=", "[", "]", "LogMessage", "{", "}", "\n\n", "logMutex", ".", "RLock", "(", ")", "\n", "for", "b", ",", "ls", ":=", "range", "logs", "{", "if", "len", "(", "bee", ...
// GetLogs returns all logs for a Bee.
[ "GetLogs", "returns", "all", "logs", "for", "a", "Bee", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/logs.go#L71-L86
21,174
muesli/beehive
bees/ircbee/irctools/irctools.go
Colored
func Colored(val string, color string) string { // 00 white 01 black 02 blue (navy) 03 green 04 red 05 brown (maroon) // 06 purple 07 orange (olive) 08 yellow 09 light green (lime) // 10 teal (a green/blue cyan) 11 light cyan (cyan) (aqua) 12 light blue (royal) // 13 pink (light purple) (fuchsia) 14 grey 15 light g...
go
func Colored(val string, color string) string { // 00 white 01 black 02 blue (navy) 03 green 04 red 05 brown (maroon) // 06 purple 07 orange (olive) 08 yellow 09 light green (lime) // 10 teal (a green/blue cyan) 11 light cyan (cyan) (aqua) 12 light blue (royal) // 13 pink (light purple) (fuchsia) 14 grey 15 light g...
[ "func", "Colored", "(", "val", "string", ",", "color", "string", ")", "string", "{", "// 00 white 01 black 02 blue (navy) 03 green 04 red 05 brown (maroon)", "// 06 purple 07 orange (olive) 08 yellow 09 light green (lime)", "// 10 teal (a green/blue cyan) 11 light cyan (cyan) (aqua) 12 lig...
// Colored wraps val in color styling tags.
[ "Colored", "wraps", "val", "in", "color", "styling", "tags", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/ircbee/irctools/irctools.go#L38-L80
21,175
muesli/beehive
bees/options.go
Value
func (opts BeeOptions) Value(name string) interface{} { for _, opt := range opts { if opt.Name == name { return opt.Value } } return nil }
go
func (opts BeeOptions) Value(name string) interface{} { for _, opt := range opts { if opt.Name == name { return opt.Value } } return nil }
[ "func", "(", "opts", "BeeOptions", ")", "Value", "(", "name", "string", ")", "interface", "{", "}", "{", "for", "_", ",", "opt", ":=", "range", "opts", "{", "if", "opt", ".", "Name", "==", "name", "{", "return", "opt", ".", "Value", "\n", "}", "\...
// Value retrieves a value from a BeeOptions slice.
[ "Value", "retrieves", "a", "value", "from", "a", "BeeOptions", "slice", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/options.go#L46-L54
21,176
muesli/beehive
bees/options.go
Bind
func (opts BeeOptions) Bind(name string, dst interface{}) error { v := opts.Value(name) if v == nil { return errors.New("Option with name " + name + " not found") } return ConvertValue(v, dst) }
go
func (opts BeeOptions) Bind(name string, dst interface{}) error { v := opts.Value(name) if v == nil { return errors.New("Option with name " + name + " not found") } return ConvertValue(v, dst) }
[ "func", "(", "opts", "BeeOptions", ")", "Bind", "(", "name", "string", ",", "dst", "interface", "{", "}", ")", "error", "{", "v", ":=", "opts", ".", "Value", "(", "name", ")", "\n", "if", "v", "==", "nil", "{", "return", "errors", ".", "New", "("...
// Bind a value from a BeeOptions slice.
[ "Bind", "a", "value", "from", "a", "BeeOptions", "slice", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/options.go#L57-L64
21,177
muesli/beehive
bees/telegrambee/telegrambee.go
getAPIKey
func getAPIKey(options *bees.BeeOptions) string { var apiKey string options.Bind("api_key", &apiKey) if strings.HasPrefix(apiKey, "file://") { buf, err := ioutil.ReadFile(strings.TrimPrefix(apiKey, "file://")) if err != nil { panic("Error reading API key file " + apiKey) } apiKey = string(buf) } if st...
go
func getAPIKey(options *bees.BeeOptions) string { var apiKey string options.Bind("api_key", &apiKey) if strings.HasPrefix(apiKey, "file://") { buf, err := ioutil.ReadFile(strings.TrimPrefix(apiKey, "file://")) if err != nil { panic("Error reading API key file " + apiKey) } apiKey = string(buf) } if st...
[ "func", "getAPIKey", "(", "options", "*", "bees", ".", "BeeOptions", ")", "string", "{", "var", "apiKey", "string", "\n", "options", ".", "Bind", "(", "\"", "\"", ",", "&", "apiKey", ")", "\n\n", "if", "strings", ".", "HasPrefix", "(", "apiKey", ",", ...
// Gets the Bot's API key from a file, the recipe config or the // TELEGRAM_API_KEY environment variable.
[ "Gets", "the", "Bot", "s", "API", "key", "from", "a", "file", "the", "recipe", "config", "or", "the", "TELEGRAM_API_KEY", "environment", "variable", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/telegrambee/telegrambee.go#L136-L154
21,178
muesli/beehive
bees/config.go
NewBeeConfig
func NewBeeConfig(name, class, description string, options BeeOptions) (BeeConfig, error) { if len(name) == 0 { return BeeConfig{}, errors.New("A Bee's name can't be empty") } b := GetBee(name) if b != nil { return BeeConfig{}, errors.New("A Bee with that name already exists") } f := GetFactory(class) if f...
go
func NewBeeConfig(name, class, description string, options BeeOptions) (BeeConfig, error) { if len(name) == 0 { return BeeConfig{}, errors.New("A Bee's name can't be empty") } b := GetBee(name) if b != nil { return BeeConfig{}, errors.New("A Bee with that name already exists") } f := GetFactory(class) if f...
[ "func", "NewBeeConfig", "(", "name", ",", "class", ",", "description", "string", ",", "options", "BeeOptions", ")", "(", "BeeConfig", ",", "error", ")", "{", "if", "len", "(", "name", ")", "==", "0", "{", "return", "BeeConfig", "{", "}", ",", "errors",...
// NewBeeConfig validates a configuration and sets up a new BeeConfig
[ "NewBeeConfig", "validates", "a", "configuration", "and", "sets", "up", "a", "new", "BeeConfig" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/config.go#L35-L56
21,179
muesli/beehive
bees/config.go
BeeConfigs
func BeeConfigs() []BeeConfig { bs := []BeeConfig{} for _, b := range bees { bs = append(bs, (*b).Config()) } return bs }
go
func BeeConfigs() []BeeConfig { bs := []BeeConfig{} for _, b := range bees { bs = append(bs, (*b).Config()) } return bs }
[ "func", "BeeConfigs", "(", ")", "[", "]", "BeeConfig", "{", "bs", ":=", "[", "]", "BeeConfig", "{", "}", "\n", "for", "_", ",", "b", ":=", "range", "bees", "{", "bs", "=", "append", "(", "bs", ",", "(", "*", "b", ")", ".", "Config", "(", ")",...
// BeeConfigs returns configs for all Bees.
[ "BeeConfigs", "returns", "configs", "for", "all", "Bees", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/config.go#L59-L66
21,180
muesli/beehive
bees/filters.go
execFilter
func execFilter(filter string, opts map[string]interface{}) bool { f := *filters.GetFilter("template") log.Println("\tExecuting filter:", filter) defer func() { if e := recover(); e != nil { log.Println("Fatal filter event:", e) } }() return f.Passes(opts, filter) }
go
func execFilter(filter string, opts map[string]interface{}) bool { f := *filters.GetFilter("template") log.Println("\tExecuting filter:", filter) defer func() { if e := recover(); e != nil { log.Println("Fatal filter event:", e) } }() return f.Passes(opts, filter) }
[ "func", "execFilter", "(", "filter", "string", ",", "opts", "map", "[", "string", "]", "interface", "{", "}", ")", "bool", "{", "f", ":=", "*", "filters", ".", "GetFilter", "(", "\"", "\"", ")", "\n", "log", ".", "Println", "(", "\"", "\\t", "\"", ...
// execFilter executes a filter. Returns whether the filter passed or not.
[ "execFilter", "executes", "a", "filter", ".", "Returns", "whether", "the", "filter", "passed", "or", "not", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/filters.go#L38-L49
21,181
muesli/beehive
bees/openweathermapbee/event.go
TriggerWeatherInformationEvent
func (mod *OpenweathermapBee) TriggerWeatherInformationEvent(v *owm.Weather) { weather := bees.Event{ Bee: mod.Name(), Name: "main_weather", Options: []bees.Placeholder{ { Name: "id", Type: "int", Value: v.ID, }, { Name: "main", Type: "string", Value: v.Main, }, { ...
go
func (mod *OpenweathermapBee) TriggerWeatherInformationEvent(v *owm.Weather) { weather := bees.Event{ Bee: mod.Name(), Name: "main_weather", Options: []bees.Placeholder{ { Name: "id", Type: "int", Value: v.ID, }, { Name: "main", Type: "string", Value: v.Main, }, { ...
[ "func", "(", "mod", "*", "OpenweathermapBee", ")", "TriggerWeatherInformationEvent", "(", "v", "*", "owm", ".", "Weather", ")", "{", "weather", ":=", "bees", ".", "Event", "{", "Bee", ":", "mod", ".", "Name", "(", ")", ",", "Name", ":", "\"", "\"", "...
// WeatherInformationEvent triggers a weather event
[ "WeatherInformationEvent", "triggers", "a", "weather", "event" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/event.go#L186-L214
21,182
muesli/beehive
filters/template/templatefilter.go
Passes
func (filter *TemplateFilter) Passes(data interface{}, value interface{}) bool { switch v := value.(type) { case string: var res bytes.Buffer if strings.Index(v, "{{test") >= 0 { v = strings.Replace(v, "{{test", "{{if", -1) v += "true{{end}}" } tmpl, err := template.New("_" + v).Funcs(templatehelper.F...
go
func (filter *TemplateFilter) Passes(data interface{}, value interface{}) bool { switch v := value.(type) { case string: var res bytes.Buffer if strings.Index(v, "{{test") >= 0 { v = strings.Replace(v, "{{test", "{{if", -1) v += "true{{end}}" } tmpl, err := template.New("_" + v).Funcs(templatehelper.F...
[ "func", "(", "filter", "*", "TemplateFilter", ")", "Passes", "(", "data", "interface", "{", "}", ",", "value", "interface", "{", "}", ")", "bool", "{", "switch", "v", ":=", "value", ".", "(", "type", ")", "{", "case", "string", ":", "var", "res", "...
// Passes returns true when the Filter matched the data.
[ "Passes", "returns", "true", "when", "the", "Filter", "matched", "the", "data", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/filters/template/templatefilter.go#L48-L70
21,183
muesli/beehive
api/resources/hives/hives_response.go
AddHive
func (r *HiveResponse) AddHive(hive *bees.BeeFactoryInterface) { r.hives[(*hive).Name()] = hive }
go
func (r *HiveResponse) AddHive(hive *bees.BeeFactoryInterface) { r.hives[(*hive).Name()] = hive }
[ "func", "(", "r", "*", "HiveResponse", ")", "AddHive", "(", "hive", "*", "bees", ".", "BeeFactoryInterface", ")", "{", "r", ".", "hives", "[", "(", "*", "hive", ")", ".", "Name", "(", ")", "]", "=", "hive", "\n", "}" ]
// AddHive adds a hive to the response
[ "AddHive", "adds", "a", "hive", "to", "the", "response" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_response.go#L64-L66
21,184
muesli/beehive
api/resources/bees/bees_response.go
AddBee
func (r *BeeResponse) AddBee(bee *bees.BeeInterface) { r.bees[(*bee).Name()] = bee hive := bees.GetFactory((*bee).Namespace()) if hive == nil { panic("Hive for Bee not found") } r.hives[(*hive).Name()] = hive r.Hives = append(r.Hives, hives.PrepareHiveResponse(r.Context, hive)) }
go
func (r *BeeResponse) AddBee(bee *bees.BeeInterface) { r.bees[(*bee).Name()] = bee hive := bees.GetFactory((*bee).Namespace()) if hive == nil { panic("Hive for Bee not found") } r.hives[(*hive).Name()] = hive r.Hives = append(r.Hives, hives.PrepareHiveResponse(r.Context, hive)) }
[ "func", "(", "r", "*", "BeeResponse", ")", "AddBee", "(", "bee", "*", "bees", ".", "BeeInterface", ")", "{", "r", ".", "bees", "[", "(", "*", "bee", ")", ".", "Name", "(", ")", "]", "=", "bee", "\n\n", "hive", ":=", "bees", ".", "GetFactory", "...
// AddBee adds a bee to the response
[ "AddBee", "adds", "a", "bee", "to", "the", "response" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_response.go#L66-L76
21,185
muesli/beehive
api/api.go
Run
func Run() { // to see what happens in the package, uncomment the following //restful.TraceLogger(log.New(os.Stdout, "[restful] ", log.LstdFlags|log.Lshortfile)) // Setup web-service smolderConfig := smolder.APIConfig{ BaseURL: canonicalURL, PathPrefix: "v1/", } context := &context.APIContext{ Config: s...
go
func Run() { // to see what happens in the package, uncomment the following //restful.TraceLogger(log.New(os.Stdout, "[restful] ", log.LstdFlags|log.Lshortfile)) // Setup web-service smolderConfig := smolder.APIConfig{ BaseURL: canonicalURL, PathPrefix: "v1/", } context := &context.APIContext{ Config: s...
[ "func", "Run", "(", ")", "{", "// to see what happens in the package, uncomment the following", "//restful.TraceLogger(log.New(os.Stdout, \"[restful] \", log.LstdFlags|log.Lshortfile))", "// Setup web-service", "smolderConfig", ":=", "smolder", ".", "APIConfig", "{", "BaseURL", ":", ...
// Run sets up the restful API container and an HTTP server go-routine
[ "Run", "sets", "up", "the", "restful", "API", "container", "and", "an", "HTTP", "server", "go", "-", "routine" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/api.go#L164-L202
21,186
muesli/beehive
bees/cronbee/cron/crontime.go
DurationUntilNextEvent
func (c *crontime) DurationUntilNextEvent() time.Duration { return c.nextEvent().Sub(time.Now()) }
go
func (c *crontime) DurationUntilNextEvent() time.Duration { return c.nextEvent().Sub(time.Now()) }
[ "func", "(", "c", "*", "crontime", ")", "DurationUntilNextEvent", "(", ")", "time", ".", "Duration", "{", "return", "c", ".", "nextEvent", "(", ")", ".", "Sub", "(", "time", ".", "Now", "(", ")", ")", "\n", "}" ]
// Returns the time.Duration until the next event.
[ "Returns", "the", "time", ".", "Duration", "until", "the", "next", "event", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L52-L54
21,187
muesli/beehive
bees/cronbee/cron/crontime.go
calculateEvent
func (c *crontime) calculateEvent(baseTime time.Time) time.Time { c.calculationInProgress = true defer c.setCalculationInProgress(false) baseTime = setNanoecond(baseTime, 10000) c.calculatedTime = baseTime // Ignore all Events in the Past & initial 'result' //c.calculatedTime = setNanoecond(c.calculatedTime, 10000...
go
func (c *crontime) calculateEvent(baseTime time.Time) time.Time { c.calculationInProgress = true defer c.setCalculationInProgress(false) baseTime = setNanoecond(baseTime, 10000) c.calculatedTime = baseTime // Ignore all Events in the Past & initial 'result' //c.calculatedTime = setNanoecond(c.calculatedTime, 10000...
[ "func", "(", "c", "*", "crontime", ")", "calculateEvent", "(", "baseTime", "time", ".", "Time", ")", "time", ".", "Time", "{", "c", ".", "calculationInProgress", "=", "true", "\n", "defer", "c", ".", "setCalculationInProgress", "(", "false", ")", "\n", "...
// This functions calculates the next event
[ "This", "functions", "calculates", "the", "next", "event" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L93-L106
21,188
muesli/beehive
bees/cronbee/cron/crontime.go
nextValidMonth
func (c *crontime) nextValidMonth(baseTime time.Time) { for _, mon := range c.month { if mon >= int(c.calculatedTime.Month()) { //log.Print("Inside Month", mon, c.calculatedTime) c.calculatedTime = setMonth(c.calculatedTime, mon) //log.Println(" :: and out", c.calculatedTime) return } } // If no resu...
go
func (c *crontime) nextValidMonth(baseTime time.Time) { for _, mon := range c.month { if mon >= int(c.calculatedTime.Month()) { //log.Print("Inside Month", mon, c.calculatedTime) c.calculatedTime = setMonth(c.calculatedTime, mon) //log.Println(" :: and out", c.calculatedTime) return } } // If no resu...
[ "func", "(", "c", "*", "crontime", ")", "nextValidMonth", "(", "baseTime", "time", ".", "Time", ")", "{", "for", "_", ",", "mon", ":=", "range", "c", ".", "month", "{", "if", "mon", ">=", "int", "(", "c", ".", "calculatedTime", ".", "Month", "(", ...
// Calculates the next valid Month based upon the previous results.
[ "Calculates", "the", "next", "valid", "Month", "based", "upon", "the", "previous", "results", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L109-L123
21,189
muesli/beehive
bees/cronbee/cron/crontime.go
nextValidDay
func (c *crontime) nextValidDay(baseTime time.Time) { for _, dom := range c.dom { if dom >= c.calculatedTime.Day() { for _, dow := range c.dow { if monthHasDow(dow, dom, int(c.calculatedTime.Month()), c.calculatedTime.Year()) { c.calculatedTime = setDay(c.calculatedTime, dom) //log.Println("Cronbee:...
go
func (c *crontime) nextValidDay(baseTime time.Time) { for _, dom := range c.dom { if dom >= c.calculatedTime.Day() { for _, dow := range c.dow { if monthHasDow(dow, dom, int(c.calculatedTime.Month()), c.calculatedTime.Year()) { c.calculatedTime = setDay(c.calculatedTime, dom) //log.Println("Cronbee:...
[ "func", "(", "c", "*", "crontime", ")", "nextValidDay", "(", "baseTime", "time", ".", "Time", ")", "{", "for", "_", ",", "dom", ":=", "range", "c", ".", "dom", "{", "if", "dom", ">=", "c", ".", "calculatedTime", ".", "Day", "(", ")", "{", "for", ...
// Calculates the next valid Day based upon the previous results.
[ "Calculates", "the", "next", "valid", "Day", "based", "upon", "the", "previous", "results", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L126-L152
21,190
muesli/beehive
bees/cronbee/cron/crontime.go
nextValidHour
func (c *crontime) nextValidHour(baseTime time.Time) { for _, hour := range c.hour { if c.calculatedTime.Day() == baseTime.Day() { if !hasPassed(hour, c.calculatedTime.Hour()) { c.calculatedTime = setHour(c.calculatedTime, hour) return } } else { c.calculatedTime = setHour(c.calculatedTime, hour) ...
go
func (c *crontime) nextValidHour(baseTime time.Time) { for _, hour := range c.hour { if c.calculatedTime.Day() == baseTime.Day() { if !hasPassed(hour, c.calculatedTime.Hour()) { c.calculatedTime = setHour(c.calculatedTime, hour) return } } else { c.calculatedTime = setHour(c.calculatedTime, hour) ...
[ "func", "(", "c", "*", "crontime", ")", "nextValidHour", "(", "baseTime", "time", ".", "Time", ")", "{", "for", "_", ",", "hour", ":=", "range", "c", ".", "hour", "{", "if", "c", ".", "calculatedTime", ".", "Day", "(", ")", "==", "baseTime", ".", ...
// Calculates the next valid Hour based upon the previous results.
[ "Calculates", "the", "next", "valid", "Hour", "based", "upon", "the", "previous", "results", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L155-L174
21,191
muesli/beehive
bees/cronbee/cron/crontime.go
nextValidMinute
func (c *crontime) nextValidMinute(baseTime time.Time) { for _, min := range c.minute { if c.calculatedTime.Hour() == baseTime.Hour() { if !hasPassed(min, c.calculatedTime.Minute()) { c.calculatedTime = setMinute(c.calculatedTime, min) return } } else { c.calculatedTime = setMinute(c.calculatedTim...
go
func (c *crontime) nextValidMinute(baseTime time.Time) { for _, min := range c.minute { if c.calculatedTime.Hour() == baseTime.Hour() { if !hasPassed(min, c.calculatedTime.Minute()) { c.calculatedTime = setMinute(c.calculatedTime, min) return } } else { c.calculatedTime = setMinute(c.calculatedTim...
[ "func", "(", "c", "*", "crontime", ")", "nextValidMinute", "(", "baseTime", "time", ".", "Time", ")", "{", "for", "_", ",", "min", ":=", "range", "c", ".", "minute", "{", "if", "c", ".", "calculatedTime", ".", "Hour", "(", ")", "==", "baseTime", "....
// Calculates the next valid Minute based upon the previous results.
[ "Calculates", "the", "next", "valid", "Minute", "based", "upon", "the", "previous", "results", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L177-L194
21,192
muesli/beehive
bees/cronbee/cron/crontime.go
nextValidSecond
func (c *crontime) nextValidSecond(baseTime time.Time) { for _, sec := range c.second { if !c.minuteHasPassed(baseTime) { // check if sec is in the past. <= prevents triggering the same event twice if sec > c.calculatedTime.Second() { c.calculatedTime = setSecond(c.calculatedTime, sec) return } } ...
go
func (c *crontime) nextValidSecond(baseTime time.Time) { for _, sec := range c.second { if !c.minuteHasPassed(baseTime) { // check if sec is in the past. <= prevents triggering the same event twice if sec > c.calculatedTime.Second() { c.calculatedTime = setSecond(c.calculatedTime, sec) return } } ...
[ "func", "(", "c", "*", "crontime", ")", "nextValidSecond", "(", "baseTime", "time", ".", "Time", ")", "{", "for", "_", ",", "sec", ":=", "range", "c", ".", "second", "{", "if", "!", "c", ".", "minuteHasPassed", "(", "baseTime", ")", "{", "// check if...
// Calculates the next valid Second based upon the previous results.
[ "Calculates", "the", "next", "valid", "Second", "based", "upon", "the", "previous", "results", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/cronbee/cron/crontime.go#L197-L215
21,193
muesli/beehive
bees/factories.go
GetFactory
func GetFactory(identifier string) *BeeFactoryInterface { factory, ok := factories[identifier] if ok { return factory } return nil }
go
func GetFactory(identifier string) *BeeFactoryInterface { factory, ok := factories[identifier] if ok { return factory } return nil }
[ "func", "GetFactory", "(", "identifier", "string", ")", "*", "BeeFactoryInterface", "{", "factory", ",", "ok", ":=", "factories", "[", "identifier", "]", "\n", "if", "ok", "{", "return", "factory", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// GetFactory returns the factory with a specific name.
[ "GetFactory", "returns", "the", "factory", "with", "a", "specific", "name", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/factories.go#L118-L125
21,194
muesli/beehive
bees/factories.go
GetFactories
func GetFactories() []*BeeFactoryInterface { r := []*BeeFactoryInterface{} for _, factory := range factories { r = append(r, factory) } return r }
go
func GetFactories() []*BeeFactoryInterface { r := []*BeeFactoryInterface{} for _, factory := range factories { r = append(r, factory) } return r }
[ "func", "GetFactories", "(", ")", "[", "]", "*", "BeeFactoryInterface", "{", "r", ":=", "[", "]", "*", "BeeFactoryInterface", "{", "}", "\n", "for", "_", ",", "factory", ":=", "range", "factories", "{", "r", "=", "append", "(", "r", ",", "factory", "...
// GetFactories returns all known bee factories.
[ "GetFactories", "returns", "all", "known", "bee", "factories", "." ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/factories.go#L128-L135
21,195
muesli/beehive
bees/chains.go
GetChain
func GetChain(id string) *Chain { for _, c := range chains { if c.Name == id { return &c } } return nil }
go
func GetChain(id string) *Chain { for _, c := range chains { if c.Name == id { return &c } } return nil }
[ "func", "GetChain", "(", "id", "string", ")", "*", "Chain", "{", "for", "_", ",", "c", ":=", "range", "chains", "{", "if", "c", ".", "Name", "==", "id", "{", "return", "&", "c", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// GetChain returns a chain with a specific id
[ "GetChain", "returns", "a", "chain", "with", "a", "specific", "id" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/chains.go#L52-L60
21,196
muesli/beehive
bees/chains.go
SetChains
func SetChains(cs []Chain) { newcs := []Chain{} // migrate old chain style for _, c := range cs { for _, el := range c.Elements { if el.Action.Name != "" { el.Action.ID = UUID() c.Actions = append(c.Actions, el.Action.ID) actions = append(actions, el.Action) } if el.Filter.Name != "" { //F...
go
func SetChains(cs []Chain) { newcs := []Chain{} // migrate old chain style for _, c := range cs { for _, el := range c.Elements { if el.Action.Name != "" { el.Action.ID = UUID() c.Actions = append(c.Actions, el.Action.ID) actions = append(actions, el.Action) } if el.Filter.Name != "" { //F...
[ "func", "SetChains", "(", "cs", "[", "]", "Chain", ")", "{", "newcs", ":=", "[", "]", "Chain", "{", "}", "\n", "// migrate old chain style", "for", "_", ",", "c", ":=", "range", "cs", "{", "for", "_", ",", "el", ":=", "range", "c", ".", "Elements",...
// SetChains sets the currently configured chains
[ "SetChains", "sets", "the", "currently", "configured", "chains" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/chains.go#L63-L84
21,197
muesli/beehive
bees/chains.go
execChains
func execChains(event *Event) { for _, c := range chains { if c.Event.Name != event.Name || c.Event.Bee != event.Bee { continue } m := make(map[string]interface{}) for _, opt := range event.Options { m[opt.Name] = opt.Value } ctx.FillMap(m) failed := false log.Println("Executing chain:", c.Name...
go
func execChains(event *Event) { for _, c := range chains { if c.Event.Name != event.Name || c.Event.Bee != event.Bee { continue } m := make(map[string]interface{}) for _, opt := range event.Options { m[opt.Name] = opt.Value } ctx.FillMap(m) failed := false log.Println("Executing chain:", c.Name...
[ "func", "execChains", "(", "event", "*", "Event", ")", "{", "for", "_", ",", "c", ":=", "range", "chains", "{", "if", "c", ".", "Event", ".", "Name", "!=", "event", ".", "Name", "||", "c", ".", "Event", ".", "Bee", "!=", "event", ".", "Bee", "{...
// execChains executes chains for an event we received
[ "execChains", "executes", "chains", "for", "an", "event", "we", "received" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/chains.go#L87-L123
21,198
muesli/beehive
app/app.go
AddFlags
func AddFlags(flags []CliFlag) { for _, flag := range flags { appflags = append(appflags, flag) } }
go
func AddFlags(flags []CliFlag) { for _, flag := range flags { appflags = append(appflags, flag) } }
[ "func", "AddFlags", "(", "flags", "[", "]", "CliFlag", ")", "{", "for", "_", ",", "flag", ":=", "range", "flags", "{", "appflags", "=", "append", "(", "appflags", ",", "flag", ")", "\n", "}", "\n", "}" ]
// AddFlags adds CliFlags to appflags
[ "AddFlags", "adds", "CliFlags", "to", "appflags" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/app/app.go#L42-L46
21,199
muesli/beehive
app/app.go
Run
func Run() { for _, f := range appflags { switch f.Value.(type) { case string: flag.StringVar((f.V).(*string), f.Name, f.Value.(string), f.Desc) case bool: flag.BoolVar((f.V).(*bool), f.Name, f.Value.(bool), f.Desc) } } flag.Parse() }
go
func Run() { for _, f := range appflags { switch f.Value.(type) { case string: flag.StringVar((f.V).(*string), f.Name, f.Value.(string), f.Desc) case bool: flag.BoolVar((f.V).(*bool), f.Name, f.Value.(bool), f.Desc) } } flag.Parse() }
[ "func", "Run", "(", ")", "{", "for", "_", ",", "f", ":=", "range", "appflags", "{", "switch", "f", ".", "Value", ".", "(", "type", ")", "{", "case", "string", ":", "flag", ".", "StringVar", "(", "(", "f", ".", "V", ")", ".", "(", "*", "string...
// Run sets up all the cli-param mappings
[ "Run", "sets", "up", "all", "the", "cli", "-", "param", "mappings" ]
4bfd4852e0b4bdcbc711323775cc7144ccd81b7e
https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/app/app.go#L49-L60