repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
asaskevich/govalidator | validator.go | IsDataURI | func IsDataURI(str string) bool {
dataURI := strings.Split(str, ",")
if !rxDataURI.MatchString(dataURI[0]) {
return false
}
return IsBase64(dataURI[1])
} | go | func IsDataURI(str string) bool {
dataURI := strings.Split(str, ",")
if !rxDataURI.MatchString(dataURI[0]) {
return false
}
return IsBase64(dataURI[1])
} | [
"func",
"IsDataURI",
"(",
"str",
"string",
")",
"bool",
"{",
"dataURI",
":=",
"strings",
".",
"Split",
"(",
"str",
",",
"\"",
"\"",
")",
"\n",
"if",
"!",
"rxDataURI",
".",
"MatchString",
"(",
"dataURI",
"[",
"0",
"]",
")",
"{",
"return",
"false",
"... | // IsDataURI checks if a string is base64 encoded data URI such as an image | [
"IsDataURI",
"checks",
"if",
"a",
"string",
"is",
"base64",
"encoded",
"data",
"URI",
"such",
"as",
"an",
"image"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L508-L514 | train |
asaskevich/govalidator | validator.go | IsISO3166Alpha2 | func IsISO3166Alpha2(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | go | func IsISO3166Alpha2(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | [
"func",
"IsISO3166Alpha2",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO3166List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha2Code",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsISO3166Alpha2 checks if a string is valid two-letter country code | [
"IsISO3166Alpha2",
"checks",
"if",
"a",
"string",
"is",
"valid",
"two",
"-",
"letter",
"country",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L517-L524 | train |
asaskevich/govalidator | validator.go | IsISO3166Alpha3 | func IsISO3166Alpha3(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha3Code {
return true
}
}
return false
} | go | func IsISO3166Alpha3(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha3Code {
return true
}
}
return false
} | [
"func",
"IsISO3166Alpha3",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO3166List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha3Code",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsISO3166Alpha3 checks if a string is valid three-letter country code | [
"IsISO3166Alpha3",
"checks",
"if",
"a",
"string",
"is",
"valid",
"three",
"-",
"letter",
"country",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L527-L534 | train |
asaskevich/govalidator | validator.go | IsISO693Alpha2 | func IsISO693Alpha2(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | go | func IsISO693Alpha2(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | [
"func",
"IsISO693Alpha2",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO693List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha2Code",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"... | // IsISO693Alpha2 checks if a string is valid two-letter language code | [
"IsISO693Alpha2",
"checks",
"if",
"a",
"string",
"is",
"valid",
"two",
"-",
"letter",
"language",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L537-L544 | train |
asaskevich/govalidator | validator.go | IsISO693Alpha3b | func IsISO693Alpha3b(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha3bCode {
return true
}
}
return false
} | go | func IsISO693Alpha3b(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha3bCode {
return true
}
}
return false
} | [
"func",
"IsISO693Alpha3b",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO693List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha3bCode",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsISO693Alpha3b checks if a string is valid three-letter language code | [
"IsISO693Alpha3b",
"checks",
"if",
"a",
"string",
"is",
"valid",
"three",
"-",
"letter",
"language",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L547-L554 | train |
asaskevich/govalidator | validator.go | IsPort | func IsPort(str string) bool {
if i, err := strconv.Atoi(str); err == nil && i > 0 && i < 65536 {
return true
}
return false
} | go | func IsPort(str string) bool {
if i, err := strconv.Atoi(str); err == nil && i > 0 && i < 65536 {
return true
}
return false
} | [
"func",
"IsPort",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"i",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"str",
")",
";",
"err",
"==",
"nil",
"&&",
"i",
">",
"0",
"&&",
"i",
"<",
"65536",
"{",
"return",
"true",
"\n",
"}",
"\n",
"re... | // IsPort checks if a string represents a valid port | [
"IsPort",
"checks",
"if",
"a",
"string",
"represents",
"a",
"valid",
"port"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L608-L613 | train |
asaskevich/govalidator | validator.go | IsIPv4 | func IsIPv4(str string) bool {
ip := net.ParseIP(str)
return ip != nil && strings.Contains(str, ".")
} | go | func IsIPv4(str string) bool {
ip := net.ParseIP(str)
return ip != nil && strings.Contains(str, ".")
} | [
"func",
"IsIPv4",
"(",
"str",
"string",
")",
"bool",
"{",
"ip",
":=",
"net",
".",
"ParseIP",
"(",
"str",
")",
"\n",
"return",
"ip",
"!=",
"nil",
"&&",
"strings",
".",
"Contains",
"(",
"str",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // IsIPv4 check if the string is an IP version 4. | [
"IsIPv4",
"check",
"if",
"the",
"string",
"is",
"an",
"IP",
"version",
"4",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L616-L619 | train |
asaskevich/govalidator | validator.go | IsRsaPublicKey | func IsRsaPublicKey(str string, keylen int) bool {
bb := bytes.NewBufferString(str)
pemBytes, err := ioutil.ReadAll(bb)
if err != nil {
return false
}
block, _ := pem.Decode(pemBytes)
if block != nil && block.Type != "PUBLIC KEY" {
return false
}
var der []byte
if block != nil {
der = block.Bytes
} els... | go | func IsRsaPublicKey(str string, keylen int) bool {
bb := bytes.NewBufferString(str)
pemBytes, err := ioutil.ReadAll(bb)
if err != nil {
return false
}
block, _ := pem.Decode(pemBytes)
if block != nil && block.Type != "PUBLIC KEY" {
return false
}
var der []byte
if block != nil {
der = block.Bytes
} els... | [
"func",
"IsRsaPublicKey",
"(",
"str",
"string",
",",
"keylen",
"int",
")",
"bool",
"{",
"bb",
":=",
"bytes",
".",
"NewBufferString",
"(",
"str",
")",
"\n",
"pemBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"bb",
")",
"\n",
"if",
"err",
"!=... | // IsRsaPublicKey check if a string is valid public key with provided length | [
"IsRsaPublicKey",
"check",
"if",
"a",
"string",
"is",
"valid",
"public",
"key",
"with",
"provided",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L667-L698 | train |
asaskevich/govalidator | validator.go | ValidateStruct | func ValidateStruct(s interface{}) (bool, error) {
if s == nil {
return true, nil
}
result := true
var err error
val := reflect.ValueOf(s)
if val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr {
val = val.Elem()
}
// we only accept structs
if val.Kind() != reflect.Struct {
return false, fmt.Err... | go | func ValidateStruct(s interface{}) (bool, error) {
if s == nil {
return true, nil
}
result := true
var err error
val := reflect.ValueOf(s)
if val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr {
val = val.Elem()
}
// we only accept structs
if val.Kind() != reflect.Struct {
return false, fmt.Err... | [
"func",
"ValidateStruct",
"(",
"s",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"result",
":=",
"true",
"\n",
"var",
"err",
"error",
"\n",
"val",
":=... | // ValidateStruct use tags for fields.
// result will be equal to `false` if there are any errors. | [
"ValidateStruct",
"use",
"tags",
"for",
"fields",
".",
"result",
"will",
"be",
"equal",
"to",
"false",
"if",
"there",
"are",
"any",
"errors",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L738-L804 | train |
asaskevich/govalidator | validator.go | IsSSN | func IsSSN(str string) bool {
if str == "" || len(str) != 11 {
return false
}
return rxSSN.MatchString(str)
} | go | func IsSSN(str string) bool {
if str == "" || len(str) != 11 {
return false
}
return rxSSN.MatchString(str)
} | [
"func",
"IsSSN",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"str",
"==",
"\"",
"\"",
"||",
"len",
"(",
"str",
")",
"!=",
"11",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"rxSSN",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // IsSSN will validate the given string as a U.S. Social Security Number | [
"IsSSN",
"will",
"validate",
"the",
"given",
"string",
"as",
"a",
"U",
".",
"S",
".",
"Social",
"Security",
"Number"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L847-L852 | train |
asaskevich/govalidator | validator.go | IsTime | func IsTime(str string, format string) bool {
_, err := time.Parse(format, str)
return err == nil
} | go | func IsTime(str string, format string) bool {
_, err := time.Parse(format, str)
return err == nil
} | [
"func",
"IsTime",
"(",
"str",
"string",
",",
"format",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"time",
".",
"Parse",
"(",
"format",
",",
"str",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"
] | // IsTime check if string is valid according to given format | [
"IsTime",
"check",
"if",
"string",
"is",
"valid",
"according",
"to",
"given",
"format"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L860-L863 | train |
asaskevich/govalidator | validator.go | IsISO4217 | func IsISO4217(str string) bool {
for _, currency := range ISO4217List {
if str == currency {
return true
}
}
return false
} | go | func IsISO4217(str string) bool {
for _, currency := range ISO4217List {
if str == currency {
return true
}
}
return false
} | [
"func",
"IsISO4217",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"currency",
":=",
"range",
"ISO4217List",
"{",
"if",
"str",
"==",
"currency",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // IsISO4217 check if string is valid ISO currency code | [
"IsISO4217",
"check",
"if",
"string",
"is",
"valid",
"ISO",
"currency",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L876-L884 | train |
asaskevich/govalidator | validator.go | ByteLength | func ByteLength(str string, params ...string) bool {
if len(params) == 2 {
min, _ := ToInt(params[0])
max, _ := ToInt(params[1])
return len(str) >= int(min) && len(str) <= int(max)
}
return false
} | go | func ByteLength(str string, params ...string) bool {
if len(params) == 2 {
min, _ := ToInt(params[0])
max, _ := ToInt(params[1])
return len(str) >= int(min) && len(str) <= int(max)
}
return false
} | [
"func",
"ByteLength",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"2",
"{",
"min",
",",
"_",
":=",
"ToInt",
"(",
"params",
"[",
"0",
"]",
")",
"\n",
"max",
",",
"_",
":=",
"ToIn... | // ByteLength check string's length | [
"ByteLength",
"check",
"string",
"s",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L887-L895 | train |
asaskevich/govalidator | validator.go | IsRsaPub | func IsRsaPub(str string, params ...string) bool {
if len(params) == 1 {
len, _ := ToInt(params[0])
return IsRsaPublicKey(str, int(len))
}
return false
} | go | func IsRsaPub(str string, params ...string) bool {
if len(params) == 1 {
len, _ := ToInt(params[0])
return IsRsaPublicKey(str, int(len))
}
return false
} | [
"func",
"IsRsaPub",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"1",
"{",
"len",
",",
"_",
":=",
"ToInt",
"(",
"params",
"[",
"0",
"]",
")",
"\n",
"return",
"IsRsaPublicKey",
"(",
... | // IsRsaPub check whether string is valid RSA key
// Alias for IsRsaPublicKey | [
"IsRsaPub",
"check",
"whether",
"string",
"is",
"valid",
"RSA",
"key",
"Alias",
"for",
"IsRsaPublicKey"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L905-L912 | train |
asaskevich/govalidator | validator.go | StringMatches | func StringMatches(s string, params ...string) bool {
if len(params) == 1 {
pattern := params[0]
return Matches(s, pattern)
}
return false
} | go | func StringMatches(s string, params ...string) bool {
if len(params) == 1 {
pattern := params[0]
return Matches(s, pattern)
}
return false
} | [
"func",
"StringMatches",
"(",
"s",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"1",
"{",
"pattern",
":=",
"params",
"[",
"0",
"]",
"\n",
"return",
"Matches",
"(",
"s",
",",
"pattern",
")",
"\n"... | // StringMatches checks if a string matches a given pattern. | [
"StringMatches",
"checks",
"if",
"a",
"string",
"matches",
"a",
"given",
"pattern",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L915-L921 | train |
asaskevich/govalidator | validator.go | Range | func Range(str string, params ...string) bool {
if len(params) == 2 {
value, _ := ToFloat(str)
min, _ := ToFloat(params[0])
max, _ := ToFloat(params[1])
return InRange(value, min, max)
}
return false
} | go | func Range(str string, params ...string) bool {
if len(params) == 2 {
value, _ := ToFloat(str)
min, _ := ToFloat(params[0])
max, _ := ToFloat(params[1])
return InRange(value, min, max)
}
return false
} | [
"func",
"Range",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"2",
"{",
"value",
",",
"_",
":=",
"ToFloat",
"(",
"str",
")",
"\n",
"min",
",",
"_",
":=",
"ToFloat",
"(",
"params",
... | // Range check string's length | [
"Range",
"check",
"string",
"s",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L937-L946 | train |
asaskevich/govalidator | validator.go | IsIn | func IsIn(str string, params ...string) bool {
for _, param := range params {
if str == param {
return true
}
}
return false
} | go | func IsIn(str string, params ...string) bool {
for _, param := range params {
if str == param {
return true
}
}
return false
} | [
"func",
"IsIn",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"param",
":=",
"range",
"params",
"{",
"if",
"str",
"==",
"param",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n"... | // IsIn check if string str is a member of the set of strings params | [
"IsIn",
"check",
"if",
"string",
"str",
"is",
"a",
"member",
"of",
"the",
"set",
"of",
"strings",
"params"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L961-L969 | train |
asaskevich/govalidator | validator.go | ErrorByField | func ErrorByField(e error, field string) string {
if e == nil {
return ""
}
return ErrorsByField(e)[field]
} | go | func ErrorByField(e error, field string) string {
if e == nil {
return ""
}
return ErrorsByField(e)[field]
} | [
"func",
"ErrorByField",
"(",
"e",
"error",
",",
"field",
"string",
")",
"string",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"ErrorsByField",
"(",
"e",
")",
"[",
"field",
"]",
"\n",
"}"
] | // ErrorByField returns error for specified field of the struct
// validated by ValidateStruct or empty string if there are no errors
// or this field doesn't exists or doesn't have any errors. | [
"ErrorByField",
"returns",
"error",
"for",
"specified",
"field",
"of",
"the",
"struct",
"validated",
"by",
"ValidateStruct",
"or",
"empty",
"string",
"if",
"there",
"are",
"no",
"errors",
"or",
"this",
"field",
"doesn",
"t",
"exists",
"or",
"doesn",
"t",
"ha... | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L1239-L1244 | train |
asaskevich/govalidator | validator.go | ErrorsByField | func ErrorsByField(e error) map[string]string {
m := make(map[string]string)
if e == nil {
return m
}
// prototype for ValidateStruct
switch e.(type) {
case Error:
m[e.(Error).Name] = e.(Error).Err.Error()
case Errors:
for _, item := range e.(Errors).Errors() {
n := ErrorsByField(item)
for k, v := r... | go | func ErrorsByField(e error) map[string]string {
m := make(map[string]string)
if e == nil {
return m
}
// prototype for ValidateStruct
switch e.(type) {
case Error:
m[e.(Error).Name] = e.(Error).Err.Error()
case Errors:
for _, item := range e.(Errors).Errors() {
n := ErrorsByField(item)
for k, v := r... | [
"func",
"ErrorsByField",
"(",
"e",
"error",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"if",
"e",
"==",
"nil",
"{",
"return",
"m",
"\n",
"}",
"\n",
"// prototype for Validate... | // ErrorsByField returns map of errors of the struct validated
// by ValidateStruct or empty map if there are no errors. | [
"ErrorsByField",
"returns",
"map",
"of",
"errors",
"of",
"the",
"struct",
"validated",
"by",
"ValidateStruct",
"or",
"empty",
"map",
"if",
"there",
"are",
"no",
"errors",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L1248-L1268 | train |
beego/bee | cmd/commands/dlv/dlv_amd64.go | buildDebug | func buildDebug() (string, error) {
args := []string{"-gcflags", "-N -l", "-o", "debug"}
args = append(args, utils.SplitQuotedFields("-ldflags='-linkmode internal'")...)
args = append(args, packageName)
if err := utils.GoCommand("build", args...); err != nil {
return "", err
}
fp, err := filepath.Abs("./debug"... | go | func buildDebug() (string, error) {
args := []string{"-gcflags", "-N -l", "-o", "debug"}
args = append(args, utils.SplitQuotedFields("-ldflags='-linkmode internal'")...)
args = append(args, packageName)
if err := utils.GoCommand("build", args...); err != nil {
return "", err
}
fp, err := filepath.Abs("./debug"... | [
"func",
"buildDebug",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"args",
"=",
"append",
"(",
"args",
",",
"utils",
".",
"Sp... | // buildDebug builds a debug binary in the current working directory | [
"buildDebug",
"builds",
"a",
"debug",
"binary",
"in",
"the",
"current",
"working",
"directory"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L86-L99 | train |
beego/bee | cmd/commands/dlv/dlv_amd64.go | loadPathsToWatch | func loadPathsToWatch(paths *[]string) error {
directory, err := os.Getwd()
if err != nil {
return err
}
filepath.Walk(directory, func(path string, info os.FileInfo, _ error) error {
if strings.HasSuffix(info.Name(), "docs") {
return filepath.SkipDir
}
if strings.HasSuffix(info.Name(), "swagger") {
re... | go | func loadPathsToWatch(paths *[]string) error {
directory, err := os.Getwd()
if err != nil {
return err
}
filepath.Walk(directory, func(path string, info os.FileInfo, _ error) error {
if strings.HasSuffix(info.Name(), "docs") {
return filepath.SkipDir
}
if strings.HasSuffix(info.Name(), "swagger") {
re... | [
"func",
"loadPathsToWatch",
"(",
"paths",
"*",
"[",
"]",
"string",
")",
"error",
"{",
"directory",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"filepath",
".",
"Walk",
"(",
... | // loadPathsToWatch loads the paths that needs to be watched for changes | [
"loadPathsToWatch",
"loads",
"the",
"paths",
"that",
"needs",
"to",
"be",
"watched",
"for",
"changes"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L102-L124 | train |
beego/bee | cmd/commands/dlv/dlv_amd64.go | startDelveDebugger | func startDelveDebugger(addr string, ch chan int) int {
beeLogger.Log.Info("Starting Delve Debugger...")
fp, err := buildDebug()
if err != nil {
beeLogger.Log.Fatalf("Error while building debug binary: %v", err)
}
defer os.Remove(fp)
abs, err := filepath.Abs("./debug")
if err != nil {
beeLogger.Log.Fatalf(... | go | func startDelveDebugger(addr string, ch chan int) int {
beeLogger.Log.Info("Starting Delve Debugger...")
fp, err := buildDebug()
if err != nil {
beeLogger.Log.Fatalf("Error while building debug binary: %v", err)
}
defer os.Remove(fp)
abs, err := filepath.Abs("./debug")
if err != nil {
beeLogger.Log.Fatalf(... | [
"func",
"startDelveDebugger",
"(",
"addr",
"string",
",",
"ch",
"chan",
"int",
")",
"int",
"{",
"beeLogger",
".",
"Log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"fp",
",",
"err",
":=",
"buildDebug",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // startDelveDebugger starts the Delve debugger server | [
"startDelveDebugger",
"starts",
"the",
"Delve",
"debugger",
"server"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L127-L189 | train |
beego/bee | cmd/commands/dlv/dlv_amd64.go | startWatcher | func startWatcher(paths []string, ch chan int) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
beeLogger.Log.Fatalf("Could not start the watcher: %v", err)
}
defer watcher.Close()
// Feed the paths to the watcher
for _, path := range paths {
if err := watcher.Add(path); err != nil {
beeLogger.Log.... | go | func startWatcher(paths []string, ch chan int) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
beeLogger.Log.Fatalf("Could not start the watcher: %v", err)
}
defer watcher.Close()
// Feed the paths to the watcher
for _, path := range paths {
if err := watcher.Add(path); err != nil {
beeLogger.Log.... | [
"func",
"startWatcher",
"(",
"paths",
"[",
"]",
"string",
",",
"ch",
"chan",
"int",
")",
"{",
"watcher",
",",
"err",
":=",
"fsnotify",
".",
"NewWatcher",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Fatalf",
"(",
"\... | // startWatcher starts the fsnotify watcher on the passed paths | [
"startWatcher",
"starts",
"the",
"fsnotify",
"watcher",
"on",
"the",
"passed",
"paths"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L194-L245 | train |
beego/bee | generate/swaggergen/g_docs.go | ParsePackagesFromDir | func ParsePackagesFromDir(dirpath string) {
c := make(chan error)
go func() {
filepath.Walk(dirpath, func(fpath string, fileInfo os.FileInfo, err error) error {
if err != nil {
return nil
}
if !fileInfo.IsDir() {
return nil
}
// skip folder if it's a 'vendor' folder within dirpath or its ch... | go | func ParsePackagesFromDir(dirpath string) {
c := make(chan error)
go func() {
filepath.Walk(dirpath, func(fpath string, fileInfo os.FileInfo, err error) error {
if err != nil {
return nil
}
if !fileInfo.IsDir() {
return nil
}
// skip folder if it's a 'vendor' folder within dirpath or its ch... | [
"func",
"ParsePackagesFromDir",
"(",
"dirpath",
"string",
")",
"{",
"c",
":=",
"make",
"(",
"chan",
"error",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"filepath",
".",
"Walk",
"(",
"dirpath",
",",
"func",
"(",
"fpath",
"string",
",",
"fileInfo",
"os",
... | // ParsePackagesFromDir parses packages from a given directory | [
"ParsePackagesFromDir",
"parses",
"packages",
"from",
"a",
"given",
"directory"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/swaggergen/g_docs.go#L106-L139 | train |
beego/bee | generate/swaggergen/g_docs.go | analyseNewNamespace | func analyseNewNamespace(ce *ast.CallExpr) (first string, others []ast.Expr) {
for i, p := range ce.Args {
if i == 0 {
switch pp := p.(type) {
case *ast.BasicLit:
first = strings.Trim(pp.Value, `"`)
}
continue
}
others = append(others, p)
}
return
} | go | func analyseNewNamespace(ce *ast.CallExpr) (first string, others []ast.Expr) {
for i, p := range ce.Args {
if i == 0 {
switch pp := p.(type) {
case *ast.BasicLit:
first = strings.Trim(pp.Value, `"`)
}
continue
}
others = append(others, p)
}
return
} | [
"func",
"analyseNewNamespace",
"(",
"ce",
"*",
"ast",
".",
"CallExpr",
")",
"(",
"first",
"string",
",",
"others",
"[",
"]",
"ast",
".",
"Expr",
")",
"{",
"for",
"i",
",",
"p",
":=",
"range",
"ce",
".",
"Args",
"{",
"if",
"i",
"==",
"0",
"{",
"... | // analyseNewNamespace returns version and the others params | [
"analyseNewNamespace",
"returns",
"version",
"and",
"the",
"others",
"params"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/swaggergen/g_docs.go#L347-L359 | train |
beego/bee | generate/g_appcode.go | String | func (tb *Table) String() string {
rv := fmt.Sprintf("type %s struct {\n", utils.CamelCase(tb.Name))
for _, v := range tb.Columns {
rv += v.String() + "\n"
}
rv += "}\n"
return rv
} | go | func (tb *Table) String() string {
rv := fmt.Sprintf("type %s struct {\n", utils.CamelCase(tb.Name))
for _, v := range tb.Columns {
rv += v.String() + "\n"
}
rv += "}\n"
return rv
} | [
"func",
"(",
"tb",
"*",
"Table",
")",
"String",
"(",
")",
"string",
"{",
"rv",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"utils",
".",
"CamelCase",
"(",
"tb",
".",
"Name",
")",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"... | // String returns the source code string for the Table struct | [
"String",
"returns",
"the",
"source",
"code",
"string",
"for",
"the",
"Table",
"struct"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L190-L197 | train |
beego/bee | generate/g_appcode.go | String | func (tag *OrmTag) String() string {
var ormOptions []string
if tag.Column != "" {
ormOptions = append(ormOptions, fmt.Sprintf("column(%s)", tag.Column))
}
if tag.Auto {
ormOptions = append(ormOptions, "auto")
}
if tag.Size != "" {
ormOptions = append(ormOptions, fmt.Sprintf("size(%s)", tag.Size))
}
if ta... | go | func (tag *OrmTag) String() string {
var ormOptions []string
if tag.Column != "" {
ormOptions = append(ormOptions, fmt.Sprintf("column(%s)", tag.Column))
}
if tag.Auto {
ormOptions = append(ormOptions, "auto")
}
if tag.Size != "" {
ormOptions = append(ormOptions, fmt.Sprintf("size(%s)", tag.Size))
}
if ta... | [
"func",
"(",
"tag",
"*",
"OrmTag",
")",
"String",
"(",
")",
"string",
"{",
"var",
"ormOptions",
"[",
"]",
"string",
"\n",
"if",
"tag",
".",
"Column",
"!=",
"\"",
"\"",
"{",
"ormOptions",
"=",
"append",
"(",
"ormOptions",
",",
"fmt",
".",
"Sprintf",
... | // String returns the ORM tag string for a column | [
"String",
"returns",
"the",
"ORM",
"tag",
"string",
"for",
"a",
"column"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L206-L264 | train |
beego/bee | generate/g_appcode.go | getTableObjects | func getTableObjects(tableNames []string, db *sql.DB, dbTransformer DbTransformer) (tables []*Table) {
// if a table has a composite pk or doesn't have pk, we can't use it yet
// these tables will be put into blacklist so that other struct will not
// reference it.
blackList := make(map[string]bool)
// process con... | go | func getTableObjects(tableNames []string, db *sql.DB, dbTransformer DbTransformer) (tables []*Table) {
// if a table has a composite pk or doesn't have pk, we can't use it yet
// these tables will be put into blacklist so that other struct will not
// reference it.
blackList := make(map[string]bool)
// process con... | [
"func",
"getTableObjects",
"(",
"tableNames",
"[",
"]",
"string",
",",
"db",
"*",
"sql",
".",
"DB",
",",
"dbTransformer",
"DbTransformer",
")",
"(",
"tables",
"[",
"]",
"*",
"Table",
")",
"{",
"// if a table has a composite pk or doesn't have pk, we can't use it yet... | // getTableObjects process each table name | [
"getTableObjects",
"process",
"each",
"table",
"name"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L345-L364 | train |
beego/bee | generate/g_appcode.go | GetGoDataType | func (*MysqlDB) GetGoDataType(sqlType string) (string, error) {
if v, ok := typeMappingMysql[sqlType]; ok {
return v, nil
}
return "", fmt.Errorf("data type '%s' not found", sqlType)
} | go | func (*MysqlDB) GetGoDataType(sqlType string) (string, error) {
if v, ok := typeMappingMysql[sqlType]; ok {
return v, nil
}
return "", fmt.Errorf("data type '%s' not found", sqlType)
} | [
"func",
"(",
"*",
"MysqlDB",
")",
"GetGoDataType",
"(",
"sqlType",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"v",
",",
"ok",
":=",
"typeMappingMysql",
"[",
"sqlType",
"]",
";",
"ok",
"{",
"return",
"v",
",",
"nil",
"\n",
"}",
"\n"... | // GetGoDataType maps an SQL data type to Golang data type | [
"GetGoDataType",
"maps",
"an",
"SQL",
"data",
"type",
"to",
"Golang",
"data",
"type"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L518-L523 | train |
beego/bee | generate/g_appcode.go | GetTableNames | func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string) {
rows, err := db.Query(`
SELECT table_name FROM information_schema.tables
WHERE table_catalog = current_database() AND
table_type = 'BASE TABLE' AND
table_schema NOT IN ('pg_catalog', 'information_schema')`)
if err != nil {
beeLogger.Log.Fatalf... | go | func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string) {
rows, err := db.Query(`
SELECT table_name FROM information_schema.tables
WHERE table_catalog = current_database() AND
table_type = 'BASE TABLE' AND
table_schema NOT IN ('pg_catalog', 'information_schema')`)
if err != nil {
beeLogger.Log.Fatalf... | [
"func",
"(",
"*",
"PostgresDB",
")",
"GetTableNames",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"tables",
"[",
"]",
"string",
")",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"`\n\t\tSELECT table_name FROM information_schema.tables\n\t\tWHERE tab... | // GetTableNames for PostgreSQL | [
"GetTableNames",
"for",
"PostgreSQL"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L526-L545 | train |
beego/bee | generate/g_appcode.go | GetConstraints | func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool) {
rows, err := db.Query(
`SELECT
c.constraint_type,
u.column_name,
cu.table_catalog AS referenced_table_catalog,
cu.table_name AS referenced_table_name,
cu.column_name AS referenced_column_name,
u.ordinal_positio... | go | func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool) {
rows, err := db.Query(
`SELECT
c.constraint_type,
u.column_name,
cu.table_catalog AS referenced_table_catalog,
cu.table_name AS referenced_table_name,
cu.column_name AS referenced_column_name,
u.ordinal_positio... | [
"func",
"(",
"*",
"PostgresDB",
")",
"GetConstraints",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"table",
"*",
"Table",
",",
"blackList",
"map",
"[",
"string",
"]",
"bool",
")",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"`SELECT\n\t\t\tc.c... | // GetConstraints for PostgreSQL | [
"GetConstraints",
"for",
"PostgreSQL"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L548-L601 | train |
beego/bee | generate/g_appcode.go | GetGoDataType | func (*PostgresDB) GetGoDataType(sqlType string) (string, error) {
if v, ok := typeMappingPostgres[sqlType]; ok {
return v, nil
}
return "", fmt.Errorf("data type '%s' not found", sqlType)
} | go | func (*PostgresDB) GetGoDataType(sqlType string) (string, error) {
if v, ok := typeMappingPostgres[sqlType]; ok {
return v, nil
}
return "", fmt.Errorf("data type '%s' not found", sqlType)
} | [
"func",
"(",
"*",
"PostgresDB",
")",
"GetGoDataType",
"(",
"sqlType",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"v",
",",
"ok",
":=",
"typeMappingPostgres",
"[",
"sqlType",
"]",
";",
"ok",
"{",
"return",
"v",
",",
"nil",
"\n",
"}",
... | // GetGoDataType returns the Go type from the mapped Postgres type | [
"GetGoDataType",
"returns",
"the",
"Go",
"type",
"from",
"the",
"mapped",
"Postgres",
"type"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L708-L713 | train |
beego/bee | generate/g_appcode.go | createPaths | func createPaths(mode byte, paths *MvcPath) {
if (mode & OModel) == OModel {
os.Mkdir(paths.ModelPath, 0777)
}
if (mode & OController) == OController {
os.Mkdir(paths.ControllerPath, 0777)
}
if (mode & ORouter) == ORouter {
os.Mkdir(paths.RouterPath, 0777)
}
} | go | func createPaths(mode byte, paths *MvcPath) {
if (mode & OModel) == OModel {
os.Mkdir(paths.ModelPath, 0777)
}
if (mode & OController) == OController {
os.Mkdir(paths.ControllerPath, 0777)
}
if (mode & ORouter) == ORouter {
os.Mkdir(paths.RouterPath, 0777)
}
} | [
"func",
"createPaths",
"(",
"mode",
"byte",
",",
"paths",
"*",
"MvcPath",
")",
"{",
"if",
"(",
"mode",
"&",
"OModel",
")",
"==",
"OModel",
"{",
"os",
".",
"Mkdir",
"(",
"paths",
".",
"ModelPath",
",",
"0777",
")",
"\n",
"}",
"\n",
"if",
"(",
"mod... | // deleteAndRecreatePaths removes several directories completely | [
"deleteAndRecreatePaths",
"removes",
"several",
"directories",
"completely"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L716-L726 | train |
beego/bee | generate/g_appcode.go | writeModelFiles | func writeModelFiles(tables []*Table, mPath string) {
w := colors.NewColorWriter(os.Stdout)
for _, tb := range tables {
filename := getFileName(tb.Name)
fpath := path.Join(mPath, filename+".go")
var f *os.File
var err error
if utils.IsExist(fpath) {
beeLogger.Log.Warnf("'%s' already exists. Do you want ... | go | func writeModelFiles(tables []*Table, mPath string) {
w := colors.NewColorWriter(os.Stdout)
for _, tb := range tables {
filename := getFileName(tb.Name)
fpath := path.Join(mPath, filename+".go")
var f *os.File
var err error
if utils.IsExist(fpath) {
beeLogger.Log.Warnf("'%s' already exists. Do you want ... | [
"func",
"writeModelFiles",
"(",
"tables",
"[",
"]",
"*",
"Table",
",",
"mPath",
"string",
")",
"{",
"w",
":=",
"colors",
".",
"NewColorWriter",
"(",
"os",
".",
"Stdout",
")",
"\n\n",
"for",
"_",
",",
"tb",
":=",
"range",
"tables",
"{",
"filename",
":... | // writeModelFiles generates model files | [
"writeModelFiles",
"generates",
"model",
"files"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L747-L800 | train |
beego/bee | generate/g_appcode.go | writeControllerFiles | func writeControllerFiles(tables []*Table, cPath string, pkgPath string) {
w := colors.NewColorWriter(os.Stdout)
for _, tb := range tables {
if tb.Pk == "" {
continue
}
filename := getFileName(tb.Name)
fpath := path.Join(cPath, filename+".go")
var f *os.File
var err error
if utils.IsExist(fpath) {
... | go | func writeControllerFiles(tables []*Table, cPath string, pkgPath string) {
w := colors.NewColorWriter(os.Stdout)
for _, tb := range tables {
if tb.Pk == "" {
continue
}
filename := getFileName(tb.Name)
fpath := path.Join(cPath, filename+".go")
var f *os.File
var err error
if utils.IsExist(fpath) {
... | [
"func",
"writeControllerFiles",
"(",
"tables",
"[",
"]",
"*",
"Table",
",",
"cPath",
"string",
",",
"pkgPath",
"string",
")",
"{",
"w",
":=",
"colors",
".",
"NewColorWriter",
"(",
"os",
".",
"Stdout",
")",
"\n\n",
"for",
"_",
",",
"tb",
":=",
"range",
... | // writeControllerFiles generates controller files | [
"writeControllerFiles",
"generates",
"controller",
"files"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L803-L842 | train |
beego/bee | generate/g_appcode.go | writeRouterFile | func writeRouterFile(tables []*Table, rPath string, pkgPath string) {
w := colors.NewColorWriter(os.Stdout)
var nameSpaces []string
for _, tb := range tables {
if tb.Pk == "" {
continue
}
// Add namespaces
nameSpace := strings.Replace(NamespaceTPL, "{{nameSpace}}", tb.Name, -1)
nameSpace = strings.Repl... | go | func writeRouterFile(tables []*Table, rPath string, pkgPath string) {
w := colors.NewColorWriter(os.Stdout)
var nameSpaces []string
for _, tb := range tables {
if tb.Pk == "" {
continue
}
// Add namespaces
nameSpace := strings.Replace(NamespaceTPL, "{{nameSpace}}", tb.Name, -1)
nameSpace = strings.Repl... | [
"func",
"writeRouterFile",
"(",
"tables",
"[",
"]",
"*",
"Table",
",",
"rPath",
"string",
",",
"pkgPath",
"string",
")",
"{",
"w",
":=",
"colors",
".",
"NewColorWriter",
"(",
"os",
".",
"Stdout",
")",
"\n\n",
"var",
"nameSpaces",
"[",
"]",
"string",
"\... | // writeRouterFile generates router file | [
"writeRouterFile",
"generates",
"router",
"file"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/g_appcode.go#L845-L889 | train |
beego/bee | cmd/commands/version/banner.go | InitBanner | func InitBanner(out io.Writer, in io.Reader) {
if in == nil {
beeLogger.Log.Fatal("The input is nil")
}
banner, err := ioutil.ReadAll(in)
if err != nil {
beeLogger.Log.Fatalf("Error while trying to read the banner: %s", err)
}
show(out, string(banner))
} | go | func InitBanner(out io.Writer, in io.Reader) {
if in == nil {
beeLogger.Log.Fatal("The input is nil")
}
banner, err := ioutil.ReadAll(in)
if err != nil {
beeLogger.Log.Fatalf("Error while trying to read the banner: %s", err)
}
show(out, string(banner))
} | [
"func",
"InitBanner",
"(",
"out",
"io",
".",
"Writer",
",",
"in",
"io",
".",
"Reader",
")",
"{",
"if",
"in",
"==",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"banner",
",",
"err",
":=",
"ioutil",
... | // InitBanner loads the banner and prints it to output
// All errors are ignored, the application will not
// print the banner in case of error. | [
"InitBanner",
"loads",
"the",
"banner",
"and",
"prints",
"it",
"to",
"output",
"All",
"errors",
"are",
"ignored",
"the",
"application",
"will",
"not",
"print",
"the",
"banner",
"in",
"case",
"of",
"error",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/version/banner.go#L31-L42 | train |
beego/bee | cmd/commands/command.go | Out | func (c *Command) Out() io.Writer {
if c.output != nil {
return *c.output
}
return colors.NewColorWriter(os.Stderr)
} | go | func (c *Command) Out() io.Writer {
if c.output != nil {
return *c.output
}
return colors.NewColorWriter(os.Stderr)
} | [
"func",
"(",
"c",
"*",
"Command",
")",
"Out",
"(",
")",
"io",
".",
"Writer",
"{",
"if",
"c",
".",
"output",
"!=",
"nil",
"{",
"return",
"*",
"c",
".",
"output",
"\n",
"}",
"\n",
"return",
"colors",
".",
"NewColorWriter",
"(",
"os",
".",
"Stderr",... | // Out returns the out writer of the current command.
// If cmd.output is nil, os.Stderr is used. | [
"Out",
"returns",
"the",
"out",
"writer",
"of",
"the",
"current",
"command",
".",
"If",
"cmd",
".",
"output",
"is",
"nil",
"os",
".",
"Stderr",
"is",
"used",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/command.go#L64-L69 | train |
beego/bee | cmd/commands/run/reload.go | readPump | func (c *wsClient) readPump() {
defer func() {
c.broker.unregister <- c
c.conn.Close()
}()
for {
_, _, err := c.conn.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
beeLogger.Log.Errorf("An error happened when reading from the Websocket client: %v", ... | go | func (c *wsClient) readPump() {
defer func() {
c.broker.unregister <- c
c.conn.Close()
}()
for {
_, _, err := c.conn.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
beeLogger.Log.Errorf("An error happened when reading from the Websocket client: %v", ... | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"readPump",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"c",
".",
"broker",
".",
"unregister",
"<-",
"c",
"\n",
"c",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n\n",
"for",
"{",
"_",... | // readPump pumps messages from the websocket connection to the broker. | [
"readPump",
"pumps",
"messages",
"from",
"the",
"websocket",
"connection",
"to",
"the",
"broker",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/reload.go#L64-L79 | train |
beego/bee | cmd/commands/run/reload.go | handleWsRequest | func handleWsRequest(broker *wsBroker, w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
beeLogger.Log.Errorf("error while upgrading server connection: %v", err)
return
}
client := &wsClient{
broker: broker,
conn: conn,
send: make(chan []byte, 256),
}... | go | func handleWsRequest(broker *wsBroker, w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
beeLogger.Log.Errorf("error while upgrading server connection: %v", err)
return
}
client := &wsClient{
broker: broker,
conn: conn,
send: make(chan []byte, 256),
}... | [
"func",
"handleWsRequest",
"(",
"broker",
"*",
"wsBroker",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"conn",
",",
"err",
":=",
"upgrader",
".",
"Upgrade",
"(",
"w",
",",
"r",
",",
"nil",
")",
"\n",
"i... | // handleWsRequest handles websocket requests from the peer. | [
"handleWsRequest",
"handles",
"websocket",
"requests",
"from",
"the",
"peer",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/reload.go#L176-L192 | train |
beego/bee | config/conf.go | LoadConfig | func LoadConfig() {
currentPath, err := os.Getwd()
if err != nil {
beeLogger.Log.Error(err.Error())
}
dir, err := os.Open(currentPath)
if err != nil {
beeLogger.Log.Error(err.Error())
}
defer dir.Close()
files, err := dir.Readdir(-1)
if err != nil {
beeLogger.Log.Error(err.Error())
}
for _, file := ... | go | func LoadConfig() {
currentPath, err := os.Getwd()
if err != nil {
beeLogger.Log.Error(err.Error())
}
dir, err := os.Open(currentPath)
if err != nil {
beeLogger.Log.Error(err.Error())
}
defer dir.Close()
files, err := dir.Readdir(-1)
if err != nil {
beeLogger.Log.Error(err.Error())
}
for _, file := ... | [
"func",
"LoadConfig",
"(",
")",
"{",
"currentPath",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n\n",
"dir",
"... | // LoadConfig loads the bee tool configuration.
// It looks for Beefile or bee.json in the current path,
// and falls back to default configuration in case not found. | [
"LoadConfig",
"loads",
"the",
"bee",
"tool",
"configuration",
".",
"It",
"looks",
"for",
"Beefile",
"or",
"bee",
".",
"json",
"in",
"the",
"current",
"path",
"and",
"falls",
"back",
"to",
"default",
"configuration",
"in",
"case",
"not",
"found",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/config/conf.go#L86-L138 | train |
beego/bee | utils/utils.go | IsInGOPATH | func IsInGOPATH(thePath string) bool {
for _, gopath := range GetGOPATHs() {
if strings.Contains(thePath, filepath.Join(gopath, "src")) {
return true
}
}
return false
} | go | func IsInGOPATH(thePath string) bool {
for _, gopath := range GetGOPATHs() {
if strings.Contains(thePath, filepath.Join(gopath, "src")) {
return true
}
}
return false
} | [
"func",
"IsInGOPATH",
"(",
"thePath",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"gopath",
":=",
"range",
"GetGOPATHs",
"(",
")",
"{",
"if",
"strings",
".",
"Contains",
"(",
"thePath",
",",
"filepath",
".",
"Join",
"(",
"gopath",
",",
"\"",
"\"",
"... | // IsInGOPATH checks whether the path is inside of any GOPATH or not | [
"IsInGOPATH",
"checks",
"whether",
"the",
"path",
"is",
"inside",
"of",
"any",
"GOPATH",
"or",
"not"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L62-L69 | train |
beego/bee | utils/utils.go | IsBeegoProject | func IsBeegoProject(thePath string) bool {
mainFiles := []string{}
hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`)
c := make(chan error)
// Walk the application path tree to look for main files.
// Main files must satisfy the 'hasBeegoRegex' regul... | go | func IsBeegoProject(thePath string) bool {
mainFiles := []string{}
hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`)
c := make(chan error)
// Walk the application path tree to look for main files.
// Main files must satisfy the 'hasBeegoRegex' regul... | [
"func",
"IsBeegoProject",
"(",
"thePath",
"string",
")",
"bool",
"{",
"mainFiles",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"hasBeegoRegex",
":=",
"regexp",
".",
"MustCompile",
"(",
"`(?s)package main.*?import.*?\\(.*?github.com/astaxie/beego\".*?\\).*func main()`",
")... | // IsBeegoProject checks whether the current path is a Beego application or not | [
"IsBeegoProject",
"checks",
"whether",
"the",
"current",
"path",
"is",
"a",
"Beego",
"application",
"or",
"not"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L72-L109 | train |
beego/bee | utils/utils.go | SnakeString | func SnakeString(s string) string {
data := make([]byte, 0, len(s)*2)
j := false
num := len(s)
for i := 0; i < num; i++ {
d := s[i]
if i > 0 && d >= 'A' && d <= 'Z' && j {
data = append(data, '_')
}
if d != '_' {
j = true
}
data = append(data, d)
}
return strings.ToLower(string(data[:]))
} | go | func SnakeString(s string) string {
data := make([]byte, 0, len(s)*2)
j := false
num := len(s)
for i := 0; i < num; i++ {
d := s[i]
if i > 0 && d >= 'A' && d <= 'Z' && j {
data = append(data, '_')
}
if d != '_' {
j = true
}
data = append(data, d)
}
return strings.ToLower(string(data[:]))
} | [
"func",
"SnakeString",
"(",
"s",
"string",
")",
"string",
"{",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"len",
"(",
"s",
")",
"*",
"2",
")",
"\n",
"j",
":=",
"false",
"\n",
"num",
":=",
"len",
"(",
"s",
")",
"\n",
"for",
... | // snake string, XxYy to xx_yy | [
"snake",
"string",
"XxYy",
"to",
"xx_yy"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L170-L185 | train |
beego/bee | utils/utils.go | FormatSourceCode | func FormatSourceCode(filename string) {
cmd := exec.Command("gofmt", "-w", filename)
if err := cmd.Run(); err != nil {
beeLogger.Log.Warnf("Error while running gofmt: %s", err)
}
} | go | func FormatSourceCode(filename string) {
cmd := exec.Command("gofmt", "-w", filename)
if err := cmd.Run(); err != nil {
beeLogger.Log.Warnf("Error while running gofmt: %s", err)
}
} | [
"func",
"FormatSourceCode",
"(",
"filename",
"string",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"filename",
")",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Run",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"bee... | // formatSourceCode formats source files | [
"formatSourceCode",
"formats",
"source",
"files"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L222-L227 | train |
beego/bee | utils/utils.go | WriteToFile | func WriteToFile(filename, content string) {
f, err := os.Create(filename)
MustCheck(err)
defer CloseFile(f)
_, err = f.WriteString(content)
MustCheck(err)
} | go | func WriteToFile(filename, content string) {
f, err := os.Create(filename)
MustCheck(err)
defer CloseFile(f)
_, err = f.WriteString(content)
MustCheck(err)
} | [
"func",
"WriteToFile",
"(",
"filename",
",",
"content",
"string",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"filename",
")",
"\n",
"MustCheck",
"(",
"err",
")",
"\n",
"defer",
"CloseFile",
"(",
"f",
")",
"\n",
"_",
",",
"err",
"=",... | // WriteToFile creates a file and writes content to it | [
"WriteToFile",
"creates",
"a",
"file",
"and",
"writes",
"content",
"to",
"it"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L244-L250 | train |
beego/bee | utils/utils.go | BeeFuncMap | func BeeFuncMap() template.FuncMap {
return template.FuncMap{
"trim": strings.TrimSpace,
"bold": colors.Bold,
"headline": colors.MagentaBold,
"foldername": colors.RedBold,
"endline": EndLine,
"tmpltostr": TmplToString,
}
} | go | func BeeFuncMap() template.FuncMap {
return template.FuncMap{
"trim": strings.TrimSpace,
"bold": colors.Bold,
"headline": colors.MagentaBold,
"foldername": colors.RedBold,
"endline": EndLine,
"tmpltostr": TmplToString,
}
} | [
"func",
"BeeFuncMap",
"(",
")",
"template",
".",
"FuncMap",
"{",
"return",
"template",
".",
"FuncMap",
"{",
"\"",
"\"",
":",
"strings",
".",
"TrimSpace",
",",
"\"",
"\"",
":",
"colors",
".",
"Bold",
",",
"\"",
"\"",
":",
"colors",
".",
"MagentaBold",
... | // BeeFuncMap returns a FuncMap of functions used in different templates. | [
"BeeFuncMap",
"returns",
"a",
"FuncMap",
"of",
"functions",
"used",
"in",
"different",
"templates",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L265-L274 | train |
beego/bee | utils/utils.go | TmplToString | func TmplToString(tmpl string, data interface{}) string {
t := template.New("tmpl").Funcs(BeeFuncMap())
template.Must(t.Parse(tmpl))
var doc bytes.Buffer
err := t.Execute(&doc, data)
MustCheck(err)
return doc.String()
} | go | func TmplToString(tmpl string, data interface{}) string {
t := template.New("tmpl").Funcs(BeeFuncMap())
template.Must(t.Parse(tmpl))
var doc bytes.Buffer
err := t.Execute(&doc, data)
MustCheck(err)
return doc.String()
} | [
"func",
"TmplToString",
"(",
"tmpl",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"string",
"{",
"t",
":=",
"template",
".",
"New",
"(",
"\"",
"\"",
")",
".",
"Funcs",
"(",
"BeeFuncMap",
"(",
")",
")",
"\n",
"template",
".",
"Must",
"(",
"t",... | // TmplToString parses a text template and return the result as a string. | [
"TmplToString",
"parses",
"a",
"text",
"template",
"and",
"return",
"the",
"result",
"as",
"a",
"string",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L277-L286 | train |
beego/bee | utils/utils.go | GetFileModTime | func GetFileModTime(path string) int64 {
path = strings.Replace(path, "\\", "/", -1)
f, err := os.Open(path)
if err != nil {
beeLogger.Log.Errorf("Failed to open file on '%s': %s", path, err)
return time.Now().Unix()
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
beeLogger.Log.Errorf("Failed to get... | go | func GetFileModTime(path string) int64 {
path = strings.Replace(path, "\\", "/", -1)
f, err := os.Open(path)
if err != nil {
beeLogger.Log.Errorf("Failed to open file on '%s': %s", path, err)
return time.Now().Unix()
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
beeLogger.Log.Errorf("Failed to get... | [
"func",
"GetFileModTime",
"(",
"path",
"string",
")",
"int64",
"{",
"path",
"=",
"strings",
".",
"Replace",
"(",
"path",
",",
"\"",
"\\\\",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
... | // GetFileModTime returns unix timestamp of `os.File.ModTime` for the given path. | [
"GetFileModTime",
"returns",
"unix",
"timestamp",
"of",
"os",
".",
"File",
".",
"ModTime",
"for",
"the",
"given",
"path",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/utils/utils.go#L411-L427 | train |
beego/bee | cmd/commands/migrate/migrate.go | RunMigration | func RunMigration(cmd *commands.Command, args []string) int {
currpath, _ := os.Getwd()
gps := utils.GetGOPATHs()
if len(gps) == 0 {
beeLogger.Log.Fatal("GOPATH environment variable is not set or empty")
}
gopath := gps[0]
beeLogger.Log.Debugf("GOPATH: %s", utils.FILE(), utils.LINE(), gopath)
// Getting co... | go | func RunMigration(cmd *commands.Command, args []string) int {
currpath, _ := os.Getwd()
gps := utils.GetGOPATHs()
if len(gps) == 0 {
beeLogger.Log.Fatal("GOPATH environment variable is not set or empty")
}
gopath := gps[0]
beeLogger.Log.Debugf("GOPATH: %s", utils.FILE(), utils.LINE(), gopath)
// Getting co... | [
"func",
"RunMigration",
"(",
"cmd",
"*",
"commands",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"int",
"{",
"currpath",
",",
"_",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n\n",
"gps",
":=",
"utils",
".",
"GetGOPATHs",
"(",
")",
"\n",
"if",
... | // runMigration is the entry point for starting a migration | [
"runMigration",
"is",
"the",
"entry",
"point",
"for",
"starting",
"a",
"migration"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L71-L140 | train |
beego/bee | cmd/commands/migrate/migrate.go | migrate | func migrate(goal, currpath, driver, connStr, dir string) {
if dir == "" {
dir = path.Join(currpath, "database", "migrations")
}
postfix := ""
if runtime.GOOS == "windows" {
postfix = ".exe"
}
binary := "m" + postfix
source := binary + ".go"
// Connect to database
db, err := sql.Open(driver, connStr)
if ... | go | func migrate(goal, currpath, driver, connStr, dir string) {
if dir == "" {
dir = path.Join(currpath, "database", "migrations")
}
postfix := ""
if runtime.GOOS == "windows" {
postfix = ".exe"
}
binary := "m" + postfix
source := binary + ".go"
// Connect to database
db, err := sql.Open(driver, connStr)
if ... | [
"func",
"migrate",
"(",
"goal",
",",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
"string",
")",
"{",
"if",
"dir",
"==",
"\"",
"\"",
"{",
"dir",
"=",
"path",
".",
"Join",
"(",
"currpath",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"... | // migrate generates source code, build it, and invoke the binary who does the actual migration | [
"migrate",
"generates",
"source",
"code",
"build",
"it",
"and",
"invoke",
"the",
"binary",
"who",
"does",
"the",
"actual",
"migration"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L143-L168 | train |
beego/bee | cmd/commands/migrate/migrate.go | checkForSchemaUpdateTable | func checkForSchemaUpdateTable(db *sql.DB, driver string) {
showTableSQL := showMigrationsTableSQL(driver)
if rows, err := db.Query(showTableSQL); err != nil {
beeLogger.Log.Fatalf("Could not show migrations table: %s", err)
} else if !rows.Next() {
// No migrations table, create new ones
createTableSQL := cre... | go | func checkForSchemaUpdateTable(db *sql.DB, driver string) {
showTableSQL := showMigrationsTableSQL(driver)
if rows, err := db.Query(showTableSQL); err != nil {
beeLogger.Log.Fatalf("Could not show migrations table: %s", err)
} else if !rows.Next() {
// No migrations table, create new ones
createTableSQL := cre... | [
"func",
"checkForSchemaUpdateTable",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"driver",
"string",
")",
"{",
"showTableSQL",
":=",
"showMigrationsTableSQL",
"(",
"driver",
")",
"\n",
"if",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"showTableSQL",
")"... | // checkForSchemaUpdateTable checks the existence of migrations table.
// It checks for the proper table structures and creates the table using MYSQL_MIGRATION_DDL if it does not exist. | [
"checkForSchemaUpdateTable",
"checks",
"the",
"existence",
"of",
"migrations",
"table",
".",
"It",
"checks",
"for",
"the",
"proper",
"table",
"structures",
"and",
"creates",
"the",
"table",
"using",
"MYSQL_MIGRATION_DDL",
"if",
"it",
"does",
"not",
"exist",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L172-L217 | train |
beego/bee | cmd/commands/migrate/migrate.go | writeMigrationSourceFile | func writeMigrationSourceFile(dir, source, driver, connStr string, latestTime int64, latestName string, task string) {
changeDir(dir)
if f, err := os.OpenFile(source, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err != nil {
beeLogger.Log.Fatalf("Could not create file: %s", err)
} else {
content := strings.Replace(Mi... | go | func writeMigrationSourceFile(dir, source, driver, connStr string, latestTime int64, latestName string, task string) {
changeDir(dir)
if f, err := os.OpenFile(source, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err != nil {
beeLogger.Log.Fatalf("Could not create file: %s", err)
} else {
content := strings.Replace(Mi... | [
"func",
"writeMigrationSourceFile",
"(",
"dir",
",",
"source",
",",
"driver",
",",
"connStr",
"string",
",",
"latestTime",
"int64",
",",
"latestName",
"string",
",",
"task",
"string",
")",
"{",
"changeDir",
"(",
"dir",
")",
"\n",
"if",
"f",
",",
"err",
"... | // writeMigrationSourceFile create the source file based on MIGRATION_MAIN_TPL | [
"writeMigrationSourceFile",
"create",
"the",
"source",
"file",
"based",
"on",
"MIGRATION_MAIN_TPL"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L291-L307 | train |
beego/bee | cmd/commands/migrate/migrate.go | changeDir | func changeDir(dir string) {
if err := os.Chdir(dir); err != nil {
beeLogger.Log.Fatalf("Could not find migration directory: %s", err)
}
} | go | func changeDir(dir string) {
if err := os.Chdir(dir); err != nil {
beeLogger.Log.Fatalf("Could not find migration directory: %s", err)
}
} | [
"func",
"changeDir",
"(",
"dir",
"string",
")",
"{",
"if",
"err",
":=",
"os",
".",
"Chdir",
"(",
"dir",
")",
";",
"err",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // changeDir changes working directory to dir.
// It exits the system when encouter an error | [
"changeDir",
"changes",
"working",
"directory",
"to",
"dir",
".",
"It",
"exits",
"the",
"system",
"when",
"encouter",
"an",
"error"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L339-L343 | train |
beego/bee | cmd/commands/migrate/migrate.go | removeTempFile | func removeTempFile(dir, file string) {
changeDir(dir)
if err := os.Remove(file); err != nil {
beeLogger.Log.Warnf("Could not remove temporary file: %s", err)
}
} | go | func removeTempFile(dir, file string) {
changeDir(dir)
if err := os.Remove(file); err != nil {
beeLogger.Log.Warnf("Could not remove temporary file: %s", err)
}
} | [
"func",
"removeTempFile",
"(",
"dir",
",",
"file",
"string",
")",
"{",
"changeDir",
"(",
"dir",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"Remove",
"(",
"file",
")",
";",
"err",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Warnf",
"(",
"\"",
"... | // removeTempFile removes a file in dir | [
"removeTempFile",
"removes",
"a",
"file",
"in",
"dir"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L346-L351 | train |
beego/bee | cmd/commands/migrate/migrate.go | formatShellErrOutput | func formatShellErrOutput(o string) {
for _, line := range strings.Split(o, "\n") {
if line != "" {
beeLogger.Log.Errorf("|> %s", line)
}
}
} | go | func formatShellErrOutput(o string) {
for _, line := range strings.Split(o, "\n") {
if line != "" {
beeLogger.Log.Errorf("|> %s", line)
}
}
} | [
"func",
"formatShellErrOutput",
"(",
"o",
"string",
")",
"{",
"for",
"_",
",",
"line",
":=",
"range",
"strings",
".",
"Split",
"(",
"o",
",",
"\"",
"\\n",
"\"",
")",
"{",
"if",
"line",
"!=",
"\"",
"\"",
"{",
"beeLogger",
".",
"Log",
".",
"Errorf",
... | // formatShellErrOutput formats the error shell output | [
"formatShellErrOutput",
"formats",
"the",
"error",
"shell",
"output"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L354-L360 | train |
beego/bee | cmd/commands/migrate/migrate.go | formatShellOutput | func formatShellOutput(o string) {
for _, line := range strings.Split(o, "\n") {
if line != "" {
beeLogger.Log.Infof("|> %s", line)
}
}
} | go | func formatShellOutput(o string) {
for _, line := range strings.Split(o, "\n") {
if line != "" {
beeLogger.Log.Infof("|> %s", line)
}
}
} | [
"func",
"formatShellOutput",
"(",
"o",
"string",
")",
"{",
"for",
"_",
",",
"line",
":=",
"range",
"strings",
".",
"Split",
"(",
"o",
",",
"\"",
"\\n",
"\"",
")",
"{",
"if",
"line",
"!=",
"\"",
"\"",
"{",
"beeLogger",
".",
"Log",
".",
"Infof",
"(... | // formatShellOutput formats the normal shell output | [
"formatShellOutput",
"formats",
"the",
"normal",
"shell",
"output"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L363-L369 | train |
beego/bee | cmd/commands/migrate/migrate.go | MigrateUpdate | func MigrateUpdate(currpath, driver, connStr, dir string) {
migrate("upgrade", currpath, driver, connStr, dir)
} | go | func MigrateUpdate(currpath, driver, connStr, dir string) {
migrate("upgrade", currpath, driver, connStr, dir)
} | [
"func",
"MigrateUpdate",
"(",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
"string",
")",
"{",
"migrate",
"(",
"\"",
"\"",
",",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
")",
"\n",
"}"
] | // MigrateUpdate does the schema update | [
"MigrateUpdate",
"does",
"the",
"schema",
"update"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L438-L440 | train |
beego/bee | cmd/commands/migrate/migrate.go | MigrateRollback | func MigrateRollback(currpath, driver, connStr, dir string) {
migrate("rollback", currpath, driver, connStr, dir)
} | go | func MigrateRollback(currpath, driver, connStr, dir string) {
migrate("rollback", currpath, driver, connStr, dir)
} | [
"func",
"MigrateRollback",
"(",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
"string",
")",
"{",
"migrate",
"(",
"\"",
"\"",
",",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
")",
"\n",
"}"
] | // MigrateRollback rolls back the latest migration | [
"MigrateRollback",
"rolls",
"back",
"the",
"latest",
"migration"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L443-L445 | train |
beego/bee | cmd/commands/migrate/migrate.go | MigrateReset | func MigrateReset(currpath, driver, connStr, dir string) {
migrate("reset", currpath, driver, connStr, dir)
} | go | func MigrateReset(currpath, driver, connStr, dir string) {
migrate("reset", currpath, driver, connStr, dir)
} | [
"func",
"MigrateReset",
"(",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
"string",
")",
"{",
"migrate",
"(",
"\"",
"\"",
",",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
")",
"\n",
"}"
] | // MigrateReset rolls back all migrations | [
"MigrateReset",
"rolls",
"back",
"all",
"migrations"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L448-L450 | train |
beego/bee | cmd/commands/migrate/migrate.go | MigrateRefresh | func MigrateRefresh(currpath, driver, connStr, dir string) {
migrate("refresh", currpath, driver, connStr, dir)
} | go | func MigrateRefresh(currpath, driver, connStr, dir string) {
migrate("refresh", currpath, driver, connStr, dir)
} | [
"func",
"MigrateRefresh",
"(",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
"string",
")",
"{",
"migrate",
"(",
"\"",
"\"",
",",
"currpath",
",",
"driver",
",",
"connStr",
",",
"dir",
")",
"\n",
"}"
] | // MigrateRefresh rolls back all migrations and start over again | [
"MigrateRefresh",
"rolls",
"back",
"all",
"migrations",
"and",
"start",
"over",
"again"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/migrate/migrate.go#L453-L455 | train |
beego/bee | cmd/commands/run/run.go | isExcluded | func isExcluded(filePath string) bool {
for _, p := range excludedPaths {
absP, err := path.Abs(p)
if err != nil {
beeLogger.Log.Errorf("Cannot get absolute path of '%s'", p)
continue
}
absFilePath, err := path.Abs(filePath)
if err != nil {
beeLogger.Log.Errorf("Cannot get absolute path of '%s'", fi... | go | func isExcluded(filePath string) bool {
for _, p := range excludedPaths {
absP, err := path.Abs(p)
if err != nil {
beeLogger.Log.Errorf("Cannot get absolute path of '%s'", p)
continue
}
absFilePath, err := path.Abs(filePath)
if err != nil {
beeLogger.Log.Errorf("Cannot get absolute path of '%s'", fi... | [
"func",
"isExcluded",
"(",
"filePath",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"excludedPaths",
"{",
"absP",
",",
"err",
":=",
"path",
".",
"Abs",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",... | // If a file is excluded | [
"If",
"a",
"file",
"is",
"excluded"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/run.go#L235-L253 | train |
beego/bee | logger/colors/color.go | NewModeColorWriter | func NewModeColorWriter(w io.Writer, mode outputMode) io.Writer {
if _, ok := w.(*colorWriter); !ok {
return &colorWriter{
w: w,
mode: mode,
}
}
return w
} | go | func NewModeColorWriter(w io.Writer, mode outputMode) io.Writer {
if _, ok := w.(*colorWriter); !ok {
return &colorWriter{
w: w,
mode: mode,
}
}
return w
} | [
"func",
"NewModeColorWriter",
"(",
"w",
"io",
".",
"Writer",
",",
"mode",
"outputMode",
")",
"io",
".",
"Writer",
"{",
"if",
"_",
",",
"ok",
":=",
"w",
".",
"(",
"*",
"colorWriter",
")",
";",
"!",
"ok",
"{",
"return",
"&",
"colorWriter",
"{",
"w",
... | // NewModeColorWriter create and initializes a new ansiColorWriter
// by specifying the outputMode. | [
"NewModeColorWriter",
"create",
"and",
"initializes",
"a",
"new",
"ansiColorWriter",
"by",
"specifying",
"the",
"outputMode",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/colors/color.go#L46-L54 | train |
beego/bee | cmd/commands/version/version.go | ShowShortVersionBanner | func ShowShortVersionBanner() {
output := colors.NewColorWriter(os.Stdout)
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner)))
} | go | func ShowShortVersionBanner() {
output := colors.NewColorWriter(os.Stdout)
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner)))
} | [
"func",
"ShowShortVersionBanner",
"(",
")",
"{",
"output",
":=",
"colors",
".",
"NewColorWriter",
"(",
"os",
".",
"Stdout",
")",
"\n",
"InitBanner",
"(",
"output",
",",
"bytes",
".",
"NewBufferString",
"(",
"colors",
".",
"MagentaBold",
"(",
"shortVersionBanne... | // ShowShortVersionBanner prints the short version banner. | [
"ShowShortVersionBanner",
"prints",
"the",
"short",
"version",
"banner",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/version/version.go#L115-L118 | train |
beego/bee | cmd/commands/run/watch.go | NewWatcher | func NewWatcher(paths []string, files []string, isgenerate bool) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
beeLogger.Log.Fatalf("Failed to create watcher: %s", err)
}
go func() {
for {
select {
case e := <-watcher.Events:
isBuild := true
if ifStaticFile(e.Name) && config.Conf.Enabl... | go | func NewWatcher(paths []string, files []string, isgenerate bool) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
beeLogger.Log.Fatalf("Failed to create watcher: %s", err)
}
go func() {
for {
select {
case e := <-watcher.Events:
isBuild := true
if ifStaticFile(e.Name) && config.Conf.Enabl... | [
"func",
"NewWatcher",
"(",
"paths",
"[",
"]",
"string",
",",
"files",
"[",
"]",
"string",
",",
"isgenerate",
"bool",
")",
"{",
"watcher",
",",
"err",
":=",
"fsnotify",
".",
"NewWatcher",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"beeLogger",
"."... | // NewWatcher starts an fsnotify Watcher on the specified paths | [
"NewWatcher",
"starts",
"an",
"fsnotify",
"Watcher",
"on",
"the",
"specified",
"paths"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L51-L112 | train |
beego/bee | cmd/commands/run/watch.go | AutoBuild | func AutoBuild(files []string, isgenerate bool) {
state.Lock()
defer state.Unlock()
os.Chdir(currpath)
cmdName := "go"
var (
err error
stderr bytes.Buffer
)
// For applications use full import path like "github.com/.../.."
// are able to use "go install" to reduce build time.
if config.Conf.GoInstall... | go | func AutoBuild(files []string, isgenerate bool) {
state.Lock()
defer state.Unlock()
os.Chdir(currpath)
cmdName := "go"
var (
err error
stderr bytes.Buffer
)
// For applications use full import path like "github.com/.../.."
// are able to use "go install" to reduce build time.
if config.Conf.GoInstall... | [
"func",
"AutoBuild",
"(",
"files",
"[",
"]",
"string",
",",
"isgenerate",
"bool",
")",
"{",
"state",
".",
"Lock",
"(",
")",
"\n",
"defer",
"state",
".",
"Unlock",
"(",
")",
"\n\n",
"os",
".",
"Chdir",
"(",
"currpath",
")",
"\n\n",
"cmdName",
":=",
... | // AutoBuild builds the specified set of files | [
"AutoBuild",
"builds",
"the",
"specified",
"set",
"of",
"files"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L115-L176 | train |
beego/bee | cmd/commands/run/watch.go | Kill | func Kill() {
defer func() {
if e := recover(); e != nil {
beeLogger.Log.Infof("Kill recover: %s", e)
}
}()
if cmd != nil && cmd.Process != nil {
// Windows does not support Interrupt
if runtime.GOOS == "windows" {
cmd.Process.Signal(os.Kill)
} else {
cmd.Process.Signal(os.Interrupt)
}
ch := ... | go | func Kill() {
defer func() {
if e := recover(); e != nil {
beeLogger.Log.Infof("Kill recover: %s", e)
}
}()
if cmd != nil && cmd.Process != nil {
// Windows does not support Interrupt
if runtime.GOOS == "windows" {
cmd.Process.Signal(os.Kill)
} else {
cmd.Process.Signal(os.Interrupt)
}
ch := ... | [
"func",
"Kill",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"e",
":=",
"recover",
"(",
")",
";",
"e",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"e",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
... | // Kill kills the running command process | [
"Kill",
"kills",
"the",
"running",
"command",
"process"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L179-L211 | train |
beego/bee | cmd/commands/run/watch.go | Restart | func Restart(appname string) {
beeLogger.Log.Debugf("Kill running process", utils.FILE(), utils.LINE())
Kill()
go Start(appname)
} | go | func Restart(appname string) {
beeLogger.Log.Debugf("Kill running process", utils.FILE(), utils.LINE())
Kill()
go Start(appname)
} | [
"func",
"Restart",
"(",
"appname",
"string",
")",
"{",
"beeLogger",
".",
"Log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"utils",
".",
"FILE",
"(",
")",
",",
"utils",
".",
"LINE",
"(",
")",
")",
"\n",
"Kill",
"(",
")",
"\n",
"go",
"Start",
"(",
"ap... | // Restart kills the running command process and starts it again | [
"Restart",
"kills",
"the",
"running",
"command",
"process",
"and",
"starts",
"it",
"again"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L214-L218 | train |
beego/bee | cmd/commands/run/watch.go | Start | func Start(appname string) {
beeLogger.Log.Infof("Restarting '%s'...", appname)
if !strings.Contains(appname, "./") {
appname = "./" + appname
}
cmd = exec.Command(appname)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if runargs != "" {
r := regexp.MustCompile("'.+'|\".+\"|\\S+")
m := r.FindAllString(run... | go | func Start(appname string) {
beeLogger.Log.Infof("Restarting '%s'...", appname)
if !strings.Contains(appname, "./") {
appname = "./" + appname
}
cmd = exec.Command(appname)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if runargs != "" {
r := regexp.MustCompile("'.+'|\".+\"|\\S+")
m := r.FindAllString(run... | [
"func",
"Start",
"(",
"appname",
"string",
")",
"{",
"beeLogger",
".",
"Log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"appname",
")",
"\n",
"if",
"!",
"strings",
".",
"Contains",
"(",
"appname",
",",
"\"",
"\"",
")",
"{",
"appname",
"=",
"\"",
"\"",
... | // Start starts the command process | [
"Start",
"starts",
"the",
"command",
"process"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L221-L242 | train |
beego/bee | cmd/commands/run/watch.go | shouldIgnoreFile | func shouldIgnoreFile(filename string) bool {
for _, regex := range ignoredFilesRegExps {
r, err := regexp.Compile(regex)
if err != nil {
beeLogger.Log.Fatalf("Could not compile regular expression: %s", err)
}
if r.MatchString(filename) {
return true
}
continue
}
return false
} | go | func shouldIgnoreFile(filename string) bool {
for _, regex := range ignoredFilesRegExps {
r, err := regexp.Compile(regex)
if err != nil {
beeLogger.Log.Fatalf("Could not compile regular expression: %s", err)
}
if r.MatchString(filename) {
return true
}
continue
}
return false
} | [
"func",
"shouldIgnoreFile",
"(",
"filename",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"regex",
":=",
"range",
"ignoredFilesRegExps",
"{",
"r",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"regex",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"beeL... | // shouldIgnoreFile ignores filenames generated by Emacs, Vim or SublimeText.
// It returns true if the file should be ignored, false otherwise. | [
"shouldIgnoreFile",
"ignores",
"filenames",
"generated",
"by",
"Emacs",
"Vim",
"or",
"SublimeText",
".",
"It",
"returns",
"true",
"if",
"the",
"file",
"should",
"be",
"ignored",
"false",
"otherwise",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L255-L267 | train |
beego/bee | cmd/commands/run/watch.go | shouldWatchFileWithExtension | func shouldWatchFileWithExtension(name string) bool {
for _, s := range watchExts {
if strings.HasSuffix(name, s) {
return true
}
}
return false
} | go | func shouldWatchFileWithExtension(name string) bool {
for _, s := range watchExts {
if strings.HasSuffix(name, s) {
return true
}
}
return false
} | [
"func",
"shouldWatchFileWithExtension",
"(",
"name",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"watchExts",
"{",
"if",
"strings",
".",
"HasSuffix",
"(",
"name",
",",
"s",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
... | // shouldWatchFileWithExtension returns true if the name of the file
// hash a suffix that should be watched. | [
"shouldWatchFileWithExtension",
"returns",
"true",
"if",
"the",
"name",
"of",
"the",
"file",
"hash",
"a",
"suffix",
"that",
"should",
"be",
"watched",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/run/watch.go#L271-L278 | train |
beego/bee | logger/logger.go | GetBeeLogger | func GetBeeLogger(w io.Writer) *BeeLogger {
once.Do(func() {
var (
err error
simpleLogFormat = `{{Now "2006/01/02 15:04:05"}} {{.Level}} ▶ {{.ID}} {{.Message}}{{EndLine}}`
debugLogFormat = `{{Now "2006/01/02 15:04:05"}} {{.Level}} ▶ {{.ID}} {{.Filename}}:{{.LineNo}} {{.Message}}{{EndLine}}`
)... | go | func GetBeeLogger(w io.Writer) *BeeLogger {
once.Do(func() {
var (
err error
simpleLogFormat = `{{Now "2006/01/02 15:04:05"}} {{.Level}} ▶ {{.ID}} {{.Message}}{{EndLine}}`
debugLogFormat = `{{Now "2006/01/02 15:04:05"}} {{.Level}} ▶ {{.ID}} {{.Filename}}:{{.LineNo}} {{.Message}}{{EndLine}}`
)... | [
"func",
"GetBeeLogger",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"BeeLogger",
"{",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"var",
"(",
"err",
"error",
"\n",
"simpleLogFormat",
"=",
"`{{Now \"2006/01/02 15:04:05\"}} {{.Level}} ▶ {{.ID}} {{.Message}}{{EndLine... | // GetBeeLogger initializes the logger instance with a NewColorWriter output
// and returns a singleton | [
"GetBeeLogger",
"initializes",
"the",
"logger",
"instance",
"with",
"a",
"NewColorWriter",
"output",
"and",
"returns",
"a",
"singleton"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L77-L102 | train |
beego/bee | logger/logger.go | SetOutput | func (l *BeeLogger) SetOutput(w io.Writer) {
l.mu.Lock()
defer l.mu.Unlock()
l.output = colors.NewColorWriter(w)
} | go | func (l *BeeLogger) SetOutput(w io.Writer) {
l.mu.Lock()
defer l.mu.Unlock()
l.output = colors.NewColorWriter(w)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"SetOutput",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"l",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"output",
"=",
"colors",
".",
"NewCo... | // SetOutput sets the logger output destination | [
"SetOutput",
"sets",
"the",
"logger",
"output",
"destination"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L105-L109 | train |
beego/bee | logger/logger.go | mustLog | func (l *BeeLogger) mustLog(level int, message string, args ...interface{}) {
if level > logLevel {
return
}
// Acquire the lock
l.mu.Lock()
defer l.mu.Unlock()
// Create the logging record and pass into the output
record := LogRecord{
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
Level:... | go | func (l *BeeLogger) mustLog(level int, message string, args ...interface{}) {
if level > logLevel {
return
}
// Acquire the lock
l.mu.Lock()
defer l.mu.Unlock()
// Create the logging record and pass into the output
record := LogRecord{
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
Level:... | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"mustLog",
"(",
"level",
"int",
",",
"message",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"level",
">",
"logLevel",
"{",
"return",
"\n",
"}",
"\n",
"// Acquire the lock",
"l",
".",
"... | // mustLog logs the message according to the specified level and arguments.
// It panics in case of an error. | [
"mustLog",
"logs",
"the",
"message",
"according",
"to",
"the",
"specified",
"level",
"and",
"arguments",
".",
"It",
"panics",
"in",
"case",
"of",
"an",
"error",
"."
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L169-L188 | train |
beego/bee | logger/logger.go | mustLogDebug | func (l *BeeLogger) mustLogDebug(message string, file string, line int, args ...interface{}) {
if !debugMode {
return
}
// Change the output to Stderr
l.SetOutput(os.Stderr)
// Create the log record
record := LogRecord{
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
Level: l.getColorL... | go | func (l *BeeLogger) mustLogDebug(message string, file string, line int, args ...interface{}) {
if !debugMode {
return
}
// Change the output to Stderr
l.SetOutput(os.Stderr)
// Create the log record
record := LogRecord{
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
Level: l.getColorL... | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"mustLogDebug",
"(",
"message",
"string",
",",
"file",
"string",
",",
"line",
"int",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"debugMode",
"{",
"return",
"\n",
"}",
"\n\n",
"// Change the ... | // mustLogDebug logs a debug message only if debug mode
// is enabled. i.e. DEBUG_ENABLED="1" | [
"mustLogDebug",
"logs",
"a",
"debug",
"message",
"only",
"if",
"debug",
"mode",
"is",
"enabled",
".",
"i",
".",
"e",
".",
"DEBUG_ENABLED",
"=",
"1"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L192-L212 | train |
beego/bee | logger/logger.go | Debug | func (l *BeeLogger) Debug(message string, file string, line int) {
l.mustLogDebug(message, file, line)
} | go | func (l *BeeLogger) Debug(message string, file string, line int) {
l.mustLogDebug(message, file, line)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Debug",
"(",
"message",
"string",
",",
"file",
"string",
",",
"line",
"int",
")",
"{",
"l",
".",
"mustLogDebug",
"(",
"message",
",",
"file",
",",
"line",
")",
"\n",
"}"
] | // Debug outputs a debug log message | [
"Debug",
"outputs",
"a",
"debug",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L215-L217 | train |
beego/bee | logger/logger.go | Debugf | func (l *BeeLogger) Debugf(message string, file string, line int, vars ...interface{}) {
l.mustLogDebug(message, file, line, vars...)
} | go | func (l *BeeLogger) Debugf(message string, file string, line int, vars ...interface{}) {
l.mustLogDebug(message, file, line, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Debugf",
"(",
"message",
"string",
",",
"file",
"string",
",",
"line",
"int",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLogDebug",
"(",
"message",
",",
"file",
",",
"line",
",",
"v... | // Debugf outputs a formatted debug log message | [
"Debugf",
"outputs",
"a",
"formatted",
"debug",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L220-L222 | train |
beego/bee | logger/logger.go | Infof | func (l *BeeLogger) Infof(message string, vars ...interface{}) {
l.mustLog(levelInfo, message, vars...)
} | go | func (l *BeeLogger) Infof(message string, vars ...interface{}) {
l.mustLog(levelInfo, message, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Infof",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelInfo",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"}"
] | // Infof outputs a formatted information log message | [
"Infof",
"outputs",
"a",
"formatted",
"information",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L230-L232 | train |
beego/bee | logger/logger.go | Warnf | func (l *BeeLogger) Warnf(message string, vars ...interface{}) {
l.mustLog(levelWarn, message, vars...)
} | go | func (l *BeeLogger) Warnf(message string, vars ...interface{}) {
l.mustLog(levelWarn, message, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Warnf",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelWarn",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"}"
] | // Warnf outputs a formatted warning log message | [
"Warnf",
"outputs",
"a",
"formatted",
"warning",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L240-L242 | train |
beego/bee | logger/logger.go | Errorf | func (l *BeeLogger) Errorf(message string, vars ...interface{}) {
l.mustLog(levelError, message, vars...)
} | go | func (l *BeeLogger) Errorf(message string, vars ...interface{}) {
l.mustLog(levelError, message, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Errorf",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelError",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"}"
] | // Errorf outputs a formatted error log message | [
"Errorf",
"outputs",
"a",
"formatted",
"error",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L250-L252 | train |
beego/bee | logger/logger.go | Fatal | func (l *BeeLogger) Fatal(message string) {
l.mustLog(levelFatal, message)
os.Exit(255)
} | go | func (l *BeeLogger) Fatal(message string) {
l.mustLog(levelFatal, message)
os.Exit(255)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Fatal",
"(",
"message",
"string",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelFatal",
",",
"message",
")",
"\n",
"os",
".",
"Exit",
"(",
"255",
")",
"\n",
"}"
] | // Fatal outputs a fatal log message and exists | [
"Fatal",
"outputs",
"a",
"fatal",
"log",
"message",
"and",
"exists"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L255-L258 | train |
beego/bee | logger/logger.go | Fatalf | func (l *BeeLogger) Fatalf(message string, vars ...interface{}) {
l.mustLog(levelFatal, message, vars...)
os.Exit(255)
} | go | func (l *BeeLogger) Fatalf(message string, vars ...interface{}) {
l.mustLog(levelFatal, message, vars...)
os.Exit(255)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Fatalf",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelFatal",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"os",
".",
"Exit",
"(",
"255",
... | // Fatalf outputs a formatted log message and exists | [
"Fatalf",
"outputs",
"a",
"formatted",
"log",
"message",
"and",
"exists"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L261-L264 | train |
beego/bee | logger/logger.go | Successf | func (l *BeeLogger) Successf(message string, vars ...interface{}) {
l.mustLog(levelSuccess, message, vars...)
} | go | func (l *BeeLogger) Successf(message string, vars ...interface{}) {
l.mustLog(levelSuccess, message, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Successf",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelSuccess",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"}"
] | // Successf outputs a formatted success log message | [
"Successf",
"outputs",
"a",
"formatted",
"success",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L272-L274 | train |
beego/bee | logger/logger.go | Hintf | func (l *BeeLogger) Hintf(message string, vars ...interface{}) {
l.mustLog(levelHint, message, vars...)
} | go | func (l *BeeLogger) Hintf(message string, vars ...interface{}) {
l.mustLog(levelHint, message, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Hintf",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelHint",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"}"
] | // Hintf outputs a formatted hint log message | [
"Hintf",
"outputs",
"a",
"formatted",
"hint",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L282-L284 | train |
beego/bee | logger/logger.go | Criticalf | func (l *BeeLogger) Criticalf(message string, vars ...interface{}) {
l.mustLog(levelCritical, message, vars...)
} | go | func (l *BeeLogger) Criticalf(message string, vars ...interface{}) {
l.mustLog(levelCritical, message, vars...)
} | [
"func",
"(",
"l",
"*",
"BeeLogger",
")",
"Criticalf",
"(",
"message",
"string",
",",
"vars",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"mustLog",
"(",
"levelCritical",
",",
"message",
",",
"vars",
"...",
")",
"\n",
"}"
] | // Criticalf outputs a formatted critical log message | [
"Criticalf",
"outputs",
"a",
"formatted",
"critical",
"log",
"message"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L292-L294 | train |
cloudfoundry/cli | actor/v3action/organization.go | GetOrganizationByName | func (actor Actor) GetOrganizationByName(name string) (Organization, Warnings, error) {
orgs, warnings, err := actor.CloudControllerClient.GetOrganizations(
ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}},
)
if err != nil {
return Organization{}, Warnings(warnings), err
}
if len(orgs) == 0 {
return... | go | func (actor Actor) GetOrganizationByName(name string) (Organization, Warnings, error) {
orgs, warnings, err := actor.CloudControllerClient.GetOrganizations(
ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}},
)
if err != nil {
return Organization{}, Warnings(warnings), err
}
if len(orgs) == 0 {
return... | [
"func",
"(",
"actor",
"Actor",
")",
"GetOrganizationByName",
"(",
"name",
"string",
")",
"(",
"Organization",
",",
"Warnings",
",",
"error",
")",
"{",
"orgs",
",",
"warnings",
",",
"err",
":=",
"actor",
".",
"CloudControllerClient",
".",
"GetOrganizations",
... | // GetOrganizationByName returns the organization with the given name. | [
"GetOrganizationByName",
"returns",
"the",
"organization",
"with",
"the",
"given",
"name",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/organization.go#L14-L27 | train |
cloudfoundry/cli | util/configv3/json_config.go | SetOrganizationInformation | func (config *Config) SetOrganizationInformation(guid string, name string) {
config.ConfigFile.TargetedOrganization.GUID = guid
config.ConfigFile.TargetedOrganization.Name = name
config.ConfigFile.TargetedOrganization.QuotaDefinition = QuotaDefinition{}
} | go | func (config *Config) SetOrganizationInformation(guid string, name string) {
config.ConfigFile.TargetedOrganization.GUID = guid
config.ConfigFile.TargetedOrganization.Name = name
config.ConfigFile.TargetedOrganization.QuotaDefinition = QuotaDefinition{}
} | [
"func",
"(",
"config",
"*",
"Config",
")",
"SetOrganizationInformation",
"(",
"guid",
"string",
",",
"name",
"string",
")",
"{",
"config",
".",
"ConfigFile",
".",
"TargetedOrganization",
".",
"GUID",
"=",
"guid",
"\n",
"config",
".",
"ConfigFile",
".",
"Targ... | // SetOrganizationInformation sets the currently targeted organization. | [
"SetOrganizationInformation",
"sets",
"the",
"currently",
"targeted",
"organization",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L140-L144 | train |
cloudfoundry/cli | util/configv3/json_config.go | SetSpaceInformation | func (config *Config) SetSpaceInformation(guid string, name string, allowSSH bool) {
config.V7SetSpaceInformation(guid, name)
config.ConfigFile.TargetedSpace.AllowSSH = allowSSH
} | go | func (config *Config) SetSpaceInformation(guid string, name string, allowSSH bool) {
config.V7SetSpaceInformation(guid, name)
config.ConfigFile.TargetedSpace.AllowSSH = allowSSH
} | [
"func",
"(",
"config",
"*",
"Config",
")",
"SetSpaceInformation",
"(",
"guid",
"string",
",",
"name",
"string",
",",
"allowSSH",
"bool",
")",
"{",
"config",
".",
"V7SetSpaceInformation",
"(",
"guid",
",",
"name",
")",
"\n",
"config",
".",
"ConfigFile",
"."... | // SetSpaceInformation sets the currently targeted space. | [
"SetSpaceInformation",
"sets",
"the",
"currently",
"targeted",
"space",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L152-L155 | train |
cloudfoundry/cli | util/configv3/json_config.go | SetTargetInformation | func (config *Config) SetTargetInformation(api string, apiVersion string, auth string, minCLIVersion string, doppler string, routing string, skipSSLValidation bool) {
config.ConfigFile.Target = api
config.ConfigFile.APIVersion = apiVersion
config.ConfigFile.AuthorizationEndpoint = auth
config.SetMinCLIVersion(minCL... | go | func (config *Config) SetTargetInformation(api string, apiVersion string, auth string, minCLIVersion string, doppler string, routing string, skipSSLValidation bool) {
config.ConfigFile.Target = api
config.ConfigFile.APIVersion = apiVersion
config.ConfigFile.AuthorizationEndpoint = auth
config.SetMinCLIVersion(minCL... | [
"func",
"(",
"config",
"*",
"Config",
")",
"SetTargetInformation",
"(",
"api",
"string",
",",
"apiVersion",
"string",
",",
"auth",
"string",
",",
"minCLIVersion",
"string",
",",
"doppler",
"string",
",",
"routing",
"string",
",",
"skipSSLValidation",
"bool",
"... | // SetTargetInformation sets the currently targeted CC API and related other
// related API URLs. | [
"SetTargetInformation",
"sets",
"the",
"currently",
"targeted",
"CC",
"API",
"and",
"related",
"other",
"related",
"API",
"URLs",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L159-L169 | train |
cloudfoundry/cli | util/configv3/json_config.go | SetUAAClientCredentials | func (config *Config) SetUAAClientCredentials(client string, clientSecret string) {
config.ConfigFile.UAAOAuthClient = client
config.ConfigFile.UAAOAuthClientSecret = clientSecret
} | go | func (config *Config) SetUAAClientCredentials(client string, clientSecret string) {
config.ConfigFile.UAAOAuthClient = client
config.ConfigFile.UAAOAuthClientSecret = clientSecret
} | [
"func",
"(",
"config",
"*",
"Config",
")",
"SetUAAClientCredentials",
"(",
"client",
"string",
",",
"clientSecret",
"string",
")",
"{",
"config",
".",
"ConfigFile",
".",
"UAAOAuthClient",
"=",
"client",
"\n",
"config",
".",
"ConfigFile",
".",
"UAAOAuthClientSecr... | // SetUAAClientCredentials sets the client credentials. | [
"SetUAAClientCredentials",
"sets",
"the",
"client",
"credentials",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L179-L182 | train |
cloudfoundry/cli | util/configv3/json_config.go | V7SetSpaceInformation | func (config *Config) V7SetSpaceInformation(guid string, name string) {
config.ConfigFile.TargetedSpace.GUID = guid
config.ConfigFile.TargetedSpace.Name = name
} | go | func (config *Config) V7SetSpaceInformation(guid string, name string) {
config.ConfigFile.TargetedSpace.GUID = guid
config.ConfigFile.TargetedSpace.Name = name
} | [
"func",
"(",
"config",
"*",
"Config",
")",
"V7SetSpaceInformation",
"(",
"guid",
"string",
",",
"name",
"string",
")",
"{",
"config",
".",
"ConfigFile",
".",
"TargetedSpace",
".",
"GUID",
"=",
"guid",
"\n",
"config",
".",
"ConfigFile",
".",
"TargetedSpace",
... | // V7SetSpaceInformation sets the currently targeted space. | [
"V7SetSpaceInformation",
"sets",
"the",
"currently",
"targeted",
"space",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L268-L271 | train |
cloudfoundry/cli | actor/v3action/actor.go | NewActor | func NewActor(client CloudControllerClient, config Config, sharedActor SharedActor, uaaClient UAAClient) *Actor {
return &Actor{
CloudControllerClient: client,
Config: config,
SharedActor: sharedActor,
UAAClient: uaaClient,
}
} | go | func NewActor(client CloudControllerClient, config Config, sharedActor SharedActor, uaaClient UAAClient) *Actor {
return &Actor{
CloudControllerClient: client,
Config: config,
SharedActor: sharedActor,
UAAClient: uaaClient,
}
} | [
"func",
"NewActor",
"(",
"client",
"CloudControllerClient",
",",
"config",
"Config",
",",
"sharedActor",
"SharedActor",
",",
"uaaClient",
"UAAClient",
")",
"*",
"Actor",
"{",
"return",
"&",
"Actor",
"{",
"CloudControllerClient",
":",
"client",
",",
"Config",
":"... | // NewActor returns a new V3 actor. | [
"NewActor",
"returns",
"a",
"new",
"V3",
"actor",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/actor.go#L24-L31 | train |
cloudfoundry/cli | api/cloudcontroller/ccv2/service_binding.go | UnmarshalJSON | func (serviceBinding *ServiceBinding) UnmarshalJSON(data []byte) error {
var ccServiceBinding struct {
Metadata internal.Metadata
Entity struct {
AppGUID string `json:"app_guid"`
ServiceInstanceGUID string `json:"service_instance_guid"`
Name string `json:"... | go | func (serviceBinding *ServiceBinding) UnmarshalJSON(data []byte) error {
var ccServiceBinding struct {
Metadata internal.Metadata
Entity struct {
AppGUID string `json:"app_guid"`
ServiceInstanceGUID string `json:"service_instance_guid"`
Name string `json:"... | [
"func",
"(",
"serviceBinding",
"*",
"ServiceBinding",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"ccServiceBinding",
"struct",
"{",
"Metadata",
"internal",
".",
"Metadata",
"\n",
"Entity",
"struct",
"{",
"AppGUID",
"string",... | // UnmarshalJSON helps unmarshal a Cloud Controller Service Binding response. | [
"UnmarshalJSON",
"helps",
"unmarshal",
"a",
"Cloud",
"Controller",
"Service",
"Binding",
"response",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L29-L50 | train |
cloudfoundry/cli | api/cloudcontroller/ccv2/service_binding.go | DeleteServiceBinding | func (client *Client) DeleteServiceBinding(serviceBindingGUID string, acceptsIncomplete bool) (ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.DeleteServiceBindingRequest,
URIParams: map[string]string{"service_binding_guid": serviceBindingGUID},
Qu... | go | func (client *Client) DeleteServiceBinding(serviceBindingGUID string, acceptsIncomplete bool) (ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.DeleteServiceBindingRequest,
URIParams: map[string]string{"service_binding_guid": serviceBindingGUID},
Qu... | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteServiceBinding",
"(",
"serviceBindingGUID",
"string",
",",
"acceptsIncomplete",
"bool",
")",
"(",
"ServiceBinding",
",",
"Warnings",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"client",
".",
"newHTTPR... | // DeleteServiceBinding deletes the specified Service Binding. An updated
// service binding is returned only if acceptsIncomplete is true. | [
"DeleteServiceBinding",
"deletes",
"the",
"specified",
"Service",
"Binding",
".",
"An",
"updated",
"service",
"binding",
"is",
"returned",
"only",
"if",
"acceptsIncomplete",
"is",
"true",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L98-L118 | train |
cloudfoundry/cli | api/cloudcontroller/ccv2/service_binding.go | GetServiceBinding | func (client *Client) GetServiceBinding(guid string) (ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceBindingRequest,
URIParams: Params{"service_binding_guid": guid},
})
if err != nil {
return ServiceBinding{}, nil, err
}
var service... | go | func (client *Client) GetServiceBinding(guid string) (ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceBindingRequest,
URIParams: Params{"service_binding_guid": guid},
})
if err != nil {
return ServiceBinding{}, nil, err
}
var service... | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetServiceBinding",
"(",
"guid",
"string",
")",
"(",
"ServiceBinding",
",",
"Warnings",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"client",
".",
"newHTTPRequest",
"(",
"requestOptions",
"{",
"RequestName... | // GetServiceBinding returns back a service binding with the provided GUID. | [
"GetServiceBinding",
"returns",
"back",
"a",
"service",
"binding",
"with",
"the",
"provided",
"GUID",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L121-L137 | train |
cloudfoundry/cli | api/cloudcontroller/ccv2/service_binding.go | GetServiceBindings | func (client *Client) GetServiceBindings(filters ...Filter) ([]ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceBindingsRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return nil, nil, err
}
var fullBindingsLi... | go | func (client *Client) GetServiceBindings(filters ...Filter) ([]ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceBindingsRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return nil, nil, err
}
var fullBindingsLi... | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetServiceBindings",
"(",
"filters",
"...",
"Filter",
")",
"(",
"[",
"]",
"ServiceBinding",
",",
"Warnings",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"client",
".",
"newHTTPRequest",
"(",
"requestOpti... | // GetServiceBindings returns back a list of Service Bindings based off of the
// provided filters. | [
"GetServiceBindings",
"returns",
"back",
"a",
"list",
"of",
"Service",
"Bindings",
"based",
"off",
"of",
"the",
"provided",
"filters",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L141-L164 | train |
cloudfoundry/cli | api/cloudcontroller/ccv2/service_binding.go | GetServiceInstanceServiceBindings | func (client *Client) GetServiceInstanceServiceBindings(serviceInstanceGUID string) ([]ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceInstanceServiceBindingsRequest,
URIParams: map[string]string{"service_instance_guid": serviceInstanceGUID... | go | func (client *Client) GetServiceInstanceServiceBindings(serviceInstanceGUID string) ([]ServiceBinding, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceInstanceServiceBindingsRequest,
URIParams: map[string]string{"service_instance_guid": serviceInstanceGUID... | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetServiceInstanceServiceBindings",
"(",
"serviceInstanceGUID",
"string",
")",
"(",
"[",
"]",
"ServiceBinding",
",",
"Warnings",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"client",
".",
"newHTTPRequest",
"... | // GetServiceInstanceServiceBindings returns back a list of Service Bindings for the provided service instance GUID. | [
"GetServiceInstanceServiceBindings",
"returns",
"back",
"a",
"list",
"of",
"Service",
"Bindings",
"for",
"the",
"provided",
"service",
"instance",
"GUID",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L167-L190 | train |
cloudfoundry/cli | api/cloudcontroller/ccv2/feature_flag.go | GetConfigFeatureFlags | func (client Client) GetConfigFeatureFlags() ([]FeatureFlag, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetConfigFeatureFlagsRequest,
})
if err != nil {
return nil, nil, err
}
var featureFlags []FeatureFlag
response := cloudcontroller.Response{
DecodeJSON... | go | func (client Client) GetConfigFeatureFlags() ([]FeatureFlag, Warnings, error) {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetConfigFeatureFlagsRequest,
})
if err != nil {
return nil, nil, err
}
var featureFlags []FeatureFlag
response := cloudcontroller.Response{
DecodeJSON... | [
"func",
"(",
"client",
"Client",
")",
"GetConfigFeatureFlags",
"(",
")",
"(",
"[",
"]",
"FeatureFlag",
",",
"Warnings",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"client",
".",
"newHTTPRequest",
"(",
"requestOptions",
"{",
"RequestName",
":",
"i... | // GetConfigFeatureFlags retrieves a list of FeatureFlag from the Cloud
// Controller. | [
"GetConfigFeatureFlags",
"retrieves",
"a",
"list",
"of",
"FeatureFlag",
"from",
"the",
"Cloud",
"Controller",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/feature_flag.go#L21-L36 | train |
cloudfoundry/cli | api/router/connection_wrapper.go | WrapConnection | func (client *Client) WrapConnection(wrapper ConnectionWrapper) {
client.connection = wrapper.Wrap(client.connection)
} | go | func (client *Client) WrapConnection(wrapper ConnectionWrapper) {
client.connection = wrapper.Wrap(client.connection)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"WrapConnection",
"(",
"wrapper",
"ConnectionWrapper",
")",
"{",
"client",
".",
"connection",
"=",
"wrapper",
".",
"Wrap",
"(",
"client",
".",
"connection",
")",
"\n",
"}"
] | // WrapConnection wraps the current Client connection in the wrapper. | [
"WrapConnection",
"wraps",
"the",
"current",
"Client",
"connection",
"in",
"the",
"wrapper",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/connection_wrapper.go#L13-L15 | train |
cloudfoundry/cli | actor/v3action/target.go | ClearTarget | func (actor Actor) ClearTarget() {
actor.Config.SetTargetInformation("", "", "", "", "", "", false)
actor.Config.SetTokenInformation("", "", "")
} | go | func (actor Actor) ClearTarget() {
actor.Config.SetTargetInformation("", "", "", "", "", "", false)
actor.Config.SetTokenInformation("", "", "")
} | [
"func",
"(",
"actor",
"Actor",
")",
"ClearTarget",
"(",
")",
"{",
"actor",
".",
"Config",
".",
"SetTargetInformation",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
")",
"\n",
... | // ClearTarget clears target information from the actor. | [
"ClearTarget",
"clears",
"target",
"information",
"from",
"the",
"actor",
"."
] | 5010c000047f246b870475e2c299556078cdad30 | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/target.go#L43-L46 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.