id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,400 | manifoldco/go-manifold | integrations/primitives/credential.go | Valid | func (c *Credential) Valid() bool {
if c.Key == "" {
log.Printf("Credential: invalid key")
return false
}
return true
} | go | func (c *Credential) Valid() bool {
if c.Key == "" {
log.Printf("Credential: invalid key")
return false
}
return true
} | [
"func",
"(",
"c",
"*",
"Credential",
")",
"Valid",
"(",
")",
"bool",
"{",
"if",
"c",
".",
"Key",
"==",
"\"",
"\"",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // Valid will validate the CredentialSpec. | [
"Valid",
"will",
"validate",
"the",
"CredentialSpec",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/primitives/credential.go#L14-L21 |
145,401 | manifoldco/go-manifold | errors.go | NewError | func NewError(t errors.Type, m ...string) *Error {
return &Error{
Type: t,
Messages: m,
}
} | go | func NewError(t errors.Type, m ...string) *Error {
return &Error{
Type: t,
Messages: m,
}
} | [
"func",
"NewError",
"(",
"t",
"errors",
".",
"Type",
",",
"m",
"...",
"string",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"Type",
":",
"t",
",",
"Messages",
":",
"m",
",",
"}",
"\n",
"}"
] | // NewError returns an Error containing 1 or more error messages | [
"NewError",
"returns",
"an",
"Error",
"containing",
"1",
"or",
"more",
"error",
"messages"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/errors.go#L29-L34 |
145,402 | manifoldco/go-manifold | errors.go | FromError | func FromError(err error) *Error {
apiErr, ok := err.(*Error)
if ok {
return apiErr
}
return NewError(errors.InternalServerError, "Internal Server Error")
} | go | func FromError(err error) *Error {
apiErr, ok := err.(*Error)
if ok {
return apiErr
}
return NewError(errors.InternalServerError, "Internal Server Error")
} | [
"func",
"FromError",
"(",
"err",
"error",
")",
"*",
"Error",
"{",
"apiErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Error",
")",
"\n",
"if",
"ok",
"{",
"return",
"apiErr",
"\n",
"}",
"\n\n",
"return",
"NewError",
"(",
"errors",
".",
"InternalServerEr... | // FromError returns an error of type Error from a struct that represents a | [
"FromError",
"returns",
"an",
"error",
"of",
"type",
"Error",
"from",
"a",
"struct",
"that",
"represents",
"a"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/errors.go#L37-L44 |
145,403 | manifoldco/go-manifold | errors.go | Error | func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.Type.String(), strings.Join(e.Messages, ","))
} | go | func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.Type.String(), strings.Join(e.Messages, ","))
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Type",
".",
"String",
"(",
")",
",",
"strings",
".",
"Join",
"(",
"e",
".",
"Messages",
",",
"\"",
"\"",
... | // Error returns the error message represented by this Error | [
"Error",
"returns",
"the",
"error",
"message",
"represented",
"by",
"this",
"Error"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/errors.go#L47-L49 |
145,404 | manifoldco/go-manifold | errors.go | ToError | func ToError(err error) HTTPError {
switch e := err.(type) {
case *Error:
return e
case HTTPError:
if et, ok := errors.TypeForStatusCode(e.StatusCode()); ok {
return NewError(et, e.Error())
}
}
return NewError(errors.InternalServerError, "Internal Server Error")
} | go | func ToError(err error) HTTPError {
switch e := err.(type) {
case *Error:
return e
case HTTPError:
if et, ok := errors.TypeForStatusCode(e.StatusCode()); ok {
return NewError(et, e.Error())
}
}
return NewError(errors.InternalServerError, "Internal Server Error")
} | [
"func",
"ToError",
"(",
"err",
"error",
")",
"HTTPError",
"{",
"switch",
"e",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Error",
":",
"return",
"e",
"\n",
"case",
"HTTPError",
":",
"if",
"et",
",",
"ok",
":=",
"errors",
".",
"TypeForSta... | // ToError receives an error and mutates it into an Error based on the concrete
// type of the Error. | [
"ToError",
"receives",
"an",
"error",
"and",
"mutates",
"it",
"into",
"an",
"Error",
"based",
"on",
"the",
"concrete",
"type",
"of",
"the",
"Error",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/errors.go#L77-L88 |
145,405 | st3v/translator | microsoft/auth/authenticator.go | NewAuthenticator | func NewAuthenticator(subscriptionKey, authURL string) _http.Authenticator {
// make buffered accessToken channel and pre-fill it with an expired token
tokenChan := make(chan *accessToken, 1)
tokenChan <- new(accessToken)
// return new authenticator that uses the above accessToken channel
return &authenticator{
... | go | func NewAuthenticator(subscriptionKey, authURL string) _http.Authenticator {
// make buffered accessToken channel and pre-fill it with an expired token
tokenChan := make(chan *accessToken, 1)
tokenChan <- new(accessToken)
// return new authenticator that uses the above accessToken channel
return &authenticator{
... | [
"func",
"NewAuthenticator",
"(",
"subscriptionKey",
",",
"authURL",
"string",
")",
"_http",
".",
"Authenticator",
"{",
"// make buffered accessToken channel and pre-fill it with an expired token",
"tokenChan",
":=",
"make",
"(",
"chan",
"*",
"accessToken",
",",
"1",
")",
... | // NewAuthenticator returns an authenticator for Microsoft API endpoints. | [
"NewAuthenticator",
"returns",
"an",
"authenticator",
"for",
"Microsoft",
"API",
"endpoints",
"."
] | d13056a5929704f264d21b102987311c0f379fc3 | https://github.com/st3v/translator/blob/d13056a5929704f264d21b102987311c0f379fc3/microsoft/auth/authenticator.go#L16-L26 |
145,406 | manifoldco/go-manifold | types.go | Equals | func (f FeatureMap) Equals(fm FeatureMap) bool {
if len(f) != len(fm) {
return false
}
for k, v := range f {
if val, ok := fm[k]; !ok || val != v {
return false
}
}
return true
} | go | func (f FeatureMap) Equals(fm FeatureMap) bool {
if len(f) != len(fm) {
return false
}
for k, v := range f {
if val, ok := fm[k]; !ok || val != v {
return false
}
}
return true
} | [
"func",
"(",
"f",
"FeatureMap",
")",
"Equals",
"(",
"fm",
"FeatureMap",
")",
"bool",
"{",
"if",
"len",
"(",
"f",
")",
"!=",
"len",
"(",
"fm",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"f",
"{",
"if",
"... | // Equals checks the equality of another FeatureMap against this one | [
"Equals",
"checks",
"the",
"equality",
"of",
"another",
"FeatureMap",
"against",
"this",
"one"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L15-L26 |
145,407 | manifoldco/go-manifold | types.go | Equals | func (m *MetadataValue) Equals(md MetadataValue) bool {
return m.Type == md.Type && m.Value == md.Value
} | go | func (m *MetadataValue) Equals(md MetadataValue) bool {
return m.Type == md.Type && m.Value == md.Value
} | [
"func",
"(",
"m",
"*",
"MetadataValue",
")",
"Equals",
"(",
"md",
"MetadataValue",
")",
"bool",
"{",
"return",
"m",
".",
"Type",
"==",
"md",
".",
"Type",
"&&",
"m",
".",
"Value",
"==",
"md",
".",
"Value",
"\n",
"}"
] | // Equals checks the equality of another MetadataValue against this one | [
"Equals",
"checks",
"the",
"equality",
"of",
"another",
"MetadataValue",
"against",
"this",
"one"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L51-L53 |
145,408 | manifoldco/go-manifold | types.go | FromMap | func (m *MetadataValue) FromMap(md map[string]interface{}) error {
typI, ok := md["type"]
if !ok {
return errors.New("Could not make MetadataValue from map, it did not contain a 'type' key")
}
typ, ok := typI.(string)
if !ok {
return errors.New("Could not make MetadataValue from map, the type key was not a str... | go | func (m *MetadataValue) FromMap(md map[string]interface{}) error {
typI, ok := md["type"]
if !ok {
return errors.New("Could not make MetadataValue from map, it did not contain a 'type' key")
}
typ, ok := typI.(string)
if !ok {
return errors.New("Could not make MetadataValue from map, the type key was not a str... | [
"func",
"(",
"m",
"*",
"MetadataValue",
")",
"FromMap",
"(",
"md",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"typI",
",",
"ok",
":=",
"md",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"errors",
".",
"N... | // FromMap tries to make a MetadataValue from a supplied map | [
"FromMap",
"tries",
"to",
"make",
"a",
"MetadataValue",
"from",
"a",
"supplied",
"map"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L112-L131 |
145,409 | manifoldco/go-manifold | types.go | UnmarshalJSON | func (m *MetadataValue) UnmarshalJSON(data []byte) error {
// New replica of struct for unmarshal to avoid infinite unmarshal loop
mv := &struct {
Type string `json:"type"`
Value interface{} `json:"value"`
}{}
json.Unmarshal(data, &mv)
m.Type = MetadataValueType(mv.Type)
m.Value = mv.Value
return m.try... | go | func (m *MetadataValue) UnmarshalJSON(data []byte) error {
// New replica of struct for unmarshal to avoid infinite unmarshal loop
mv := &struct {
Type string `json:"type"`
Value interface{} `json:"value"`
}{}
json.Unmarshal(data, &mv)
m.Type = MetadataValueType(mv.Type)
m.Value = mv.Value
return m.try... | [
"func",
"(",
"m",
"*",
"MetadataValue",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"// New replica of struct for unmarshal to avoid infinite unmarshal loop",
"mv",
":=",
"&",
"struct",
"{",
"Type",
"string",
"`json:\"type\"`",
"\n",
"Val... | // UnmarshalJSON controls how a MetadataValue is parsed from JSON | [
"UnmarshalJSON",
"controls",
"how",
"a",
"MetadataValue",
"is",
"parsed",
"from",
"JSON"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L134-L144 |
145,410 | manifoldco/go-manifold | types.go | Validate | func (m *MetadataValue) Validate(_ interface{}) error {
switch m.Type {
case MetadataValueTypeString:
_, ok := m.Value.(string)
if !ok {
return errors.New("Expected value to be a string but it was not")
}
case MetadataValueTypeInt:
_, ok := m.Value.(int64)
if !ok {
return errors.New("Expected value t... | go | func (m *MetadataValue) Validate(_ interface{}) error {
switch m.Type {
case MetadataValueTypeString:
_, ok := m.Value.(string)
if !ok {
return errors.New("Expected value to be a string but it was not")
}
case MetadataValueTypeInt:
_, ok := m.Value.(int64)
if !ok {
return errors.New("Expected value t... | [
"func",
"(",
"m",
"*",
"MetadataValue",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"m",
".",
"Type",
"{",
"case",
"MetadataValueTypeString",
":",
"_",
",",
"ok",
":=",
"m",
".",
"Value",
".",
"(",
"string",
")",
... | // Validate validates this MetadataValue | [
"Validate",
"validates",
"this",
"MetadataValue"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L147-L183 |
145,411 | manifoldco/go-manifold | types.go | Equals | func (m Metadata) Equals(md Metadata) bool {
if len(m) != len(md) {
return false
}
for k, v := range m {
if val, ok := md[k]; !ok || !val.Equals(v) {
return false
}
}
return true
} | go | func (m Metadata) Equals(md Metadata) bool {
if len(m) != len(md) {
return false
}
for k, v := range m {
if val, ok := md[k]; !ok || !val.Equals(v) {
return false
}
}
return true
} | [
"func",
"(",
"m",
"Metadata",
")",
"Equals",
"(",
"md",
"Metadata",
")",
"bool",
"{",
"if",
"len",
"(",
"m",
")",
"!=",
"len",
"(",
"md",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"if",
"val"... | // Equals checks the equality of another Metadata against this one | [
"Equals",
"checks",
"the",
"equality",
"of",
"another",
"Metadata",
"against",
"this",
"one"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L198-L209 |
145,412 | manifoldco/go-manifold | types.go | Validate | func (m Metadata) Validate(_ interface{}) error {
for k, v := range m {
// Make sure key is a label
if err := Label(k).Validate(nil); err != nil {
return errors.Errorf("Key '%s' is not a valid Manifold Label", k)
}
// Make sure value is valid
if err := v.Validate(nil); err != nil {
return errors.Errorf... | go | func (m Metadata) Validate(_ interface{}) error {
for k, v := range m {
// Make sure key is a label
if err := Label(k).Validate(nil); err != nil {
return errors.Errorf("Key '%s' is not a valid Manifold Label", k)
}
// Make sure value is valid
if err := v.Validate(nil); err != nil {
return errors.Errorf... | [
"func",
"(",
"m",
"Metadata",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"// Make sure key is a label",
"if",
"err",
":=",
"Label",
"(",
"k",
")",
".",
"Validate",
"(",
"nil",
... | // Validate validates this Metadata | [
"Validate",
"validates",
"this",
"Metadata"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L212-L231 |
145,413 | manifoldco/go-manifold | types.go | GetString | func (m Metadata) GetString(key string) (*string, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeString {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(string)
return &out, nil
} | go | func (m Metadata) GetString(key string) (*string, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeString {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(string)
return &out, nil
} | [
"func",
"(",
"m",
"Metadata",
")",
"GetString",
"(",
"key",
"string",
")",
"(",
"*",
"string",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"m",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ErrMetadataNonexistantKey",
"\n"... | // GetString returns the value of the specified key as a string, or returns an error | [
"GetString",
"returns",
"the",
"value",
"of",
"the",
"specified",
"key",
"as",
"a",
"string",
"or",
"returns",
"an",
"error"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L234-L244 |
145,414 | manifoldco/go-manifold | types.go | GetBool | func (m Metadata) GetBool(key string) (*bool, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeBool {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(bool)
return &out, nil
} | go | func (m Metadata) GetBool(key string) (*bool, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeBool {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(bool)
return &out, nil
} | [
"func",
"(",
"m",
"Metadata",
")",
"GetBool",
"(",
"key",
"string",
")",
"(",
"*",
"bool",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"m",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ErrMetadataNonexistantKey",
"\n",
... | // GetBool returns the value of the specified key as a bool, or returns an error | [
"GetBool",
"returns",
"the",
"value",
"of",
"the",
"specified",
"key",
"as",
"a",
"bool",
"or",
"returns",
"an",
"error"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L247-L257 |
145,415 | manifoldco/go-manifold | types.go | GetInt | func (m Metadata) GetInt(key string) (*int64, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeInt {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(int64)
return &out, nil
} | go | func (m Metadata) GetInt(key string) (*int64, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeInt {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(int64)
return &out, nil
} | [
"func",
"(",
"m",
"Metadata",
")",
"GetInt",
"(",
"key",
"string",
")",
"(",
"*",
"int64",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"m",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ErrMetadataNonexistantKey",
"\n",
... | // GetInt returns the value of the specified key as a int64, or returns an error | [
"GetInt",
"returns",
"the",
"value",
"of",
"the",
"specified",
"key",
"as",
"a",
"int64",
"or",
"returns",
"an",
"error"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L260-L270 |
145,416 | manifoldco/go-manifold | types.go | GetFloat | func (m Metadata) GetFloat(key string) (*float64, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeFloat {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(float64)
return &out, nil
} | go | func (m Metadata) GetFloat(key string) (*float64, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeFloat {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(float64)
return &out, nil
} | [
"func",
"(",
"m",
"Metadata",
")",
"GetFloat",
"(",
"key",
"string",
")",
"(",
"*",
"float64",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"m",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ErrMetadataNonexistantKey",
"\n"... | // GetFloat returns the value of the specified key as a float64, or returns an error | [
"GetFloat",
"returns",
"the",
"value",
"of",
"the",
"specified",
"key",
"as",
"a",
"float64",
"or",
"returns",
"an",
"error"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L273-L283 |
145,417 | manifoldco/go-manifold | types.go | GetObject | func (m Metadata) GetObject(key string) (Metadata, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeObject {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(Metadata)
return out, nil
} | go | func (m Metadata) GetObject(key string) (Metadata, error) {
val, ok := m[key]
if !ok {
return nil, ErrMetadataNonexistantKey
}
if val.Type != MetadataValueTypeObject {
return nil, ErrMetadataUnexpectedValueType
}
out, _ := val.Value.(Metadata)
return out, nil
} | [
"func",
"(",
"m",
"Metadata",
")",
"GetObject",
"(",
"key",
"string",
")",
"(",
"Metadata",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"m",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"ErrMetadataNonexistantKey",
"\n",
"... | // GetObject returns the value of the specified key as a Metadata, or returns an error | [
"GetObject",
"returns",
"the",
"value",
"of",
"the",
"specified",
"key",
"as",
"a",
"Metadata",
"or",
"returns",
"an",
"error"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L286-L296 |
145,418 | manifoldco/go-manifold | types.go | Equals | func (a AnnotationsMap) Equals(fm AnnotationsMap) bool {
if len(a) != len(fm) {
return false
}
for key, value := range a {
val, ok := fm[key]
if !ok || len(value) != len(val) {
return false
}
for subkey, subvalue := range value {
if subval := fm[key][subkey]; subvalue != subval {
return false
... | go | func (a AnnotationsMap) Equals(fm AnnotationsMap) bool {
if len(a) != len(fm) {
return false
}
for key, value := range a {
val, ok := fm[key]
if !ok || len(value) != len(val) {
return false
}
for subkey, subvalue := range value {
if subval := fm[key][subkey]; subvalue != subval {
return false
... | [
"func",
"(",
"a",
"AnnotationsMap",
")",
"Equals",
"(",
"fm",
"AnnotationsMap",
")",
"bool",
"{",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"fm",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"a",
"{... | // Equals checks the equality of another AnnotationsMap against this one | [
"Equals",
"checks",
"the",
"equality",
"of",
"another",
"AnnotationsMap",
"against",
"this",
"one"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L318-L335 |
145,419 | manifoldco/go-manifold | types.go | Validate | func (a AnnotationsMap) Validate(_ interface{}) error {
countReserved := 0
for key, value := range a {
// Make sure the key is a valid key
if err := AnnotationKey(key).Validate(nil); err != nil {
return errors.Errorf("Key '%s' is not a valid annotation key", key)
}
// Make sure that, if the key is reserved... | go | func (a AnnotationsMap) Validate(_ interface{}) error {
countReserved := 0
for key, value := range a {
// Make sure the key is a valid key
if err := AnnotationKey(key).Validate(nil); err != nil {
return errors.Errorf("Key '%s' is not a valid annotation key", key)
}
// Make sure that, if the key is reserved... | [
"func",
"(",
"a",
"AnnotationsMap",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"countReserved",
":=",
"0",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"a",
"{",
"// Make sure the key is a valid key",
"if",
"err",
":=",
"Annot... | // Validate validates this AnnotationsMap | [
"Validate",
"validates",
"this",
"AnnotationsMap"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/types.go#L338-L372 |
145,420 | manifoldco/go-manifold | formats.go | Validate | func (e Email) Validate(_ interface{}) error {
if govalidator.IsEmail(string(e)) {
return nil
}
return errInvalidEmail
} | go | func (e Email) Validate(_ interface{}) error {
if govalidator.IsEmail(string(e)) {
return nil
}
return errInvalidEmail
} | [
"func",
"(",
"e",
"Email",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"govalidator",
".",
"IsEmail",
"(",
"string",
"(",
"e",
")",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"errInvalidEmail",
"\n",
"}"
] | // Validate ensures that the email is valid | [
"Validate",
"ensures",
"that",
"the",
"email",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/formats.go#L68-L74 |
145,421 | manifoldco/go-manifold | formats.go | Validate | func (key AnnotationKey) Validate(_ interface{}) error {
if annotationKeyRegex.Match([]byte(key)) {
return nil
}
return errInvalidAnnotationKey
} | go | func (key AnnotationKey) Validate(_ interface{}) error {
if annotationKeyRegex.Match([]byte(key)) {
return nil
}
return errInvalidAnnotationKey
} | [
"func",
"(",
"key",
"AnnotationKey",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"annotationKeyRegex",
".",
"Match",
"(",
"[",
"]",
"byte",
"(",
"key",
")",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"errIn... | // Validate ensures the annotation key is valid | [
"Validate",
"ensures",
"the",
"annotation",
"key",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/formats.go#L104-L110 |
145,422 | manifoldco/go-manifold | formats.go | Validate | func (val AnnotationValue) Validate(_ interface{}) error {
if annotationValueRegex.Match([]byte(val)) {
return nil
}
return errInvalidAnnotationValue
} | go | func (val AnnotationValue) Validate(_ interface{}) error {
if annotationValueRegex.Match([]byte(val)) {
return nil
}
return errInvalidAnnotationValue
} | [
"func",
"(",
"val",
"AnnotationValue",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"annotationValueRegex",
".",
"Match",
"(",
"[",
"]",
"byte",
"(",
"val",
")",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"e... | // Validate ensures the annotation value is valid | [
"Validate",
"ensures",
"the",
"annotation",
"value",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/formats.go#L116-L122 |
145,423 | manifoldco/go-manifold | formats.go | Validate | func (key CredentialKey) Validate(_ interface{}) error {
if credentialKeyRegex.Match([]byte(key)) {
return nil
}
return errInvalidCredentialKey
} | go | func (key CredentialKey) Validate(_ interface{}) error {
if credentialKeyRegex.Match([]byte(key)) {
return nil
}
return errInvalidCredentialKey
} | [
"func",
"(",
"key",
"CredentialKey",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"credentialKeyRegex",
".",
"Match",
"(",
"[",
"]",
"byte",
"(",
"key",
")",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"errIn... | // Validate ensures the credential key is valid | [
"Validate",
"ensures",
"the",
"credential",
"key",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/formats.go#L128-L134 |
145,424 | manifoldco/go-manifold | formats.go | Validate | func (body CredentialBody) Validate(_ interface{}) error {
if len(body) > maxCredentialBodySize {
return errInvalidCredentialValue
}
return nil
} | go | func (body CredentialBody) Validate(_ interface{}) error {
if len(body) > maxCredentialBodySize {
return errInvalidCredentialValue
}
return nil
} | [
"func",
"(",
"body",
"CredentialBody",
")",
"Validate",
"(",
"_",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"body",
")",
">",
"maxCredentialBodySize",
"{",
"return",
"errInvalidCredentialValue",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"... | // Validate ensures the credential body is valid | [
"Validate",
"ensures",
"the",
"credential",
"body",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/formats.go#L140-L146 |
145,425 | najeira/ltsv | writer.go | NewWriter | func NewWriter(w io.Writer) *Writer {
return &Writer{
Delimiter: '\t',
UseCRLF: false,
w: bufio.NewWriter(w),
}
} | go | func NewWriter(w io.Writer) *Writer {
return &Writer{
Delimiter: '\t',
UseCRLF: false,
w: bufio.NewWriter(w),
}
} | [
"func",
"NewWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"Writer",
"{",
"return",
"&",
"Writer",
"{",
"Delimiter",
":",
"'\\t'",
",",
"UseCRLF",
":",
"false",
",",
"w",
":",
"bufio",
".",
"NewWriter",
"(",
"w",
")",
",",
"}",
"\n",
"}"
] | // NewWriter returns a new Writer that writes to w. | [
"NewWriter",
"returns",
"a",
"new",
"Writer",
"that",
"writes",
"to",
"w",
"."
] | 40eb84a5b5d21afa8f26f357445d910c62011166 | https://github.com/najeira/ltsv/blob/40eb84a5b5d21afa8f26f357445d910c62011166/writer.go#L43-L49 |
145,426 | najeira/ltsv | writer.go | Write | func (w *Writer) Write(record interface{}) error {
m, ok := record.(map[string]string)
if ok {
return w.writeMapString(m)
}
return w.writeAny(reflect.ValueOf(record))
} | go | func (w *Writer) Write(record interface{}) error {
m, ok := record.(map[string]string)
if ok {
return w.writeMapString(m)
}
return w.writeAny(reflect.ValueOf(record))
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"record",
"interface",
"{",
"}",
")",
"error",
"{",
"m",
",",
"ok",
":=",
"record",
".",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"if",
"ok",
"{",
"return",
"w",
".",
"writeMapString... | // Writer writes a single CSV record to w along with any necessary quoting.
// A record is a slice of strings with each string being one field. | [
"Writer",
"writes",
"a",
"single",
"CSV",
"record",
"to",
"w",
"along",
"with",
"any",
"necessary",
"quoting",
".",
"A",
"record",
"is",
"a",
"slice",
"of",
"strings",
"with",
"each",
"string",
"being",
"one",
"field",
"."
] | 40eb84a5b5d21afa8f26f357445d910c62011166 | https://github.com/najeira/ltsv/blob/40eb84a5b5d21afa8f26f357445d910c62011166/writer.go#L53-L59 |
145,427 | najeira/ltsv | writer.go | WriteAll | func (w *Writer) WriteAll(records interface{}) error {
m, ok := records.([]map[string]string)
if ok {
return w.writeMapStringAll(m)
}
return w.writeAnyAll(reflect.ValueOf(records))
} | go | func (w *Writer) WriteAll(records interface{}) error {
m, ok := records.([]map[string]string)
if ok {
return w.writeMapStringAll(m)
}
return w.writeAnyAll(reflect.ValueOf(records))
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"WriteAll",
"(",
"records",
"interface",
"{",
"}",
")",
"error",
"{",
"m",
",",
"ok",
":=",
"records",
".",
"(",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"if",
"ok",
"{",
"return",
"w",
"."... | // WriteAll writes multiple LTSV records to w using Write and then calls Flush. | [
"WriteAll",
"writes",
"multiple",
"LTSV",
"records",
"to",
"w",
"using",
"Write",
"and",
"then",
"calls",
"Flush",
"."
] | 40eb84a5b5d21afa8f26f357445d910c62011166 | https://github.com/najeira/ltsv/blob/40eb84a5b5d21afa8f26f357445d910c62011166/writer.go#L104-L110 |
145,428 | manifoldco/go-manifold | names/names.go | ForResource | func ForResource(product manifold.Label, id manifold.ID) manifold.Label {
idBytes := id[2:]
offset := 0
adj, offset := fetchWord(idBytes, data.Adjectives, offset, aShare)
color, offset := fetchWord(idBytes, data.Colors, offset, cShare)
shape, _ := fetchWord(idBytes, data.Shapes, offset, sShare)
label := fmt.Spr... | go | func ForResource(product manifold.Label, id manifold.ID) manifold.Label {
idBytes := id[2:]
offset := 0
adj, offset := fetchWord(idBytes, data.Adjectives, offset, aShare)
color, offset := fetchWord(idBytes, data.Colors, offset, cShare)
shape, _ := fetchWord(idBytes, data.Shapes, offset, sShare)
label := fmt.Spr... | [
"func",
"ForResource",
"(",
"product",
"manifold",
".",
"Label",
",",
"id",
"manifold",
".",
"ID",
")",
"manifold",
".",
"Label",
"{",
"idBytes",
":=",
"id",
"[",
"2",
":",
"]",
"\n\n",
"offset",
":=",
"0",
"\n",
"adj",
",",
"offset",
":=",
"fetchWor... | // ForResource returns a new label combining a product label with a random label
// for the resource based on its id. | [
"ForResource",
"returns",
"a",
"new",
"label",
"combining",
"a",
"product",
"label",
"with",
"a",
"random",
"label",
"for",
"the",
"resource",
"based",
"on",
"its",
"id",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/names/names.go#L47-L59 |
145,429 | manifoldco/go-manifold | integrations/client.go | NewClient | func NewClient(cl *manifold.Client, team *string) (*Client, error) {
c := &Client{
Client: cl,
team: team,
projectIDs: map[string]*manifold.ID{},
}
return c, c.ensureTeamID()
} | go | func NewClient(cl *manifold.Client, team *string) (*Client, error) {
c := &Client{
Client: cl,
team: team,
projectIDs: map[string]*manifold.ID{},
}
return c, c.ensureTeamID()
} | [
"func",
"NewClient",
"(",
"cl",
"*",
"manifold",
".",
"Client",
",",
"team",
"*",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"c",
":=",
"&",
"Client",
"{",
"Client",
":",
"cl",
",",
"team",
":",
"team",
",",
"projectIDs",
":",
"ma... | // NewClient returns a new wrapper client for the provided client, bound to the
// provided team. | [
"NewClient",
"returns",
"a",
"new",
"wrapper",
"client",
"for",
"the",
"provided",
"client",
"bound",
"to",
"the",
"provided",
"team",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L39-L46 |
145,430 | manifoldco/go-manifold | integrations/client.go | GetResource | func (c *Client) GetResource(ctx context.Context, project *string, res *primitives.Resource) (*manifold.Resource, error) {
rs, err := c.GetResources(ctx, project, []*primitives.Resource{res})
if err != nil {
return nil, err
}
if len(rs) > 1 {
// Names are unique per project. If no project is specified it could... | go | func (c *Client) GetResource(ctx context.Context, project *string, res *primitives.Resource) (*manifold.Resource, error) {
rs, err := c.GetResources(ctx, project, []*primitives.Resource{res})
if err != nil {
return nil, err
}
if len(rs) > 1 {
// Names are unique per project. If no project is specified it could... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetResource",
"(",
"ctx",
"context",
".",
"Context",
",",
"project",
"*",
"string",
",",
"res",
"*",
"primitives",
".",
"Resource",
")",
"(",
"*",
"manifold",
".",
"Resource",
",",
"error",
")",
"{",
"rs",
",",
... | // GetResource gets a resource for a specific label. If no resource is given,
// this will error. | [
"GetResource",
"gets",
"a",
"resource",
"for",
"a",
"specific",
"label",
".",
"If",
"no",
"resource",
"is",
"given",
"this",
"will",
"error",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L50-L64 |
145,431 | manifoldco/go-manifold | integrations/client.go | GetProjectCredentialValues | func (c *Client) GetProjectCredentialValues(ctx context.Context, project *primitives.Project) (map[string][]*primitives.CredentialValue, error) {
if !project.Valid() {
return nil, ErrProjectInvalid
}
for _, r := range project.Resources {
if !r.Valid() {
return nil, ErrResourceInvalid
}
}
resources, err ... | go | func (c *Client) GetProjectCredentialValues(ctx context.Context, project *primitives.Project) (map[string][]*primitives.CredentialValue, error) {
if !project.Valid() {
return nil, ErrProjectInvalid
}
for _, r := range project.Resources {
if !r.Valid() {
return nil, ErrResourceInvalid
}
}
resources, err ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetProjectCredentialValues",
"(",
"ctx",
"context",
".",
"Context",
",",
"project",
"*",
"primitives",
".",
"Project",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"primitives",
".",
"CredentialValue",
",",
"... | // GetProjectCredentialValues fetches a Project's set of CredentialValues
// If the Project's list of resource is populated, then the CredentialValues
// are mapped to their owning Resource using the Resource name. This will
// also provide defaults if you have provided a Default value. Unlike
// GetResourcesCredential... | [
"GetProjectCredentialValues",
"fetches",
"a",
"Project",
"s",
"set",
"of",
"CredentialValues",
"If",
"the",
"Project",
"s",
"list",
"of",
"resource",
"is",
"populated",
"then",
"the",
"CredentialValues",
"are",
"mapped",
"to",
"their",
"owning",
"Resource",
"using... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L72-L100 |
145,432 | manifoldco/go-manifold | integrations/client.go | GetResourceCredentialValues | func (c *Client) GetResourceCredentialValues(ctx context.Context, project *string, res *primitives.Resource) ([]*primitives.CredentialValue, error) {
resourceCreds, err := c.GetResourcesCredentialValues(ctx, project, []*primitives.Resource{res})
if err != nil {
return nil, err
}
creds, ok := resourceCreds[res.Na... | go | func (c *Client) GetResourceCredentialValues(ctx context.Context, project *string, res *primitives.Resource) ([]*primitives.CredentialValue, error) {
resourceCreds, err := c.GetResourcesCredentialValues(ctx, project, []*primitives.Resource{res})
if err != nil {
return nil, err
}
creds, ok := resourceCreds[res.Na... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetResourceCredentialValues",
"(",
"ctx",
"context",
".",
"Context",
",",
"project",
"*",
"string",
",",
"res",
"*",
"primitives",
".",
"Resource",
")",
"(",
"[",
"]",
"*",
"primitives",
".",
"CredentialValue",
",",
... | // GetResourceCredentialValues is a wrapper function that knows how to get a set
// of specific credentials for a given requested resource. | [
"GetResourceCredentialValues",
"is",
"a",
"wrapper",
"function",
"that",
"knows",
"how",
"to",
"get",
"a",
"set",
"of",
"specific",
"credentials",
"for",
"a",
"given",
"requested",
"resource",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L104-L116 |
145,433 | manifoldco/go-manifold | integrations/client.go | GetResourcesCredentialValues | func (c *Client) GetResourcesCredentialValues(ctx context.Context, project *string, res []*primitives.Resource) (map[string][]*primitives.CredentialValue, error) {
for _, r := range res {
if !r.Valid() {
return nil, ErrResourceInvalid
}
}
resources, err := c.GetResources(ctx, project, res)
if err != nil {
... | go | func (c *Client) GetResourcesCredentialValues(ctx context.Context, project *string, res []*primitives.Resource) (map[string][]*primitives.CredentialValue, error) {
for _, r := range res {
if !r.Valid() {
return nil, ErrResourceInvalid
}
}
resources, err := c.GetResources(ctx, project, res)
if err != nil {
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetResourcesCredentialValues",
"(",
"ctx",
"context",
".",
"Context",
",",
"project",
"*",
"string",
",",
"res",
"[",
"]",
"*",
"primitives",
".",
"Resource",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
... | // GetResourcesCredentialValues is a wrapper function that gets a list of
// CredentialValues for a list of resources and then maps all the credentials to
// it's specific Resource using the Resource Name.
// This also takes care of filling up the gaps. If you have requested a
// ResourceCredential with a non existing ... | [
"GetResourcesCredentialValues",
"is",
"a",
"wrapper",
"function",
"that",
"gets",
"a",
"list",
"of",
"CredentialValues",
"for",
"a",
"list",
"of",
"resources",
"and",
"then",
"maps",
"all",
"the",
"credentials",
"to",
"it",
"s",
"specific",
"Resource",
"using",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L125-L147 |
145,434 | manifoldco/go-manifold | integrations/client.go | GetResources | func (c *Client) GetResources(ctx context.Context, project *string, res []*primitives.Resource) ([]*manifold.Resource, error) {
for _, r := range res {
if !r.Valid() {
return nil, ErrResourceInvalid
}
}
pID, err := c.ProjectID(project)
if err != nil {
return nil, err
}
resourceList := c.Client.Resource... | go | func (c *Client) GetResources(ctx context.Context, project *string, res []*primitives.Resource) ([]*manifold.Resource, error) {
for _, r := range res {
if !r.Valid() {
return nil, ErrResourceInvalid
}
}
pID, err := c.ProjectID(project)
if err != nil {
return nil, err
}
resourceList := c.Client.Resource... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetResources",
"(",
"ctx",
"context",
".",
"Context",
",",
"project",
"*",
"string",
",",
"res",
"[",
"]",
"*",
"primitives",
".",
"Resource",
")",
"(",
"[",
"]",
"*",
"manifold",
".",
"Resource",
",",
"error",
... | // GetResources fetches a set of resources according to their labels. If no
// resources are given, all the resources will be fetched. If one of the
// requested resources is not available, this will return an error. | [
"GetResources",
"fetches",
"a",
"set",
"of",
"resources",
"according",
"to",
"their",
"labels",
".",
"If",
"no",
"resources",
"are",
"given",
"all",
"the",
"resources",
"will",
"be",
"fetched",
".",
"If",
"one",
"of",
"the",
"requested",
"resources",
"is",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L272-L307 |
145,435 | manifoldco/go-manifold | integrations/client.go | ProjectID | func (c *Client) ProjectID(label *string) (*manifold.ID, error) {
if label == nil {
return nil, nil
}
if v, ok := c.getCachedProjectID(*label); ok {
return v, nil
}
projectList := c.Client.Projects.List(context.Background(), &manifold.ProjectsListOpts{
Label: label,
TeamID: c.TeamID,
})
defer projectL... | go | func (c *Client) ProjectID(label *string) (*manifold.ID, error) {
if label == nil {
return nil, nil
}
if v, ok := c.getCachedProjectID(*label); ok {
return v, nil
}
projectList := c.Client.Projects.List(context.Background(), &manifold.ProjectsListOpts{
Label: label,
TeamID: c.TeamID,
})
defer projectL... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ProjectID",
"(",
"label",
"*",
"string",
")",
"(",
"*",
"manifold",
".",
"ID",
",",
"error",
")",
"{",
"if",
"label",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"v",
",",
"ok",... | // ProjectID will return the ID for a project based on it's label. It uses an
// internal cache so it doesn't have to multiple requests for a single label. | [
"ProjectID",
"will",
"return",
"the",
"ID",
"for",
"a",
"project",
"based",
"on",
"it",
"s",
"label",
".",
"It",
"uses",
"an",
"internal",
"cache",
"so",
"it",
"doesn",
"t",
"have",
"to",
"multiple",
"requests",
"for",
"a",
"single",
"label",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L311-L339 |
145,436 | manifoldco/go-manifold | integrations/client.go | getCachedProjectID | func (c *Client) getCachedProjectID(label string) (*manifold.ID, bool) {
c.RLock()
defer c.RUnlock()
v, ok := c.projectIDs[label]
return v, ok
} | go | func (c *Client) getCachedProjectID(label string) (*manifold.ID, bool) {
c.RLock()
defer c.RUnlock()
v, ok := c.projectIDs[label]
return v, ok
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"getCachedProjectID",
"(",
"label",
"string",
")",
"(",
"*",
"manifold",
".",
"ID",
",",
"bool",
")",
"{",
"c",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
... | // wrapper around the map to get a ReadLock for concurrency. This could easily
// be done with Go 1.9 sync.Map, but we want to support versions below. | [
"wrapper",
"around",
"the",
"map",
"to",
"get",
"a",
"ReadLock",
"for",
"concurrency",
".",
"This",
"could",
"easily",
"be",
"done",
"with",
"Go",
"1",
".",
"9",
"sync",
".",
"Map",
"but",
"we",
"want",
"to",
"support",
"versions",
"below",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L343-L349 |
145,437 | manifoldco/go-manifold | integrations/client.go | setCachedProjectID | func (c *Client) setCachedProjectID(label string, id *manifold.ID) {
c.Lock()
defer c.Unlock()
c.projectIDs[label] = id
} | go | func (c *Client) setCachedProjectID(label string, id *manifold.ID) {
c.Lock()
defer c.Unlock()
c.projectIDs[label] = id
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"setCachedProjectID",
"(",
"label",
"string",
",",
"id",
"*",
"manifold",
".",
"ID",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
".",
"projectIDs",
"[",
"la... | // wrapper around the map to get a Lock for concurrency. This could easily be
// done with Go 1.9 sync.Map, but we want to support versions below. | [
"wrapper",
"around",
"the",
"map",
"to",
"get",
"a",
"Lock",
"for",
"concurrency",
".",
"This",
"could",
"easily",
"be",
"done",
"with",
"Go",
"1",
".",
"9",
"sync",
".",
"Map",
"but",
"we",
"want",
"to",
"support",
"versions",
"below",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/client.go#L353-L358 |
145,438 | manifoldco/go-manifold | zz_oag_generated_marketplace.go | Current | func (i *CredentialIter) Current() (*Credential, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *CredentialIter) Current() (*Credential, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"CredentialIter",
")",
"Current",
"(",
")",
"(",
"*",
"Credential",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"page",... | // Current returns the current Credential, and an optional error. Once an error has been returned,
// the CredentialIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"Credential",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"CredentialIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
"calls... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_marketplace.go#L173-L178 |
145,439 | manifoldco/go-manifold | zz_oag_generated_marketplace.go | Current | func (i *ProjectIter) Current() (*Project, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *ProjectIter) Current() (*Project, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"ProjectIter",
")",
"Current",
"(",
")",
"(",
"*",
"Project",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"page",
"["... | // Current returns the current Project, and an optional error. Once an error has been returned,
// the ProjectIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"Project",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"ProjectIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
"calls",
"... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_marketplace.go#L209-L214 |
145,440 | manifoldco/go-manifold | zz_oag_generated_marketplace.go | Current | func (i *ResourceIter) Current() (*Resource, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *ResourceIter) Current() (*Resource, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"ResourceIter",
")",
"Current",
"(",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"page",
"... | // Current returns the current Resource, and an optional error. Once an error has been returned,
// the ResourceIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"Resource",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"ResourceIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
"calls",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_marketplace.go#L245-L250 |
145,441 | manifoldco/go-manifold | zz_oag_generated_marketplace.go | NewMarketplace | func NewMarketplace() *MarketplaceClient {
c := &MarketplaceClient{}
c.common.backend = DefaultBackend()
c.Credentials = (*CredentialsClient)(&c.common)
c.Internal = (*InternalClient)(&c.common)
c.Projects = (*ProjectsClient)(&c.common)
c.Resources = (*ResourcesClient)(&c.common)
return c
} | go | func NewMarketplace() *MarketplaceClient {
c := &MarketplaceClient{}
c.common.backend = DefaultBackend()
c.Credentials = (*CredentialsClient)(&c.common)
c.Internal = (*InternalClient)(&c.common)
c.Projects = (*ProjectsClient)(&c.common)
c.Resources = (*ResourcesClient)(&c.common)
return c
} | [
"func",
"NewMarketplace",
"(",
")",
"*",
"MarketplaceClient",
"{",
"c",
":=",
"&",
"MarketplaceClient",
"{",
"}",
"\n",
"c",
".",
"common",
".",
"backend",
"=",
"DefaultBackend",
"(",
")",
"\n\n",
"c",
".",
"Credentials",
"=",
"(",
"*",
"CredentialsClient"... | // NewMarketplace returns a new MarketplaceClient with the default configuration. | [
"NewMarketplace",
"returns",
"a",
"new",
"MarketplaceClient",
"with",
"the",
"default",
"configuration",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_marketplace.go#L643-L653 |
145,442 | st3v/translator | http/client.go | NewClient | func NewClient(authenticator Authenticator) Client {
return &client{
client: &http.Client{},
authenticator: authenticator,
}
} | go | func NewClient(authenticator Authenticator) Client {
return &client{
client: &http.Client{},
authenticator: authenticator,
}
} | [
"func",
"NewClient",
"(",
"authenticator",
"Authenticator",
")",
"Client",
"{",
"return",
"&",
"client",
"{",
"client",
":",
"&",
"http",
".",
"Client",
"{",
"}",
",",
"authenticator",
":",
"authenticator",
",",
"}",
"\n",
"}"
] | // NewClient instantiates a Client and initializes it with the passed Authenticator. | [
"NewClient",
"instantiates",
"a",
"Client",
"and",
"initializes",
"it",
"with",
"the",
"passed",
"Authenticator",
"."
] | d13056a5929704f264d21b102987311c0f379fc3 | https://github.com/st3v/translator/blob/d13056a5929704f264d21b102987311c0f379fc3/http/client.go#L21-L26 |
145,443 | manifoldco/go-manifold | flexid.go | SubDomain | func (d Domain) SubDomain() string {
parts := domainRegex.FindSubmatch([]byte(d))
if len(parts[1]) > 0 {
subdomain := string(parts[1])
return subdomain[:len(subdomain)-1]
}
return ""
} | go | func (d Domain) SubDomain() string {
parts := domainRegex.FindSubmatch([]byte(d))
if len(parts[1]) > 0 {
subdomain := string(parts[1])
return subdomain[:len(subdomain)-1]
}
return ""
} | [
"func",
"(",
"d",
"Domain",
")",
"SubDomain",
"(",
")",
"string",
"{",
"parts",
":=",
"domainRegex",
".",
"FindSubmatch",
"(",
"[",
"]",
"byte",
"(",
"d",
")",
")",
"\n\n",
"if",
"len",
"(",
"parts",
"[",
"1",
"]",
")",
">",
"0",
"{",
"subdomain"... | // SubDomain returns the subdomain portion of the domain | [
"SubDomain",
"returns",
"the",
"subdomain",
"portion",
"of",
"the",
"domain"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L66-L75 |
145,444 | manifoldco/go-manifold | flexid.go | Validate | func (c Class) Validate(r strfmt.Registry) error {
return c.Label().Validate(r)
} | go | func (c Class) Validate(r strfmt.Registry) error {
return c.Label().Validate(r)
} | [
"func",
"(",
"c",
"Class",
")",
"Validate",
"(",
"r",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"return",
"c",
".",
"Label",
"(",
")",
".",
"Validate",
"(",
"r",
")",
"\n",
"}"
] | // Validate implements the runtime Validatable interface | [
"Validate",
"implements",
"the",
"runtime",
"Validatable",
"interface"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L86-L88 |
145,445 | manifoldco/go-manifold | flexid.go | NewFlexID | func NewFlexID(d Domain, c Class, id ExternalID) (*FlexID, error) {
out := FlexID{d.String(), c.String(), id.String()}
if err := out.Validate(nil); err != nil {
return nil, err
}
return &out, nil
} | go | func NewFlexID(d Domain, c Class, id ExternalID) (*FlexID, error) {
out := FlexID{d.String(), c.String(), id.String()}
if err := out.Validate(nil); err != nil {
return nil, err
}
return &out, nil
} | [
"func",
"NewFlexID",
"(",
"d",
"Domain",
",",
"c",
"Class",
",",
"id",
"ExternalID",
")",
"(",
"*",
"FlexID",
",",
"error",
")",
"{",
"out",
":=",
"FlexID",
"{",
"d",
".",
"String",
"(",
")",
",",
"c",
".",
"String",
"(",
")",
",",
"id",
".",
... | // NewFlexID constructs a FlexID from the provided Domain, Class, and ID parts | [
"NewFlexID",
"constructs",
"a",
"FlexID",
"from",
"the",
"provided",
"Domain",
"Class",
"and",
"ID",
"parts"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L144-L150 |
145,446 | manifoldco/go-manifold | flexid.go | FlexIDFromID | func FlexIDFromID(id ID) *FlexID {
return &FlexID{id.Domain().String(), id.Class().String(), id.ID().String()}
} | go | func FlexIDFromID(id ID) *FlexID {
return &FlexID{id.Domain().String(), id.Class().String(), id.ID().String()}
} | [
"func",
"FlexIDFromID",
"(",
"id",
"ID",
")",
"*",
"FlexID",
"{",
"return",
"&",
"FlexID",
"{",
"id",
".",
"Domain",
"(",
")",
".",
"String",
"(",
")",
",",
"id",
".",
"Class",
"(",
")",
".",
"String",
"(",
")",
",",
"id",
".",
"ID",
"(",
")"... | // FlexIDFromID takes a Manifold ID and converts it to a FlexID for storage | [
"FlexIDFromID",
"takes",
"a",
"Manifold",
"ID",
"and",
"converts",
"it",
"to",
"a",
"FlexID",
"for",
"storage"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L153-L155 |
145,447 | manifoldco/go-manifold | flexid.go | String | func (id FlexID) String() string {
return fmt.Sprintf("%s%s%s%s%s", id.Domain(), pathSeperator, id.Class(),
pathSeperator, id.ID())
} | go | func (id FlexID) String() string {
return fmt.Sprintf("%s%s%s%s%s", id.Domain(), pathSeperator, id.Class(),
pathSeperator, id.ID())
} | [
"func",
"(",
"id",
"FlexID",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"id",
".",
"Domain",
"(",
")",
",",
"pathSeperator",
",",
"id",
".",
"Class",
"(",
")",
",",
"pathSeperator",
",",
"id",
"... | // String implements the Stringer interface for go | [
"String",
"implements",
"the",
"Stringer",
"interface",
"for",
"go"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L183-L186 |
145,448 | manifoldco/go-manifold | flexid.go | Validate | func (id FlexID) Validate(v strfmt.Registry) error {
if err := id.Domain().Validate(v); err != nil {
return err
}
if id.Class().Validate(v) != nil {
return errInvalidClass
}
if err := id.ID().Validate(v); err != nil {
return err
}
return nil
} | go | func (id FlexID) Validate(v strfmt.Registry) error {
if err := id.Domain().Validate(v); err != nil {
return err
}
if id.Class().Validate(v) != nil {
return errInvalidClass
}
if err := id.ID().Validate(v); err != nil {
return err
}
return nil
} | [
"func",
"(",
"id",
"FlexID",
")",
"Validate",
"(",
"v",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"if",
"err",
":=",
"id",
".",
"Domain",
"(",
")",
".",
"Validate",
"(",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\... | // Validate implements the Validate interface for goswagger
// which always succeeds because the ID is already parsed | [
"Validate",
"implements",
"the",
"Validate",
"interface",
"for",
"goswagger",
"which",
"always",
"succeeds",
"because",
"the",
"ID",
"is",
"already",
"parsed"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L190-L202 |
145,449 | manifoldco/go-manifold | flexid.go | AsManifoldID | func (id FlexID) AsManifoldID() (*ID, error) {
if id.Domain() != ManifoldDomain {
return nil, ErrNotAManifoldID
}
mid, err := DecodeIDFromString(id.ID().String())
if err != nil {
return nil, ErrNotAManifoldID
}
if mid.Type().Name() != id.Class().String() {
return nil, ErrManifoldIDTypeMismatch
}
return &m... | go | func (id FlexID) AsManifoldID() (*ID, error) {
if id.Domain() != ManifoldDomain {
return nil, ErrNotAManifoldID
}
mid, err := DecodeIDFromString(id.ID().String())
if err != nil {
return nil, ErrNotAManifoldID
}
if mid.Type().Name() != id.Class().String() {
return nil, ErrManifoldIDTypeMismatch
}
return &m... | [
"func",
"(",
"id",
"FlexID",
")",
"AsManifoldID",
"(",
")",
"(",
"*",
"ID",
",",
"error",
")",
"{",
"if",
"id",
".",
"Domain",
"(",
")",
"!=",
"ManifoldDomain",
"{",
"return",
"nil",
",",
"ErrNotAManifoldID",
"\n",
"}",
"\n",
"mid",
",",
"err",
":=... | // AsManifoldID validates that the FlexID adheres with the requirements of a ManifoldID
// and attempts to cast it to one | [
"AsManifoldID",
"validates",
"that",
"the",
"FlexID",
"adheres",
"with",
"the",
"requirements",
"of",
"a",
"ManifoldID",
"and",
"attempts",
"to",
"cast",
"it",
"to",
"one"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L270-L282 |
145,450 | manifoldco/go-manifold | flexid.go | IsEmpty | func (id FlexID) IsEmpty() bool {
if id.ID() == "" {
// Just checking the ID portion should be sufficient
// This will allow for Empty Domains, and Classes, though they would still
// be invalid, this is not designed to check validity
return true
}
// We also need to check if it's a Manifold ID because it w... | go | func (id FlexID) IsEmpty() bool {
if id.ID() == "" {
// Just checking the ID portion should be sufficient
// This will allow for Empty Domains, and Classes, though they would still
// be invalid, this is not designed to check validity
return true
}
// We also need to check if it's a Manifold ID because it w... | [
"func",
"(",
"id",
"FlexID",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"if",
"id",
".",
"ID",
"(",
")",
"==",
"\"",
"\"",
"{",
"// Just checking the ID portion should be sufficient",
"// This will allow for Empty Domains, and Classes, though they would still",
"// be invali... | // IsEmpty checks if the FlexID is considered empty or not | [
"IsEmpty",
"checks",
"if",
"the",
"FlexID",
"is",
"considered",
"empty",
"or",
"not"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/flexid.go#L285-L301 |
145,451 | st3v/translator | example/main.go | helloWorld | func helloWorld(t translator.Translator) {
languages, err := t.Languages()
if err != nil {
fmt.Printf("Error retrieving languages: %s\n", err.Error())
return
}
fmt.Printf("%d Supported Languages:\n", len(languages))
fmt.Println("-----------------------")
translations := make([]<-chan string, len(languages))... | go | func helloWorld(t translator.Translator) {
languages, err := t.Languages()
if err != nil {
fmt.Printf("Error retrieving languages: %s\n", err.Error())
return
}
fmt.Printf("%d Supported Languages:\n", len(languages))
fmt.Println("-----------------------")
translations := make([]<-chan string, len(languages))... | [
"func",
"helloWorld",
"(",
"t",
"translator",
".",
"Translator",
")",
"{",
"languages",
",",
"err",
":=",
"t",
".",
"Languages",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
".",
"Error",
... | // Fetches all supported languages and triggers concurrent translations of 'Hello World' for each of them. | [
"Fetches",
"all",
"supported",
"languages",
"and",
"triggers",
"concurrent",
"translations",
"of",
"Hello",
"World",
"for",
"each",
"of",
"them",
"."
] | d13056a5929704f264d21b102987311c0f379fc3 | https://github.com/st3v/translator/blob/d13056a5929704f264d21b102987311c0f379fc3/example/main.go#L20-L38 |
145,452 | st3v/translator | example/main.go | translate | func translate(t translator.Translator, text, from string, to translator.Language) <-chan string {
out := make(chan string)
go func() {
translation, err := t.Translate(text, from, to.Code)
if err != nil {
out <- fmt.Sprintf("Error during translation for %s: %s", to.Name, err.Error())
} else {
out <- fmt.S... | go | func translate(t translator.Translator, text, from string, to translator.Language) <-chan string {
out := make(chan string)
go func() {
translation, err := t.Translate(text, from, to.Code)
if err != nil {
out <- fmt.Sprintf("Error during translation for %s: %s", to.Name, err.Error())
} else {
out <- fmt.S... | [
"func",
"translate",
"(",
"t",
"translator",
".",
"Translator",
",",
"text",
",",
"from",
"string",
",",
"to",
"translator",
".",
"Language",
")",
"<-",
"chan",
"string",
"{",
"out",
":=",
"make",
"(",
"chan",
"string",
")",
"\n",
"go",
"func",
"(",
... | // Starts a go routine to translate text for a particular language. Returns a channel that will be
// used to send either the translation or an error string if something went wrong. | [
"Starts",
"a",
"go",
"routine",
"to",
"translate",
"text",
"for",
"a",
"particular",
"language",
".",
"Returns",
"a",
"channel",
"that",
"will",
"be",
"used",
"to",
"send",
"either",
"the",
"translation",
"or",
"an",
"error",
"string",
"if",
"something",
"... | d13056a5929704f264d21b102987311c0f379fc3 | https://github.com/st3v/translator/blob/d13056a5929704f264d21b102987311c0f379fc3/example/main.go#L42-L54 |
145,453 | st3v/translator | example/main.go | mergeChannels | func mergeChannels(cs []<-chan string) <-chan string {
var wg sync.WaitGroup
out := make(chan string)
output := func(c <-chan string) {
for n := range c {
out <- n
}
wg.Done()
}
wg.Add(len(cs))
for _, c := range cs {
go output(c)
}
go func() {
wg.Wait()
close(out)
}()
return out
} | go | func mergeChannels(cs []<-chan string) <-chan string {
var wg sync.WaitGroup
out := make(chan string)
output := func(c <-chan string) {
for n := range c {
out <- n
}
wg.Done()
}
wg.Add(len(cs))
for _, c := range cs {
go output(c)
}
go func() {
wg.Wait()
close(out)
}()
return out
} | [
"func",
"mergeChannels",
"(",
"cs",
"[",
"]",
"<-",
"chan",
"string",
")",
"<-",
"chan",
"string",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"out",
":=",
"make",
"(",
"chan",
"string",
")",
"\n\n",
"output",
":=",
"func",
"(",
"c",
"<-",
"c... | // Merges a slice of incoming channels of strings into a single incoming channel of strings. | [
"Merges",
"a",
"slice",
"of",
"incoming",
"channels",
"of",
"strings",
"into",
"a",
"single",
"incoming",
"channel",
"of",
"strings",
"."
] | d13056a5929704f264d21b102987311c0f379fc3 | https://github.com/st3v/translator/blob/d13056a5929704f264d21b102987311c0f379fc3/example/main.go#L57-L78 |
145,454 | martinhoefling/goxkcdpwgen | xkcdpwgen/pwgen.go | GeneratePasswordString | func (g *Generator) GeneratePasswordString() string {
var words = make([]string, g.numwords)
for i := 0; i < g.numwords; i++ {
if g.capitalize {
words[i] = strings.Title(randomWord(g.wordlist))
} else {
words[i] = randomWord(g.wordlist)
}
}
return strings.Join(words, g.delimiter)
} | go | func (g *Generator) GeneratePasswordString() string {
var words = make([]string, g.numwords)
for i := 0; i < g.numwords; i++ {
if g.capitalize {
words[i] = strings.Title(randomWord(g.wordlist))
} else {
words[i] = randomWord(g.wordlist)
}
}
return strings.Join(words, g.delimiter)
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"GeneratePasswordString",
"(",
")",
"string",
"{",
"var",
"words",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"g",
".",
"numwords",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"g",
".",
"numwords",
";... | // GeneratePasswordString creates a randomized password returned as string | [
"GeneratePasswordString",
"creates",
"a",
"randomized",
"password",
"returned",
"as",
"string"
] | 7dc3d102eca3f9a46609656f3883f9ba2f05af53 | https://github.com/martinhoefling/goxkcdpwgen/blob/7dc3d102eca3f9a46609656f3883f9ba2f05af53/xkcdpwgen/pwgen.go#L27-L37 |
145,455 | martinhoefling/goxkcdpwgen | xkcdpwgen/pwgen.go | UseLangWordlist | func (g *Generator) UseLangWordlist(lang string) error {
var ok bool
g.wordlist, ok = wordlists[lang]
if !ok {
return fmt.Errorf("language \"%s\" has no matching wordlist", lang)
}
return nil
} | go | func (g *Generator) UseLangWordlist(lang string) error {
var ok bool
g.wordlist, ok = wordlists[lang]
if !ok {
return fmt.Errorf("language \"%s\" has no matching wordlist", lang)
}
return nil
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"UseLangWordlist",
"(",
"lang",
"string",
")",
"error",
"{",
"var",
"ok",
"bool",
"\n",
"g",
".",
"wordlist",
",",
"ok",
"=",
"wordlists",
"[",
"lang",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
... | // UseLangWordlist sets wordlist matching to provided lang string | [
"UseLangWordlist",
"sets",
"wordlist",
"matching",
"to",
"provided",
"lang",
"string"
] | 7dc3d102eca3f9a46609656f3883f9ba2f05af53 | https://github.com/martinhoefling/goxkcdpwgen/blob/7dc3d102eca3f9a46609656f3883f9ba2f05af53/xkcdpwgen/pwgen.go#L60-L67 |
145,456 | manifoldco/go-manifold | zz_oag_generated_identity.go | Current | func (i *APITokenIter) Current() (*APIToken, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *APITokenIter) Current() (*APIToken, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"APITokenIter",
")",
"Current",
"(",
")",
"(",
"*",
"APIToken",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"page",
"... | // Current returns the current APIToken, and an optional error. Once an error has been returned,
// the APITokenIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"APIToken",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"APITokenIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
"calls",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L298-L303 |
145,457 | manifoldco/go-manifold | zz_oag_generated_identity.go | Current | func (i *InviteIter) Current() (*Invite, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *InviteIter) Current() (*Invite, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"InviteIter",
")",
"Current",
"(",
")",
"(",
"*",
"Invite",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"page",
"[",
... | // Current returns the current Invite, and an optional error. Once an error has been returned,
// the InviteIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"Invite",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"InviteIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
"calls",
"to... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L334-L339 |
145,458 | manifoldco/go-manifold | zz_oag_generated_identity.go | Current | func (i *MemberProfileIter) Current() (*MemberProfile, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *MemberProfileIter) Current() (*MemberProfile, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"MemberProfileIter",
")",
"Current",
"(",
")",
"(",
"*",
"MemberProfile",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"... | // Current returns the current MemberProfile, and an optional error. Once an error has been returned,
// the MemberProfileIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"MemberProfile",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"MemberProfileIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L370-L375 |
145,459 | manifoldco/go-manifold | zz_oag_generated_identity.go | Next | func (i *TeamIter) Next() bool {
if i.first && i.err != nil {
i.first = false
return true
}
i.first = false
i.i++
return i.i < len(i.page)
} | go | func (i *TeamIter) Next() bool {
if i.first && i.err != nil {
i.first = false
return true
}
i.first = false
i.i++
return i.i < len(i.page)
} | [
"func",
"(",
"i",
"*",
"TeamIter",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"i",
".",
"first",
"&&",
"i",
".",
"err",
"!=",
"nil",
"{",
"i",
".",
"first",
"=",
"false",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"i",
".",
"first",
"=",
"false"... | // Next advances the TeamIter and returns a boolean indicating if the end has been reached.
// Next must be called before the first call to Current.
// Calls to Current after Next returns false will return an error. | [
"Next",
"advances",
"the",
"TeamIter",
"and",
"returns",
"a",
"boolean",
"indicating",
"if",
"the",
"end",
"has",
"been",
"reached",
".",
"Next",
"must",
"be",
"called",
"before",
"the",
"first",
"call",
"to",
"Current",
".",
"Calls",
"to",
"Current",
"aft... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L393-L401 |
145,460 | manifoldco/go-manifold | zz_oag_generated_identity.go | Current | func (i *TeamIter) Current() (*Team, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *TeamIter) Current() (*Team, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"TeamIter",
")",
"Current",
"(",
")",
"(",
"*",
"Team",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
"page",
"[",
"i... | // Current returns the current Team, and an optional error. Once an error has been returned,
// the TeamIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"Team",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"TeamIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
"calls",
"to",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L406-L411 |
145,461 | manifoldco/go-manifold | zz_oag_generated_identity.go | Current | func (i *TeamMembershipIter) Current() (*TeamMembership, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *TeamMembershipIter) Current() (*TeamMembership, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"TeamMembershipIter",
")",
"Current",
"(",
")",
"(",
"*",
"TeamMembership",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",
... | // Current returns the current TeamMembership, and an optional error. Once an error has been returned,
// the TeamMembershipIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"TeamMembership",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"TeamMembershipIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent",
... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L442-L447 |
145,462 | manifoldco/go-manifold | zz_oag_generated_identity.go | NewIdentity | func NewIdentity() *IdentityClient {
c := &IdentityClient{}
c.common.backend = DefaultBackend()
c.Analytics = (*AnalyticsClient)(&c.common)
c.Invites = (*InvitesClient)(&c.common)
c.Memberships = (*MembershipsClient)(&c.common)
c.Self = (*SelfClient)(&c.common)
c.Teams = (*TeamsClient)(&c.common)
c.Tokens = (*... | go | func NewIdentity() *IdentityClient {
c := &IdentityClient{}
c.common.backend = DefaultBackend()
c.Analytics = (*AnalyticsClient)(&c.common)
c.Invites = (*InvitesClient)(&c.common)
c.Memberships = (*MembershipsClient)(&c.common)
c.Self = (*SelfClient)(&c.common)
c.Teams = (*TeamsClient)(&c.common)
c.Tokens = (*... | [
"func",
"NewIdentity",
"(",
")",
"*",
"IdentityClient",
"{",
"c",
":=",
"&",
"IdentityClient",
"{",
"}",
"\n",
"c",
".",
"common",
".",
"backend",
"=",
"DefaultBackend",
"(",
")",
"\n\n",
"c",
".",
"Analytics",
"=",
"(",
"*",
"AnalyticsClient",
")",
"(... | // NewIdentity returns a new IdentityClient with the default configuration. | [
"NewIdentity",
"returns",
"a",
"new",
"IdentityClient",
"with",
"the",
"default",
"configuration",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/zz_oag_generated_identity.go#L1163-L1176 |
145,463 | manifoldco/go-manifold | integrations/primitives/resource.go | Valid | func (r *Resource) Valid() bool {
if r.Name == "" {
fmt.Println("no resource spec label")
return false
}
for _, c := range r.Credentials {
if !c.Valid() {
return false
}
}
return true
} | go | func (r *Resource) Valid() bool {
if r.Name == "" {
fmt.Println("no resource spec label")
return false
}
for _, c := range r.Credentials {
if !c.Valid() {
return false
}
}
return true
} | [
"func",
"(",
"r",
"*",
"Resource",
")",
"Valid",
"(",
")",
"bool",
"{",
"if",
"r",
".",
"Name",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"c",
":=",
"range... | // Valid will validate the Resource. | [
"Valid",
"will",
"validate",
"the",
"Resource",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/primitives/resource.go#L16-L29 |
145,464 | manifoldco/go-manifold | events/events.go | Validate | func (s SourceType) Validate(interface{}) error {
switch s {
case SourceDashboard, SourceCLI, SourceSystem, SourceProvider:
return nil
default:
return manifold.NewError(errors.BadRequestError, fmt.Sprintf("invalid source type %q", s))
}
} | go | func (s SourceType) Validate(interface{}) error {
switch s {
case SourceDashboard, SourceCLI, SourceSystem, SourceProvider:
return nil
default:
return manifold.NewError(errors.BadRequestError, fmt.Sprintf("invalid source type %q", s))
}
} | [
"func",
"(",
"s",
"SourceType",
")",
"Validate",
"(",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"s",
"{",
"case",
"SourceDashboard",
",",
"SourceCLI",
",",
"SourceSystem",
",",
"SourceProvider",
":",
"return",
"nil",
"\n",
"default",
":",
"return... | // Validate whether source type is valid | [
"Validate",
"whether",
"source",
"type",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L54-L61 |
145,465 | manifoldco/go-manifold | events/events.go | New | func New() (*Event, error) {
id, err := manifold.NewID(idtype.ActivityEvent)
if err != nil {
return nil, err
}
evt := &Event{
ID: id,
StructType: "event",
StructVersion: 1,
}
return evt, nil
} | go | func New() (*Event, error) {
id, err := manifold.NewID(idtype.ActivityEvent)
if err != nil {
return nil, err
}
evt := &Event{
ID: id,
StructType: "event",
StructVersion: 1,
}
return evt, nil
} | [
"func",
"New",
"(",
")",
"(",
"*",
"Event",
",",
"error",
")",
"{",
"id",
",",
"err",
":=",
"manifold",
".",
"NewID",
"(",
"idtype",
".",
"ActivityEvent",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
... | // New returns a new event without a body. | [
"New",
"returns",
"a",
"new",
"event",
"without",
"a",
"body",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L86-L99 |
145,466 | manifoldco/go-manifold | events/events.go | Validate | func (e *Event) Validate(v strfmt.Registry) error {
if err := e.ID.Validate(v); err != nil {
return err
}
if e.Version() != 1 {
return manifold.NewError(errors.BadRequestError, "Expected version to be 1")
}
return e.Body.Validate(v)
} | go | func (e *Event) Validate(v strfmt.Registry) error {
if err := e.ID.Validate(v); err != nil {
return err
}
if e.Version() != 1 {
return manifold.NewError(errors.BadRequestError, "Expected version to be 1")
}
return e.Body.Validate(v)
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"Validate",
"(",
"v",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"if",
"err",
":=",
"e",
".",
"ID",
".",
"Validate",
"(",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
... | // Validate returns whether or not the given Event is valid | [
"Validate",
"returns",
"whether",
"or",
"not",
"the",
"given",
"Event",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L111-L121 |
145,467 | manifoldco/go-manifold | events/events.go | Analytics | func (e *Event) Analytics() map[string]interface{} {
m := analyticsProperties(e.Body)
scope := e.Body.Scope()
if scope != nil && scope.ID.Type() == idtype.Team {
m["team_id"] = scope.ID
m["team_name"] = scope.Name
}
return m
} | go | func (e *Event) Analytics() map[string]interface{} {
m := analyticsProperties(e.Body)
scope := e.Body.Scope()
if scope != nil && scope.ID.Type() == idtype.Team {
m["team_id"] = scope.ID
m["team_name"] = scope.Name
}
return m
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"Analytics",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"m",
":=",
"analyticsProperties",
"(",
"e",
".",
"Body",
")",
"\n\n",
"scope",
":=",
"e",
".",
"Body",
".",
"Scope",
"(",
")",
"\n\... | // Analytics returns a property map for analytics consumption. | [
"Analytics",
"returns",
"a",
"property",
"map",
"for",
"analytics",
"consumption",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L129-L140 |
145,468 | manifoldco/go-manifold | events/events.go | UnmarshalJSON | func (e *Event) UnmarshalJSON(b []byte) error {
o := outEvent{}
err := json.Unmarshal(b, &o)
if err != nil {
return err
}
v := BaseBody{}
err = json.Unmarshal(o.Body, &v)
if err != nil {
return err
}
var body Body
switch v.Type() {
case TypeOperationProvisioned:
body = &OperationProvisioned{}
case T... | go | func (e *Event) UnmarshalJSON(b []byte) error {
o := outEvent{}
err := json.Unmarshal(b, &o)
if err != nil {
return err
}
v := BaseBody{}
err = json.Unmarshal(o.Body, &v)
if err != nil {
return err
}
var body Body
switch v.Type() {
case TypeOperationProvisioned:
body = &OperationProvisioned{}
case T... | [
"func",
"(",
"e",
"*",
"Event",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"o",
":=",
"outEvent",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"o",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // UnmarshalJSON implements the json.Unmarshaler interface for an event | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"for",
"an",
"event"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L150-L200 |
145,469 | manifoldco/go-manifold | events/events.go | CreatedAt | func (b *BaseBody) CreatedAt() *strfmt.DateTime {
t := strfmt.DateTime(b.StructCreatedAt)
return &t
} | go | func (b *BaseBody) CreatedAt() *strfmt.DateTime {
t := strfmt.DateTime(b.StructCreatedAt)
return &t
} | [
"func",
"(",
"b",
"*",
"BaseBody",
")",
"CreatedAt",
"(",
")",
"*",
"strfmt",
".",
"DateTime",
"{",
"t",
":=",
"strfmt",
".",
"DateTime",
"(",
"b",
".",
"StructCreatedAt",
")",
"\n",
"return",
"&",
"t",
"\n",
"}"
] | // CreatedAt returns the body's CreatedAt | [
"CreatedAt",
"returns",
"the",
"body",
"s",
"CreatedAt"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L286-L289 |
145,470 | manifoldco/go-manifold | events/events.go | SetCreatedAt | func (b *BaseBody) SetCreatedAt(t *strfmt.DateTime) {
if t == nil {
b.StructCreatedAt = time.Now().UTC()
} else {
b.StructCreatedAt = time.Time(*t)
}
} | go | func (b *BaseBody) SetCreatedAt(t *strfmt.DateTime) {
if t == nil {
b.StructCreatedAt = time.Now().UTC()
} else {
b.StructCreatedAt = time.Time(*t)
}
} | [
"func",
"(",
"b",
"*",
"BaseBody",
")",
"SetCreatedAt",
"(",
"t",
"*",
"strfmt",
".",
"DateTime",
")",
"{",
"if",
"t",
"==",
"nil",
"{",
"b",
".",
"StructCreatedAt",
"=",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
"\n",
"}",
"else",
"{... | // SetCreatedAt sets the body's CreatedAt | [
"SetCreatedAt",
"sets",
"the",
"body",
"s",
"CreatedAt"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L292-L298 |
145,471 | manifoldco/go-manifold | events/events.go | SetSource | func (b *BaseBody) SetSource(s *string) {
if s == nil {
b.StructSource = SourceSystem
} else {
b.StructSource = SourceType(*s)
}
} | go | func (b *BaseBody) SetSource(s *string) {
if s == nil {
b.StructSource = SourceSystem
} else {
b.StructSource = SourceType(*s)
}
} | [
"func",
"(",
"b",
"*",
"BaseBody",
")",
"SetSource",
"(",
"s",
"*",
"string",
")",
"{",
"if",
"s",
"==",
"nil",
"{",
"b",
".",
"StructSource",
"=",
"SourceSystem",
"\n",
"}",
"else",
"{",
"b",
".",
"StructSource",
"=",
"SourceType",
"(",
"*",
"s",
... | // SetSource sets the body's Source | [
"SetSource",
"sets",
"the",
"body",
"s",
"Source"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L307-L313 |
145,472 | manifoldco/go-manifold | events/events.go | Validate | func (e Error) Validate(v interface{}) error {
if e.Message == "" {
return fmt.Errorf("invalid error message %q", e.Message)
}
if e.Code <= 0 {
return fmt.Errorf("invalid error code %d", e.Code)
}
return nil
} | go | func (e Error) Validate(v interface{}) error {
if e.Message == "" {
return fmt.Errorf("invalid error message %q", e.Message)
}
if e.Code <= 0 {
return fmt.Errorf("invalid error code %d", e.Code)
}
return nil
} | [
"func",
"(",
"e",
"Error",
")",
"Validate",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"e",
".",
"Message",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"e",
".",
"Message",
")",
"\n",
"}",
"\n\n",... | // Validate returns whether or not the given Error is valid | [
"Validate",
"returns",
"whether",
"or",
"not",
"the",
"given",
"Error",
"is",
"valid"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L653-L663 |
145,473 | manifoldco/go-manifold | events/events.go | analyticsProperties | func analyticsProperties(s interface{}) map[string]interface{} {
m := make(map[string]interface{})
v := reflect.ValueOf(s).Elem()
t := v.Type()
if v.Kind() != reflect.Struct {
return m
}
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
switch field.Kind() {
case reflect.Ptr:
if field.IsNil()... | go | func analyticsProperties(s interface{}) map[string]interface{} {
m := make(map[string]interface{})
v := reflect.ValueOf(s).Elem()
t := v.Type()
if v.Kind() != reflect.Struct {
return m
}
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
switch field.Kind() {
case reflect.Ptr:
if field.IsNil()... | [
"func",
"analyticsProperties",
"(",
"s",
"interface",
"{",
"}",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n\n",
"v",
":=",
"reflect",
".",
"ValueOf",
... | // analyticsProperties generates property map for analytics consumption by
// finding all struct fields with the analytics tag and copying its value to a
// map | [
"analyticsProperties",
"generates",
"property",
"map",
"for",
"analytics",
"consumption",
"by",
"finding",
"all",
"struct",
"fields",
"with",
"the",
"analytics",
"tag",
"and",
"copying",
"its",
"value",
"to",
"a",
"map"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/events/events.go#L668-L705 |
145,474 | manifoldco/go-manifold | manifold.go | WithAPIToken | func WithAPIToken(token string) ConfigFunc {
return func(c *Client) {
ot := c.client.Transport
c.client.Transport = rtFunc(func(r *http.Request) (*http.Response, error) {
if token != "" {
r.Header.Set("Authorization", "Bearer "+token)
}
return ot.RoundTrip(r)
})
}
} | go | func WithAPIToken(token string) ConfigFunc {
return func(c *Client) {
ot := c.client.Transport
c.client.Transport = rtFunc(func(r *http.Request) (*http.Response, error) {
if token != "" {
r.Header.Set("Authorization", "Bearer "+token)
}
return ot.RoundTrip(r)
})
}
} | [
"func",
"WithAPIToken",
"(",
"token",
"string",
")",
"ConfigFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"ot",
":=",
"c",
".",
"client",
".",
"Transport",
"\n",
"c",
".",
"client",
".",
"Transport",
"=",
"rtFunc",
"(",
"func",
"("... | // WithAPIToken returns a configuration func to set the API key to use for
// authentication. | [
"WithAPIToken",
"returns",
"a",
"configuration",
"func",
"to",
"set",
"the",
"API",
"key",
"to",
"use",
"for",
"authentication",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/manifold.go#L67-L77 |
145,475 | manifoldco/go-manifold | manifold.go | Login | func (c *IdentityClient) Login(ctx context.Context, email, password string) (string, error) {
lt, err := c.Tokens.CreateLogin(ctx, &LoginTokenRequest{Email: email})
if err != nil {
return "", err
}
salt, err := base64.NewFromString(lt.Salt)
if err != nil {
return "", err
}
_, pk, err := deriveKeypair(passw... | go | func (c *IdentityClient) Login(ctx context.Context, email, password string) (string, error) {
lt, err := c.Tokens.CreateLogin(ctx, &LoginTokenRequest{Email: email})
if err != nil {
return "", err
}
salt, err := base64.NewFromString(lt.Salt)
if err != nil {
return "", err
}
_, pk, err := deriveKeypair(passw... | [
"func",
"(",
"c",
"*",
"IdentityClient",
")",
"Login",
"(",
"ctx",
"context",
".",
"Context",
",",
"email",
",",
"password",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"lt",
",",
"err",
":=",
"c",
".",
"Tokens",
".",
"CreateLogin",
"(",
... | // Login logs a user in to Manifold using the provided email and password. It
// returns the user's JWT auth token on success. This token is not stored on the
// API client; you must instantiate a new one to use it. | [
"Login",
"logs",
"a",
"user",
"in",
"to",
"Manifold",
"using",
"the",
"provided",
"email",
"and",
"password",
".",
"It",
"returns",
"the",
"user",
"s",
"JWT",
"auth",
"token",
"on",
"success",
".",
"This",
"token",
"is",
"not",
"stored",
"on",
"the",
"... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/manifold.go#L104-L130 |
145,476 | manifoldco/go-manifold | number/number.go | ToInt64 | func ToInt64(val interface{}) (int64, error) {
switch v := val.(type) {
case int:
return int64(v), nil
case int8:
return int64(v), nil
case int16:
return int64(v), nil
case int32:
return int64(v), nil
case int64:
return v, nil
case float32:
f := val.(float32)
i := int64(f)
if f != float32(i) {
... | go | func ToInt64(val interface{}) (int64, error) {
switch v := val.(type) {
case int:
return int64(v), nil
case int8:
return int64(v), nil
case int16:
return int64(v), nil
case int32:
return int64(v), nil
case int64:
return v, nil
case float32:
f := val.(float32)
i := int64(f)
if f != float32(i) {
... | [
"func",
"ToInt64",
"(",
"val",
"interface",
"{",
"}",
")",
"(",
"int64",
",",
"error",
")",
"{",
"switch",
"v",
":=",
"val",
".",
"(",
"type",
")",
"{",
"case",
"int",
":",
"return",
"int64",
"(",
"v",
")",
",",
"nil",
"\n",
"case",
"int8",
":"... | // ToInt64 takes an interface and converts many things to int64 if able, returns error if it fails | [
"ToInt64",
"takes",
"an",
"interface",
"and",
"converts",
"many",
"things",
"to",
"int64",
"if",
"able",
"returns",
"error",
"if",
"it",
"fails"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/number/number.go#L12-L47 |
145,477 | manifoldco/go-manifold | number/number.go | ToFloat64 | func ToFloat64(val interface{}) (float64, error) {
switch v := val.(type) {
case int:
return float64(v), nil
case int8:
return float64(v), nil
case int16:
return float64(v), nil
case int32:
return float64(v), nil
case int64:
return float64(v), nil
case float32:
return float64(v), nil
case float64:
... | go | func ToFloat64(val interface{}) (float64, error) {
switch v := val.(type) {
case int:
return float64(v), nil
case int8:
return float64(v), nil
case int16:
return float64(v), nil
case int32:
return float64(v), nil
case int64:
return float64(v), nil
case float32:
return float64(v), nil
case float64:
... | [
"func",
"ToFloat64",
"(",
"val",
"interface",
"{",
"}",
")",
"(",
"float64",
",",
"error",
")",
"{",
"switch",
"v",
":=",
"val",
".",
"(",
"type",
")",
"{",
"case",
"int",
":",
"return",
"float64",
"(",
"v",
")",
",",
"nil",
"\n",
"case",
"int8",... | // ToFloat64 takes an interface and converts many things to float64 if able, returns error if it fails | [
"ToFloat64",
"takes",
"an",
"interface",
"and",
"converts",
"many",
"things",
"to",
"float64",
"if",
"able",
"returns",
"error",
"if",
"it",
"fails"
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/number/number.go#L50-L73 |
145,478 | manifoldco/go-manifold | errors/errors.go | TypeForStatusCode | func TypeForStatusCode(code int) (Type, bool) {
// Go doesn't like returning the optional return value immediately so we
// need to assign it before returning it.
et, ok := inverseMap[code]
return et, ok
} | go | func TypeForStatusCode(code int) (Type, bool) {
// Go doesn't like returning the optional return value immediately so we
// need to assign it before returning it.
et, ok := inverseMap[code]
return et, ok
} | [
"func",
"TypeForStatusCode",
"(",
"code",
"int",
")",
"(",
"Type",
",",
"bool",
")",
"{",
"// Go doesn't like returning the optional return value immediately so we",
"// need to assign it before returning it.",
"et",
",",
"ok",
":=",
"inverseMap",
"[",
"code",
"]",
"\n",
... | // TypeForStatusCode returns the Type that is matched for a given
// status code. If no Type is found, it will return false. | [
"TypeForStatusCode",
"returns",
"the",
"Type",
"that",
"is",
"matched",
"for",
"a",
"given",
"status",
"code",
".",
"If",
"no",
"Type",
"is",
"found",
"it",
"will",
"return",
"false",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/errors/errors.go#L32-L37 |
145,479 | st3v/translator | http/mocks.go | NewAuthenticatedClient | func NewAuthenticatedClient() Client {
authenticator := newMockAuthenticator(func(request *http.Request) error {
request.Header.Set("Authorization", "fake-authorization")
return nil
})
return NewClient(authenticator)
} | go | func NewAuthenticatedClient() Client {
authenticator := newMockAuthenticator(func(request *http.Request) error {
request.Header.Set("Authorization", "fake-authorization")
return nil
})
return NewClient(authenticator)
} | [
"func",
"NewAuthenticatedClient",
"(",
")",
"Client",
"{",
"authenticator",
":=",
"newMockAuthenticator",
"(",
"func",
"(",
"request",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"request",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
... | // NewAuthenticatedClient returns an HTTP client with a mocked-out authenticator. | [
"NewAuthenticatedClient",
"returns",
"an",
"HTTP",
"client",
"with",
"a",
"mocked",
"-",
"out",
"authenticator",
"."
] | d13056a5929704f264d21b102987311c0f379fc3 | https://github.com/st3v/translator/blob/d13056a5929704f264d21b102987311c0f379fc3/http/mocks.go#L6-L13 |
145,480 | cybozu-go/netutil | tcpkeepalive.go | Accept | func (l TCPKeepAliveListener) Accept() (c net.Conn, err error) {
tc, err := l.AcceptTCP()
if err != nil {
return
}
tc.SetKeepAlive(true)
tc.SetKeepAlivePeriod(keepAlivePeriod)
return tc, nil
} | go | func (l TCPKeepAliveListener) Accept() (c net.Conn, err error) {
tc, err := l.AcceptTCP()
if err != nil {
return
}
tc.SetKeepAlive(true)
tc.SetKeepAlivePeriod(keepAlivePeriod)
return tc, nil
} | [
"func",
"(",
"l",
"TCPKeepAliveListener",
")",
"Accept",
"(",
")",
"(",
"c",
"net",
".",
"Conn",
",",
"err",
"error",
")",
"{",
"tc",
",",
"err",
":=",
"l",
".",
"AcceptTCP",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"... | // Accept returns a TCP keep-alive enabled connection. | [
"Accept",
"returns",
"a",
"TCP",
"keep",
"-",
"alive",
"enabled",
"connection",
"."
] | 635e66124747b7034c7f21e7c7031cfa1b4039e1 | https://github.com/cybozu-go/netutil/blob/635e66124747b7034c7f21e7c7031cfa1b4039e1/tcpkeepalive.go#L18-L26 |
145,481 | manifoldco/go-manifold | integrations/primitives/project.go | Valid | func (p *Project) Valid() bool {
if p.Name == "" {
fmt.Println("no project spec name")
return false
}
for _, r := range p.Resources {
if !r.Valid() {
return false
}
}
return true
} | go | func (p *Project) Valid() bool {
if p.Name == "" {
fmt.Println("no project spec name")
return false
}
for _, r := range p.Resources {
if !r.Valid() {
return false
}
}
return true
} | [
"func",
"(",
"p",
"*",
"Project",
")",
"Valid",
"(",
")",
"bool",
"{",
"if",
"p",
".",
"Name",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"r",
":=",
"range"... | // Valid will validate the Project. | [
"Valid",
"will",
"validate",
"the",
"Project",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/integrations/primitives/project.go#L16-L29 |
145,482 | manifoldco/go-manifold | gateway/zz_oag_generated_gateway.go | Current | func (i *ResolvedProductIter) Current() (*ResolvedProduct, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | go | func (i *ResolvedProductIter) Current() (*ResolvedProduct, error) {
if i.err != nil {
return nil, i.err
}
return &i.page[i.i], nil
} | [
"func",
"(",
"i",
"*",
"ResolvedProductIter",
")",
"Current",
"(",
")",
"(",
"*",
"ResolvedProduct",
",",
"error",
")",
"{",
"if",
"i",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"i",
".",
"err",
"\n",
"}",
"\n",
"return",
"&",
"i",
".",... | // Current returns the current ResolvedProduct, and an optional error. Once an error has been returned,
// the ResolvedProductIter is closed, or the end of iteration is reached, subsequent calls to Current
// will return an error. | [
"Current",
"returns",
"the",
"current",
"ResolvedProduct",
"and",
"an",
"optional",
"error",
".",
"Once",
"an",
"error",
"has",
"been",
"returned",
"the",
"ResolvedProductIter",
"is",
"closed",
"or",
"the",
"end",
"of",
"iteration",
"is",
"reached",
"subsequent"... | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/gateway/zz_oag_generated_gateway.go#L399-L404 |
145,483 | manifoldco/go-manifold | gateway/zz_oag_generated_gateway.go | NewAPI | func NewAPI() *APIClient {
c := &APIClient{}
c.common.backend = DefaultBackend()
c.ID = (*IDClient)(&c.common)
c.Product = (*ProductClient)(&c.common)
c.Products = (*ProductsClient)(&c.common)
c.Resource = (*ResourceClient)(&c.common)
c.Resources = (*ResourcesClient)(&c.common)
return c
} | go | func NewAPI() *APIClient {
c := &APIClient{}
c.common.backend = DefaultBackend()
c.ID = (*IDClient)(&c.common)
c.Product = (*ProductClient)(&c.common)
c.Products = (*ProductsClient)(&c.common)
c.Resource = (*ResourceClient)(&c.common)
c.Resources = (*ResourcesClient)(&c.common)
return c
} | [
"func",
"NewAPI",
"(",
")",
"*",
"APIClient",
"{",
"c",
":=",
"&",
"APIClient",
"{",
"}",
"\n",
"c",
".",
"common",
".",
"backend",
"=",
"DefaultBackend",
"(",
")",
"\n\n",
"c",
".",
"ID",
"=",
"(",
"*",
"IDClient",
")",
"(",
"&",
"c",
".",
"co... | // NewAPI returns a new APIClient with the default configuration. | [
"NewAPI",
"returns",
"a",
"new",
"APIClient",
"with",
"the",
"default",
"configuration",
"."
] | 8458bf091a9e8b6242d12d26f08571ca3acc483d | https://github.com/manifoldco/go-manifold/blob/8458bf091a9e8b6242d12d26f08571ca3acc483d/gateway/zz_oag_generated_gateway.go#L779-L790 |
145,484 | masterzen/simplexml | dom/element.go | DeclareNamespace | func (node *Element) DeclareNamespace(ns Namespace) *Element {
// check if we already have it
prefix := node.namespacePrefix(ns.Uri)
if prefix == ns.Prefix {
return node
}
// add it
node.namespaces = append(node.namespaces, &ns)
return node
} | go | func (node *Element) DeclareNamespace(ns Namespace) *Element {
// check if we already have it
prefix := node.namespacePrefix(ns.Uri)
if prefix == ns.Prefix {
return node
}
// add it
node.namespaces = append(node.namespaces, &ns)
return node
} | [
"func",
"(",
"node",
"*",
"Element",
")",
"DeclareNamespace",
"(",
"ns",
"Namespace",
")",
"*",
"Element",
"{",
"// check if we already have it",
"prefix",
":=",
"node",
".",
"namespacePrefix",
"(",
"ns",
".",
"Uri",
")",
"\n",
"if",
"prefix",
"==",
"ns",
... | // Add a namespace declaration to this node | [
"Add",
"a",
"namespace",
"declaration",
"to",
"this",
"node"
] | 31eea30827864c9ab643aa5a0d5b2d4988ec8409 | https://github.com/masterzen/simplexml/blob/31eea30827864c9ab643aa5a0d5b2d4988ec8409/dom/element.go#L78-L87 |
145,485 | masterzen/simplexml | dom/element.go | namespacePrefix | func (node *Element) namespacePrefix(uri string) string {
for _, ns := range node.namespaces {
if ns.Uri == uri {
return ns.Prefix
}
}
if node.parent == nil {
return ""
}
return node.parent.namespacePrefix(uri)
} | go | func (node *Element) namespacePrefix(uri string) string {
for _, ns := range node.namespaces {
if ns.Uri == uri {
return ns.Prefix
}
}
if node.parent == nil {
return ""
}
return node.parent.namespacePrefix(uri)
} | [
"func",
"(",
"node",
"*",
"Element",
")",
"namespacePrefix",
"(",
"uri",
"string",
")",
"string",
"{",
"for",
"_",
",",
"ns",
":=",
"range",
"node",
".",
"namespaces",
"{",
"if",
"ns",
".",
"Uri",
"==",
"uri",
"{",
"return",
"ns",
".",
"Prefix",
"\... | // Finds the prefix of the given namespace if it has been declared
// in this node or in one of its parent | [
"Finds",
"the",
"prefix",
"of",
"the",
"given",
"namespace",
"if",
"it",
"has",
"been",
"declared",
"in",
"this",
"node",
"or",
"in",
"one",
"of",
"its",
"parent"
] | 31eea30827864c9ab643aa5a0d5b2d4988ec8409 | https://github.com/masterzen/simplexml/blob/31eea30827864c9ab643aa5a0d5b2d4988ec8409/dom/element.go#L183-L193 |
145,486 | mrunalp/fileutils | fileutils.go | CopyFile | func CopyFile(source string, dest string) error {
si, err := os.Lstat(source)
if err != nil {
return err
}
st, ok := si.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("could not convert to syscall.Stat_t")
}
uid := int(st.Uid)
gid := int(st.Gid)
// Handle symlinks
if si.Mode()&os.ModeSymlink != 0 {... | go | func CopyFile(source string, dest string) error {
si, err := os.Lstat(source)
if err != nil {
return err
}
st, ok := si.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("could not convert to syscall.Stat_t")
}
uid := int(st.Uid)
gid := int(st.Gid)
// Handle symlinks
if si.Mode()&os.ModeSymlink != 0 {... | [
"func",
"CopyFile",
"(",
"source",
"string",
",",
"dest",
"string",
")",
"error",
"{",
"si",
",",
"err",
":=",
"os",
".",
"Lstat",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"st",
",",
"ok",
":=",... | // CopyFile copies the file at source to dest | [
"CopyFile",
"copies",
"the",
"file",
"at",
"source",
"to",
"dest"
] | 7d4729fb36185a7c1719923406c9d40e54fb93c7 | https://github.com/mrunalp/fileutils/blob/7d4729fb36185a7c1719923406c9d40e54fb93c7/fileutils.go#L12-L86 |
145,487 | mrunalp/fileutils | fileutils.go | CopyDirectory | func CopyDirectory(source string, dest string) error {
fi, err := os.Stat(source)
if err != nil {
return err
}
// Get owner.
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("could not convert to syscall.Stat_t")
}
// We have to pick an owner here anyway.
if err := MkdirAllNewAs(dest, fi.M... | go | func CopyDirectory(source string, dest string) error {
fi, err := os.Stat(source)
if err != nil {
return err
}
// Get owner.
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("could not convert to syscall.Stat_t")
}
// We have to pick an owner here anyway.
if err := MkdirAllNewAs(dest, fi.M... | [
"func",
"CopyDirectory",
"(",
"source",
"string",
",",
"dest",
"string",
")",
"error",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Get owner.",
"st",... | // CopyDirectory copies the files under the source directory
// to dest directory. The dest directory is created if it
// does not exist. | [
"CopyDirectory",
"copies",
"the",
"files",
"under",
"the",
"source",
"directory",
"to",
"dest",
"directory",
".",
"The",
"dest",
"directory",
"is",
"created",
"if",
"it",
"does",
"not",
"exist",
"."
] | 7d4729fb36185a7c1719923406c9d40e54fb93c7 | https://github.com/mrunalp/fileutils/blob/7d4729fb36185a7c1719923406c9d40e54fb93c7/fileutils.go#L91-L144 |
145,488 | getlantern/golog | golog.go | RegisterReporter | func RegisterReporter(reporter ErrorReporter) {
reportersMutex.Lock()
reporters = append(reporters, reporter)
reportersMutex.Unlock()
} | go | func RegisterReporter(reporter ErrorReporter) {
reportersMutex.Lock()
reporters = append(reporters, reporter)
reportersMutex.Unlock()
} | [
"func",
"RegisterReporter",
"(",
"reporter",
"ErrorReporter",
")",
"{",
"reportersMutex",
".",
"Lock",
"(",
")",
"\n",
"reporters",
"=",
"append",
"(",
"reporters",
",",
"reporter",
")",
"\n",
"reportersMutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // RegisterReporter registers the given ErrorReporter. All logged Errors are
// sent to this reporter. | [
"RegisterReporter",
"registers",
"the",
"given",
"ErrorReporter",
".",
"All",
"logged",
"Errors",
"are",
"sent",
"to",
"this",
"reporter",
"."
] | cca714f7feb5df8e455f409b549d384441ac4578 | https://github.com/getlantern/golog/blob/cca714f7feb5df8e455f409b549d384441ac4578/golog.go#L84-L88 |
145,489 | getlantern/golog | golog.go | linePrefix | func (l *logger) linePrefix(skipFrames int) string {
runtime.Callers(skipFrames, l.pc)
funcForPc := runtime.FuncForPC(l.pc[0])
file, line := funcForPc.FileLine(l.pc[0] - 1)
return fmt.Sprintf("%s%s:%d ", l.prefix, filepath.Base(file), line)
} | go | func (l *logger) linePrefix(skipFrames int) string {
runtime.Callers(skipFrames, l.pc)
funcForPc := runtime.FuncForPC(l.pc[0])
file, line := funcForPc.FileLine(l.pc[0] - 1)
return fmt.Sprintf("%s%s:%d ", l.prefix, filepath.Base(file), line)
} | [
"func",
"(",
"l",
"*",
"logger",
")",
"linePrefix",
"(",
"skipFrames",
"int",
")",
"string",
"{",
"runtime",
".",
"Callers",
"(",
"skipFrames",
",",
"l",
".",
"pc",
")",
"\n",
"funcForPc",
":=",
"runtime",
".",
"FuncForPC",
"(",
"l",
".",
"pc",
"[",
... | // attaches the file and line number corresponding to
// the log message | [
"attaches",
"the",
"file",
"and",
"line",
"number",
"corresponding",
"to",
"the",
"log",
"message"
] | cca714f7feb5df8e455f409b549d384441ac4578 | https://github.com/getlantern/golog/blob/cca714f7feb5df8e455f409b549d384441ac4578/golog.go#L203-L208 |
145,490 | getlantern/golog | golog.go | Write | func (w *errorWriter) Write(p []byte) (n int, err error) {
s := string(p)
if s[len(s)-1] == '\n' {
s = s[:len(s)-1]
}
w.l.print(GetOutputs().ErrorOut, 6, "ERROR", s)
return len(p), nil
} | go | func (w *errorWriter) Write(p []byte) (n int, err error) {
s := string(p)
if s[len(s)-1] == '\n' {
s = s[:len(s)-1]
}
w.l.print(GetOutputs().ErrorOut, 6, "ERROR", s)
return len(p), nil
} | [
"func",
"(",
"w",
"*",
"errorWriter",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"s",
":=",
"string",
"(",
"p",
")",
"\n",
"if",
"s",
"[",
"len",
"(",
"s",
")",
"-",
"1",
"]",
"==",
"'\\... | // Write implements method of io.Writer, due to different call depth,
// it will not log correct file and line prefix | [
"Write",
"implements",
"method",
"of",
"io",
".",
"Writer",
"due",
"to",
"different",
"call",
"depth",
"it",
"will",
"not",
"log",
"correct",
"file",
"and",
"line",
"prefix"
] | cca714f7feb5df8e455f409b549d384441ac4578 | https://github.com/getlantern/golog/blob/cca714f7feb5df8e455f409b549d384441ac4578/golog.go#L379-L386 |
145,491 | luismesas/goPi | spi/SPIDevice.go | Open | func (spi *SPIDevice) Open() error {
spiDevice := fmt.Sprintf("%s%d.%d", SPIDEV, spi.Bus, spi.Chip)
var err error
spi.file, err = os.OpenFile(spiDevice, os.O_RDWR, 0)
// spi.file, err = os.Create(spiDevice)
if err != nil {
return fmt.Errorf("I can't see %s. Have you enabled the SPI module? (%s)", spiDevice, SPI... | go | func (spi *SPIDevice) Open() error {
spiDevice := fmt.Sprintf("%s%d.%d", SPIDEV, spi.Bus, spi.Chip)
var err error
spi.file, err = os.OpenFile(spiDevice, os.O_RDWR, 0)
// spi.file, err = os.Create(spiDevice)
if err != nil {
return fmt.Errorf("I can't see %s. Have you enabled the SPI module? (%s)", spiDevice, SPI... | [
"func",
"(",
"spi",
"*",
"SPIDevice",
")",
"Open",
"(",
")",
"error",
"{",
"spiDevice",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"SPIDEV",
",",
"spi",
".",
"Bus",
",",
"spi",
".",
"Chip",
")",
"\n\n",
"var",
"err",
"error",
"\n",
"spi",... | // Opens SPI device | [
"Opens",
"SPI",
"device"
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/spi/SPIDevice.go#L41-L52 |
145,492 | luismesas/goPi | spi/SPIDevice.go | Close | func (spi *SPIDevice) Close() error {
err := spi.file.Close()
if err != nil {
return fmt.Errorf("Error closing spi", err)
}
return nil
} | go | func (spi *SPIDevice) Close() error {
err := spi.file.Close()
if err != nil {
return fmt.Errorf("Error closing spi", err)
}
return nil
} | [
"func",
"(",
"spi",
"*",
"SPIDevice",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"spi",
".",
"file",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
... | // Closes SPI device | [
"Closes",
"SPI",
"device"
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/spi/SPIDevice.go#L55-L61 |
145,493 | luismesas/goPi | MCP23S17/MCP23S17.go | Read | func (mcp *MCP23S17) Read(address byte) byte {
ctrl_byte := mcp.getSPIControlByte(READ_CMD)
data, err := mcp.Device.Send([3]byte{ctrl_byte, address, 0})
if err != nil {
panic(fmt.Sprintf("Error reading from MCP23S17: %s\n", err))
return 0x00
}
if len(data) == 0 {
return 0x00
}
return data[2]
} | go | func (mcp *MCP23S17) Read(address byte) byte {
ctrl_byte := mcp.getSPIControlByte(READ_CMD)
data, err := mcp.Device.Send([3]byte{ctrl_byte, address, 0})
if err != nil {
panic(fmt.Sprintf("Error reading from MCP23S17: %s\n", err))
return 0x00
}
if len(data) == 0 {
return 0x00
}
return data[2]
} | [
"func",
"(",
"mcp",
"*",
"MCP23S17",
")",
"Read",
"(",
"address",
"byte",
")",
"byte",
"{",
"ctrl_byte",
":=",
"mcp",
".",
"getSPIControlByte",
"(",
"READ_CMD",
")",
"\n",
"data",
",",
"err",
":=",
"mcp",
".",
"Device",
".",
"Send",
"(",
"[",
"3",
... | // Returns the value of the address specified. | [
"Returns",
"the",
"value",
"of",
"the",
"address",
"specified",
"."
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/MCP23S17/MCP23S17.go#L142-L153 |
145,494 | luismesas/goPi | MCP23S17/MCP23S17.go | Write | func (mcp *MCP23S17) Write(data byte, address byte) {
ctrl_byte := mcp.getSPIControlByte(WRITE_CMD)
_, err := mcp.Device.Send([3]byte{ctrl_byte, address, data})
if err != nil {
panic(fmt.Sprintf("Error writing on MCP23S17: %s\n", err))
}
} | go | func (mcp *MCP23S17) Write(data byte, address byte) {
ctrl_byte := mcp.getSPIControlByte(WRITE_CMD)
_, err := mcp.Device.Send([3]byte{ctrl_byte, address, data})
if err != nil {
panic(fmt.Sprintf("Error writing on MCP23S17: %s\n", err))
}
} | [
"func",
"(",
"mcp",
"*",
"MCP23S17",
")",
"Write",
"(",
"data",
"byte",
",",
"address",
"byte",
")",
"{",
"ctrl_byte",
":=",
"mcp",
".",
"getSPIControlByte",
"(",
"WRITE_CMD",
")",
"\n",
"_",
",",
"err",
":=",
"mcp",
".",
"Device",
".",
"Send",
"(",
... | // Writes data to the address specified. | [
"Writes",
"data",
"to",
"the",
"address",
"specified",
"."
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/MCP23S17/MCP23S17.go#L156-L162 |
145,495 | luismesas/goPi | MCP23S17/MCP23S17.go | ReadBit | func (mcp *MCP23S17) ReadBit(bit_num uint, address byte) byte {
value := mcp.Read(address)
return (value >> bit_num) & 1
} | go | func (mcp *MCP23S17) ReadBit(bit_num uint, address byte) byte {
value := mcp.Read(address)
return (value >> bit_num) & 1
} | [
"func",
"(",
"mcp",
"*",
"MCP23S17",
")",
"ReadBit",
"(",
"bit_num",
"uint",
",",
"address",
"byte",
")",
"byte",
"{",
"value",
":=",
"mcp",
".",
"Read",
"(",
"address",
")",
"\n",
"return",
"(",
"value",
">>",
"bit_num",
")",
"&",
"1",
"\n",
"}"
] | // Returns the bit specified from the address. | [
"Returns",
"the",
"bit",
"specified",
"from",
"the",
"address",
"."
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/MCP23S17/MCP23S17.go#L165-L168 |
145,496 | luismesas/goPi | MCP23S17/MCP23S17.go | WriteBit | func (mcp *MCP23S17) WriteBit(data byte, bit_num uint, address byte) {
value := mcp.Read(address)
if data > 0 {
value = value | (1 << bit_num) //set
} else {
value = value & (0xff ^ (1 << bit_num)) //clear
}
mcp.Write(value, address)
} | go | func (mcp *MCP23S17) WriteBit(data byte, bit_num uint, address byte) {
value := mcp.Read(address)
if data > 0 {
value = value | (1 << bit_num) //set
} else {
value = value & (0xff ^ (1 << bit_num)) //clear
}
mcp.Write(value, address)
} | [
"func",
"(",
"mcp",
"*",
"MCP23S17",
")",
"WriteBit",
"(",
"data",
"byte",
",",
"bit_num",
"uint",
",",
"address",
"byte",
")",
"{",
"value",
":=",
"mcp",
".",
"Read",
"(",
"address",
")",
"\n",
"if",
"data",
">",
"0",
"{",
"value",
"=",
"value",
... | // Writes the value given to the bit in the address specified. | [
"Writes",
"the",
"value",
"given",
"to",
"the",
"bit",
"in",
"the",
"address",
"specified",
"."
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/MCP23S17/MCP23S17.go#L171-L179 |
145,497 | luismesas/goPi | MCP23S17/MCP23S17.go | ClearInterrupts | func (mcp *MCP23S17) ClearInterrupts(port int) {
var address byte
address = INTCAPA
if port == GPIOA {
address = INTCAPB
}
mcp.Read(address)
} | go | func (mcp *MCP23S17) ClearInterrupts(port int) {
var address byte
address = INTCAPA
if port == GPIOA {
address = INTCAPB
}
mcp.Read(address)
} | [
"func",
"(",
"mcp",
"*",
"MCP23S17",
")",
"ClearInterrupts",
"(",
"port",
"int",
")",
"{",
"var",
"address",
"byte",
"\n",
"address",
"=",
"INTCAPA",
"\n",
"if",
"port",
"==",
"GPIOA",
"{",
"address",
"=",
"INTCAPB",
"\n",
"}",
"\n",
"mcp",
".",
"Rea... | // Clears the interrupt flags by reading the capture register. | [
"Clears",
"the",
"interrupt",
"flags",
"by",
"reading",
"the",
"capture",
"register",
"."
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/MCP23S17/MCP23S17.go#L182-L189 |
145,498 | luismesas/goPi | piface/piface.go | NewPiFaceDigital | func NewPiFaceDigital(hardware_addr byte, bus int, chip_select int) *PiFaceDigital {
pfd := new(PiFaceDigital)
pfd.mcp = MCP23S17.NewMCP23S17(hardware_addr, bus, chip_select)
// pfd.device = interrupts.NewGPIOInterruptDevice()
pfd.InputPins = make([]*MCP23S17.MCP23S17RegisterBitNeg, 8)
for i := range pfd.InputPin... | go | func NewPiFaceDigital(hardware_addr byte, bus int, chip_select int) *PiFaceDigital {
pfd := new(PiFaceDigital)
pfd.mcp = MCP23S17.NewMCP23S17(hardware_addr, bus, chip_select)
// pfd.device = interrupts.NewGPIOInterruptDevice()
pfd.InputPins = make([]*MCP23S17.MCP23S17RegisterBitNeg, 8)
for i := range pfd.InputPin... | [
"func",
"NewPiFaceDigital",
"(",
"hardware_addr",
"byte",
",",
"bus",
"int",
",",
"chip_select",
"int",
")",
"*",
"PiFaceDigital",
"{",
"pfd",
":=",
"new",
"(",
"PiFaceDigital",
")",
"\n",
"pfd",
".",
"mcp",
"=",
"MCP23S17",
".",
"NewMCP23S17",
"(",
"hardw... | // Create a new PiFaceDigital Instance | [
"Create",
"a",
"new",
"PiFaceDigital",
"Instance"
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/piface/piface.go#L37-L72 |
145,499 | luismesas/goPi | piface/piface.go | InitBoard | func (pfd *PiFaceDigital) InitBoard() error {
err := pfd.mcp.Open()
if err != nil {
return err
}
var ioconfig byte
ioconfig = (MCP23S17.BANK_OFF |
MCP23S17.INT_MIRROR_OFF |
MCP23S17.SEQOP_OFF |
MCP23S17.DISSLW_OFF |
MCP23S17.HAEN_ON |
MCP23S17.ODR_OFF |
MCP23S17.INTPOL_LOW)
pfd.mcp.IOCON.SetValue... | go | func (pfd *PiFaceDigital) InitBoard() error {
err := pfd.mcp.Open()
if err != nil {
return err
}
var ioconfig byte
ioconfig = (MCP23S17.BANK_OFF |
MCP23S17.INT_MIRROR_OFF |
MCP23S17.SEQOP_OFF |
MCP23S17.DISSLW_OFF |
MCP23S17.HAEN_ON |
MCP23S17.ODR_OFF |
MCP23S17.INTPOL_LOW)
pfd.mcp.IOCON.SetValue... | [
"func",
"(",
"pfd",
"*",
"PiFaceDigital",
")",
"InitBoard",
"(",
")",
"error",
"{",
"err",
":=",
"pfd",
".",
"mcp",
".",
"Open",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"ioconfig",
"byte",
"\n",
"... | // Initialize the board | [
"Initialize",
"the",
"board"
] | abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c | https://github.com/luismesas/goPi/blob/abc9b85cfb5fdde8a715ca5d205e044e8b8fe52c/piface/piface.go#L75-L103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.