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
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
jmoiron/sqlx
named.go
Select
func (n *NamedStmt) Select(dest interface{}, arg interface{}) error { rows, err := n.Queryx(arg) if err != nil { return err } // if something happens here, we want to make sure the rows are Closed defer rows.Close() return scanAll(rows, dest, false) }
go
func (n *NamedStmt) Select(dest interface{}, arg interface{}) error { rows, err := n.Queryx(arg) if err != nil { return err } // if something happens here, we want to make sure the rows are Closed defer rows.Close() return scanAll(rows, dest, false) }
[ "func", "(", "n", "*", "NamedStmt", ")", "Select", "(", "dest", "interface", "{", "}", ",", "arg", "interface", "{", "}", ")", "error", "{", "rows", ",", "err", ":=", "n", ".", "Queryx", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// if something happens here, we want to make sure the rows are Closed", "defer", "rows", ".", "Close", "(", ")", "\n", "return", "scanAll", "(", "rows", ",", "dest", ",", "false", ")", "\n", "}" ]
// Select using this NamedStmt // Any named placeholder parameters are replaced with fields from arg.
[ "Select", "using", "this", "NamedStmt", "Any", "named", "placeholder", "parameters", "are", "replaced", "with", "fields", "from", "arg", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L101-L109
train
jmoiron/sqlx
named.go
Get
func (n *NamedStmt) Get(dest interface{}, arg interface{}) error { r := n.QueryRowx(arg) return r.scanAny(dest, false) }
go
func (n *NamedStmt) Get(dest interface{}, arg interface{}) error { r := n.QueryRowx(arg) return r.scanAny(dest, false) }
[ "func", "(", "n", "*", "NamedStmt", ")", "Get", "(", "dest", "interface", "{", "}", ",", "arg", "interface", "{", "}", ")", "error", "{", "r", ":=", "n", ".", "QueryRowx", "(", "arg", ")", "\n", "return", "r", ".", "scanAny", "(", "dest", ",", "false", ")", "\n", "}" ]
// Get using this NamedStmt // Any named placeholder parameters are replaced with fields from arg.
[ "Get", "using", "this", "NamedStmt", "Any", "named", "placeholder", "parameters", "are", "replaced", "with", "fields", "from", "arg", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L113-L116
train
jmoiron/sqlx
named.go
Unsafe
func (n *NamedStmt) Unsafe() *NamedStmt { r := &NamedStmt{Params: n.Params, Stmt: n.Stmt, QueryString: n.QueryString} r.Stmt.unsafe = true return r }
go
func (n *NamedStmt) Unsafe() *NamedStmt { r := &NamedStmt{Params: n.Params, Stmt: n.Stmt, QueryString: n.QueryString} r.Stmt.unsafe = true return r }
[ "func", "(", "n", "*", "NamedStmt", ")", "Unsafe", "(", ")", "*", "NamedStmt", "{", "r", ":=", "&", "NamedStmt", "{", "Params", ":", "n", ".", "Params", ",", "Stmt", ":", "n", ".", "Stmt", ",", "QueryString", ":", "n", ".", "QueryString", "}", "\n", "r", ".", "Stmt", ".", "unsafe", "=", "true", "\n", "return", "r", "\n", "}" ]
// Unsafe creates an unsafe version of the NamedStmt
[ "Unsafe", "creates", "an", "unsafe", "version", "of", "the", "NamedStmt" ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L119-L123
train
jmoiron/sqlx
named.go
bindArgs
func bindArgs(names []string, arg interface{}, m *reflectx.Mapper) ([]interface{}, error) { arglist := make([]interface{}, 0, len(names)) // grab the indirected value of arg v := reflect.ValueOf(arg) for v = reflect.ValueOf(arg); v.Kind() == reflect.Ptr; { v = v.Elem() } err := m.TraversalsByNameFunc(v.Type(), names, func(i int, t []int) error { if len(t) == 0 { return fmt.Errorf("could not find name %s in %#v", names[i], arg) } val := reflectx.FieldByIndexesReadOnly(v, t) arglist = append(arglist, val.Interface()) return nil }) return arglist, err }
go
func bindArgs(names []string, arg interface{}, m *reflectx.Mapper) ([]interface{}, error) { arglist := make([]interface{}, 0, len(names)) // grab the indirected value of arg v := reflect.ValueOf(arg) for v = reflect.ValueOf(arg); v.Kind() == reflect.Ptr; { v = v.Elem() } err := m.TraversalsByNameFunc(v.Type(), names, func(i int, t []int) error { if len(t) == 0 { return fmt.Errorf("could not find name %s in %#v", names[i], arg) } val := reflectx.FieldByIndexesReadOnly(v, t) arglist = append(arglist, val.Interface()) return nil }) return arglist, err }
[ "func", "bindArgs", "(", "names", "[", "]", "string", ",", "arg", "interface", "{", "}", ",", "m", "*", "reflectx", ".", "Mapper", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "arglist", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ",", "len", "(", "names", ")", ")", "\n\n", "// grab the indirected value of arg", "v", ":=", "reflect", ".", "ValueOf", "(", "arg", ")", "\n", "for", "v", "=", "reflect", ".", "ValueOf", "(", "arg", ")", ";", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", ";", "{", "v", "=", "v", ".", "Elem", "(", ")", "\n", "}", "\n\n", "err", ":=", "m", ".", "TraversalsByNameFunc", "(", "v", ".", "Type", "(", ")", ",", "names", ",", "func", "(", "i", "int", ",", "t", "[", "]", "int", ")", "error", "{", "if", "len", "(", "t", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "names", "[", "i", "]", ",", "arg", ")", "\n", "}", "\n\n", "val", ":=", "reflectx", ".", "FieldByIndexesReadOnly", "(", "v", ",", "t", ")", "\n", "arglist", "=", "append", "(", "arglist", ",", "val", ".", "Interface", "(", ")", ")", "\n\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "arglist", ",", "err", "\n", "}" ]
// private interface to generate a list of interfaces from a given struct // type, given a list of names to pull out of the struct. Used by public // BindStruct interface.
[ "private", "interface", "to", "generate", "a", "list", "of", "interfaces", "from", "a", "given", "struct", "type", "given", "a", "list", "of", "names", "to", "pull", "out", "of", "the", "struct", ".", "Used", "by", "public", "BindStruct", "interface", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L159-L180
train
jmoiron/sqlx
named.go
bindMapArgs
func bindMapArgs(names []string, arg map[string]interface{}) ([]interface{}, error) { arglist := make([]interface{}, 0, len(names)) for _, name := range names { val, ok := arg[name] if !ok { return arglist, fmt.Errorf("could not find name %s in %#v", name, arg) } arglist = append(arglist, val) } return arglist, nil }
go
func bindMapArgs(names []string, arg map[string]interface{}) ([]interface{}, error) { arglist := make([]interface{}, 0, len(names)) for _, name := range names { val, ok := arg[name] if !ok { return arglist, fmt.Errorf("could not find name %s in %#v", name, arg) } arglist = append(arglist, val) } return arglist, nil }
[ "func", "bindMapArgs", "(", "names", "[", "]", "string", ",", "arg", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "arglist", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ",", "len", "(", "names", ")", ")", "\n\n", "for", "_", ",", "name", ":=", "range", "names", "{", "val", ",", "ok", ":=", "arg", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "arglist", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "arg", ")", "\n", "}", "\n", "arglist", "=", "append", "(", "arglist", ",", "val", ")", "\n", "}", "\n", "return", "arglist", ",", "nil", "\n", "}" ]
// like bindArgs, but for maps.
[ "like", "bindArgs", "but", "for", "maps", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L183-L194
train
jmoiron/sqlx
named.go
bindStruct
func bindStruct(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) { bound, names, err := compileNamedQuery([]byte(query), bindType) if err != nil { return "", []interface{}{}, err } arglist, err := bindArgs(names, arg, m) if err != nil { return "", []interface{}{}, err } return bound, arglist, nil }
go
func bindStruct(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) { bound, names, err := compileNamedQuery([]byte(query), bindType) if err != nil { return "", []interface{}{}, err } arglist, err := bindArgs(names, arg, m) if err != nil { return "", []interface{}{}, err } return bound, arglist, nil }
[ "func", "bindStruct", "(", "bindType", "int", ",", "query", "string", ",", "arg", "interface", "{", "}", ",", "m", "*", "reflectx", ".", "Mapper", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "bound", ",", "names", ",", "err", ":=", "compileNamedQuery", "(", "[", "]", "byte", "(", "query", ")", ",", "bindType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "}", ",", "err", "\n", "}", "\n\n", "arglist", ",", "err", ":=", "bindArgs", "(", "names", ",", "arg", ",", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "bound", ",", "arglist", ",", "nil", "\n", "}" ]
// bindStruct binds a named parameter query with fields from a struct argument. // The rules for binding field names to parameter names follow the same // conventions as for StructScan, including obeying the `db` struct tags.
[ "bindStruct", "binds", "a", "named", "parameter", "query", "with", "fields", "from", "a", "struct", "argument", ".", "The", "rules", "for", "binding", "field", "names", "to", "parameter", "names", "follow", "the", "same", "conventions", "as", "for", "StructScan", "including", "obeying", "the", "db", "struct", "tags", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L199-L211
train
jmoiron/sqlx
named.go
bindArray
func bindArray(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) { // do the initial binding with QUESTION; if bindType is not question, // we can rebind it at the end. bound, names, err := compileNamedQuery([]byte(query), QUESTION) if err != nil { return "", []interface{}{}, err } arrayValue := reflect.ValueOf(arg) arrayLen := arrayValue.Len() if arrayLen == 0 { return "", []interface{}{}, fmt.Errorf("length of array is 0: %#v", arg) } var arglist []interface{} for i := 0; i < arrayLen; i++ { elemArglist, err := bindArgs(names, arrayValue.Index(i).Interface(), m) if err != nil { return "", []interface{}{}, err } arglist = append(arglist, elemArglist...) } if arrayLen > 1 { bound = fixBound(bound, arrayLen) } // adjust binding type if we weren't on question if bindType != QUESTION { bound = Rebind(bindType, bound) } return bound, arglist, nil }
go
func bindArray(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) { // do the initial binding with QUESTION; if bindType is not question, // we can rebind it at the end. bound, names, err := compileNamedQuery([]byte(query), QUESTION) if err != nil { return "", []interface{}{}, err } arrayValue := reflect.ValueOf(arg) arrayLen := arrayValue.Len() if arrayLen == 0 { return "", []interface{}{}, fmt.Errorf("length of array is 0: %#v", arg) } var arglist []interface{} for i := 0; i < arrayLen; i++ { elemArglist, err := bindArgs(names, arrayValue.Index(i).Interface(), m) if err != nil { return "", []interface{}{}, err } arglist = append(arglist, elemArglist...) } if arrayLen > 1 { bound = fixBound(bound, arrayLen) } // adjust binding type if we weren't on question if bindType != QUESTION { bound = Rebind(bindType, bound) } return bound, arglist, nil }
[ "func", "bindArray", "(", "bindType", "int", ",", "query", "string", ",", "arg", "interface", "{", "}", ",", "m", "*", "reflectx", ".", "Mapper", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "// do the initial binding with QUESTION; if bindType is not question,", "// we can rebind it at the end.", "bound", ",", "names", ",", "err", ":=", "compileNamedQuery", "(", "[", "]", "byte", "(", "query", ")", ",", "QUESTION", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "}", ",", "err", "\n", "}", "\n", "arrayValue", ":=", "reflect", ".", "ValueOf", "(", "arg", ")", "\n", "arrayLen", ":=", "arrayValue", ".", "Len", "(", ")", "\n", "if", "arrayLen", "==", "0", "{", "return", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ")", "\n", "}", "\n", "var", "arglist", "[", "]", "interface", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "arrayLen", ";", "i", "++", "{", "elemArglist", ",", "err", ":=", "bindArgs", "(", "names", ",", "arrayValue", ".", "Index", "(", "i", ")", ".", "Interface", "(", ")", ",", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "}", ",", "err", "\n", "}", "\n", "arglist", "=", "append", "(", "arglist", ",", "elemArglist", "...", ")", "\n", "}", "\n", "if", "arrayLen", ">", "1", "{", "bound", "=", "fixBound", "(", "bound", ",", "arrayLen", ")", "\n", "}", "\n", "// adjust binding type if we weren't on question", "if", "bindType", "!=", "QUESTION", "{", "bound", "=", "Rebind", "(", "bindType", ",", "bound", ")", "\n", "}", "\n", "return", "bound", ",", "arglist", ",", "nil", "\n", "}" ]
// bindArray binds a named parameter query with fields from an array or slice of // structs argument.
[ "bindArray", "binds", "a", "named", "parameter", "query", "with", "fields", "from", "an", "array", "or", "slice", "of", "structs", "argument", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L233-L261
train
jmoiron/sqlx
named.go
bindMap
func bindMap(bindType int, query string, args map[string]interface{}) (string, []interface{}, error) { bound, names, err := compileNamedQuery([]byte(query), bindType) if err != nil { return "", []interface{}{}, err } arglist, err := bindMapArgs(names, args) return bound, arglist, err }
go
func bindMap(bindType int, query string, args map[string]interface{}) (string, []interface{}, error) { bound, names, err := compileNamedQuery([]byte(query), bindType) if err != nil { return "", []interface{}{}, err } arglist, err := bindMapArgs(names, args) return bound, arglist, err }
[ "func", "bindMap", "(", "bindType", "int", ",", "query", "string", ",", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "bound", ",", "names", ",", "err", ":=", "compileNamedQuery", "(", "[", "]", "byte", "(", "query", ")", ",", "bindType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "}", ",", "err", "\n", "}", "\n\n", "arglist", ",", "err", ":=", "bindMapArgs", "(", "names", ",", "args", ")", "\n", "return", "bound", ",", "arglist", ",", "err", "\n", "}" ]
// bindMap binds a named parameter query with a map of arguments.
[ "bindMap", "binds", "a", "named", "parameter", "query", "with", "a", "map", "of", "arguments", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L264-L272
train
jmoiron/sqlx
named.go
Named
func Named(query string, arg interface{}) (string, []interface{}, error) { return bindNamedMapper(QUESTION, query, arg, mapper()) }
go
func Named(query string, arg interface{}) (string, []interface{}, error) { return bindNamedMapper(QUESTION, query, arg, mapper()) }
[ "func", "Named", "(", "query", "string", ",", "arg", "interface", "{", "}", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "return", "bindNamedMapper", "(", "QUESTION", ",", "query", ",", "arg", ",", "mapper", "(", ")", ")", "\n", "}" ]
// Named takes a query using named parameters and an argument and // returns a new query with a list of args that can be executed by // a database. The return value uses the `?` bindvar.
[ "Named", "takes", "a", "query", "using", "named", "parameters", "and", "an", "argument", "and", "returns", "a", "new", "query", "with", "a", "list", "of", "args", "that", "can", "be", "executed", "by", "a", "database", ".", "The", "return", "value", "uses", "the", "?", "bindvar", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L377-L379
train
jmoiron/sqlx
named.go
NamedExec
func NamedExec(e Ext, query string, arg interface{}) (sql.Result, error) { q, args, err := bindNamedMapper(BindType(e.DriverName()), query, arg, mapperFor(e)) if err != nil { return nil, err } return e.Exec(q, args...) }
go
func NamedExec(e Ext, query string, arg interface{}) (sql.Result, error) { q, args, err := bindNamedMapper(BindType(e.DriverName()), query, arg, mapperFor(e)) if err != nil { return nil, err } return e.Exec(q, args...) }
[ "func", "NamedExec", "(", "e", "Ext", ",", "query", "string", ",", "arg", "interface", "{", "}", ")", "(", "sql", ".", "Result", ",", "error", ")", "{", "q", ",", "args", ",", "err", ":=", "bindNamedMapper", "(", "BindType", "(", "e", ".", "DriverName", "(", ")", ")", ",", "query", ",", "arg", ",", "mapperFor", "(", "e", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "e", ".", "Exec", "(", "q", ",", "args", "...", ")", "\n", "}" ]
// NamedExec uses BindStruct to get a query executable by the driver and // then runs Exec on the result. Returns an error from the binding // or the query execution itself.
[ "NamedExec", "uses", "BindStruct", "to", "get", "a", "query", "executable", "by", "the", "driver", "and", "then", "runs", "Exec", "on", "the", "result", ".", "Returns", "an", "error", "from", "the", "binding", "or", "the", "query", "execution", "itself", "." ]
38398a30ed8516ffda617a04c822de09df8a3ec5
https://github.com/jmoiron/sqlx/blob/38398a30ed8516ffda617a04c822de09df8a3ec5/named.go#L407-L413
train
google/go-github
github/event.go
ParsePayload
func (e *Event) ParsePayload() (payload interface{}, err error) { switch *e.Type { case "CheckRunEvent": payload = &CheckRunEvent{} case "CheckSuiteEvent": payload = &CheckSuiteEvent{} case "CommitCommentEvent": payload = &CommitCommentEvent{} case "CreateEvent": payload = &CreateEvent{} case "DeleteEvent": payload = &DeleteEvent{} case "DeployKeyEvent": payload = &DeployKeyEvent{} case "DeploymentEvent": payload = &DeploymentEvent{} case "DeploymentStatusEvent": payload = &DeploymentStatusEvent{} case "ForkEvent": payload = &ForkEvent{} case "GitHubAppAuthorizationEvent": payload = &GitHubAppAuthorizationEvent{} case "GollumEvent": payload = &GollumEvent{} case "InstallationEvent": payload = &InstallationEvent{} case "InstallationRepositoriesEvent": payload = &InstallationRepositoriesEvent{} case "IssueCommentEvent": payload = &IssueCommentEvent{} case "IssuesEvent": payload = &IssuesEvent{} case "LabelEvent": payload = &LabelEvent{} case "MarketplacePurchaseEvent": payload = &MarketplacePurchaseEvent{} case "MemberEvent": payload = &MemberEvent{} case "MembershipEvent": payload = &MembershipEvent{} case "MetaEvent": payload = &MetaEvent{} case "MilestoneEvent": payload = &MilestoneEvent{} case "OrganizationEvent": payload = &OrganizationEvent{} case "OrgBlockEvent": payload = &OrgBlockEvent{} case "PageBuildEvent": payload = &PageBuildEvent{} case "PingEvent": payload = &PingEvent{} case "ProjectEvent": payload = &ProjectEvent{} case "ProjectCardEvent": payload = &ProjectCardEvent{} case "ProjectColumnEvent": payload = &ProjectColumnEvent{} case "PublicEvent": payload = &PublicEvent{} case "PullRequestEvent": payload = &PullRequestEvent{} case "PullRequestReviewEvent": payload = &PullRequestReviewEvent{} case "PullRequestReviewCommentEvent": payload = &PullRequestReviewCommentEvent{} case "PushEvent": payload = &PushEvent{} case "ReleaseEvent": payload = &ReleaseEvent{} case "RepositoryEvent": payload = &RepositoryEvent{} case "RepositoryVulnerabilityAlertEvent": payload = &RepositoryVulnerabilityAlertEvent{} case "StarEvent": payload = &StarEvent{} case "StatusEvent": payload = &StatusEvent{} case "TeamEvent": payload = &TeamEvent{} case "TeamAddEvent": payload = &TeamAddEvent{} case "WatchEvent": payload = &WatchEvent{} } err = json.Unmarshal(*e.RawPayload, &payload) return payload, err }
go
func (e *Event) ParsePayload() (payload interface{}, err error) { switch *e.Type { case "CheckRunEvent": payload = &CheckRunEvent{} case "CheckSuiteEvent": payload = &CheckSuiteEvent{} case "CommitCommentEvent": payload = &CommitCommentEvent{} case "CreateEvent": payload = &CreateEvent{} case "DeleteEvent": payload = &DeleteEvent{} case "DeployKeyEvent": payload = &DeployKeyEvent{} case "DeploymentEvent": payload = &DeploymentEvent{} case "DeploymentStatusEvent": payload = &DeploymentStatusEvent{} case "ForkEvent": payload = &ForkEvent{} case "GitHubAppAuthorizationEvent": payload = &GitHubAppAuthorizationEvent{} case "GollumEvent": payload = &GollumEvent{} case "InstallationEvent": payload = &InstallationEvent{} case "InstallationRepositoriesEvent": payload = &InstallationRepositoriesEvent{} case "IssueCommentEvent": payload = &IssueCommentEvent{} case "IssuesEvent": payload = &IssuesEvent{} case "LabelEvent": payload = &LabelEvent{} case "MarketplacePurchaseEvent": payload = &MarketplacePurchaseEvent{} case "MemberEvent": payload = &MemberEvent{} case "MembershipEvent": payload = &MembershipEvent{} case "MetaEvent": payload = &MetaEvent{} case "MilestoneEvent": payload = &MilestoneEvent{} case "OrganizationEvent": payload = &OrganizationEvent{} case "OrgBlockEvent": payload = &OrgBlockEvent{} case "PageBuildEvent": payload = &PageBuildEvent{} case "PingEvent": payload = &PingEvent{} case "ProjectEvent": payload = &ProjectEvent{} case "ProjectCardEvent": payload = &ProjectCardEvent{} case "ProjectColumnEvent": payload = &ProjectColumnEvent{} case "PublicEvent": payload = &PublicEvent{} case "PullRequestEvent": payload = &PullRequestEvent{} case "PullRequestReviewEvent": payload = &PullRequestReviewEvent{} case "PullRequestReviewCommentEvent": payload = &PullRequestReviewCommentEvent{} case "PushEvent": payload = &PushEvent{} case "ReleaseEvent": payload = &ReleaseEvent{} case "RepositoryEvent": payload = &RepositoryEvent{} case "RepositoryVulnerabilityAlertEvent": payload = &RepositoryVulnerabilityAlertEvent{} case "StarEvent": payload = &StarEvent{} case "StatusEvent": payload = &StatusEvent{} case "TeamEvent": payload = &TeamEvent{} case "TeamAddEvent": payload = &TeamAddEvent{} case "WatchEvent": payload = &WatchEvent{} } err = json.Unmarshal(*e.RawPayload, &payload) return payload, err }
[ "func", "(", "e", "*", "Event", ")", "ParsePayload", "(", ")", "(", "payload", "interface", "{", "}", ",", "err", "error", ")", "{", "switch", "*", "e", ".", "Type", "{", "case", "\"", "\"", ":", "payload", "=", "&", "CheckRunEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "CheckSuiteEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "CommitCommentEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "CreateEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "DeleteEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "DeployKeyEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "DeploymentEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "DeploymentStatusEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "ForkEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "GitHubAppAuthorizationEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "GollumEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "InstallationEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "InstallationRepositoriesEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "IssueCommentEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "IssuesEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "LabelEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "MarketplacePurchaseEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "MemberEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "MembershipEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "MetaEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "MilestoneEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "OrganizationEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "OrgBlockEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PageBuildEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PingEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "ProjectEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "ProjectCardEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "ProjectColumnEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PublicEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PullRequestEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PullRequestReviewEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PullRequestReviewCommentEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "PushEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "ReleaseEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "RepositoryEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "RepositoryVulnerabilityAlertEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "StarEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "StatusEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "TeamEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "TeamAddEvent", "{", "}", "\n", "case", "\"", "\"", ":", "payload", "=", "&", "WatchEvent", "{", "}", "\n", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "*", "e", ".", "RawPayload", ",", "&", "payload", ")", "\n", "return", "payload", ",", "err", "\n", "}" ]
// ParsePayload parses the event payload. For recognized event types, // a value of the corresponding struct type will be returned.
[ "ParsePayload", "parses", "the", "event", "payload", ".", "For", "recognized", "event", "types", "a", "value", "of", "the", "corresponding", "struct", "type", "will", "be", "returned", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/event.go#L31-L118
train
google/go-github
github/repos_contents.go
GetContent
func (r *RepositoryContent) GetContent() (string, error) { var encoding string if r.Encoding != nil { encoding = *r.Encoding } switch encoding { case "base64": c, err := base64.StdEncoding.DecodeString(*r.Content) return string(c), err case "": if r.Content == nil { return "", nil } return *r.Content, nil default: return "", fmt.Errorf("unsupported content encoding: %v", encoding) } }
go
func (r *RepositoryContent) GetContent() (string, error) { var encoding string if r.Encoding != nil { encoding = *r.Encoding } switch encoding { case "base64": c, err := base64.StdEncoding.DecodeString(*r.Content) return string(c), err case "": if r.Content == nil { return "", nil } return *r.Content, nil default: return "", fmt.Errorf("unsupported content encoding: %v", encoding) } }
[ "func", "(", "r", "*", "RepositoryContent", ")", "GetContent", "(", ")", "(", "string", ",", "error", ")", "{", "var", "encoding", "string", "\n", "if", "r", ".", "Encoding", "!=", "nil", "{", "encoding", "=", "*", "r", ".", "Encoding", "\n", "}", "\n\n", "switch", "encoding", "{", "case", "\"", "\"", ":", "c", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "*", "r", ".", "Content", ")", "\n", "return", "string", "(", "c", ")", ",", "err", "\n", "case", "\"", "\"", ":", "if", "r", ".", "Content", "==", "nil", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "return", "*", "r", ".", "Content", ",", "nil", "\n", "default", ":", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "encoding", ")", "\n", "}", "\n", "}" ]
// GetContent returns the content of r, decoding it if necessary.
[ "GetContent", "returns", "the", "content", "of", "r", "decoding", "it", "if", "necessary", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/repos_contents.go#L71-L89
train
google/go-github
github/repos_contents.go
DownloadContents
func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, filepath string, opt *RepositoryContentGetOptions) (io.ReadCloser, error) { dir := path.Dir(filepath) filename := path.Base(filepath) _, dirContents, _, err := s.GetContents(ctx, owner, repo, dir, opt) if err != nil { return nil, err } for _, contents := range dirContents { if *contents.Name == filename { if contents.DownloadURL == nil || *contents.DownloadURL == "" { return nil, fmt.Errorf("No download link found for %s", filepath) } resp, err := s.client.client.Get(*contents.DownloadURL) if err != nil { return nil, err } return resp.Body, nil } } return nil, fmt.Errorf("No file named %s found in %s", filename, dir) }
go
func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, filepath string, opt *RepositoryContentGetOptions) (io.ReadCloser, error) { dir := path.Dir(filepath) filename := path.Base(filepath) _, dirContents, _, err := s.GetContents(ctx, owner, repo, dir, opt) if err != nil { return nil, err } for _, contents := range dirContents { if *contents.Name == filename { if contents.DownloadURL == nil || *contents.DownloadURL == "" { return nil, fmt.Errorf("No download link found for %s", filepath) } resp, err := s.client.client.Get(*contents.DownloadURL) if err != nil { return nil, err } return resp.Body, nil } } return nil, fmt.Errorf("No file named %s found in %s", filename, dir) }
[ "func", "(", "s", "*", "RepositoriesService", ")", "DownloadContents", "(", "ctx", "context", ".", "Context", ",", "owner", ",", "repo", ",", "filepath", "string", ",", "opt", "*", "RepositoryContentGetOptions", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "dir", ":=", "path", ".", "Dir", "(", "filepath", ")", "\n", "filename", ":=", "path", ".", "Base", "(", "filepath", ")", "\n", "_", ",", "dirContents", ",", "_", ",", "err", ":=", "s", ".", "GetContents", "(", "ctx", ",", "owner", ",", "repo", ",", "dir", ",", "opt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "contents", ":=", "range", "dirContents", "{", "if", "*", "contents", ".", "Name", "==", "filename", "{", "if", "contents", ".", "DownloadURL", "==", "nil", "||", "*", "contents", ".", "DownloadURL", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "filepath", ")", "\n", "}", "\n", "resp", ",", "err", ":=", "s", ".", "client", ".", "client", ".", "Get", "(", "*", "contents", ".", "DownloadURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "resp", ".", "Body", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "filename", ",", "dir", ")", "\n", "}" ]
// DownloadContents returns an io.ReadCloser that reads the contents of the // specified file. This function will work with files of any size, as opposed // to GetContents which is limited to 1 Mb files. It is the caller's // responsibility to close the ReadCloser.
[ "DownloadContents", "returns", "an", "io", ".", "ReadCloser", "that", "reads", "the", "contents", "of", "the", "specified", "file", ".", "This", "function", "will", "work", "with", "files", "of", "any", "size", "as", "opposed", "to", "GetContents", "which", "is", "limited", "to", "1", "Mb", "files", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "close", "the", "ReadCloser", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/repos_contents.go#L116-L136
train
google/go-github
github/timestamp.go
UnmarshalJSON
func (t *Timestamp) UnmarshalJSON(data []byte) (err error) { str := string(data) i, err := strconv.ParseInt(str, 10, 64) if err == nil { t.Time = time.Unix(i, 0) } else { t.Time, err = time.Parse(`"`+time.RFC3339+`"`, str) } return }
go
func (t *Timestamp) UnmarshalJSON(data []byte) (err error) { str := string(data) i, err := strconv.ParseInt(str, 10, 64) if err == nil { t.Time = time.Unix(i, 0) } else { t.Time, err = time.Parse(`"`+time.RFC3339+`"`, str) } return }
[ "func", "(", "t", "*", "Timestamp", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "str", ":=", "string", "(", "data", ")", "\n", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "str", ",", "10", ",", "64", ")", "\n", "if", "err", "==", "nil", "{", "t", ".", "Time", "=", "time", ".", "Unix", "(", "i", ",", "0", ")", "\n", "}", "else", "{", "t", ".", "Time", ",", "err", "=", "time", ".", "Parse", "(", "`\"`", "+", "time", ".", "RFC3339", "+", "`\"`", ",", "str", ")", "\n", "}", "\n", "return", "\n", "}" ]
// UnmarshalJSON implements the json.Unmarshaler interface. // Time is expected in RFC3339 or Unix format.
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", ".", "Time", "is", "expected", "in", "RFC3339", "or", "Unix", "format", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/timestamp.go#L27-L36
train
google/go-github
github/timestamp.go
Equal
func (t Timestamp) Equal(u Timestamp) bool { return t.Time.Equal(u.Time) }
go
func (t Timestamp) Equal(u Timestamp) bool { return t.Time.Equal(u.Time) }
[ "func", "(", "t", "Timestamp", ")", "Equal", "(", "u", "Timestamp", ")", "bool", "{", "return", "t", ".", "Time", ".", "Equal", "(", "u", ".", "Time", ")", "\n", "}" ]
// Equal reports whether t and u are equal based on time.Equal
[ "Equal", "reports", "whether", "t", "and", "u", "are", "equal", "based", "on", "time", ".", "Equal" ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/timestamp.go#L39-L41
train
google/go-github
example/simple/main.go
FetchOrganizations
func FetchOrganizations(username string) ([]*github.Organization, error) { client := github.NewClient(nil) orgs, _, err := client.Organizations.List(context.Background(), username, nil) return orgs, err }
go
func FetchOrganizations(username string) ([]*github.Organization, error) { client := github.NewClient(nil) orgs, _, err := client.Organizations.List(context.Background(), username, nil) return orgs, err }
[ "func", "FetchOrganizations", "(", "username", "string", ")", "(", "[", "]", "*", "github", ".", "Organization", ",", "error", ")", "{", "client", ":=", "github", ".", "NewClient", "(", "nil", ")", "\n", "orgs", ",", "_", ",", "err", ":=", "client", ".", "Organizations", ".", "List", "(", "context", ".", "Background", "(", ")", ",", "username", ",", "nil", ")", "\n", "return", "orgs", ",", "err", "\n", "}" ]
// Fetch all the public organizations' membership of a user. //
[ "Fetch", "all", "the", "public", "organizations", "membership", "of", "a", "user", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/example/simple/main.go#L20-L24
train
google/go-github
github/migrations_source_import.go
CommitAuthors
func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeImportPreview) var authors []*SourceImportAuthor resp, err := s.client.Do(ctx, req, &authors) if err != nil { return nil, resp, err } return authors, resp, nil }
go
func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeImportPreview) var authors []*SourceImportAuthor resp, err := s.client.Do(ctx, req, &authors) if err != nil { return nil, resp, err } return authors, resp, nil }
[ "func", "(", "s", "*", "MigrationService", ")", "CommitAuthors", "(", "ctx", "context", ".", "Context", ",", "owner", ",", "repo", "string", ")", "(", "[", "]", "*", "SourceImportAuthor", ",", "*", "Response", ",", "error", ")", "{", "u", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "owner", ",", "repo", ")", "\n", "req", ",", "err", ":=", "s", ".", "client", ".", "NewRequest", "(", "\"", "\"", ",", "u", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "// TODO: remove custom Accept header when this API fully launches", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "mediaTypeImportPreview", ")", "\n\n", "var", "authors", "[", "]", "*", "SourceImportAuthor", "\n", "resp", ",", "err", ":=", "s", ".", "client", ".", "Do", "(", "ctx", ",", "req", ",", "&", "authors", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "resp", ",", "err", "\n", "}", "\n\n", "return", "authors", ",", "resp", ",", "nil", "\n", "}" ]
// CommitAuthors gets the authors mapped from the original repository. // // Each type of source control system represents authors in a different way. // For example, a Git commit author has a display name and an email address, // but a Subversion commit author just has a username. The GitHub Importer will // make the author information valid, but the author might not be correct. For // example, it will change the bare Subversion username "hubot" into something // like "hubot <hubot@12341234-abab-fefe-8787-fedcba987654>". // // This method and MapCommitAuthor allow you to provide correct Git author // information. // // GitHub API docs: https://developer.github.com/v3/migration/source_imports/#get-commit-authors
[ "CommitAuthors", "gets", "the", "authors", "mapped", "from", "the", "original", "repository", ".", "Each", "type", "of", "source", "control", "system", "represents", "authors", "in", "a", "different", "way", ".", "For", "example", "a", "Git", "commit", "author", "has", "a", "display", "name", "and", "an", "email", "address", "but", "a", "Subversion", "commit", "author", "just", "has", "a", "username", ".", "The", "GitHub", "Importer", "will", "make", "the", "author", "information", "valid", "but", "the", "author", "might", "not", "be", "correct", ".", "For", "example", "it", "will", "change", "the", "bare", "Subversion", "username", "hubot", "into", "something", "like", "hubot", "<hubot" ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/migrations_source_import.go#L226-L243
train
google/go-github
github/github.go
NewUploadRequest
func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string) (*http.Request, error) { if !strings.HasSuffix(c.UploadURL.Path, "/") { return nil, fmt.Errorf("UploadURL must have a trailing slash, but %q does not", c.UploadURL) } u, err := c.UploadURL.Parse(urlStr) if err != nil { return nil, err } req, err := http.NewRequest("POST", u.String(), reader) if err != nil { return nil, err } req.ContentLength = size if mediaType == "" { mediaType = defaultMediaType } req.Header.Set("Content-Type", mediaType) req.Header.Set("Accept", mediaTypeV3) req.Header.Set("User-Agent", c.UserAgent) return req, nil }
go
func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string) (*http.Request, error) { if !strings.HasSuffix(c.UploadURL.Path, "/") { return nil, fmt.Errorf("UploadURL must have a trailing slash, but %q does not", c.UploadURL) } u, err := c.UploadURL.Parse(urlStr) if err != nil { return nil, err } req, err := http.NewRequest("POST", u.String(), reader) if err != nil { return nil, err } req.ContentLength = size if mediaType == "" { mediaType = defaultMediaType } req.Header.Set("Content-Type", mediaType) req.Header.Set("Accept", mediaTypeV3) req.Header.Set("User-Agent", c.UserAgent) return req, nil }
[ "func", "(", "c", "*", "Client", ")", "NewUploadRequest", "(", "urlStr", "string", ",", "reader", "io", ".", "Reader", ",", "size", "int64", ",", "mediaType", "string", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "if", "!", "strings", ".", "HasSuffix", "(", "c", ".", "UploadURL", ".", "Path", ",", "\"", "\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c", ".", "UploadURL", ")", "\n", "}", "\n", "u", ",", "err", ":=", "c", ".", "UploadURL", ".", "Parse", "(", "urlStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "u", ".", "String", "(", ")", ",", "reader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "req", ".", "ContentLength", "=", "size", "\n\n", "if", "mediaType", "==", "\"", "\"", "{", "mediaType", "=", "defaultMediaType", "\n", "}", "\n", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "mediaType", ")", "\n", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "mediaTypeV3", ")", "\n", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "c", ".", "UserAgent", ")", "\n", "return", "req", ",", "nil", "\n", "}" ]
// NewUploadRequest creates an upload request. A relative URL can be provided in // urlStr, in which case it is resolved relative to the UploadURL of the Client. // Relative URLs should always be specified without a preceding slash.
[ "NewUploadRequest", "creates", "an", "upload", "request", ".", "A", "relative", "URL", "can", "be", "provided", "in", "urlStr", "in", "which", "case", "it", "is", "resolved", "relative", "to", "the", "UploadURL", "of", "the", "Client", ".", "Relative", "URLs", "should", "always", "be", "specified", "without", "a", "preceding", "slash", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github.go#L354-L376
train
google/go-github
github/github.go
newResponse
func newResponse(r *http.Response) *Response { response := &Response{Response: r} response.populatePageValues() response.Rate = parseRate(r) return response }
go
func newResponse(r *http.Response) *Response { response := &Response{Response: r} response.populatePageValues() response.Rate = parseRate(r) return response }
[ "func", "newResponse", "(", "r", "*", "http", ".", "Response", ")", "*", "Response", "{", "response", ":=", "&", "Response", "{", "Response", ":", "r", "}", "\n", "response", ".", "populatePageValues", "(", ")", "\n", "response", ".", "Rate", "=", "parseRate", "(", "r", ")", "\n", "return", "response", "\n", "}" ]
// newResponse creates a new Response for the provided http.Response. // r must not be nil.
[ "newResponse", "creates", "a", "new", "Response", "for", "the", "provided", "http", ".", "Response", ".", "r", "must", "not", "be", "nil", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github.go#L401-L406
train
google/go-github
github/github.go
populatePageValues
func (r *Response) populatePageValues() { if links, ok := r.Response.Header["Link"]; ok && len(links) > 0 { for _, link := range strings.Split(links[0], ",") { segments := strings.Split(strings.TrimSpace(link), ";") // link must at least have href and rel if len(segments) < 2 { continue } // ensure href is properly formatted if !strings.HasPrefix(segments[0], "<") || !strings.HasSuffix(segments[0], ">") { continue } // try to pull out page parameter url, err := url.Parse(segments[0][1 : len(segments[0])-1]) if err != nil { continue } page := url.Query().Get("page") if page == "" { continue } for _, segment := range segments[1:] { switch strings.TrimSpace(segment) { case `rel="next"`: r.NextPage, _ = strconv.Atoi(page) case `rel="prev"`: r.PrevPage, _ = strconv.Atoi(page) case `rel="first"`: r.FirstPage, _ = strconv.Atoi(page) case `rel="last"`: r.LastPage, _ = strconv.Atoi(page) } } } } }
go
func (r *Response) populatePageValues() { if links, ok := r.Response.Header["Link"]; ok && len(links) > 0 { for _, link := range strings.Split(links[0], ",") { segments := strings.Split(strings.TrimSpace(link), ";") // link must at least have href and rel if len(segments) < 2 { continue } // ensure href is properly formatted if !strings.HasPrefix(segments[0], "<") || !strings.HasSuffix(segments[0], ">") { continue } // try to pull out page parameter url, err := url.Parse(segments[0][1 : len(segments[0])-1]) if err != nil { continue } page := url.Query().Get("page") if page == "" { continue } for _, segment := range segments[1:] { switch strings.TrimSpace(segment) { case `rel="next"`: r.NextPage, _ = strconv.Atoi(page) case `rel="prev"`: r.PrevPage, _ = strconv.Atoi(page) case `rel="first"`: r.FirstPage, _ = strconv.Atoi(page) case `rel="last"`: r.LastPage, _ = strconv.Atoi(page) } } } } }
[ "func", "(", "r", "*", "Response", ")", "populatePageValues", "(", ")", "{", "if", "links", ",", "ok", ":=", "r", ".", "Response", ".", "Header", "[", "\"", "\"", "]", ";", "ok", "&&", "len", "(", "links", ")", ">", "0", "{", "for", "_", ",", "link", ":=", "range", "strings", ".", "Split", "(", "links", "[", "0", "]", ",", "\"", "\"", ")", "{", "segments", ":=", "strings", ".", "Split", "(", "strings", ".", "TrimSpace", "(", "link", ")", ",", "\"", "\"", ")", "\n\n", "// link must at least have href and rel", "if", "len", "(", "segments", ")", "<", "2", "{", "continue", "\n", "}", "\n\n", "// ensure href is properly formatted", "if", "!", "strings", ".", "HasPrefix", "(", "segments", "[", "0", "]", ",", "\"", "\"", ")", "||", "!", "strings", ".", "HasSuffix", "(", "segments", "[", "0", "]", ",", "\"", "\"", ")", "{", "continue", "\n", "}", "\n\n", "// try to pull out page parameter", "url", ",", "err", ":=", "url", ".", "Parse", "(", "segments", "[", "0", "]", "[", "1", ":", "len", "(", "segments", "[", "0", "]", ")", "-", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "page", ":=", "url", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "page", "==", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "for", "_", ",", "segment", ":=", "range", "segments", "[", "1", ":", "]", "{", "switch", "strings", ".", "TrimSpace", "(", "segment", ")", "{", "case", "`rel=\"next\"`", ":", "r", ".", "NextPage", ",", "_", "=", "strconv", ".", "Atoi", "(", "page", ")", "\n", "case", "`rel=\"prev\"`", ":", "r", ".", "PrevPage", ",", "_", "=", "strconv", ".", "Atoi", "(", "page", ")", "\n", "case", "`rel=\"first\"`", ":", "r", ".", "FirstPage", ",", "_", "=", "strconv", ".", "Atoi", "(", "page", ")", "\n", "case", "`rel=\"last\"`", ":", "r", ".", "LastPage", ",", "_", "=", "strconv", ".", "Atoi", "(", "page", ")", "\n", "}", "\n\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// populatePageValues parses the HTTP Link response headers and populates the // various pagination link values in the Response.
[ "populatePageValues", "parses", "the", "HTTP", "Link", "response", "headers", "and", "populates", "the", "various", "pagination", "link", "values", "in", "the", "Response", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github.go#L410-L450
train
google/go-github
github/github.go
parseRate
func parseRate(r *http.Response) Rate { var rate Rate if limit := r.Header.Get(headerRateLimit); limit != "" { rate.Limit, _ = strconv.Atoi(limit) } if remaining := r.Header.Get(headerRateRemaining); remaining != "" { rate.Remaining, _ = strconv.Atoi(remaining) } if reset := r.Header.Get(headerRateReset); reset != "" { if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 { rate.Reset = Timestamp{time.Unix(v, 0)} } } return rate }
go
func parseRate(r *http.Response) Rate { var rate Rate if limit := r.Header.Get(headerRateLimit); limit != "" { rate.Limit, _ = strconv.Atoi(limit) } if remaining := r.Header.Get(headerRateRemaining); remaining != "" { rate.Remaining, _ = strconv.Atoi(remaining) } if reset := r.Header.Get(headerRateReset); reset != "" { if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 { rate.Reset = Timestamp{time.Unix(v, 0)} } } return rate }
[ "func", "parseRate", "(", "r", "*", "http", ".", "Response", ")", "Rate", "{", "var", "rate", "Rate", "\n", "if", "limit", ":=", "r", ".", "Header", ".", "Get", "(", "headerRateLimit", ")", ";", "limit", "!=", "\"", "\"", "{", "rate", ".", "Limit", ",", "_", "=", "strconv", ".", "Atoi", "(", "limit", ")", "\n", "}", "\n", "if", "remaining", ":=", "r", ".", "Header", ".", "Get", "(", "headerRateRemaining", ")", ";", "remaining", "!=", "\"", "\"", "{", "rate", ".", "Remaining", ",", "_", "=", "strconv", ".", "Atoi", "(", "remaining", ")", "\n", "}", "\n", "if", "reset", ":=", "r", ".", "Header", ".", "Get", "(", "headerRateReset", ")", ";", "reset", "!=", "\"", "\"", "{", "if", "v", ",", "_", ":=", "strconv", ".", "ParseInt", "(", "reset", ",", "10", ",", "64", ")", ";", "v", "!=", "0", "{", "rate", ".", "Reset", "=", "Timestamp", "{", "time", ".", "Unix", "(", "v", ",", "0", ")", "}", "\n", "}", "\n", "}", "\n", "return", "rate", "\n", "}" ]
// parseRate parses the rate related headers.
[ "parseRate", "parses", "the", "rate", "related", "headers", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github.go#L453-L467
train
google/go-github
github/github.go
RateLimits
func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error) { req, err := c.NewRequest("GET", "rate_limit", nil) if err != nil { return nil, nil, err } response := new(struct { Resources *RateLimits `json:"resources"` }) resp, err := c.Do(ctx, req, response) if err != nil { return nil, nil, err } if response.Resources != nil { c.rateMu.Lock() if response.Resources.Core != nil { c.rateLimits[coreCategory] = *response.Resources.Core } if response.Resources.Search != nil { c.rateLimits[searchCategory] = *response.Resources.Search } c.rateMu.Unlock() } return response.Resources, resp, nil }
go
func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error) { req, err := c.NewRequest("GET", "rate_limit", nil) if err != nil { return nil, nil, err } response := new(struct { Resources *RateLimits `json:"resources"` }) resp, err := c.Do(ctx, req, response) if err != nil { return nil, nil, err } if response.Resources != nil { c.rateMu.Lock() if response.Resources.Core != nil { c.rateLimits[coreCategory] = *response.Resources.Core } if response.Resources.Search != nil { c.rateLimits[searchCategory] = *response.Resources.Search } c.rateMu.Unlock() } return response.Resources, resp, nil }
[ "func", "(", "c", "*", "Client", ")", "RateLimits", "(", "ctx", "context", ".", "Context", ")", "(", "*", "RateLimits", ",", "*", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "new", "(", "struct", "{", "Resources", "*", "RateLimits", "`json:\"resources\"`", "\n", "}", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Do", "(", "ctx", ",", "req", ",", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "response", ".", "Resources", "!=", "nil", "{", "c", ".", "rateMu", ".", "Lock", "(", ")", "\n", "if", "response", ".", "Resources", ".", "Core", "!=", "nil", "{", "c", ".", "rateLimits", "[", "coreCategory", "]", "=", "*", "response", ".", "Resources", ".", "Core", "\n", "}", "\n", "if", "response", ".", "Resources", ".", "Search", "!=", "nil", "{", "c", ".", "rateLimits", "[", "searchCategory", "]", "=", "*", "response", ".", "Resources", ".", "Search", "\n", "}", "\n", "c", ".", "rateMu", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "return", "response", ".", "Resources", ",", "resp", ",", "nil", "\n", "}" ]
// RateLimits returns the rate limits for the current client.
[ "RateLimits", "returns", "the", "rate", "limits", "for", "the", "current", "client", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github.go#L836-L862
train
google/go-github
github/messages.go
genMAC
func genMAC(message, key []byte, hashFunc func() hash.Hash) []byte { mac := hmac.New(hashFunc, key) mac.Write(message) return mac.Sum(nil) }
go
func genMAC(message, key []byte, hashFunc func() hash.Hash) []byte { mac := hmac.New(hashFunc, key) mac.Write(message) return mac.Sum(nil) }
[ "func", "genMAC", "(", "message", ",", "key", "[", "]", "byte", ",", "hashFunc", "func", "(", ")", "hash", ".", "Hash", ")", "[", "]", "byte", "{", "mac", ":=", "hmac", ".", "New", "(", "hashFunc", ",", "key", ")", "\n", "mac", ".", "Write", "(", "message", ")", "\n", "return", "mac", ".", "Sum", "(", "nil", ")", "\n", "}" ]
// genMAC generates the HMAC signature for a message provided the secret key // and hashFunc.
[ "genMAC", "generates", "the", "HMAC", "signature", "for", "a", "message", "provided", "the", "secret", "key", "and", "hashFunc", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/messages.go#L89-L93
train
google/go-github
github/messages.go
checkMAC
func checkMAC(message, messageMAC, key []byte, hashFunc func() hash.Hash) bool { expectedMAC := genMAC(message, key, hashFunc) return hmac.Equal(messageMAC, expectedMAC) }
go
func checkMAC(message, messageMAC, key []byte, hashFunc func() hash.Hash) bool { expectedMAC := genMAC(message, key, hashFunc) return hmac.Equal(messageMAC, expectedMAC) }
[ "func", "checkMAC", "(", "message", ",", "messageMAC", ",", "key", "[", "]", "byte", ",", "hashFunc", "func", "(", ")", "hash", ".", "Hash", ")", "bool", "{", "expectedMAC", ":=", "genMAC", "(", "message", ",", "key", ",", "hashFunc", ")", "\n", "return", "hmac", ".", "Equal", "(", "messageMAC", ",", "expectedMAC", ")", "\n", "}" ]
// checkMAC reports whether messageMAC is a valid HMAC tag for message.
[ "checkMAC", "reports", "whether", "messageMAC", "is", "a", "valid", "HMAC", "tag", "for", "message", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/messages.go#L96-L99
train
google/go-github
github/messages.go
messageMAC
func messageMAC(signature string) ([]byte, func() hash.Hash, error) { if signature == "" { return nil, nil, errors.New("missing signature") } sigParts := strings.SplitN(signature, "=", 2) if len(sigParts) != 2 { return nil, nil, fmt.Errorf("error parsing signature %q", signature) } var hashFunc func() hash.Hash switch sigParts[0] { case sha1Prefix: hashFunc = sha1.New case sha256Prefix: hashFunc = sha256.New case sha512Prefix: hashFunc = sha512.New default: return nil, nil, fmt.Errorf("unknown hash type prefix: %q", sigParts[0]) } buf, err := hex.DecodeString(sigParts[1]) if err != nil { return nil, nil, fmt.Errorf("error decoding signature %q: %v", signature, err) } return buf, hashFunc, nil }
go
func messageMAC(signature string) ([]byte, func() hash.Hash, error) { if signature == "" { return nil, nil, errors.New("missing signature") } sigParts := strings.SplitN(signature, "=", 2) if len(sigParts) != 2 { return nil, nil, fmt.Errorf("error parsing signature %q", signature) } var hashFunc func() hash.Hash switch sigParts[0] { case sha1Prefix: hashFunc = sha1.New case sha256Prefix: hashFunc = sha256.New case sha512Prefix: hashFunc = sha512.New default: return nil, nil, fmt.Errorf("unknown hash type prefix: %q", sigParts[0]) } buf, err := hex.DecodeString(sigParts[1]) if err != nil { return nil, nil, fmt.Errorf("error decoding signature %q: %v", signature, err) } return buf, hashFunc, nil }
[ "func", "messageMAC", "(", "signature", "string", ")", "(", "[", "]", "byte", ",", "func", "(", ")", "hash", ".", "Hash", ",", "error", ")", "{", "if", "signature", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "sigParts", ":=", "strings", ".", "SplitN", "(", "signature", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "sigParts", ")", "!=", "2", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "signature", ")", "\n", "}", "\n\n", "var", "hashFunc", "func", "(", ")", "hash", ".", "Hash", "\n", "switch", "sigParts", "[", "0", "]", "{", "case", "sha1Prefix", ":", "hashFunc", "=", "sha1", ".", "New", "\n", "case", "sha256Prefix", ":", "hashFunc", "=", "sha256", ".", "New", "\n", "case", "sha512Prefix", ":", "hashFunc", "=", "sha512", ".", "New", "\n", "default", ":", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "sigParts", "[", "0", "]", ")", "\n", "}", "\n\n", "buf", ",", "err", ":=", "hex", ".", "DecodeString", "(", "sigParts", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "signature", ",", "err", ")", "\n", "}", "\n", "return", "buf", ",", "hashFunc", ",", "nil", "\n", "}" ]
// messageMAC returns the hex-decoded HMAC tag from the signature and its // corresponding hash function.
[ "messageMAC", "returns", "the", "hex", "-", "decoded", "HMAC", "tag", "from", "the", "signature", "and", "its", "corresponding", "hash", "function", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/messages.go#L103-L129
train
google/go-github
example/commitpr/main.go
getRef
func getRef() (ref *github.Reference, err error) { if ref, _, err = client.Git.GetRef(ctx, *sourceOwner, *sourceRepo, "refs/heads/"+*commitBranch); err == nil { return ref, nil } // We consider that an error means the branch has not been found and needs to // be created. if *commitBranch == *baseBranch { return nil, errors.New("The commit branch does not exist but `-base-branch` is the same as `-commit-branch`") } if *baseBranch == "" { return nil, errors.New("The `-base-branch` should not be set to an empty string when the branch specified by `-commit-branch` does not exists") } var baseRef *github.Reference if baseRef, _, err = client.Git.GetRef(ctx, *sourceOwner, *sourceRepo, "refs/heads/"+*baseBranch); err != nil { return nil, err } newRef := &github.Reference{Ref: github.String("refs/heads/" + *commitBranch), Object: &github.GitObject{SHA: baseRef.Object.SHA}} ref, _, err = client.Git.CreateRef(ctx, *sourceOwner, *sourceRepo, newRef) return ref, err }
go
func getRef() (ref *github.Reference, err error) { if ref, _, err = client.Git.GetRef(ctx, *sourceOwner, *sourceRepo, "refs/heads/"+*commitBranch); err == nil { return ref, nil } // We consider that an error means the branch has not been found and needs to // be created. if *commitBranch == *baseBranch { return nil, errors.New("The commit branch does not exist but `-base-branch` is the same as `-commit-branch`") } if *baseBranch == "" { return nil, errors.New("The `-base-branch` should not be set to an empty string when the branch specified by `-commit-branch` does not exists") } var baseRef *github.Reference if baseRef, _, err = client.Git.GetRef(ctx, *sourceOwner, *sourceRepo, "refs/heads/"+*baseBranch); err != nil { return nil, err } newRef := &github.Reference{Ref: github.String("refs/heads/" + *commitBranch), Object: &github.GitObject{SHA: baseRef.Object.SHA}} ref, _, err = client.Git.CreateRef(ctx, *sourceOwner, *sourceRepo, newRef) return ref, err }
[ "func", "getRef", "(", ")", "(", "ref", "*", "github", ".", "Reference", ",", "err", "error", ")", "{", "if", "ref", ",", "_", ",", "err", "=", "client", ".", "Git", ".", "GetRef", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "\"", "\"", "+", "*", "commitBranch", ")", ";", "err", "==", "nil", "{", "return", "ref", ",", "nil", "\n", "}", "\n\n", "// We consider that an error means the branch has not been found and needs to", "// be created.", "if", "*", "commitBranch", "==", "*", "baseBranch", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "*", "baseBranch", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "baseRef", "*", "github", ".", "Reference", "\n", "if", "baseRef", ",", "_", ",", "err", "=", "client", ".", "Git", ".", "GetRef", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "\"", "\"", "+", "*", "baseBranch", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "newRef", ":=", "&", "github", ".", "Reference", "{", "Ref", ":", "github", ".", "String", "(", "\"", "\"", "+", "*", "commitBranch", ")", ",", "Object", ":", "&", "github", ".", "GitObject", "{", "SHA", ":", "baseRef", ".", "Object", ".", "SHA", "}", "}", "\n", "ref", ",", "_", ",", "err", "=", "client", ".", "Git", ".", "CreateRef", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "newRef", ")", "\n", "return", "ref", ",", "err", "\n", "}" ]
// getRef returns the commit branch reference object if it exists or creates it // from the base branch before returning it.
[ "getRef", "returns", "the", "commit", "branch", "reference", "object", "if", "it", "exists", "or", "creates", "it", "from", "the", "base", "branch", "before", "returning", "it", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/example/commitpr/main.go#L62-L84
train
google/go-github
example/commitpr/main.go
getTree
func getTree(ref *github.Reference) (tree *github.Tree, err error) { // Create a tree with what to commit. entries := []github.TreeEntry{} // Load each file into the tree. for _, fileArg := range strings.Split(*sourceFiles, ",") { file, content, err := getFileContent(fileArg) if err != nil { return nil, err } entries = append(entries, github.TreeEntry{Path: github.String(file), Type: github.String("blob"), Content: github.String(string(content)), Mode: github.String("100644")}) } tree, _, err = client.Git.CreateTree(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA, entries) return tree, err }
go
func getTree(ref *github.Reference) (tree *github.Tree, err error) { // Create a tree with what to commit. entries := []github.TreeEntry{} // Load each file into the tree. for _, fileArg := range strings.Split(*sourceFiles, ",") { file, content, err := getFileContent(fileArg) if err != nil { return nil, err } entries = append(entries, github.TreeEntry{Path: github.String(file), Type: github.String("blob"), Content: github.String(string(content)), Mode: github.String("100644")}) } tree, _, err = client.Git.CreateTree(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA, entries) return tree, err }
[ "func", "getTree", "(", "ref", "*", "github", ".", "Reference", ")", "(", "tree", "*", "github", ".", "Tree", ",", "err", "error", ")", "{", "// Create a tree with what to commit.", "entries", ":=", "[", "]", "github", ".", "TreeEntry", "{", "}", "\n\n", "// Load each file into the tree.", "for", "_", ",", "fileArg", ":=", "range", "strings", ".", "Split", "(", "*", "sourceFiles", ",", "\"", "\"", ")", "{", "file", ",", "content", ",", "err", ":=", "getFileContent", "(", "fileArg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "entries", "=", "append", "(", "entries", ",", "github", ".", "TreeEntry", "{", "Path", ":", "github", ".", "String", "(", "file", ")", ",", "Type", ":", "github", ".", "String", "(", "\"", "\"", ")", ",", "Content", ":", "github", ".", "String", "(", "string", "(", "content", ")", ")", ",", "Mode", ":", "github", ".", "String", "(", "\"", "\"", ")", "}", ")", "\n", "}", "\n\n", "tree", ",", "_", ",", "err", "=", "client", ".", "Git", ".", "CreateTree", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "*", "ref", ".", "Object", ".", "SHA", ",", "entries", ")", "\n", "return", "tree", ",", "err", "\n", "}" ]
// getTree generates the tree to commit based on the given files and the commit // of the ref you got in getRef.
[ "getTree", "generates", "the", "tree", "to", "commit", "based", "on", "the", "given", "files", "and", "the", "commit", "of", "the", "ref", "you", "got", "in", "getRef", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/example/commitpr/main.go#L88-L103
train
google/go-github
example/commitpr/main.go
getFileContent
func getFileContent(fileArg string) (targetName string, b []byte, err error) { var localFile string files := strings.Split(fileArg, ":") switch { case len(files) < 1: return "", nil, errors.New("empty `-files` parameter") case len(files) == 1: localFile = files[0] targetName = files[0] default: localFile = files[0] targetName = files[1] } b, err = ioutil.ReadFile(localFile) return targetName, b, err }
go
func getFileContent(fileArg string) (targetName string, b []byte, err error) { var localFile string files := strings.Split(fileArg, ":") switch { case len(files) < 1: return "", nil, errors.New("empty `-files` parameter") case len(files) == 1: localFile = files[0] targetName = files[0] default: localFile = files[0] targetName = files[1] } b, err = ioutil.ReadFile(localFile) return targetName, b, err }
[ "func", "getFileContent", "(", "fileArg", "string", ")", "(", "targetName", "string", ",", "b", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "localFile", "string", "\n", "files", ":=", "strings", ".", "Split", "(", "fileArg", ",", "\"", "\"", ")", "\n", "switch", "{", "case", "len", "(", "files", ")", "<", "1", ":", "return", "\"", "\"", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "case", "len", "(", "files", ")", "==", "1", ":", "localFile", "=", "files", "[", "0", "]", "\n", "targetName", "=", "files", "[", "0", "]", "\n", "default", ":", "localFile", "=", "files", "[", "0", "]", "\n", "targetName", "=", "files", "[", "1", "]", "\n", "}", "\n\n", "b", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "localFile", ")", "\n", "return", "targetName", ",", "b", ",", "err", "\n", "}" ]
// getFileContent loads the local content of a file and return the target name // of the file in the target repository and its contents.
[ "getFileContent", "loads", "the", "local", "content", "of", "a", "file", "and", "return", "the", "target", "name", "of", "the", "file", "in", "the", "target", "repository", "and", "its", "contents", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/example/commitpr/main.go#L107-L123
train
google/go-github
example/commitpr/main.go
pushCommit
func pushCommit(ref *github.Reference, tree *github.Tree) (err error) { // Get the parent commit to attach the commit to. parent, _, err := client.Repositories.GetCommit(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA) if err != nil { return err } // This is not always populated, but is needed. parent.Commit.SHA = parent.SHA // Create the commit using the tree. date := time.Now() author := &github.CommitAuthor{Date: &date, Name: authorName, Email: authorEmail} commit := &github.Commit{Author: author, Message: commitMessage, Tree: tree, Parents: []github.Commit{*parent.Commit}} newCommit, _, err := client.Git.CreateCommit(ctx, *sourceOwner, *sourceRepo, commit) if err != nil { return err } // Attach the commit to the master branch. ref.Object.SHA = newCommit.SHA _, _, err = client.Git.UpdateRef(ctx, *sourceOwner, *sourceRepo, ref, false) return err }
go
func pushCommit(ref *github.Reference, tree *github.Tree) (err error) { // Get the parent commit to attach the commit to. parent, _, err := client.Repositories.GetCommit(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA) if err != nil { return err } // This is not always populated, but is needed. parent.Commit.SHA = parent.SHA // Create the commit using the tree. date := time.Now() author := &github.CommitAuthor{Date: &date, Name: authorName, Email: authorEmail} commit := &github.Commit{Author: author, Message: commitMessage, Tree: tree, Parents: []github.Commit{*parent.Commit}} newCommit, _, err := client.Git.CreateCommit(ctx, *sourceOwner, *sourceRepo, commit) if err != nil { return err } // Attach the commit to the master branch. ref.Object.SHA = newCommit.SHA _, _, err = client.Git.UpdateRef(ctx, *sourceOwner, *sourceRepo, ref, false) return err }
[ "func", "pushCommit", "(", "ref", "*", "github", ".", "Reference", ",", "tree", "*", "github", ".", "Tree", ")", "(", "err", "error", ")", "{", "// Get the parent commit to attach the commit to.", "parent", ",", "_", ",", "err", ":=", "client", ".", "Repositories", ".", "GetCommit", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "*", "ref", ".", "Object", ".", "SHA", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// This is not always populated, but is needed.", "parent", ".", "Commit", ".", "SHA", "=", "parent", ".", "SHA", "\n\n", "// Create the commit using the tree.", "date", ":=", "time", ".", "Now", "(", ")", "\n", "author", ":=", "&", "github", ".", "CommitAuthor", "{", "Date", ":", "&", "date", ",", "Name", ":", "authorName", ",", "Email", ":", "authorEmail", "}", "\n", "commit", ":=", "&", "github", ".", "Commit", "{", "Author", ":", "author", ",", "Message", ":", "commitMessage", ",", "Tree", ":", "tree", ",", "Parents", ":", "[", "]", "github", ".", "Commit", "{", "*", "parent", ".", "Commit", "}", "}", "\n", "newCommit", ",", "_", ",", "err", ":=", "client", ".", "Git", ".", "CreateCommit", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "commit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Attach the commit to the master branch.", "ref", ".", "Object", ".", "SHA", "=", "newCommit", ".", "SHA", "\n", "_", ",", "_", ",", "err", "=", "client", ".", "Git", ".", "UpdateRef", "(", "ctx", ",", "*", "sourceOwner", ",", "*", "sourceRepo", ",", "ref", ",", "false", ")", "\n", "return", "err", "\n", "}" ]
// createCommit creates the commit in the given reference using the given tree.
[ "createCommit", "creates", "the", "commit", "in", "the", "given", "reference", "using", "the", "given", "tree", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/example/commitpr/main.go#L126-L148
train
google/go-github
github/misc.go
Octocat
func (c *Client) Octocat(ctx context.Context, message string) (string, *Response, error) { u := "octocat" if message != "" { u = fmt.Sprintf("%s?s=%s", u, url.QueryEscape(message)) } req, err := c.NewRequest("GET", u, nil) if err != nil { return "", nil, err } buf := new(bytes.Buffer) resp, err := c.Do(ctx, req, buf) if err != nil { return "", resp, err } return buf.String(), resp, nil }
go
func (c *Client) Octocat(ctx context.Context, message string) (string, *Response, error) { u := "octocat" if message != "" { u = fmt.Sprintf("%s?s=%s", u, url.QueryEscape(message)) } req, err := c.NewRequest("GET", u, nil) if err != nil { return "", nil, err } buf := new(bytes.Buffer) resp, err := c.Do(ctx, req, buf) if err != nil { return "", resp, err } return buf.String(), resp, nil }
[ "func", "(", "c", "*", "Client", ")", "Octocat", "(", "ctx", "context", ".", "Context", ",", "message", "string", ")", "(", "string", ",", "*", "Response", ",", "error", ")", "{", "u", ":=", "\"", "\"", "\n", "if", "message", "!=", "\"", "\"", "{", "u", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "u", ",", "url", ".", "QueryEscape", "(", "message", ")", ")", "\n", "}", "\n\n", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "u", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Do", "(", "ctx", ",", "req", ",", "buf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "resp", ",", "err", "\n", "}", "\n\n", "return", "buf", ".", "String", "(", ")", ",", "resp", ",", "nil", "\n", "}" ]
// Octocat returns an ASCII art octocat with the specified message in a speech // bubble. If message is empty, a random zen phrase is used.
[ "Octocat", "returns", "an", "ASCII", "art", "octocat", "with", "the", "specified", "message", "in", "a", "speech", "bubble", ".", "If", "message", "is", "empty", "a", "random", "zen", "phrase", "is", "used", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/misc.go#L189-L207
train
google/go-github
github/github-accessors.go
GetRetryAfter
func (a *AbuseRateLimitError) GetRetryAfter() time.Duration { if a == nil || a.RetryAfter == nil { return 0 } return *a.RetryAfter }
go
func (a *AbuseRateLimitError) GetRetryAfter() time.Duration { if a == nil || a.RetryAfter == nil { return 0 } return *a.RetryAfter }
[ "func", "(", "a", "*", "AbuseRateLimitError", ")", "GetRetryAfter", "(", ")", "time", ".", "Duration", "{", "if", "a", "==", "nil", "||", "a", ".", "RetryAfter", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "a", ".", "RetryAfter", "\n", "}" ]
// GetRetryAfter returns the RetryAfter field if it's non-nil, zero value otherwise.
[ "GetRetryAfter", "returns", "the", "RetryAfter", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L16-L21
train
google/go-github
github/github-accessors.go
GetVerifiablePasswordAuthentication
func (a *APIMeta) GetVerifiablePasswordAuthentication() bool { if a == nil || a.VerifiablePasswordAuthentication == nil { return false } return *a.VerifiablePasswordAuthentication }
go
func (a *APIMeta) GetVerifiablePasswordAuthentication() bool { if a == nil || a.VerifiablePasswordAuthentication == nil { return false } return *a.VerifiablePasswordAuthentication }
[ "func", "(", "a", "*", "APIMeta", ")", "GetVerifiablePasswordAuthentication", "(", ")", "bool", "{", "if", "a", "==", "nil", "||", "a", ".", "VerifiablePasswordAuthentication", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "a", ".", "VerifiablePasswordAuthentication", "\n", "}" ]
// GetVerifiablePasswordAuthentication returns the VerifiablePasswordAuthentication field if it's non-nil, zero value otherwise.
[ "GetVerifiablePasswordAuthentication", "returns", "the", "VerifiablePasswordAuthentication", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L112-L117
train
google/go-github
github/github-accessors.go
GetExternalURL
func (a *App) GetExternalURL() string { if a == nil || a.ExternalURL == nil { return "" } return *a.ExternalURL }
go
func (a *App) GetExternalURL() string { if a == nil || a.ExternalURL == nil { return "" } return *a.ExternalURL }
[ "func", "(", "a", "*", "App", ")", "GetExternalURL", "(", ")", "string", "{", "if", "a", "==", "nil", "||", "a", ".", "ExternalURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "a", ".", "ExternalURL", "\n", "}" ]
// GetExternalURL returns the ExternalURL field if it's non-nil, zero value otherwise.
[ "GetExternalURL", "returns", "the", "ExternalURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L136-L141
train
google/go-github
github/github-accessors.go
GetHashedToken
func (a *Authorization) GetHashedToken() string { if a == nil || a.HashedToken == nil { return "" } return *a.HashedToken }
go
func (a *Authorization) GetHashedToken() string { if a == nil || a.HashedToken == nil { return "" } return *a.HashedToken }
[ "func", "(", "a", "*", "Authorization", ")", "GetHashedToken", "(", ")", "string", "{", "if", "a", "==", "nil", "||", "a", ".", "HashedToken", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "a", ".", "HashedToken", "\n", "}" ]
// GetHashedToken returns the HashedToken field if it's non-nil, zero value otherwise.
[ "GetHashedToken", "returns", "the", "HashedToken", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L240-L245
train
google/go-github
github/github-accessors.go
GetTokenLastEight
func (a *Authorization) GetTokenLastEight() string { if a == nil || a.TokenLastEight == nil { return "" } return *a.TokenLastEight }
go
func (a *Authorization) GetTokenLastEight() string { if a == nil || a.TokenLastEight == nil { return "" } return *a.TokenLastEight }
[ "func", "(", "a", "*", "Authorization", ")", "GetTokenLastEight", "(", ")", "string", "{", "if", "a", "==", "nil", "||", "a", ".", "TokenLastEight", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "a", ".", "TokenLastEight", "\n", "}" ]
// GetTokenLastEight returns the TokenLastEight field if it's non-nil, zero value otherwise.
[ "GetTokenLastEight", "returns", "the", "TokenLastEight", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L280-L285
train
google/go-github
github/github-accessors.go
GetClientSecret
func (a *AuthorizationRequest) GetClientSecret() string { if a == nil || a.ClientSecret == nil { return "" } return *a.ClientSecret }
go
func (a *AuthorizationRequest) GetClientSecret() string { if a == nil || a.ClientSecret == nil { return "" } return *a.ClientSecret }
[ "func", "(", "a", "*", "AuthorizationRequest", ")", "GetClientSecret", "(", ")", "string", "{", "if", "a", "==", "nil", "||", "a", ".", "ClientSecret", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "a", ".", "ClientSecret", "\n", "}" ]
// GetClientSecret returns the ClientSecret field if it's non-nil, zero value otherwise.
[ "GetClientSecret", "returns", "the", "ClientSecret", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L344-L349
train
google/go-github
github/github-accessors.go
GetSetting
func (a *AutoTriggerCheck) GetSetting() bool { if a == nil || a.Setting == nil { return false } return *a.Setting }
go
func (a *AutoTriggerCheck) GetSetting() bool { if a == nil || a.Setting == nil { return false } return *a.Setting }
[ "func", "(", "a", "*", "AutoTriggerCheck", ")", "GetSetting", "(", ")", "bool", "{", "if", "a", "==", "nil", "||", "a", ".", "Setting", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "a", ".", "Setting", "\n", "}" ]
// GetSetting returns the Setting field if it's non-nil, zero value otherwise.
[ "GetSetting", "returns", "the", "Setting", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L408-L413
train
google/go-github
github/github-accessors.go
GetProtected
func (b *Branch) GetProtected() bool { if b == nil || b.Protected == nil { return false } return *b.Protected }
go
func (b *Branch) GetProtected() bool { if b == nil || b.Protected == nil { return false } return *b.Protected }
[ "func", "(", "b", "*", "Branch", ")", "GetProtected", "(", ")", "bool", "{", "if", "b", "==", "nil", "||", "b", ".", "Protected", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "b", ".", "Protected", "\n", "}" ]
// GetProtected returns the Protected field if it's non-nil, zero value otherwise.
[ "GetProtected", "returns", "the", "Protected", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L480-L485
train
google/go-github
github/github-accessors.go
GetAnnotationLevel
func (c *CheckRunAnnotation) GetAnnotationLevel() string { if c == nil || c.AnnotationLevel == nil { return "" } return *c.AnnotationLevel }
go
func (c *CheckRunAnnotation) GetAnnotationLevel() string { if c == nil || c.AnnotationLevel == nil { return "" } return *c.AnnotationLevel }
[ "func", "(", "c", "*", "CheckRunAnnotation", ")", "GetAnnotationLevel", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "AnnotationLevel", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "AnnotationLevel", "\n", "}" ]
// GetAnnotationLevel returns the AnnotationLevel field if it's non-nil, zero value otherwise.
[ "GetAnnotationLevel", "returns", "the", "AnnotationLevel", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L608-L613
train
google/go-github
github/github-accessors.go
GetBlobHRef
func (c *CheckRunAnnotation) GetBlobHRef() string { if c == nil || c.BlobHRef == nil { return "" } return *c.BlobHRef }
go
func (c *CheckRunAnnotation) GetBlobHRef() string { if c == nil || c.BlobHRef == nil { return "" } return *c.BlobHRef }
[ "func", "(", "c", "*", "CheckRunAnnotation", ")", "GetBlobHRef", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "BlobHRef", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "BlobHRef", "\n", "}" ]
// GetBlobHRef returns the BlobHRef field if it's non-nil, zero value otherwise.
[ "GetBlobHRef", "returns", "the", "BlobHRef", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L616-L621
train
google/go-github
github/github-accessors.go
GetEndLine
func (c *CheckRunAnnotation) GetEndLine() int { if c == nil || c.EndLine == nil { return 0 } return *c.EndLine }
go
func (c *CheckRunAnnotation) GetEndLine() int { if c == nil || c.EndLine == nil { return 0 } return *c.EndLine }
[ "func", "(", "c", "*", "CheckRunAnnotation", ")", "GetEndLine", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "EndLine", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "EndLine", "\n", "}" ]
// GetEndLine returns the EndLine field if it's non-nil, zero value otherwise.
[ "GetEndLine", "returns", "the", "EndLine", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L624-L629
train
google/go-github
github/github-accessors.go
GetRawDetails
func (c *CheckRunAnnotation) GetRawDetails() string { if c == nil || c.RawDetails == nil { return "" } return *c.RawDetails }
go
func (c *CheckRunAnnotation) GetRawDetails() string { if c == nil || c.RawDetails == nil { return "" } return *c.RawDetails }
[ "func", "(", "c", "*", "CheckRunAnnotation", ")", "GetRawDetails", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "RawDetails", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "RawDetails", "\n", "}" ]
// GetRawDetails returns the RawDetails field if it's non-nil, zero value otherwise.
[ "GetRawDetails", "returns", "the", "RawDetails", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L648-L653
train
google/go-github
github/github-accessors.go
GetStartLine
func (c *CheckRunAnnotation) GetStartLine() int { if c == nil || c.StartLine == nil { return 0 } return *c.StartLine }
go
func (c *CheckRunAnnotation) GetStartLine() int { if c == nil || c.StartLine == nil { return 0 } return *c.StartLine }
[ "func", "(", "c", "*", "CheckRunAnnotation", ")", "GetStartLine", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "StartLine", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "StartLine", "\n", "}" ]
// GetStartLine returns the StartLine field if it's non-nil, zero value otherwise.
[ "GetStartLine", "returns", "the", "StartLine", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L656-L661
train
google/go-github
github/github-accessors.go
GetAlt
func (c *CheckRunImage) GetAlt() string { if c == nil || c.Alt == nil { return "" } return *c.Alt }
go
func (c *CheckRunImage) GetAlt() string { if c == nil || c.Alt == nil { return "" } return *c.Alt }
[ "func", "(", "c", "*", "CheckRunImage", ")", "GetAlt", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "Alt", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "Alt", "\n", "}" ]
// GetAlt returns the Alt field if it's non-nil, zero value otherwise.
[ "GetAlt", "returns", "the", "Alt", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L728-L733
train
google/go-github
github/github-accessors.go
GetCaption
func (c *CheckRunImage) GetCaption() string { if c == nil || c.Caption == nil { return "" } return *c.Caption }
go
func (c *CheckRunImage) GetCaption() string { if c == nil || c.Caption == nil { return "" } return *c.Caption }
[ "func", "(", "c", "*", "CheckRunImage", ")", "GetCaption", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "Caption", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "Caption", "\n", "}" ]
// GetCaption returns the Caption field if it's non-nil, zero value otherwise.
[ "GetCaption", "returns", "the", "Caption", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L736-L741
train
google/go-github
github/github-accessors.go
GetImageURL
func (c *CheckRunImage) GetImageURL() string { if c == nil || c.ImageURL == nil { return "" } return *c.ImageURL }
go
func (c *CheckRunImage) GetImageURL() string { if c == nil || c.ImageURL == nil { return "" } return *c.ImageURL }
[ "func", "(", "c", "*", "CheckRunImage", ")", "GetImageURL", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "ImageURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "ImageURL", "\n", "}" ]
// GetImageURL returns the ImageURL field if it's non-nil, zero value otherwise.
[ "GetImageURL", "returns", "the", "ImageURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L744-L749
train
google/go-github
github/github-accessors.go
GetAnnotationsCount
func (c *CheckRunOutput) GetAnnotationsCount() int { if c == nil || c.AnnotationsCount == nil { return 0 } return *c.AnnotationsCount }
go
func (c *CheckRunOutput) GetAnnotationsCount() int { if c == nil || c.AnnotationsCount == nil { return 0 } return *c.AnnotationsCount }
[ "func", "(", "c", "*", "CheckRunOutput", ")", "GetAnnotationsCount", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "AnnotationsCount", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "AnnotationsCount", "\n", "}" ]
// GetAnnotationsCount returns the AnnotationsCount field if it's non-nil, zero value otherwise.
[ "GetAnnotationsCount", "returns", "the", "AnnotationsCount", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L752-L757
train
google/go-github
github/github-accessors.go
GetAnnotationsURL
func (c *CheckRunOutput) GetAnnotationsURL() string { if c == nil || c.AnnotationsURL == nil { return "" } return *c.AnnotationsURL }
go
func (c *CheckRunOutput) GetAnnotationsURL() string { if c == nil || c.AnnotationsURL == nil { return "" } return *c.AnnotationsURL }
[ "func", "(", "c", "*", "CheckRunOutput", ")", "GetAnnotationsURL", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "AnnotationsURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "AnnotationsURL", "\n", "}" ]
// GetAnnotationsURL returns the AnnotationsURL field if it's non-nil, zero value otherwise.
[ "GetAnnotationsURL", "returns", "the", "AnnotationsURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L760-L765
train
google/go-github
github/github-accessors.go
GetAfterSHA
func (c *CheckSuite) GetAfterSHA() string { if c == nil || c.AfterSHA == nil { return "" } return *c.AfterSHA }
go
func (c *CheckSuite) GetAfterSHA() string { if c == nil || c.AfterSHA == nil { return "" } return *c.AfterSHA }
[ "func", "(", "c", "*", "CheckSuite", ")", "GetAfterSHA", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "AfterSHA", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "AfterSHA", "\n", "}" ]
// GetAfterSHA returns the AfterSHA field if it's non-nil, zero value otherwise.
[ "GetAfterSHA", "returns", "the", "AfterSHA", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L792-L797
train
google/go-github
github/github-accessors.go
GetBeforeSHA
func (c *CheckSuite) GetBeforeSHA() string { if c == nil || c.BeforeSHA == nil { return "" } return *c.BeforeSHA }
go
func (c *CheckSuite) GetBeforeSHA() string { if c == nil || c.BeforeSHA == nil { return "" } return *c.BeforeSHA }
[ "func", "(", "c", "*", "CheckSuite", ")", "GetBeforeSHA", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "BeforeSHA", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "BeforeSHA", "\n", "}" ]
// GetBeforeSHA returns the BeforeSHA field if it's non-nil, zero value otherwise.
[ "GetBeforeSHA", "returns", "the", "BeforeSHA", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L808-L813
train
google/go-github
github/github-accessors.go
GetTotalCommitComments
func (c *CommentStats) GetTotalCommitComments() int { if c == nil || c.TotalCommitComments == nil { return 0 } return *c.TotalCommitComments }
go
func (c *CommentStats) GetTotalCommitComments() int { if c == nil || c.TotalCommitComments == nil { return 0 } return *c.TotalCommitComments }
[ "func", "(", "c", "*", "CommentStats", ")", "GetTotalCommitComments", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "TotalCommitComments", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "TotalCommitComments", "\n", "}" ]
// GetTotalCommitComments returns the TotalCommitComments field if it's non-nil, zero value otherwise.
[ "GetTotalCommitComments", "returns", "the", "TotalCommitComments", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1088-L1093
train
google/go-github
github/github-accessors.go
GetTotalGistComments
func (c *CommentStats) GetTotalGistComments() int { if c == nil || c.TotalGistComments == nil { return 0 } return *c.TotalGistComments }
go
func (c *CommentStats) GetTotalGistComments() int { if c == nil || c.TotalGistComments == nil { return 0 } return *c.TotalGistComments }
[ "func", "(", "c", "*", "CommentStats", ")", "GetTotalGistComments", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "TotalGistComments", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "TotalGistComments", "\n", "}" ]
// GetTotalGistComments returns the TotalGistComments field if it's non-nil, zero value otherwise.
[ "GetTotalGistComments", "returns", "the", "TotalGistComments", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1096-L1101
train
google/go-github
github/github-accessors.go
GetTotalIssueComments
func (c *CommentStats) GetTotalIssueComments() int { if c == nil || c.TotalIssueComments == nil { return 0 } return *c.TotalIssueComments }
go
func (c *CommentStats) GetTotalIssueComments() int { if c == nil || c.TotalIssueComments == nil { return 0 } return *c.TotalIssueComments }
[ "func", "(", "c", "*", "CommentStats", ")", "GetTotalIssueComments", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "TotalIssueComments", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "TotalIssueComments", "\n", "}" ]
// GetTotalIssueComments returns the TotalIssueComments field if it's non-nil, zero value otherwise.
[ "GetTotalIssueComments", "returns", "the", "TotalIssueComments", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1104-L1109
train
google/go-github
github/github-accessors.go
GetTotalPullRequestComments
func (c *CommentStats) GetTotalPullRequestComments() int { if c == nil || c.TotalPullRequestComments == nil { return 0 } return *c.TotalPullRequestComments }
go
func (c *CommentStats) GetTotalPullRequestComments() int { if c == nil || c.TotalPullRequestComments == nil { return 0 } return *c.TotalPullRequestComments }
[ "func", "(", "c", "*", "CommentStats", ")", "GetTotalPullRequestComments", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "TotalPullRequestComments", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "TotalPullRequestComments", "\n", "}" ]
// GetTotalPullRequestComments returns the TotalPullRequestComments field if it's non-nil, zero value otherwise.
[ "GetTotalPullRequestComments", "returns", "the", "TotalPullRequestComments", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1112-L1117
train
google/go-github
github/github-accessors.go
GetCommentCount
func (c *Commit) GetCommentCount() int { if c == nil || c.CommentCount == nil { return 0 } return *c.CommentCount }
go
func (c *Commit) GetCommentCount() int { if c == nil || c.CommentCount == nil { return 0 } return *c.CommentCount }
[ "func", "(", "c", "*", "Commit", ")", "GetCommentCount", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "CommentCount", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "CommentCount", "\n", "}" ]
// GetCommentCount returns the CommentCount field if it's non-nil, zero value otherwise.
[ "GetCommentCount", "returns", "the", "CommentCount", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1128-L1133
train
google/go-github
github/github-accessors.go
GetDate
func (c *CommitAuthor) GetDate() time.Time { if c == nil || c.Date == nil { return time.Time{} } return *c.Date }
go
func (c *CommitAuthor) GetDate() time.Time { if c == nil || c.Date == nil { return time.Time{} } return *c.Date }
[ "func", "(", "c", "*", "CommitAuthor", ")", "GetDate", "(", ")", "time", ".", "Time", "{", "if", "c", "==", "nil", "||", "c", ".", "Date", "==", "nil", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "return", "*", "c", ".", "Date", "\n", "}" ]
// GetDate returns the Date field if it's non-nil, zero value otherwise.
[ "GetDate", "returns", "the", "Date", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1208-L1213
train
google/go-github
github/github-accessors.go
GetBlobURL
func (c *CommitFile) GetBlobURL() string { if c == nil || c.BlobURL == nil { return "" } return *c.BlobURL }
go
func (c *CommitFile) GetBlobURL() string { if c == nil || c.BlobURL == nil { return "" } return *c.BlobURL }
[ "func", "(", "c", "*", "CommitFile", ")", "GetBlobURL", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "BlobURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "BlobURL", "\n", "}" ]
// GetBlobURL returns the BlobURL field if it's non-nil, zero value otherwise.
[ "GetBlobURL", "returns", "the", "BlobURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1288-L1293
train
google/go-github
github/github-accessors.go
GetChanges
func (c *CommitFile) GetChanges() int { if c == nil || c.Changes == nil { return 0 } return *c.Changes }
go
func (c *CommitFile) GetChanges() int { if c == nil || c.Changes == nil { return 0 } return *c.Changes }
[ "func", "(", "c", "*", "CommitFile", ")", "GetChanges", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "Changes", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "Changes", "\n", "}" ]
// GetChanges returns the Changes field if it's non-nil, zero value otherwise.
[ "GetChanges", "returns", "the", "Changes", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1296-L1301
train
google/go-github
github/github-accessors.go
GetPatch
func (c *CommitFile) GetPatch() string { if c == nil || c.Patch == nil { return "" } return *c.Patch }
go
func (c *CommitFile) GetPatch() string { if c == nil || c.Patch == nil { return "" } return *c.Patch }
[ "func", "(", "c", "*", "CommitFile", ")", "GetPatch", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "Patch", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "Patch", "\n", "}" ]
// GetPatch returns the Patch field if it's non-nil, zero value otherwise.
[ "GetPatch", "returns", "the", "Patch", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1328-L1333
train
google/go-github
github/github-accessors.go
GetPreviousFilename
func (c *CommitFile) GetPreviousFilename() string { if c == nil || c.PreviousFilename == nil { return "" } return *c.PreviousFilename }
go
func (c *CommitFile) GetPreviousFilename() string { if c == nil || c.PreviousFilename == nil { return "" } return *c.PreviousFilename }
[ "func", "(", "c", "*", "CommitFile", ")", "GetPreviousFilename", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "PreviousFilename", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "PreviousFilename", "\n", "}" ]
// GetPreviousFilename returns the PreviousFilename field if it's non-nil, zero value otherwise.
[ "GetPreviousFilename", "returns", "the", "PreviousFilename", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1336-L1341
train
google/go-github
github/github-accessors.go
GetAheadBy
func (c *CommitsComparison) GetAheadBy() int { if c == nil || c.AheadBy == nil { return 0 } return *c.AheadBy }
go
func (c *CommitsComparison) GetAheadBy() int { if c == nil || c.AheadBy == nil { return 0 } return *c.AheadBy }
[ "func", "(", "c", "*", "CommitsComparison", ")", "GetAheadBy", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "AheadBy", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "AheadBy", "\n", "}" ]
// GetAheadBy returns the AheadBy field if it's non-nil, zero value otherwise.
[ "GetAheadBy", "returns", "the", "AheadBy", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1440-L1445
train
google/go-github
github/github-accessors.go
GetBehindBy
func (c *CommitsComparison) GetBehindBy() int { if c == nil || c.BehindBy == nil { return 0 } return *c.BehindBy }
go
func (c *CommitsComparison) GetBehindBy() int { if c == nil || c.BehindBy == nil { return 0 } return *c.BehindBy }
[ "func", "(", "c", "*", "CommitsComparison", ")", "GetBehindBy", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "BehindBy", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "BehindBy", "\n", "}" ]
// GetBehindBy returns the BehindBy field if it's non-nil, zero value otherwise.
[ "GetBehindBy", "returns", "the", "BehindBy", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1456-L1461
train
google/go-github
github/github-accessors.go
GetPermalinkURL
func (c *CommitsComparison) GetPermalinkURL() string { if c == nil || c.PermalinkURL == nil { return "" } return *c.PermalinkURL }
go
func (c *CommitsComparison) GetPermalinkURL() string { if c == nil || c.PermalinkURL == nil { return "" } return *c.PermalinkURL }
[ "func", "(", "c", "*", "CommitsComparison", ")", "GetPermalinkURL", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "PermalinkURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "PermalinkURL", "\n", "}" ]
// GetPermalinkURL returns the PermalinkURL field if it's non-nil, zero value otherwise.
[ "GetPermalinkURL", "returns", "the", "PermalinkURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1496-L1501
train
google/go-github
github/github-accessors.go
GetTotalCommits
func (c *CommitsComparison) GetTotalCommits() int { if c == nil || c.TotalCommits == nil { return 0 } return *c.TotalCommits }
go
func (c *CommitsComparison) GetTotalCommits() int { if c == nil || c.TotalCommits == nil { return 0 } return *c.TotalCommits }
[ "func", "(", "c", "*", "CommitsComparison", ")", "GetTotalCommits", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "TotalCommits", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "TotalCommits", "\n", "}" ]
// GetTotalCommits returns the TotalCommits field if it's non-nil, zero value otherwise.
[ "GetTotalCommits", "returns", "the", "TotalCommits", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1512-L1517
train
google/go-github
github/github-accessors.go
GetHealthPercentage
func (c *CommunityHealthMetrics) GetHealthPercentage() int { if c == nil || c.HealthPercentage == nil { return 0 } return *c.HealthPercentage }
go
func (c *CommunityHealthMetrics) GetHealthPercentage() int { if c == nil || c.HealthPercentage == nil { return 0 } return *c.HealthPercentage }
[ "func", "(", "c", "*", "CommunityHealthMetrics", ")", "GetHealthPercentage", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "HealthPercentage", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "HealthPercentage", "\n", "}" ]
// GetHealthPercentage returns the HealthPercentage field if it's non-nil, zero value otherwise.
[ "GetHealthPercentage", "returns", "the", "HealthPercentage", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1624-L1629
train
google/go-github
github/github-accessors.go
GetContributions
func (c *Contributor) GetContributions() int { if c == nil || c.Contributions == nil { return 0 } return *c.Contributions }
go
func (c *Contributor) GetContributions() int { if c == nil || c.Contributions == nil { return 0 } return *c.Contributions }
[ "func", "(", "c", "*", "Contributor", ")", "GetContributions", "(", ")", "int", "{", "if", "c", "==", "nil", "||", "c", ".", "Contributions", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "Contributions", "\n", "}" ]
// GetContributions returns the Contributions field if it's non-nil, zero value otherwise.
[ "GetContributions", "returns", "the", "Contributions", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1648-L1653
train
google/go-github
github/github-accessors.go
GetInviteeID
func (c *CreateOrgInvitationOptions) GetInviteeID() int64 { if c == nil || c.InviteeID == nil { return 0 } return *c.InviteeID }
go
func (c *CreateOrgInvitationOptions) GetInviteeID() int64 { if c == nil || c.InviteeID == nil { return 0 } return *c.InviteeID }
[ "func", "(", "c", "*", "CreateOrgInvitationOptions", ")", "GetInviteeID", "(", ")", "int64", "{", "if", "c", "==", "nil", "||", "c", ".", "InviteeID", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "c", ".", "InviteeID", "\n", "}" ]
// GetInviteeID returns the InviteeID field if it's non-nil, zero value otherwise.
[ "GetInviteeID", "returns", "the", "InviteeID", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L1936-L1941
train
google/go-github
github/github-accessors.go
GetAutoMerge
func (d *DeploymentRequest) GetAutoMerge() bool { if d == nil || d.AutoMerge == nil { return false } return *d.AutoMerge }
go
func (d *DeploymentRequest) GetAutoMerge() bool { if d == nil || d.AutoMerge == nil { return false } return *d.AutoMerge }
[ "func", "(", "d", "*", "DeploymentRequest", ")", "GetAutoMerge", "(", ")", "bool", "{", "if", "d", "==", "nil", "||", "d", ".", "AutoMerge", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "d", ".", "AutoMerge", "\n", "}" ]
// GetAutoMerge returns the AutoMerge field if it's non-nil, zero value otherwise.
[ "GetAutoMerge", "returns", "the", "AutoMerge", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2152-L2157
train
google/go-github
github/github-accessors.go
GetProductionEnvironment
func (d *DeploymentRequest) GetProductionEnvironment() bool { if d == nil || d.ProductionEnvironment == nil { return false } return *d.ProductionEnvironment }
go
func (d *DeploymentRequest) GetProductionEnvironment() bool { if d == nil || d.ProductionEnvironment == nil { return false } return *d.ProductionEnvironment }
[ "func", "(", "d", "*", "DeploymentRequest", ")", "GetProductionEnvironment", "(", ")", "bool", "{", "if", "d", "==", "nil", "||", "d", ".", "ProductionEnvironment", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "d", ".", "ProductionEnvironment", "\n", "}" ]
// GetProductionEnvironment returns the ProductionEnvironment field if it's non-nil, zero value otherwise.
[ "GetProductionEnvironment", "returns", "the", "ProductionEnvironment", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2184-L2189
train
google/go-github
github/github-accessors.go
GetRequiredContexts
func (d *DeploymentRequest) GetRequiredContexts() []string { if d == nil || d.RequiredContexts == nil { return nil } return *d.RequiredContexts }
go
func (d *DeploymentRequest) GetRequiredContexts() []string { if d == nil || d.RequiredContexts == nil { return nil } return *d.RequiredContexts }
[ "func", "(", "d", "*", "DeploymentRequest", ")", "GetRequiredContexts", "(", ")", "[", "]", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "RequiredContexts", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "*", "d", ".", "RequiredContexts", "\n", "}" ]
// GetRequiredContexts returns the RequiredContexts field if it's non-nil, zero value otherwise.
[ "GetRequiredContexts", "returns", "the", "RequiredContexts", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2200-L2205
train
google/go-github
github/github-accessors.go
GetTransientEnvironment
func (d *DeploymentRequest) GetTransientEnvironment() bool { if d == nil || d.TransientEnvironment == nil { return false } return *d.TransientEnvironment }
go
func (d *DeploymentRequest) GetTransientEnvironment() bool { if d == nil || d.TransientEnvironment == nil { return false } return *d.TransientEnvironment }
[ "func", "(", "d", "*", "DeploymentRequest", ")", "GetTransientEnvironment", "(", ")", "bool", "{", "if", "d", "==", "nil", "||", "d", ".", "TransientEnvironment", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "d", ".", "TransientEnvironment", "\n", "}" ]
// GetTransientEnvironment returns the TransientEnvironment field if it's non-nil, zero value otherwise.
[ "GetTransientEnvironment", "returns", "the", "TransientEnvironment", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2216-L2221
train
google/go-github
github/github-accessors.go
GetDeploymentURL
func (d *DeploymentStatus) GetDeploymentURL() string { if d == nil || d.DeploymentURL == nil { return "" } return *d.DeploymentURL }
go
func (d *DeploymentStatus) GetDeploymentURL() string { if d == nil || d.DeploymentURL == nil { return "" } return *d.DeploymentURL }
[ "func", "(", "d", "*", "DeploymentStatus", ")", "GetDeploymentURL", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "DeploymentURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "DeploymentURL", "\n", "}" ]
// GetDeploymentURL returns the DeploymentURL field if it's non-nil, zero value otherwise.
[ "GetDeploymentURL", "returns", "the", "DeploymentURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2240-L2245
train
google/go-github
github/github-accessors.go
GetAutoInactive
func (d *DeploymentStatusRequest) GetAutoInactive() bool { if d == nil || d.AutoInactive == nil { return false } return *d.AutoInactive }
go
func (d *DeploymentStatusRequest) GetAutoInactive() bool { if d == nil || d.AutoInactive == nil { return false } return *d.AutoInactive }
[ "func", "(", "d", "*", "DeploymentStatusRequest", ")", "GetAutoInactive", "(", ")", "bool", "{", "if", "d", "==", "nil", "||", "d", ".", "AutoInactive", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "d", ".", "AutoInactive", "\n", "}" ]
// GetAutoInactive returns the AutoInactive field if it's non-nil, zero value otherwise.
[ "GetAutoInactive", "returns", "the", "AutoInactive", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2344-L2349
train
google/go-github
github/github-accessors.go
GetEnvironmentURL
func (d *DeploymentStatusRequest) GetEnvironmentURL() string { if d == nil || d.EnvironmentURL == nil { return "" } return *d.EnvironmentURL }
go
func (d *DeploymentStatusRequest) GetEnvironmentURL() string { if d == nil || d.EnvironmentURL == nil { return "" } return *d.EnvironmentURL }
[ "func", "(", "d", "*", "DeploymentStatusRequest", ")", "GetEnvironmentURL", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "EnvironmentURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "EnvironmentURL", "\n", "}" ]
// GetEnvironmentURL returns the EnvironmentURL field if it's non-nil, zero value otherwise.
[ "GetEnvironmentURL", "returns", "the", "EnvironmentURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2368-L2373
train
google/go-github
github/github-accessors.go
GetLogURL
func (d *DeploymentStatusRequest) GetLogURL() string { if d == nil || d.LogURL == nil { return "" } return *d.LogURL }
go
func (d *DeploymentStatusRequest) GetLogURL() string { if d == nil || d.LogURL == nil { return "" } return *d.LogURL }
[ "func", "(", "d", "*", "DeploymentStatusRequest", ")", "GetLogURL", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "LogURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "LogURL", "\n", "}" ]
// GetLogURL returns the LogURL field if it's non-nil, zero value otherwise.
[ "GetLogURL", "returns", "the", "LogURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2376-L2381
train
google/go-github
github/github-accessors.go
GetDiscussionURL
func (d *DiscussionComment) GetDiscussionURL() string { if d == nil || d.DiscussionURL == nil { return "" } return *d.DiscussionURL }
go
func (d *DiscussionComment) GetDiscussionURL() string { if d == nil || d.DiscussionURL == nil { return "" } return *d.DiscussionURL }
[ "func", "(", "d", "*", "DiscussionComment", ")", "GetDiscussionURL", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "DiscussionURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "DiscussionURL", "\n", "}" ]
// GetDiscussionURL returns the DiscussionURL field if it's non-nil, zero value otherwise.
[ "GetDiscussionURL", "returns", "the", "DiscussionURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2432-L2437
train
google/go-github
github/github-accessors.go
GetTeams
func (d *DismissalRestrictionsRequest) GetTeams() []string { if d == nil || d.Teams == nil { return nil } return *d.Teams }
go
func (d *DismissalRestrictionsRequest) GetTeams() []string { if d == nil || d.Teams == nil { return nil } return *d.Teams }
[ "func", "(", "d", "*", "DismissalRestrictionsRequest", ")", "GetTeams", "(", ")", "[", "]", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "Teams", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "*", "d", ".", "Teams", "\n", "}" ]
// GetTeams returns the Teams field if it's non-nil, zero value otherwise.
[ "GetTeams", "returns", "the", "Teams", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2496-L2501
train
google/go-github
github/github-accessors.go
GetUsers
func (d *DismissalRestrictionsRequest) GetUsers() []string { if d == nil || d.Users == nil { return nil } return *d.Users }
go
func (d *DismissalRestrictionsRequest) GetUsers() []string { if d == nil || d.Users == nil { return nil } return *d.Users }
[ "func", "(", "d", "*", "DismissalRestrictionsRequest", ")", "GetUsers", "(", ")", "[", "]", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "Users", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "*", "d", ".", "Users", "\n", "}" ]
// GetUsers returns the Users field if it's non-nil, zero value otherwise.
[ "GetUsers", "returns", "the", "Users", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2504-L2509
train
google/go-github
github/github-accessors.go
GetDismissalCommitID
func (d *DismissedReview) GetDismissalCommitID() string { if d == nil || d.DismissalCommitID == nil { return "" } return *d.DismissalCommitID }
go
func (d *DismissedReview) GetDismissalCommitID() string { if d == nil || d.DismissalCommitID == nil { return "" } return *d.DismissalCommitID }
[ "func", "(", "d", "*", "DismissedReview", ")", "GetDismissalCommitID", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "DismissalCommitID", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "DismissalCommitID", "\n", "}" ]
// GetDismissalCommitID returns the DismissalCommitID field if it's non-nil, zero value otherwise.
[ "GetDismissalCommitID", "returns", "the", "DismissalCommitID", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2512-L2517
train
google/go-github
github/github-accessors.go
GetDismissalMessage
func (d *DismissedReview) GetDismissalMessage() string { if d == nil || d.DismissalMessage == nil { return "" } return *d.DismissalMessage }
go
func (d *DismissedReview) GetDismissalMessage() string { if d == nil || d.DismissalMessage == nil { return "" } return *d.DismissalMessage }
[ "func", "(", "d", "*", "DismissedReview", ")", "GetDismissalMessage", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "DismissalMessage", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "DismissalMessage", "\n", "}" ]
// GetDismissalMessage returns the DismissalMessage field if it's non-nil, zero value otherwise.
[ "GetDismissalMessage", "returns", "the", "DismissalMessage", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2520-L2525
train
google/go-github
github/github-accessors.go
GetReviewID
func (d *DismissedReview) GetReviewID() int64 { if d == nil || d.ReviewID == nil { return 0 } return *d.ReviewID }
go
func (d *DismissedReview) GetReviewID() int64 { if d == nil || d.ReviewID == nil { return 0 } return *d.ReviewID }
[ "func", "(", "d", "*", "DismissedReview", ")", "GetReviewID", "(", ")", "int64", "{", "if", "d", "==", "nil", "||", "d", ".", "ReviewID", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "d", ".", "ReviewID", "\n", "}" ]
// GetReviewID returns the ReviewID field if it's non-nil, zero value otherwise.
[ "GetReviewID", "returns", "the", "ReviewID", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2528-L2533
train
google/go-github
github/github-accessors.go
GetRawPayload
func (e *Event) GetRawPayload() json.RawMessage { if e == nil || e.RawPayload == nil { return json.RawMessage{} } return *e.RawPayload }
go
func (e *Event) GetRawPayload() json.RawMessage { if e == nil || e.RawPayload == nil { return json.RawMessage{} } return *e.RawPayload }
[ "func", "(", "e", "*", "Event", ")", "GetRawPayload", "(", ")", "json", ".", "RawMessage", "{", "if", "e", "==", "nil", "||", "e", ".", "RawPayload", "==", "nil", "{", "return", "json", ".", "RawMessage", "{", "}", "\n", "}", "\n", "return", "*", "e", ".", "RawPayload", "\n", "}" ]
// GetRawPayload returns the RawPayload field if it's non-nil, zero value otherwise.
[ "GetRawPayload", "returns", "the", "RawPayload", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2608-L2613
train
google/go-github
github/github-accessors.go
GetCurrentUserActorURL
func (f *Feeds) GetCurrentUserActorURL() string { if f == nil || f.CurrentUserActorURL == nil { return "" } return *f.CurrentUserActorURL }
go
func (f *Feeds) GetCurrentUserActorURL() string { if f == nil || f.CurrentUserActorURL == nil { return "" } return *f.CurrentUserActorURL }
[ "func", "(", "f", "*", "Feeds", ")", "GetCurrentUserActorURL", "(", ")", "string", "{", "if", "f", "==", "nil", "||", "f", ".", "CurrentUserActorURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "f", ".", "CurrentUserActorURL", "\n", "}" ]
// GetCurrentUserActorURL returns the CurrentUserActorURL field if it's non-nil, zero value otherwise.
[ "GetCurrentUserActorURL", "returns", "the", "CurrentUserActorURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2648-L2653
train
google/go-github
github/github-accessors.go
GetCurrentUserOrganizationURL
func (f *Feeds) GetCurrentUserOrganizationURL() string { if f == nil || f.CurrentUserOrganizationURL == nil { return "" } return *f.CurrentUserOrganizationURL }
go
func (f *Feeds) GetCurrentUserOrganizationURL() string { if f == nil || f.CurrentUserOrganizationURL == nil { return "" } return *f.CurrentUserOrganizationURL }
[ "func", "(", "f", "*", "Feeds", ")", "GetCurrentUserOrganizationURL", "(", ")", "string", "{", "if", "f", "==", "nil", "||", "f", ".", "CurrentUserOrganizationURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "f", ".", "CurrentUserOrganizationURL", "\n", "}" ]
// GetCurrentUserOrganizationURL returns the CurrentUserOrganizationURL field if it's non-nil, zero value otherwise.
[ "GetCurrentUserOrganizationURL", "returns", "the", "CurrentUserOrganizationURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2656-L2661
train
google/go-github
github/github-accessors.go
GetCurrentUserPublicURL
func (f *Feeds) GetCurrentUserPublicURL() string { if f == nil || f.CurrentUserPublicURL == nil { return "" } return *f.CurrentUserPublicURL }
go
func (f *Feeds) GetCurrentUserPublicURL() string { if f == nil || f.CurrentUserPublicURL == nil { return "" } return *f.CurrentUserPublicURL }
[ "func", "(", "f", "*", "Feeds", ")", "GetCurrentUserPublicURL", "(", ")", "string", "{", "if", "f", "==", "nil", "||", "f", ".", "CurrentUserPublicURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "f", ".", "CurrentUserPublicURL", "\n", "}" ]
// GetCurrentUserPublicURL returns the CurrentUserPublicURL field if it's non-nil, zero value otherwise.
[ "GetCurrentUserPublicURL", "returns", "the", "CurrentUserPublicURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2664-L2669
train
google/go-github
github/github-accessors.go
GetCurrentUserURL
func (f *Feeds) GetCurrentUserURL() string { if f == nil || f.CurrentUserURL == nil { return "" } return *f.CurrentUserURL }
go
func (f *Feeds) GetCurrentUserURL() string { if f == nil || f.CurrentUserURL == nil { return "" } return *f.CurrentUserURL }
[ "func", "(", "f", "*", "Feeds", ")", "GetCurrentUserURL", "(", ")", "string", "{", "if", "f", "==", "nil", "||", "f", ".", "CurrentUserURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "f", ".", "CurrentUserURL", "\n", "}" ]
// GetCurrentUserURL returns the CurrentUserURL field if it's non-nil, zero value otherwise.
[ "GetCurrentUserURL", "returns", "the", "CurrentUserURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2672-L2677
train
google/go-github
github/github-accessors.go
GetTimelineURL
func (f *Feeds) GetTimelineURL() string { if f == nil || f.TimelineURL == nil { return "" } return *f.TimelineURL }
go
func (f *Feeds) GetTimelineURL() string { if f == nil || f.TimelineURL == nil { return "" } return *f.TimelineURL }
[ "func", "(", "f", "*", "Feeds", ")", "GetTimelineURL", "(", ")", "string", "{", "if", "f", "==", "nil", "||", "f", ".", "TimelineURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "f", ".", "TimelineURL", "\n", "}" ]
// GetTimelineURL returns the TimelineURL field if it's non-nil, zero value otherwise.
[ "GetTimelineURL", "returns", "the", "TimelineURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2680-L2685
train
google/go-github
github/github-accessors.go
GetUserURL
func (f *Feeds) GetUserURL() string { if f == nil || f.UserURL == nil { return "" } return *f.UserURL }
go
func (f *Feeds) GetUserURL() string { if f == nil || f.UserURL == nil { return "" } return *f.UserURL }
[ "func", "(", "f", "*", "Feeds", ")", "GetUserURL", "(", ")", "string", "{", "if", "f", "==", "nil", "||", "f", ".", "UserURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "f", ".", "UserURL", "\n", "}" ]
// GetUserURL returns the UserURL field if it's non-nil, zero value otherwise.
[ "GetUserURL", "returns", "the", "UserURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2688-L2693
train
google/go-github
github/github-accessors.go
GetGitPullURL
func (g *Gist) GetGitPullURL() string { if g == nil || g.GitPullURL == nil { return "" } return *g.GitPullURL }
go
func (g *Gist) GetGitPullURL() string { if g == nil || g.GitPullURL == nil { return "" } return *g.GitPullURL }
[ "func", "(", "g", "*", "Gist", ")", "GetGitPullURL", "(", ")", "string", "{", "if", "g", "==", "nil", "||", "g", ".", "GitPullURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "g", ".", "GitPullURL", "\n", "}" ]
// GetGitPullURL returns the GitPullURL field if it's non-nil, zero value otherwise.
[ "GetGitPullURL", "returns", "the", "GitPullURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2752-L2757
train
google/go-github
github/github-accessors.go
GetGitPushURL
func (g *Gist) GetGitPushURL() string { if g == nil || g.GitPushURL == nil { return "" } return *g.GitPushURL }
go
func (g *Gist) GetGitPushURL() string { if g == nil || g.GitPushURL == nil { return "" } return *g.GitPushURL }
[ "func", "(", "g", "*", "Gist", ")", "GetGitPushURL", "(", ")", "string", "{", "if", "g", "==", "nil", "||", "g", ".", "GitPushURL", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "g", ".", "GitPushURL", "\n", "}" ]
// GetGitPushURL returns the GitPushURL field if it's non-nil, zero value otherwise.
[ "GetGitPushURL", "returns", "the", "GitPushURL", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2760-L2765
train
google/go-github
github/github-accessors.go
GetCommittedAt
func (g *GistCommit) GetCommittedAt() Timestamp { if g == nil || g.CommittedAt == nil { return Timestamp{} } return *g.CommittedAt }
go
func (g *GistCommit) GetCommittedAt() Timestamp { if g == nil || g.CommittedAt == nil { return Timestamp{} } return *g.CommittedAt }
[ "func", "(", "g", "*", "GistCommit", ")", "GetCommittedAt", "(", ")", "Timestamp", "{", "if", "g", "==", "nil", "||", "g", ".", "CommittedAt", "==", "nil", "{", "return", "Timestamp", "{", "}", "\n", "}", "\n", "return", "*", "g", ".", "CommittedAt", "\n", "}" ]
// GetCommittedAt returns the CommittedAt field if it's non-nil, zero value otherwise.
[ "GetCommittedAt", "returns", "the", "CommittedAt", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2864-L2869
train
google/go-github
github/github-accessors.go
GetVersion
func (g *GistCommit) GetVersion() string { if g == nil || g.Version == nil { return "" } return *g.Version }
go
func (g *GistCommit) GetVersion() string { if g == nil || g.Version == nil { return "" } return *g.Version }
[ "func", "(", "g", "*", "GistCommit", ")", "GetVersion", "(", ")", "string", "{", "if", "g", "==", "nil", "||", "g", ".", "Version", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "g", ".", "Version", "\n", "}" ]
// GetVersion returns the Version field if it's non-nil, zero value otherwise.
[ "GetVersion", "returns", "the", "Version", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L2896-L2901
train
google/go-github
github/github-accessors.go
GetTotalGists
func (g *GistStats) GetTotalGists() int { if g == nil || g.TotalGists == nil { return 0 } return *g.TotalGists }
go
func (g *GistStats) GetTotalGists() int { if g == nil || g.TotalGists == nil { return 0 } return *g.TotalGists }
[ "func", "(", "g", "*", "GistStats", ")", "GetTotalGists", "(", ")", "int", "{", "if", "g", "==", "nil", "||", "g", ".", "TotalGists", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "g", ".", "TotalGists", "\n", "}" ]
// GetTotalGists returns the TotalGists field if it's non-nil, zero value otherwise.
[ "GetTotalGists", "returns", "the", "TotalGists", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3016-L3021
train
google/go-github
github/github-accessors.go
GetSource
func (g *Gitignore) GetSource() string { if g == nil || g.Source == nil { return "" } return *g.Source }
go
func (g *Gitignore) GetSource() string { if g == nil || g.Source == nil { return "" } return *g.Source }
[ "func", "(", "g", "*", "Gitignore", ")", "GetSource", "(", ")", "string", "{", "if", "g", "==", "nil", "||", "g", ".", "Source", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "g", ".", "Source", "\n", "}" ]
// GetSource returns the Source field if it's non-nil, zero value otherwise.
[ "GetSource", "returns", "the", "Source", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3048-L3053
train
google/go-github
github/github-accessors.go
GetCanCertify
func (g *GPGKey) GetCanCertify() bool { if g == nil || g.CanCertify == nil { return false } return *g.CanCertify }
go
func (g *GPGKey) GetCanCertify() bool { if g == nil || g.CanCertify == nil { return false } return *g.CanCertify }
[ "func", "(", "g", "*", "GPGKey", ")", "GetCanCertify", "(", ")", "bool", "{", "if", "g", "==", "nil", "||", "g", ".", "CanCertify", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "g", ".", "CanCertify", "\n", "}" ]
// GetCanCertify returns the CanCertify field if it's non-nil, zero value otherwise.
[ "GetCanCertify", "returns", "the", "CanCertify", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3120-L3125
train
google/go-github
github/github-accessors.go
GetCanEncryptComms
func (g *GPGKey) GetCanEncryptComms() bool { if g == nil || g.CanEncryptComms == nil { return false } return *g.CanEncryptComms }
go
func (g *GPGKey) GetCanEncryptComms() bool { if g == nil || g.CanEncryptComms == nil { return false } return *g.CanEncryptComms }
[ "func", "(", "g", "*", "GPGKey", ")", "GetCanEncryptComms", "(", ")", "bool", "{", "if", "g", "==", "nil", "||", "g", ".", "CanEncryptComms", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "g", ".", "CanEncryptComms", "\n", "}" ]
// GetCanEncryptComms returns the CanEncryptComms field if it's non-nil, zero value otherwise.
[ "GetCanEncryptComms", "returns", "the", "CanEncryptComms", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3128-L3133
train
google/go-github
github/github-accessors.go
GetCanEncryptStorage
func (g *GPGKey) GetCanEncryptStorage() bool { if g == nil || g.CanEncryptStorage == nil { return false } return *g.CanEncryptStorage }
go
func (g *GPGKey) GetCanEncryptStorage() bool { if g == nil || g.CanEncryptStorage == nil { return false } return *g.CanEncryptStorage }
[ "func", "(", "g", "*", "GPGKey", ")", "GetCanEncryptStorage", "(", ")", "bool", "{", "if", "g", "==", "nil", "||", "g", ".", "CanEncryptStorage", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "g", ".", "CanEncryptStorage", "\n", "}" ]
// GetCanEncryptStorage returns the CanEncryptStorage field if it's non-nil, zero value otherwise.
[ "GetCanEncryptStorage", "returns", "the", "CanEncryptStorage", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3136-L3141
train
google/go-github
github/github-accessors.go
GetCanSign
func (g *GPGKey) GetCanSign() bool { if g == nil || g.CanSign == nil { return false } return *g.CanSign }
go
func (g *GPGKey) GetCanSign() bool { if g == nil || g.CanSign == nil { return false } return *g.CanSign }
[ "func", "(", "g", "*", "GPGKey", ")", "GetCanSign", "(", ")", "bool", "{", "if", "g", "==", "nil", "||", "g", ".", "CanSign", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "*", "g", ".", "CanSign", "\n", "}" ]
// GetCanSign returns the CanSign field if it's non-nil, zero value otherwise.
[ "GetCanSign", "returns", "the", "CanSign", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3144-L3149
train
google/go-github
github/github-accessors.go
GetKeyID
func (g *GPGKey) GetKeyID() string { if g == nil || g.KeyID == nil { return "" } return *g.KeyID }
go
func (g *GPGKey) GetKeyID() string { if g == nil || g.KeyID == nil { return "" } return *g.KeyID }
[ "func", "(", "g", "*", "GPGKey", ")", "GetKeyID", "(", ")", "string", "{", "if", "g", "==", "nil", "||", "g", ".", "KeyID", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "g", ".", "KeyID", "\n", "}" ]
// GetKeyID returns the KeyID field if it's non-nil, zero value otherwise.
[ "GetKeyID", "returns", "the", "KeyID", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3176-L3181
train
google/go-github
github/github-accessors.go
GetPrimaryKeyID
func (g *GPGKey) GetPrimaryKeyID() int64 { if g == nil || g.PrimaryKeyID == nil { return 0 } return *g.PrimaryKeyID }
go
func (g *GPGKey) GetPrimaryKeyID() int64 { if g == nil || g.PrimaryKeyID == nil { return 0 } return *g.PrimaryKeyID }
[ "func", "(", "g", "*", "GPGKey", ")", "GetPrimaryKeyID", "(", ")", "int64", "{", "if", "g", "==", "nil", "||", "g", ".", "PrimaryKeyID", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "g", ".", "PrimaryKeyID", "\n", "}" ]
// GetPrimaryKeyID returns the PrimaryKeyID field if it's non-nil, zero value otherwise.
[ "GetPrimaryKeyID", "returns", "the", "PrimaryKeyID", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "." ]
1fef44b9b427e6c43f92b2f20918e496c275393f
https://github.com/google/go-github/blob/1fef44b9b427e6c43f92b2f20918e496c275393f/github/github-accessors.go#L3184-L3189
train