id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
143,800 | beamly/go-gocd | gocd/resource_pipeline_material_tfs.go | unmarshallMaterialAttributesTfs | func unmarshallMaterialAttributesTfs(mtfs *MaterialAttributesTfs, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mtfs.Name = value.(string)
case "url":
mtfs.URL = value.(string)
case "project_path":
mtfs.ProjectPath = value.(stri... | go | func unmarshallMaterialAttributesTfs(mtfs *MaterialAttributesTfs, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mtfs.Name = value.(string)
case "url":
mtfs.URL = value.(string)
case "project_path":
mtfs.ProjectPath = value.(stri... | [
"func",
"unmarshallMaterialAttributesTfs",
"(",
"mtfs",
"*",
"MaterialAttributesTfs",
",",
"i",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"i",
"{",
"if",
"value",
"==",
"nil",
"{",
"continue",
... | // UnmarshallInterface from a JSON string to a MaterialAttributesTfs struct | [
"UnmarshallInterface",
"from",
"a",
"JSON",
"string",
"to",
"a",
"MaterialAttributesTfs",
"struct"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_pipeline_material_tfs.go#L44-L78 |
143,801 | beamly/go-gocd | gocd/resource_jobs.go | Validate | func (j *Job) Validate() (err error) {
if j.Name == "" {
err = errors.New("`gocd.Jobs.Name` is empty")
}
return
} | go | func (j *Job) Validate() (err error) {
if j.Name == "" {
err = errors.New("`gocd.Jobs.Name` is empty")
}
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Validate",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"j",
".",
"Name",
"==",
"\"",
"\"",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Validate a job structure has non-nil values on correct attributes | [
"Validate",
"a",
"job",
"structure",
"has",
"non",
"-",
"nil",
"values",
"on",
"correct",
"attributes"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_jobs.go#L23-L28 |
143,802 | beamly/go-gocd | gocd/resource_jobs.go | UnmarshalJSON | func (tf *TimeoutField) UnmarshalJSON(b []byte) (err error) {
// The target `valint` value has -1 so that we have a value which does not match
// the expected value (probably) and we can ensure the methods is working and not just putting
// the default in (which is `0`).
valInt := -1
value := string(b)
if value... | go | func (tf *TimeoutField) UnmarshalJSON(b []byte) (err error) {
// The target `valint` value has -1 so that we have a value which does not match
// the expected value (probably) and we can ensure the methods is working and not just putting
// the default in (which is `0`).
valInt := -1
value := string(b)
if value... | [
"func",
"(",
"tf",
"*",
"TimeoutField",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"// The target `valint` value has -1 so that we have a value which does not match",
"// the expected value (probably) and we can ensure the methods is w... | // UnmarshalJSON and handle "never", "null", and integers. | [
"UnmarshalJSON",
"and",
"handle",
"never",
"null",
"and",
"integers",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_jobs.go#L31-L48 |
143,803 | beamly/go-gocd | gocd/resource_jobs.go | MarshalJSON | func (tf TimeoutField) MarshalJSON() (b []byte, err error) {
return []byte(strconv.Itoa(int(tf))), nil
} | go | func (tf TimeoutField) MarshalJSON() (b []byte, err error) {
return []byte(strconv.Itoa(int(tf))), nil
} | [
"func",
"(",
"tf",
"TimeoutField",
")",
"MarshalJSON",
"(",
")",
"(",
"b",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"tf",
")",
")",
")",
",",
"nil",
"\n",
"}"
] | // MarshalJSON of TimeoutField into a string | [
"MarshalJSON",
"of",
"TimeoutField",
"into",
"a",
"string"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_jobs.go#L51-L53 |
143,804 | beamly/go-gocd | gocd/genericactions.go | genericHeadAction | func (c *Client) genericHeadAction(ctx context.Context, path string, apiversion string) (bool, *APIResponse, error) {
_, resp, err := c.httpAction(ctx, &APIClientRequest{
Method: "HEAD",
Path: path,
APIVersion: apiversion,
ResponseType: responseTypeJSON,
})
exists := resp.HTTP.StatusCode >= ... | go | func (c *Client) genericHeadAction(ctx context.Context, path string, apiversion string) (bool, *APIResponse, error) {
_, resp, err := c.httpAction(ctx, &APIClientRequest{
Method: "HEAD",
Path: path,
APIVersion: apiversion,
ResponseType: responseTypeJSON,
})
exists := resp.HTTP.StatusCode >= ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"genericHeadAction",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"apiversion",
"string",
")",
"(",
"bool",
",",
"*",
"APIResponse",
",",
"error",
")",
"{",
"_",
",",
"resp",
",",
"err",
":=... | // Handles any call to HEAD by returning whether or not we got a 2xx code. | [
"Handles",
"any",
"call",
"to",
"HEAD",
"by",
"returning",
"whether",
"or",
"not",
"we",
"got",
"a",
"2xx",
"code",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/genericactions.go#L25-L37 |
143,805 | beamly/go-gocd | gocd/genericactions.go | deleteAction | func (c *Client) deleteAction(ctx context.Context, path string, apiversion string) (string, *APIResponse, error) {
a := StringResponse{}
_, resp, err := c.httpAction(ctx, &APIClientRequest{
Method: "DELETE",
Path: path,
APIVersion: apiversion,
ResponseType: responseTypeJSON,
ResponseBody: &a... | go | func (c *Client) deleteAction(ctx context.Context, path string, apiversion string) (string, *APIResponse, error) {
a := StringResponse{}
_, resp, err := c.httpAction(ctx, &APIClientRequest{
Method: "DELETE",
Path: path,
APIVersion: apiversion,
ResponseType: responseTypeJSON,
ResponseBody: &a... | [
"func",
"(",
"c",
"*",
"Client",
")",
"deleteAction",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"apiversion",
"string",
")",
"(",
"string",
",",
"*",
"APIResponse",
",",
"error",
")",
"{",
"a",
":=",
"StringResponse",
"{",
"}",... | // Returns a message from the DELETE action on the provided HTTP resource. | [
"Returns",
"a",
"message",
"from",
"the",
"DELETE",
"action",
"on",
"the",
"provided",
"HTTP",
"resource",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/genericactions.go#L60-L71 |
143,806 | beamly/go-gocd | gocd/resource_pipeline_material_plugin.go | unmarshallMaterialAttributesPlugin | func unmarshallMaterialAttributesPlugin(mapp *MaterialAttributesPlugin, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "ref":
mapp.Ref = value.(string)
case "destination":
mapp.Destination = value.(string)
case "filter":
mapp.Filter = unma... | go | func unmarshallMaterialAttributesPlugin(mapp *MaterialAttributesPlugin, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "ref":
mapp.Ref = value.(string)
case "destination":
mapp.Destination = value.(string)
case "filter":
mapp.Filter = unma... | [
"func",
"unmarshallMaterialAttributesPlugin",
"(",
"mapp",
"*",
"MaterialAttributesPlugin",
",",
"i",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"i",
"{",
"if",
"value",
"==",
"nil",
"{",
"continu... | // UnmarshallInterface from a JSON string to a MaterialAttributesPlugin struct | [
"UnmarshallInterface",
"from",
"a",
"JSON",
"string",
"to",
"a",
"MaterialAttributesPlugin",
"struct"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_pipeline_material_plugin.go#L34-L50 |
143,807 | beamly/go-gocd | gocd/jobs.go | MarshalJSON | func (v *EnvironmentVariable) MarshalJSON() ([]byte, error) {
if v.EncryptedValue != "" {
return json.Marshal(&encryptedEnvironmentVariable{
Name: v.Name,
Secure: v.Secure,
EncryptedValue: v.EncryptedValue,
})
}
return json.Marshal(&unencryptedEnvironmentVariable{
Name: v.Name,
... | go | func (v *EnvironmentVariable) MarshalJSON() ([]byte, error) {
if v.EncryptedValue != "" {
return json.Marshal(&encryptedEnvironmentVariable{
Name: v.Name,
Secure: v.Secure,
EncryptedValue: v.EncryptedValue,
})
}
return json.Marshal(&unencryptedEnvironmentVariable{
Name: v.Name,
... | [
"func",
"(",
"v",
"*",
"EnvironmentVariable",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"v",
".",
"EncryptedValue",
"!=",
"\"",
"\"",
"{",
"return",
"json",
".",
"Marshal",
"(",
"&",
"encryptedEnvironmentVariable"... | // MarshalJSON is a custom JSON Marhsaller for EnvironmentVariables to handle empty values | [
"MarshalJSON",
"is",
"a",
"custom",
"JSON",
"Marhsaller",
"for",
"EnvironmentVariables",
"to",
"handle",
"empty",
"values"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/jobs.go#L88-L102 |
143,808 | beamly/go-gocd | gocd/jobs.go | ListScheduled | func (js *JobsService) ListScheduled(ctx context.Context) (jobs []*JobSchedule, resp *APIResponse, err error) {
j := &JobScheduleResponse{}
_, resp, err = js.client.getAction(ctx, &APIClientRequest{
Path: "jobs/scheduled.xml",
ResponseBody: j,
ResponseType: responseTypeXML,
})
jobs = j.Jobs
return
} | go | func (js *JobsService) ListScheduled(ctx context.Context) (jobs []*JobSchedule, resp *APIResponse, err error) {
j := &JobScheduleResponse{}
_, resp, err = js.client.getAction(ctx, &APIClientRequest{
Path: "jobs/scheduled.xml",
ResponseBody: j,
ResponseType: responseTypeXML,
})
jobs = j.Jobs
return
} | [
"func",
"(",
"js",
"*",
"JobsService",
")",
"ListScheduled",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"jobs",
"[",
"]",
"*",
"JobSchedule",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"j",
":=",
"&",
"JobScheduleResponse",
"... | // ListScheduled lists Pipeline groups | [
"ListScheduled",
"lists",
"Pipeline",
"groups"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/jobs.go#L189-L199 |
143,809 | beamly/go-gocd | gocd/resource_pipeline_material_hg.go | unmarshallMaterialAttributesHg | func unmarshallMaterialAttributesHg(mhg *MaterialAttributesHg, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mhg.Name = value.(string)
case "url":
mhg.URL = value.(string)
case "destination":
mhg.Destination = value.(string)
cas... | go | func unmarshallMaterialAttributesHg(mhg *MaterialAttributesHg, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mhg.Name = value.(string)
case "url":
mhg.URL = value.(string)
case "destination":
mhg.Destination = value.(string)
cas... | [
"func",
"unmarshallMaterialAttributesHg",
"(",
"mhg",
"*",
"MaterialAttributesHg",
",",
"i",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"i",
"{",
"if",
"value",
"==",
"nil",
"{",
"continue",
"\n... | // UnmarshallInterface from a JSON string to a MaterialAttributesHg struct | [
"UnmarshallInterface",
"from",
"a",
"JSON",
"string",
"to",
"a",
"MaterialAttributesHg",
"struct"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_pipeline_material_hg.go#L44-L64 |
143,810 | beamly/go-gocd | cli/pipeline.go | getPipelineStatusAction | func getPipelineStatusAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var name string
if name = c.String("name"); name == "" {
return nil, nil, NewFlagError("name")
}
return client.Pipelines.GetStatus(context.Background(), name, -1)
} | go | func getPipelineStatusAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var name string
if name = c.String("name"); name == "" {
return nil, nil, NewFlagError("name")
}
return client.Pipelines.GetStatus(context.Background(), name, -1)
} | [
"func",
"getPipelineStatusAction",
"(",
"client",
"*",
"gocd",
".",
"Client",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"(",
"r",
"interface",
"{",
"}",
",",
"resp",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"{",
"var",
"name",
"str... | // GetPipelineStatusAction handles the business logic between the command objects and the go-gocd library. | [
"GetPipelineStatusAction",
"handles",
"the",
"business",
"logic",
"between",
"the",
"command",
"objects",
"and",
"the",
"go",
"-",
"gocd",
"library",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L26-L32 |
143,811 | beamly/go-gocd | cli/pipeline.go | getPipelineAction | func getPipelineAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var name string
if name = c.String("name"); name == "" {
return nil, nil, NewFlagError("name")
}
return client.PipelineConfigs.Get(context.Background(), c.String("name"))
} | go | func getPipelineAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var name string
if name = c.String("name"); name == "" {
return nil, nil, NewFlagError("name")
}
return client.PipelineConfigs.Get(context.Background(), c.String("name"))
} | [
"func",
"getPipelineAction",
"(",
"client",
"*",
"gocd",
".",
"Client",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"(",
"r",
"interface",
"{",
"}",
",",
"resp",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"{",
"var",
"name",
"string",
... | // GetPipelineAction handles the business logic between the command objects and the go-gocd library. | [
"GetPipelineAction",
"handles",
"the",
"business",
"logic",
"between",
"the",
"command",
"objects",
"and",
"the",
"go",
"-",
"gocd",
"library",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L35-L41 |
143,812 | beamly/go-gocd | cli/pipeline.go | getPipelineStatusCommand | func getPipelineStatusCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineStatusCommandName,
Usage: GetPipelineStatusCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(getPipelineStatusAction),
}
} | go | func getPipelineStatusCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineStatusCommandName,
Usage: GetPipelineStatusCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(getPipelineStatusAction),
}
} | [
"func",
"getPipelineStatusCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"GetPipelineStatusCommandName",
",",
"Usage",
":",
"GetPipelineStatusCommandUsage",
",",
"Category",
":",
"\"",
"\"",
",",
"F... | // GetPipelineStatusCommand handles the interaction between the cli flags and the action handler for
// get-pipeline | [
"GetPipelineStatusCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L86-L96 |
143,813 | beamly/go-gocd | cli/pipeline.go | pausePipelineCommand | func pausePipelineCommand() *cli.Command {
return &cli.Command{
Name: PausePipelineCommandName,
Usage: PausePipelineCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(pausePipelineAction),
}
} | go | func pausePipelineCommand() *cli.Command {
return &cli.Command{
Name: PausePipelineCommandName,
Usage: PausePipelineCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(pausePipelineAction),
}
} | [
"func",
"pausePipelineCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"PausePipelineCommandName",
",",
"Usage",
":",
"PausePipelineCommandUsage",
",",
"Category",
":",
"\"",
"\"",
",",
"Flags",
":"... | // PausePipelineCommand handles the interaction between the cli flags and the action handler for
// get-pipeline | [
"PausePipelineCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L100-L110 |
143,814 | beamly/go-gocd | cli/pipeline.go | unpausePipelineCommand | func unpausePipelineCommand() *cli.Command {
return &cli.Command{
Name: UnpausePipelineCommandName,
Usage: UnpausePipelineCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(unpausePipelineAction),
}
} | go | func unpausePipelineCommand() *cli.Command {
return &cli.Command{
Name: UnpausePipelineCommandName,
Usage: UnpausePipelineCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(unpausePipelineAction),
}
} | [
"func",
"unpausePipelineCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"UnpausePipelineCommandName",
",",
"Usage",
":",
"UnpausePipelineCommandUsage",
",",
"Category",
":",
"\"",
"\"",
",",
"Flags",... | // UnpausePipelineCommand handles the interaction between the cli flags and the action handler for
// get-pipeline | [
"UnpausePipelineCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L114-L124 |
143,815 | beamly/go-gocd | cli/pipeline.go | releasePipelineLockCommand | func releasePipelineLockCommand() *cli.Command {
return &cli.Command{
Name: ReleasePipelineLockCommandName,
Usage: ReleasePipelineLockCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(releasePipelineLockAction),
}
} | go | func releasePipelineLockCommand() *cli.Command {
return &cli.Command{
Name: ReleasePipelineLockCommandName,
Usage: ReleasePipelineLockCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(releasePipelineLockAction),
}
} | [
"func",
"releasePipelineLockCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"ReleasePipelineLockCommandName",
",",
"Usage",
":",
"ReleasePipelineLockCommandUsage",
",",
"Category",
":",
"\"",
"\"",
","... | // ReleasePipelineLockCommand handles the interaction between the cli flags and the action handler for
// get-pipeline | [
"ReleasePipelineLockCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L128-L138 |
143,816 | beamly/go-gocd | cli/pipeline.go | getPipelineCommand | func getPipelineCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineCommandName,
Usage: GetPipelineCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(getPipelineAction),
}
} | go | func getPipelineCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineCommandName,
Usage: GetPipelineCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(getPipelineAction),
}
} | [
"func",
"getPipelineCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"GetPipelineCommandName",
",",
"Usage",
":",
"GetPipelineCommandUsage",
",",
"Category",
":",
"\"",
"\"",
",",
"Flags",
":",
"[... | // GetPipelineCommand handles the interaction between the cli flags and the action handler for
// get-pipeline | [
"GetPipelineCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L142-L152 |
143,817 | beamly/go-gocd | cli/pipeline.go | getPipelineHistoryCommand | func getPipelineHistoryCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineHistoryCommandName,
Usage: GetPipelineHistoryCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(getPipelineHistoryAction),
}
} | go | func getPipelineHistoryCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineHistoryCommandName,
Usage: GetPipelineHistoryCommandUsage,
Category: "Pipelines",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
Action: ActionWrapper(getPipelineHistoryAction),
}
} | [
"func",
"getPipelineHistoryCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"GetPipelineHistoryCommandName",
",",
"Usage",
":",
"GetPipelineHistoryCommandUsage",
",",
"Category",
":",
"\"",
"\"",
",",
... | // GetPipelineHistoryCommand handles the interaction between the cli flags and the action handler for
// get-pipeline-history-action | [
"GetPipelineHistoryCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline",
"-",
"history",
"-",
"action"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipeline.go#L156-L166 |
143,818 | beamly/go-gocd | cli/configure.go | generateConfig | func generateConfig() (cfg *gocd.Configuration, err error) {
cfg = &gocd.Configuration{}
qs := []*survey.Question{
{
Name: "server",
Prompt: &survey.Input{Message: "GoCD Server (should contain '/go/' suffix)"},
Validate: survey.Required,
},
{
Name: "username",
Prompt: &survey.Input{Messag... | go | func generateConfig() (cfg *gocd.Configuration, err error) {
cfg = &gocd.Configuration{}
qs := []*survey.Question{
{
Name: "server",
Prompt: &survey.Input{Message: "GoCD Server (should contain '/go/' suffix)"},
Validate: survey.Required,
},
{
Name: "username",
Prompt: &survey.Input{Messag... | [
"func",
"generateConfig",
"(",
")",
"(",
"cfg",
"*",
"gocd",
".",
"Configuration",
",",
"err",
"error",
")",
"{",
"cfg",
"=",
"&",
"gocd",
".",
"Configuration",
"{",
"}",
"\n",
"qs",
":=",
"[",
"]",
"*",
"survey",
".",
"Question",
"{",
"{",
"Name",... | // Build a default template | [
"Build",
"a",
"default",
"template"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/configure.go#L73-L97 |
143,819 | beamly/go-gocd | cli/configure.go | configureCommand | func configureCommand() *cli.Command {
return &cli.Command{
Name: configureCommandName,
Usage: configureCommandUsage,
Action: func(c *cli.Context) (err error) {
return configActionRunner{
context: c,
generateConfig: generateConfig,
loadConfigs: gocd.LoadConfigFromFile,
writeConfigs: wri... | go | func configureCommand() *cli.Command {
return &cli.Command{
Name: configureCommandName,
Usage: configureCommandUsage,
Action: func(c *cli.Context) (err error) {
return configActionRunner{
context: c,
generateConfig: generateConfig,
loadConfigs: gocd.LoadConfigFromFile,
writeConfigs: wri... | [
"func",
"configureCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"configureCommandName",
",",
"Usage",
":",
"configureCommandUsage",
",",
"Action",
":",
"func",
"(",
"c",
"*",
"cli",
".",
"Con... | // ConfigureCommand handles the interaction between the cli flags and the action handler for configure | [
"ConfigureCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"configure"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/configure.go#L100-L117 |
143,820 | beamly/go-gocd | gocd/resource_properties.go | NewPropertiesFrame | func NewPropertiesFrame(frame [][]string) *Properties {
p := Properties{}
for i, line := range frame {
if i == 0 {
p.Header = line
} else {
p.AddRow(line)
}
}
return &p
} | go | func NewPropertiesFrame(frame [][]string) *Properties {
p := Properties{}
for i, line := range frame {
if i == 0 {
p.Header = line
} else {
p.AddRow(line)
}
}
return &p
} | [
"func",
"NewPropertiesFrame",
"(",
"frame",
"[",
"]",
"[",
"]",
"string",
")",
"*",
"Properties",
"{",
"p",
":=",
"Properties",
"{",
"}",
"\n",
"for",
"i",
",",
"line",
":=",
"range",
"frame",
"{",
"if",
"i",
"==",
"0",
"{",
"p",
".",
"Header",
"... | // NewPropertiesFrame generate a new data frame for properties on a gocd job. | [
"NewPropertiesFrame",
"generate",
"a",
"new",
"data",
"frame",
"for",
"properties",
"on",
"a",
"gocd",
"job",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L29-L39 |
143,821 | beamly/go-gocd | gocd/resource_properties.go | Get | func (pr Properties) Get(row int, column string) string {
var columnIdx int
for i, key := range pr.Header {
if key == column {
columnIdx = i
}
}
return pr.DataFrame[row][columnIdx]
} | go | func (pr Properties) Get(row int, column string) string {
var columnIdx int
for i, key := range pr.Header {
if key == column {
columnIdx = i
}
}
return pr.DataFrame[row][columnIdx]
} | [
"func",
"(",
"pr",
"Properties",
")",
"Get",
"(",
"row",
"int",
",",
"column",
"string",
")",
"string",
"{",
"var",
"columnIdx",
"int",
"\n",
"for",
"i",
",",
"key",
":=",
"range",
"pr",
".",
"Header",
"{",
"if",
"key",
"==",
"column",
"{",
"column... | // Get a single parameter value for a given run of the job. | [
"Get",
"a",
"single",
"parameter",
"value",
"for",
"a",
"given",
"run",
"of",
"the",
"job",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L42-L50 |
143,822 | beamly/go-gocd | gocd/resource_properties.go | AddRow | func (pr *Properties) AddRow(r []string) {
pr.SetRow(len(pr.DataFrame), r)
} | go | func (pr *Properties) AddRow(r []string) {
pr.SetRow(len(pr.DataFrame), r)
} | [
"func",
"(",
"pr",
"*",
"Properties",
")",
"AddRow",
"(",
"r",
"[",
"]",
"string",
")",
"{",
"pr",
".",
"SetRow",
"(",
"len",
"(",
"pr",
".",
"DataFrame",
")",
",",
"r",
")",
"\n",
"}"
] | // AddRow to an existing properties data frame | [
"AddRow",
"to",
"an",
"existing",
"properties",
"data",
"frame"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L53-L55 |
143,823 | beamly/go-gocd | gocd/resource_properties.go | SetRow | func (pr *Properties) SetRow(row int, r []string) {
for row >= len(pr.DataFrame) {
pr.DataFrame = append(pr.DataFrame, []string{})
}
pr.DataFrame[row] = r
} | go | func (pr *Properties) SetRow(row int, r []string) {
for row >= len(pr.DataFrame) {
pr.DataFrame = append(pr.DataFrame, []string{})
}
pr.DataFrame[row] = r
} | [
"func",
"(",
"pr",
"*",
"Properties",
")",
"SetRow",
"(",
"row",
"int",
",",
"r",
"[",
"]",
"string",
")",
"{",
"for",
"row",
">=",
"len",
"(",
"pr",
".",
"DataFrame",
")",
"{",
"pr",
".",
"DataFrame",
"=",
"append",
"(",
"pr",
".",
"DataFrame",
... | // SetRow in an existing data frame | [
"SetRow",
"in",
"an",
"existing",
"data",
"frame"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L58-L63 |
143,824 | beamly/go-gocd | gocd/resource_properties.go | MarshallCSV | func (pr Properties) MarshallCSV() (string, error) {
buf := new(bytes.Buffer)
w := csv.NewWriter(buf)
if err := w.Write(pr.Header); err != nil {
return buf.String(), err
}
for _, line := range pr.DataFrame {
if err := w.Write(line); err != nil {
return buf.String(), err
}
}
w.Flush()
return buf.String... | go | func (pr Properties) MarshallCSV() (string, error) {
buf := new(bytes.Buffer)
w := csv.NewWriter(buf)
if err := w.Write(pr.Header); err != nil {
return buf.String(), err
}
for _, line := range pr.DataFrame {
if err := w.Write(line); err != nil {
return buf.String(), err
}
}
w.Flush()
return buf.String... | [
"func",
"(",
"pr",
"Properties",
")",
"MarshallCSV",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"w",
":=",
"csv",
".",
"NewWriter",
"(",
"buf",
")",
"\n",
"if",
"err",
":=",
"w",
... | // MarshallCSV returns the data frame as a string | [
"MarshallCSV",
"returns",
"the",
"data",
"frame",
"as",
"a",
"string"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L66-L80 |
143,825 | beamly/go-gocd | gocd/resource_properties.go | UnmarshallCSV | func (pr *Properties) UnmarshallCSV(raw string) error {
r := csv.NewReader(strings.NewReader(raw))
r.TrimLeadingSpace = true
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
return err
}
if pr.UnmarshallWithHeader && len(pr.Header) == 0 && len(pr.DataFrame) == 0 {
pr.Head... | go | func (pr *Properties) UnmarshallCSV(raw string) error {
r := csv.NewReader(strings.NewReader(raw))
r.TrimLeadingSpace = true
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
return err
}
if pr.UnmarshallWithHeader && len(pr.Header) == 0 && len(pr.DataFrame) == 0 {
pr.Head... | [
"func",
"(",
"pr",
"*",
"Properties",
")",
"UnmarshallCSV",
"(",
"raw",
"string",
")",
"error",
"{",
"r",
":=",
"csv",
".",
"NewReader",
"(",
"strings",
".",
"NewReader",
"(",
"raw",
")",
")",
"\n",
"r",
".",
"TrimLeadingSpace",
"=",
"true",
"\n",
"f... | // UnmarshallCSV returns the data frame from a string | [
"UnmarshallCSV",
"returns",
"the",
"data",
"frame",
"from",
"a",
"string"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L83-L101 |
143,826 | beamly/go-gocd | gocd/resource_properties.go | Write | func (pr *Properties) Write(p []byte) (n int, err error) {
numBytes := len(p)
raw, err := ioutil.ReadAll(bytes.NewReader(p))
if err != nil {
return 0, err
}
pr.UnmarshallCSV(string(raw))
return numBytes, nil
} | go | func (pr *Properties) Write(p []byte) (n int, err error) {
numBytes := len(p)
raw, err := ioutil.ReadAll(bytes.NewReader(p))
if err != nil {
return 0, err
}
pr.UnmarshallCSV(string(raw))
return numBytes, nil
} | [
"func",
"(",
"pr",
"*",
"Properties",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"numBytes",
":=",
"len",
"(",
"p",
")",
"\n",
"raw",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"bytes",
... | // Write the data frame to a byte stream as a csv. | [
"Write",
"the",
"data",
"frame",
"to",
"a",
"byte",
"stream",
"as",
"a",
"csv",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L104-L113 |
143,827 | beamly/go-gocd | gocd/resource_properties.go | MarshalJSON | func (pr *Properties) MarshalJSON() ([]byte, error) {
structures := make([]map[string]string, len(pr.DataFrame))
for i, row := range pr.DataFrame {
rowStructure := map[string]string{}
for j, key := range pr.Header {
value := row[j]
rowStructure[key] = value
}
if pr.IsDatum {
return json.Marshal(row... | go | func (pr *Properties) MarshalJSON() ([]byte, error) {
structures := make([]map[string]string, len(pr.DataFrame))
for i, row := range pr.DataFrame {
rowStructure := map[string]string{}
for j, key := range pr.Header {
value := row[j]
rowStructure[key] = value
}
if pr.IsDatum {
return json.Marshal(row... | [
"func",
"(",
"pr",
"*",
"Properties",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"structures",
":=",
"make",
"(",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"pr",
".",
"DataFrame",
")",
")",
... | // MarshalJSON converts the properties structure to a list of maps | [
"MarshalJSON",
"converts",
"the",
"properties",
"structure",
"to",
"a",
"list",
"of",
"maps"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_properties.go#L116-L135 |
143,828 | beamly/go-gocd | gocd/links.go | Add | func (al *HALLinks) Add(link *HALLink) {
al.links = append(al.links, link)
} | go | func (al *HALLinks) Add(link *HALLink) {
al.links = append(al.links, link)
} | [
"func",
"(",
"al",
"*",
"HALLinks",
")",
"Add",
"(",
"link",
"*",
"HALLink",
")",
"{",
"al",
".",
"links",
"=",
"append",
"(",
"al",
".",
"links",
",",
"link",
")",
"\n",
"}"
] | // Add a link | [
"Add",
"a",
"link"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/links.go#L20-L22 |
143,829 | beamly/go-gocd | gocd/links.go | Get | func (al HALLinks) Get(name string) (link *HALLink) {
link, _ = al.GetOk(name)
return
} | go | func (al HALLinks) Get(name string) (link *HALLink) {
link, _ = al.GetOk(name)
return
} | [
"func",
"(",
"al",
"HALLinks",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"link",
"*",
"HALLink",
")",
"{",
"link",
",",
"_",
"=",
"al",
".",
"GetOk",
"(",
"name",
")",
"\n",
"return",
"\n",
"}"
] | // Get a HALLink by name | [
"Get",
"a",
"HALLink",
"by",
"name"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/links.go#L25-L28 |
143,830 | beamly/go-gocd | gocd/links.go | GetOk | func (al HALLinks) GetOk(name string) (link *HALLink, ok bool) {
for _, link = range al.links {
if strings.ToLower(link.Name) == strings.ToLower(name) {
ok = true
return
}
}
link = nil
return
} | go | func (al HALLinks) GetOk(name string) (link *HALLink, ok bool) {
for _, link = range al.links {
if strings.ToLower(link.Name) == strings.ToLower(name) {
ok = true
return
}
}
link = nil
return
} | [
"func",
"(",
"al",
"HALLinks",
")",
"GetOk",
"(",
"name",
"string",
")",
"(",
"link",
"*",
"HALLink",
",",
"ok",
"bool",
")",
"{",
"for",
"_",
",",
"link",
"=",
"range",
"al",
".",
"links",
"{",
"if",
"strings",
".",
"ToLower",
"(",
"link",
".",
... | // GetOk a HALLink by name, and if it doesn't exist, return false | [
"GetOk",
"a",
"HALLink",
"by",
"name",
"and",
"if",
"it",
"doesn",
"t",
"exist",
"return",
"false"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/links.go#L31-L40 |
143,831 | beamly/go-gocd | gocd/links.go | Keys | func (al HALLinks) Keys() (keys []string) {
keys = make([]string, len(al.links))
for i, l := range al.links {
keys[i] = l.Name
}
return
} | go | func (al HALLinks) Keys() (keys []string) {
keys = make([]string, len(al.links))
for i, l := range al.links {
keys[i] = l.Name
}
return
} | [
"func",
"(",
"al",
"HALLinks",
")",
"Keys",
"(",
")",
"(",
"keys",
"[",
"]",
"string",
")",
"{",
"keys",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"al",
".",
"links",
")",
")",
"\n",
"for",
"i",
",",
"l",
":=",
"range",
"al",
"... | // Keys returns a string list of link names | [
"Keys",
"returns",
"a",
"string",
"list",
"of",
"link",
"names"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/links.go#L43-L49 |
143,832 | beamly/go-gocd | gocd/links.go | MarshallJSON | func (al HALLinks) MarshallJSON() ([]byte, error) {
ls := map[string]*linkHref{}
for _, link := range al.links {
ls[link.Name] = &linkHref{H: link.URL.String()}
}
return json.Marshal(ls)
} | go | func (al HALLinks) MarshallJSON() ([]byte, error) {
ls := map[string]*linkHref{}
for _, link := range al.links {
ls[link.Name] = &linkHref{H: link.URL.String()}
}
return json.Marshal(ls)
} | [
"func",
"(",
"al",
"HALLinks",
")",
"MarshallJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"ls",
":=",
"map",
"[",
"string",
"]",
"*",
"linkHref",
"{",
"}",
"\n",
"for",
"_",
",",
"link",
":=",
"range",
"al",
".",
"links",
"{"... | // MarshallJSON allows the encoding of links into JSON | [
"MarshallJSON",
"allows",
"the",
"encoding",
"of",
"links",
"into",
"JSON"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/links.go#L52-L58 |
143,833 | beamly/go-gocd | gocd/links.go | UnmarshalJSON | func (al *HALLinks) UnmarshalJSON(j []byte) (err error) {
var d linkField
if err = json.Unmarshal(j, &d); err != nil {
return
}
var u *url.URL
for linkName, value := range d {
if u, err = url.Parse(value["href"]); err != nil {
break
}
al.Add(&HALLink{
Name: linkName,
URL: u,
})
}
return
} | go | func (al *HALLinks) UnmarshalJSON(j []byte) (err error) {
var d linkField
if err = json.Unmarshal(j, &d); err != nil {
return
}
var u *url.URL
for linkName, value := range d {
if u, err = url.Parse(value["href"]); err != nil {
break
}
al.Add(&HALLink{
Name: linkName,
URL: u,
})
}
return
} | [
"func",
"(",
"al",
"*",
"HALLinks",
")",
"UnmarshalJSON",
"(",
"j",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"var",
"d",
"linkField",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"j",
",",
"&",
"d",
")",
";",
"err",
"!=",... | // UnmarshalJSON allows the decoding of links from JSON | [
"UnmarshalJSON",
"allows",
"the",
"decoding",
"of",
"links",
"from",
"JSON"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/links.go#L61-L78 |
143,834 | beamly/go-gocd | gocd/properties.go | ListHistorical | func (ps *PropertiesService) ListHistorical(ctx context.Context, pr *PropertyRequest) (*Properties, *APIResponse, error) {
u := ps.client.BaseURL()
q := u.Query()
q.Set("pipelineName", pr.Pipeline)
q.Set("stageName", pr.Stage)
q.Set("jobName", pr.Job)
if pr.Limit >= 0 && pr.LimitPipeline != "" {
q.Set("limitCou... | go | func (ps *PropertiesService) ListHistorical(ctx context.Context, pr *PropertyRequest) (*Properties, *APIResponse, error) {
u := ps.client.BaseURL()
q := u.Query()
q.Set("pipelineName", pr.Pipeline)
q.Set("stageName", pr.Stage)
q.Set("jobName", pr.Job)
if pr.Limit >= 0 && pr.LimitPipeline != "" {
q.Set("limitCou... | [
"func",
"(",
"ps",
"*",
"PropertiesService",
")",
"ListHistorical",
"(",
"ctx",
"context",
".",
"Context",
",",
"pr",
"*",
"PropertyRequest",
")",
"(",
"*",
"Properties",
",",
"*",
"APIResponse",
",",
"error",
")",
"{",
"u",
":=",
"ps",
".",
"client",
... | // ListHistorical properties for a given pipeline, stage, job. | [
"ListHistorical",
"properties",
"for",
"a",
"given",
"pipeline",
"stage",
"job",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/properties.go#L79-L91 |
143,835 | beamly/go-gocd | gocd/config_repo.go | List | func (crs *ConfigRepoService) List(ctx context.Context) (repos []*ConfigRepo, resp *APIResponse, err error) {
r := &ConfigReposListResponse{}
_, resp, err = crs.client.getAction(ctx, &APIClientRequest{
Path: "admin/config_repos",
ResponseBody: r,
APIVersion: apiV1,
})
for _, repos := range r.Embedd... | go | func (crs *ConfigRepoService) List(ctx context.Context) (repos []*ConfigRepo, resp *APIResponse, err error) {
r := &ConfigReposListResponse{}
_, resp, err = crs.client.getAction(ctx, &APIClientRequest{
Path: "admin/config_repos",
ResponseBody: r,
APIVersion: apiV1,
})
for _, repos := range r.Embedd... | [
"func",
"(",
"crs",
"*",
"ConfigRepoService",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"repos",
"[",
"]",
"*",
"ConfigRepo",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"r",
":=",
"&",
"ConfigReposListResponse",
... | // List returns all available config repos, these are config repositories that
// are present in the in `cruise-config.xml` | [
"List",
"returns",
"all",
"available",
"config",
"repos",
"these",
"are",
"config",
"repositories",
"that",
"are",
"present",
"in",
"the",
"in",
"cruise",
"-",
"config",
".",
"xml"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config_repo.go#L41-L55 |
143,836 | beamly/go-gocd | gocd/config_repo.go | Get | func (crs *ConfigRepoService) Get(ctx context.Context, id string) (out *ConfigRepo, resp *APIResponse, err error) {
out = &ConfigRepo{}
_, resp, err = crs.client.getAction(ctx, &APIClientRequest{
Path: fmt.Sprintf("admin/config_repos/%s", id),
ResponseBody: out,
APIVersion: apiV1,
})
out.client = c... | go | func (crs *ConfigRepoService) Get(ctx context.Context, id string) (out *ConfigRepo, resp *APIResponse, err error) {
out = &ConfigRepo{}
_, resp, err = crs.client.getAction(ctx, &APIClientRequest{
Path: fmt.Sprintf("admin/config_repos/%s", id),
ResponseBody: out,
APIVersion: apiV1,
})
out.client = c... | [
"func",
"(",
"crs",
"*",
"ConfigRepoService",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"out",
"*",
"ConfigRepo",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"out",
"=",
"&",
"ConfigRepo",
"... | // Get fetches the config repo object for a specified id | [
"Get",
"fetches",
"the",
"config",
"repo",
"object",
"for",
"a",
"specified",
"id"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config_repo.go#L58-L68 |
143,837 | beamly/go-gocd | gocd/config_repo.go | Create | func (crs *ConfigRepoService) Create(ctx context.Context, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error) {
out = &ConfigRepo{}
_, resp, err = crs.client.postAction(ctx, &APIClientRequest{
Path: "admin/config_repos",
RequestBody: cr,
ResponseBody: out,
APIVersion: apiV1,
})
out.c... | go | func (crs *ConfigRepoService) Create(ctx context.Context, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error) {
out = &ConfigRepo{}
_, resp, err = crs.client.postAction(ctx, &APIClientRequest{
Path: "admin/config_repos",
RequestBody: cr,
ResponseBody: out,
APIVersion: apiV1,
})
out.c... | [
"func",
"(",
"crs",
"*",
"ConfigRepoService",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"cr",
"*",
"ConfigRepo",
")",
"(",
"out",
"*",
"ConfigRepo",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"out",
"=",
"&",
"Co... | // Create a config repo | [
"Create",
"a",
"config",
"repo"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config_repo.go#L71-L82 |
143,838 | beamly/go-gocd | gocd/config_repo.go | Update | func (crs *ConfigRepoService) Update(ctx context.Context, id string, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error) {
out = &ConfigRepo{}
_, resp, err = crs.client.putAction(ctx, &APIClientRequest{
Path: fmt.Sprintf("admin/config_repos/%s", id),
RequestBody: cr,
ResponseBody: out,
AP... | go | func (crs *ConfigRepoService) Update(ctx context.Context, id string, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error) {
out = &ConfigRepo{}
_, resp, err = crs.client.putAction(ctx, &APIClientRequest{
Path: fmt.Sprintf("admin/config_repos/%s", id),
RequestBody: cr,
ResponseBody: out,
AP... | [
"func",
"(",
"crs",
"*",
"ConfigRepoService",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
",",
"cr",
"*",
"ConfigRepo",
")",
"(",
"out",
"*",
"ConfigRepo",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
... | // Update config repos for specified config repo id | [
"Update",
"config",
"repos",
"for",
"specified",
"config",
"repo",
"id"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config_repo.go#L85-L96 |
143,839 | beamly/go-gocd | gocd/config_repo.go | Delete | func (crs *ConfigRepoService) Delete(ctx context.Context, id string) (string, *APIResponse, error) {
return crs.client.deleteAction(ctx, fmt.Sprintf("admin/config_repos/%s", id), apiV1)
} | go | func (crs *ConfigRepoService) Delete(ctx context.Context, id string) (string, *APIResponse, error) {
return crs.client.deleteAction(ctx, fmt.Sprintf("admin/config_repos/%s", id), apiV1)
} | [
"func",
"(",
"crs",
"*",
"ConfigRepoService",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"string",
",",
"*",
"APIResponse",
",",
"error",
")",
"{",
"return",
"crs",
".",
"client",
".",
"deleteAction",
"(",
"ctx... | // Delete the specified config repo | [
"Delete",
"the",
"specified",
"config",
"repo"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config_repo.go#L99-L101 |
143,840 | beamly/go-gocd | gocd/resource_pipeline_material_git.go | unmarshallMaterialAttributesGit | func unmarshallMaterialAttributesGit(mag *MaterialAttributesGit, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mag.Name = value.(string)
case "url":
mag.URL = value.(string)
case "auto_update":
mag.AutoUpdate = value.(bool)
case... | go | func unmarshallMaterialAttributesGit(mag *MaterialAttributesGit, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mag.Name = value.(string)
case "url":
mag.URL = value.(string)
case "auto_update":
mag.AutoUpdate = value.(bool)
case... | [
"func",
"unmarshallMaterialAttributesGit",
"(",
"mag",
"*",
"MaterialAttributesGit",
",",
"i",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"i",
"{",
"if",
"value",
"==",
"nil",
"{",
"continue",
"... | // UnmarshallInterface from a JSON string to a MaterialAttributesGit struct | [
"UnmarshallInterface",
"from",
"a",
"JSON",
"string",
"to",
"a",
"MaterialAttributesGit",
"struct"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_pipeline_material_git.go#L53-L81 |
143,841 | gemnasium/migrate | pipe/pipe.go | Close | func Close(pipe chan interface{}, err error) {
if err != nil {
pipe <- err
}
close(pipe)
} | go | func Close(pipe chan interface{}, err error) {
if err != nil {
pipe <- err
}
close(pipe)
} | [
"func",
"Close",
"(",
"pipe",
"chan",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"pipe",
"<-",
"err",
"\n",
"}",
"\n",
"close",
"(",
"pipe",
")",
"\n",
"}"
] | // Close closes a pipe and optionally sends an error | [
"Close",
"closes",
"a",
"pipe",
"and",
"optionally",
"sends",
"an",
"error"
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/pipe/pipe.go#L14-L19 |
143,842 | gemnasium/migrate | pipe/pipe.go | WaitAndRedirect | func WaitAndRedirect(pipe, redirectPipe chan interface{}, interrupt chan os.Signal) (ok bool) {
errorReceived := false
interruptsReceived := 0
if pipe != nil && redirectPipe != nil {
for {
select {
case <-interrupt:
interruptsReceived += 1
if interruptsReceived > 1 {
os.Exit(5)
} else {
... | go | func WaitAndRedirect(pipe, redirectPipe chan interface{}, interrupt chan os.Signal) (ok bool) {
errorReceived := false
interruptsReceived := 0
if pipe != nil && redirectPipe != nil {
for {
select {
case <-interrupt:
interruptsReceived += 1
if interruptsReceived > 1 {
os.Exit(5)
} else {
... | [
"func",
"WaitAndRedirect",
"(",
"pipe",
",",
"redirectPipe",
"chan",
"interface",
"{",
"}",
",",
"interrupt",
"chan",
"os",
".",
"Signal",
")",
"(",
"ok",
"bool",
")",
"{",
"errorReceived",
":=",
"false",
"\n",
"interruptsReceived",
":=",
"0",
"\n",
"if",
... | // WaitAndRedirect waits for pipe to be closed and
// redirects all messages from pipe to redirectPipe
// while it waits. It also checks if there was an
// interrupt send and will quit gracefully if yes. | [
"WaitAndRedirect",
"waits",
"for",
"pipe",
"to",
"be",
"closed",
"and",
"redirects",
"all",
"messages",
"from",
"pipe",
"to",
"redirectPipe",
"while",
"it",
"waits",
".",
"It",
"also",
"checks",
"if",
"there",
"was",
"an",
"interrupt",
"send",
"and",
"will",... | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/pipe/pipe.go#L25-L55 |
143,843 | gemnasium/migrate | pipe/pipe.go | ReadErrors | func ReadErrors(pipe chan interface{}) []error {
err := make([]error, 0)
if pipe != nil {
for {
select {
case item, ok := <-pipe:
if !ok {
return err
} else {
switch item.(type) {
case error:
err = append(err, item.(error))
}
}
}
}
}
return err
} | go | func ReadErrors(pipe chan interface{}) []error {
err := make([]error, 0)
if pipe != nil {
for {
select {
case item, ok := <-pipe:
if !ok {
return err
} else {
switch item.(type) {
case error:
err = append(err, item.(error))
}
}
}
}
}
return err
} | [
"func",
"ReadErrors",
"(",
"pipe",
"chan",
"interface",
"{",
"}",
")",
"[",
"]",
"error",
"{",
"err",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"if",
"pipe",
"!=",
"nil",
"{",
"for",
"{",
"select",
"{",
"case",
"item",
",",
"ok... | // ReadErrors selects all received errors and returns them.
// This is helpful for synchronous migration functions. | [
"ReadErrors",
"selects",
"all",
"received",
"errors",
"and",
"returns",
"them",
".",
"This",
"is",
"helpful",
"for",
"synchronous",
"migration",
"functions",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/pipe/pipe.go#L59-L77 |
143,844 | gemnasium/migrate | migrate/migrate.go | Up | func Up(pipe chan interface{}, url, migrationsPath string) {
d, files, versions, err := initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath)
defer func() {
if err != nil {
pipe <- err
}
if d != nil {
if err = d.Close(); err != nil {
pipe <- err
}
}
go pipep.Close(pipe, nil)
}()
... | go | func Up(pipe chan interface{}, url, migrationsPath string) {
d, files, versions, err := initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath)
defer func() {
if err != nil {
pipe <- err
}
if d != nil {
if err = d.Close(); err != nil {
pipe <- err
}
}
go pipep.Close(pipe, nil)
}()
... | [
"func",
"Up",
"(",
"pipe",
"chan",
"interface",
"{",
"}",
",",
"url",
",",
"migrationsPath",
"string",
")",
"{",
"d",
",",
"files",
",",
"versions",
",",
"err",
":=",
"initDriverAndReadMigrationFilesAndGetVersions",
"(",
"url",
",",
"migrationsPath",
")",
"\... | // Up applies all available migrations. | [
"Up",
"applies",
"all",
"available",
"migrations",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L22-L54 |
143,845 | gemnasium/migrate | migrate/migrate.go | Redo | func Redo(pipe chan interface{}, url, migrationsPath string) {
pipe1 := pipep.New()
go Migrate(pipe1, url, migrationsPath, -1)
if ok := pipep.WaitAndRedirect(pipe1, pipe, handleInterrupts()); !ok {
go pipep.Close(pipe, nil)
return
}
go Migrate(pipe, url, migrationsPath, +1)
} | go | func Redo(pipe chan interface{}, url, migrationsPath string) {
pipe1 := pipep.New()
go Migrate(pipe1, url, migrationsPath, -1)
if ok := pipep.WaitAndRedirect(pipe1, pipe, handleInterrupts()); !ok {
go pipep.Close(pipe, nil)
return
}
go Migrate(pipe, url, migrationsPath, +1)
} | [
"func",
"Redo",
"(",
"pipe",
"chan",
"interface",
"{",
"}",
",",
"url",
",",
"migrationsPath",
"string",
")",
"{",
"pipe1",
":=",
"pipep",
".",
"New",
"(",
")",
"\n",
"go",
"Migrate",
"(",
"pipe1",
",",
"url",
",",
"migrationsPath",
",",
"-",
"1",
... | // Redo rolls back the most recently applied migration, then runs it again. | [
"Redo",
"rolls",
"back",
"the",
"most",
"recently",
"applied",
"migration",
"then",
"runs",
"it",
"again",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L108-L116 |
143,846 | gemnasium/migrate | migrate/migrate.go | Reset | func Reset(pipe chan interface{}, url, migrationsPath string) {
pipe1 := pipep.New()
go Down(pipe1, url, migrationsPath)
if ok := pipep.WaitAndRedirect(pipe1, pipe, handleInterrupts()); !ok {
go pipep.Close(pipe, nil)
return
}
go Up(pipe, url, migrationsPath)
} | go | func Reset(pipe chan interface{}, url, migrationsPath string) {
pipe1 := pipep.New()
go Down(pipe1, url, migrationsPath)
if ok := pipep.WaitAndRedirect(pipe1, pipe, handleInterrupts()); !ok {
go pipep.Close(pipe, nil)
return
}
go Up(pipe, url, migrationsPath)
} | [
"func",
"Reset",
"(",
"pipe",
"chan",
"interface",
"{",
"}",
",",
"url",
",",
"migrationsPath",
"string",
")",
"{",
"pipe1",
":=",
"pipep",
".",
"New",
"(",
")",
"\n",
"go",
"Down",
"(",
"pipe1",
",",
"url",
",",
"migrationsPath",
")",
"\n",
"if",
... | // Reset runs the down and up migration function. | [
"Reset",
"runs",
"the",
"down",
"and",
"up",
"migration",
"function",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L127-L135 |
143,847 | gemnasium/migrate | migrate/migrate.go | Versions | func Versions(url, migrationsPath string) (versions file.Versions, err error) {
d, err := driver.New(url)
if err != nil {
return file.Versions{}, err
}
return d.Versions()
} | go | func Versions(url, migrationsPath string) (versions file.Versions, err error) {
d, err := driver.New(url)
if err != nil {
return file.Versions{}, err
}
return d.Versions()
} | [
"func",
"Versions",
"(",
"url",
",",
"migrationsPath",
"string",
")",
"(",
"versions",
"file",
".",
"Versions",
",",
"err",
"error",
")",
"{",
"d",
",",
"err",
":=",
"driver",
".",
"New",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // Versions returns applied versions. | [
"Versions",
"returns",
"applied",
"versions",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L197-L203 |
143,848 | gemnasium/migrate | migrate/migrate.go | Create | func Create(url, migrationsPath, name string) (*file.MigrationFile, error) {
d, files, _, err := initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath)
if err != nil {
return nil, err
}
versionStr := time.Now().UTC().Format("20060102150405")
v, _ := strconv.ParseUint(versionStr, 10, 64)
version := ... | go | func Create(url, migrationsPath, name string) (*file.MigrationFile, error) {
d, files, _, err := initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath)
if err != nil {
return nil, err
}
versionStr := time.Now().UTC().Format("20060102150405")
v, _ := strconv.ParseUint(versionStr, 10, 64)
version := ... | [
"func",
"Create",
"(",
"url",
",",
"migrationsPath",
",",
"name",
"string",
")",
"(",
"*",
"file",
".",
"MigrationFile",
",",
"error",
")",
"{",
"d",
",",
"files",
",",
"_",
",",
"err",
":=",
"initDriverAndReadMigrationFilesAndGetVersions",
"(",
"url",
","... | // Create creates new migration files on disk. | [
"Create",
"creates",
"new",
"migration",
"files",
"on",
"disk",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L206-L253 |
143,849 | gemnasium/migrate | migrate/migrate.go | initDriverAndReadMigrationFilesAndGetVersions | func initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath string) (driver.Driver, file.MigrationFiles, file.Versions, error) {
d, err := driver.New(url)
if err != nil {
return nil, nil, file.Versions{}, err
}
files, err := file.ReadMigrationFiles(migrationsPath, file.FilenameRegex(d.FilenameExtension... | go | func initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath string) (driver.Driver, file.MigrationFiles, file.Versions, error) {
d, err := driver.New(url)
if err != nil {
return nil, nil, file.Versions{}, err
}
files, err := file.ReadMigrationFiles(migrationsPath, file.FilenameRegex(d.FilenameExtension... | [
"func",
"initDriverAndReadMigrationFilesAndGetVersions",
"(",
"url",
",",
"migrationsPath",
"string",
")",
"(",
"driver",
".",
"Driver",
",",
"file",
".",
"MigrationFiles",
",",
"file",
".",
"Versions",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"driver",
... | // initDriverAndReadMigrationFilesAndGetVersionsAndGetVersion is a small helper
// function that is common to most of the migration funcs. | [
"initDriverAndReadMigrationFilesAndGetVersionsAndGetVersion",
"is",
"a",
"small",
"helper",
"function",
"that",
"is",
"common",
"to",
"most",
"of",
"the",
"migration",
"funcs",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L257-L276 |
143,850 | gemnasium/migrate | migrate/migrate.go | handleInterrupts | func handleInterrupts() chan os.Signal {
if interrupts {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
return c
}
return nil
} | go | func handleInterrupts() chan os.Signal {
if interrupts {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
return c
}
return nil
} | [
"func",
"handleInterrupts",
"(",
")",
"chan",
"os",
".",
"Signal",
"{",
"if",
"interrupts",
"{",
"c",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"c",
",",
"os",
".",
"Interrupt",
")",
"\n",
... | // interrupts returns a signal channel if interrupts checking is
// enabled. nil otherwise. | [
"interrupts",
"returns",
"a",
"signal",
"channel",
"if",
"interrupts",
"checking",
"is",
"enabled",
".",
"nil",
"otherwise",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/migrate/migrate.go#L304-L311 |
143,851 | gemnasium/migrate | driver/sqlite3/sqlite3.go | splitStatements | func splitStatements(in string) []string {
result := make([]string, 0)
qs := strings.Split(in, ";")
for _, q := range qs {
if q = strings.TrimSpace(q); q != "" {
result = append(result, q+";")
}
}
return result
} | go | func splitStatements(in string) []string {
result := make([]string, 0)
qs := strings.Split(in, ";")
for _, q := range qs {
if q = strings.TrimSpace(q); q != "" {
result = append(result, q+";")
}
}
return result
} | [
"func",
"splitStatements",
"(",
"in",
"string",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n\n",
"qs",
":=",
"strings",
".",
"Split",
"(",
"in",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"... | // This naive implementation doesn't account for quoted ";" inside statements.
// It should work for most migrations but can be improved in the future. | [
"This",
"naive",
"implementation",
"doesn",
"t",
"account",
"for",
"quoted",
";",
"inside",
"statements",
".",
"It",
"should",
"work",
"for",
"most",
"migrations",
"but",
"can",
"be",
"improved",
"in",
"the",
"future",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/driver/sqlite3/sqlite3.go#L159-L169 |
143,852 | gemnasium/migrate | file/file.go | FilenameRegex | func FilenameRegex(filenameExtension string) *regexp.Regexp {
return regexp.MustCompile(fmt.Sprintf(filenameRegex, filenameExtension))
} | go | func FilenameRegex(filenameExtension string) *regexp.Regexp {
return regexp.MustCompile(fmt.Sprintf(filenameRegex, filenameExtension))
} | [
"func",
"FilenameRegex",
"(",
"filenameExtension",
"string",
")",
"*",
"regexp",
".",
"Regexp",
"{",
"return",
"regexp",
".",
"MustCompile",
"(",
"fmt",
".",
"Sprintf",
"(",
"filenameRegex",
",",
"filenameExtension",
")",
")",
"\n",
"}"
] | // FilenameRegex builds regular expression stmt with given
// filename extension from driver. | [
"FilenameRegex",
"builds",
"regular",
"expression",
"stmt",
"with",
"given",
"filename",
"extension",
"from",
"driver",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L23-L25 |
143,853 | gemnasium/migrate | file/file.go | Contains | func (versions Versions) Contains(version Version) bool {
for _, v := range versions {
if v == version {
return true
}
}
return false
} | go | func (versions Versions) Contains(version Version) bool {
for _, v := range versions {
if v == version {
return true
}
}
return false
} | [
"func",
"(",
"versions",
"Versions",
")",
"Contains",
"(",
"version",
"Version",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"versions",
"{",
"if",
"v",
"==",
"version",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",... | // Contains checks if a _version_ is contained in the list of migrations. | [
"Contains",
"checks",
"if",
"a",
"_version_",
"is",
"contained",
"in",
"the",
"list",
"of",
"migrations",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L31-L38 |
143,854 | gemnasium/migrate | file/file.go | ReadContent | func (f *File) ReadContent() error {
if len(f.Content) == 0 {
content, err := ioutil.ReadFile(path.Join(f.Path, f.FileName))
if err != nil {
return err
}
f.Content = content
}
return nil
} | go | func (f *File) ReadContent() error {
if len(f.Content) == 0 {
content, err := ioutil.ReadFile(path.Join(f.Path, f.FileName))
if err != nil {
return err
}
f.Content = content
}
return nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"ReadContent",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"f",
".",
"Content",
")",
"==",
"0",
"{",
"content",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
".",
"Join",
"(",
"f",
".",
"Path",
",",... | // ReadContent reads the file into the content if it's empty. | [
"ReadContent",
"reads",
"the",
"file",
"into",
"the",
"content",
"if",
"it",
"s",
"empty",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L98-L107 |
143,855 | gemnasium/migrate | file/file.go | Pending | func (mf *MigrationFiles) Pending(versions Versions) (Files, error) {
sort.Sort(mf)
files := make(Files, 0)
for _, migrationFile := range *mf {
if !versions.Contains(migrationFile.Version) && migrationFile.UpFile != nil {
files = append(files, *migrationFile.UpFile)
}
}
return files, nil
} | go | func (mf *MigrationFiles) Pending(versions Versions) (Files, error) {
sort.Sort(mf)
files := make(Files, 0)
for _, migrationFile := range *mf {
if !versions.Contains(migrationFile.Version) && migrationFile.UpFile != nil {
files = append(files, *migrationFile.UpFile)
}
}
return files, nil
} | [
"func",
"(",
"mf",
"*",
"MigrationFiles",
")",
"Pending",
"(",
"versions",
"Versions",
")",
"(",
"Files",
",",
"error",
")",
"{",
"sort",
".",
"Sort",
"(",
"mf",
")",
"\n",
"files",
":=",
"make",
"(",
"Files",
",",
"0",
")",
"\n",
"for",
"_",
","... | // Pending returns the list of pending migration files. | [
"Pending",
"returns",
"the",
"list",
"of",
"pending",
"migration",
"files",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L110-L119 |
143,856 | gemnasium/migrate | file/file.go | Applied | func (mf *MigrationFiles) Applied(versions Versions) (Files, error) {
sort.Sort(sort.Reverse(mf))
files := make(Files, 0)
for _, migrationFile := range *mf {
if versions.Contains(migrationFile.Version) && migrationFile.DownFile != nil {
files = append(files, *migrationFile.DownFile)
}
}
return files, nil
} | go | func (mf *MigrationFiles) Applied(versions Versions) (Files, error) {
sort.Sort(sort.Reverse(mf))
files := make(Files, 0)
for _, migrationFile := range *mf {
if versions.Contains(migrationFile.Version) && migrationFile.DownFile != nil {
files = append(files, *migrationFile.DownFile)
}
}
return files, nil
} | [
"func",
"(",
"mf",
"*",
"MigrationFiles",
")",
"Applied",
"(",
"versions",
"Versions",
")",
"(",
"Files",
",",
"error",
")",
"{",
"sort",
".",
"Sort",
"(",
"sort",
".",
"Reverse",
"(",
"mf",
")",
")",
"\n",
"files",
":=",
"make",
"(",
"Files",
",",... | // Applied returns the list of applied migration files. | [
"Applied",
"returns",
"the",
"list",
"of",
"applied",
"migration",
"files",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L122-L131 |
143,857 | gemnasium/migrate | file/file.go | Relative | func (mf *MigrationFiles) Relative(relativeN int, versions Versions) (Files, error) {
var d direction.Direction
if relativeN > 0 {
d = direction.Up
} else if relativeN < 0 {
d = direction.Down
} else { // relativeN == 0
return nil, nil
}
var files Files
var err error
if d == direction.Up {
files, err =... | go | func (mf *MigrationFiles) Relative(relativeN int, versions Versions) (Files, error) {
var d direction.Direction
if relativeN > 0 {
d = direction.Up
} else if relativeN < 0 {
d = direction.Down
} else { // relativeN == 0
return nil, nil
}
var files Files
var err error
if d == direction.Up {
files, err =... | [
"func",
"(",
"mf",
"*",
"MigrationFiles",
")",
"Relative",
"(",
"relativeN",
"int",
",",
"versions",
"Versions",
")",
"(",
"Files",
",",
"error",
")",
"{",
"var",
"d",
"direction",
".",
"Direction",
"\n",
"if",
"relativeN",
">",
"0",
"{",
"d",
"=",
"... | // Relative travels relatively through migration files.
//
// +1 will fetch the next up migration file
// +2 will fetch the next two up migration files
// +n will fetch ...
// -1 will fetch the the previous down migration file
// -2 will fetch the next two previous down migration files
// -n will fetch ... | [
"Relative",
"travels",
"relatively",
"through",
"migration",
"files",
".",
"+",
"1",
"will",
"fetch",
"the",
"next",
"up",
"migration",
"file",
"+",
"2",
"will",
"fetch",
"the",
"next",
"two",
"up",
"migration",
"files",
"+",
"n",
"will",
"fetch",
"...",
... | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L141-L163 |
143,858 | gemnasium/migrate | file/file.go | parseFilenameSchema | func parseFilenameSchema(filename string, filenameRegex *regexp.Regexp) (version Version, name string, d direction.Direction, err error) {
matches := filenameRegex.FindStringSubmatch(filename)
if len(matches) != 4 {
return 0, "", 0, errors.New("Unable to parse filename schema")
}
v, err := strconv.ParseUint(matc... | go | func parseFilenameSchema(filename string, filenameRegex *regexp.Regexp) (version Version, name string, d direction.Direction, err error) {
matches := filenameRegex.FindStringSubmatch(filename)
if len(matches) != 4 {
return 0, "", 0, errors.New("Unable to parse filename schema")
}
v, err := strconv.ParseUint(matc... | [
"func",
"parseFilenameSchema",
"(",
"filename",
"string",
",",
"filenameRegex",
"*",
"regexp",
".",
"Regexp",
")",
"(",
"version",
"Version",
",",
"name",
"string",
",",
"d",
"direction",
".",
"Direction",
",",
"err",
"error",
")",
"{",
"matches",
":=",
"f... | // parseFilenameSchema parses the filename. | [
"parseFilenameSchema",
"parses",
"the",
"filename",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L267-L288 |
143,859 | gemnasium/migrate | file/file.go | LineColumnFromOffset | func LineColumnFromOffset(data []byte, offset int) (line, column int) {
// TODO is there a better way?
fs := token.NewFileSet()
tf := fs.AddFile("", fs.Base(), len(data))
tf.SetLinesForContent(data)
pos := tf.Position(tf.Pos(offset))
return pos.Line, pos.Column
} | go | func LineColumnFromOffset(data []byte, offset int) (line, column int) {
// TODO is there a better way?
fs := token.NewFileSet()
tf := fs.AddFile("", fs.Base(), len(data))
tf.SetLinesForContent(data)
pos := tf.Position(tf.Pos(offset))
return pos.Line, pos.Column
} | [
"func",
"LineColumnFromOffset",
"(",
"data",
"[",
"]",
"byte",
",",
"offset",
"int",
")",
"(",
"line",
",",
"column",
"int",
")",
"{",
"// TODO is there a better way?",
"fs",
":=",
"token",
".",
"NewFileSet",
"(",
")",
"\n",
"tf",
":=",
"fs",
".",
"AddFi... | // LineColumnFromOffset reads data and returns line and column integer for a given offset. | [
"LineColumnFromOffset",
"reads",
"data",
"and",
"returns",
"line",
"and",
"column",
"integer",
"for",
"a",
"given",
"offset",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L307-L314 |
143,860 | gemnasium/migrate | file/file.go | LinesBeforeAndAfter | func LinesBeforeAndAfter(data []byte, line, before, after int, lineNumbers bool) []byte {
// TODO(gemnasium): Trim empty lines at the beginning and at the end
// TODO(gemnasium): Trim offset whitespace at the beginning of each line, so that indentation is preserved
startLine := line - before
endLine := line + after... | go | func LinesBeforeAndAfter(data []byte, line, before, after int, lineNumbers bool) []byte {
// TODO(gemnasium): Trim empty lines at the beginning and at the end
// TODO(gemnasium): Trim offset whitespace at the beginning of each line, so that indentation is preserved
startLine := line - before
endLine := line + after... | [
"func",
"LinesBeforeAndAfter",
"(",
"data",
"[",
"]",
"byte",
",",
"line",
",",
"before",
",",
"after",
"int",
",",
"lineNumbers",
"bool",
")",
"[",
"]",
"byte",
"{",
"// TODO(gemnasium): Trim empty lines at the beginning and at the end",
"// TODO(gemnasium): Trim offse... | // LinesBeforeAndAfter reads n lines before and after a given line.
// Set lineNumbers to true, to prepend line numbers. | [
"LinesBeforeAndAfter",
"reads",
"n",
"lines",
"before",
"and",
"after",
"a",
"given",
"line",
".",
"Set",
"lineNumbers",
"to",
"true",
"to",
"prepend",
"line",
"numbers",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/file/file.go#L318-L351 |
143,861 | gemnasium/migrate | driver/registry.go | GetDriver | func GetDriver(name string) Driver {
driversMu.Lock()
defer driversMu.Unlock()
driver := drivers[name]
return driver
} | go | func GetDriver(name string) Driver {
driversMu.Lock()
defer driversMu.Unlock()
driver := drivers[name]
return driver
} | [
"func",
"GetDriver",
"(",
"name",
"string",
")",
"Driver",
"{",
"driversMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"driversMu",
".",
"Unlock",
"(",
")",
"\n",
"driver",
":=",
"drivers",
"[",
"name",
"]",
"\n",
"return",
"driver",
"\n",
"}"
] | // Retrieves a registered driver by name. | [
"Retrieves",
"a",
"registered",
"driver",
"by",
"name",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/driver/registry.go#L26-L31 |
143,862 | gemnasium/migrate | driver/cassandra/cassandra.go | parseConsistency | func parseConsistency(consistencyStr string) (consistency gocql.Consistency, err error) {
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("Failed to parse consistency \"%s\": %v", consistencyStr, r)
}
}
}()
consistency = gocql.ParseConsistenc... | go | func parseConsistency(consistencyStr string) (consistency gocql.Consistency, err error) {
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("Failed to parse consistency \"%s\": %v", consistencyStr, r)
}
}
}()
consistency = gocql.ParseConsistenc... | [
"func",
"parseConsistency",
"(",
"consistencyStr",
"string",
")",
"(",
"consistency",
"gocql",
".",
"Consistency",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"var",
... | // ParseConsistency wraps gocql.ParseConsistency to return an error
// instead of a panicing. | [
"ParseConsistency",
"wraps",
"gocql",
".",
"ParseConsistency",
"to",
"return",
"an",
"error",
"instead",
"of",
"a",
"panicing",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/driver/cassandra/cassandra.go#L173-L186 |
143,863 | gemnasium/migrate | driver/driver.go | New | func New(url string) (Driver, error) {
u, err := neturl.Parse(url)
if err != nil {
return nil, err
}
d := GetDriver(u.Scheme)
if d == nil {
return nil, fmt.Errorf("Driver '%s' not found.", u.Scheme)
}
verifyFilenameExtension(u.Scheme, d)
if err := d.Initialize(url); err != nil {
return nil, err
}
retu... | go | func New(url string) (Driver, error) {
u, err := neturl.Parse(url)
if err != nil {
return nil, err
}
d := GetDriver(u.Scheme)
if d == nil {
return nil, fmt.Errorf("Driver '%s' not found.", u.Scheme)
}
verifyFilenameExtension(u.Scheme, d)
if err := d.Initialize(url); err != nil {
return nil, err
}
retu... | [
"func",
"New",
"(",
"url",
"string",
")",
"(",
"Driver",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"neturl",
".",
"Parse",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"d",
":=",
"... | // New returns Driver and calls Initialize on it. | [
"New",
"returns",
"Driver",
"and",
"calls",
"Initialize",
"on",
"it",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/driver/driver.go#L41-L57 |
143,864 | gemnasium/migrate | driver/driver.go | verifyFilenameExtension | func verifyFilenameExtension(driverName string, d Driver) {
f := d.FilenameExtension()
if f == "" {
panic(fmt.Sprintf("%s.FilenameExtension() returns empty string.", driverName))
}
if f[0:1] == "." {
panic(fmt.Sprintf("%s.FilenameExtension() returned string must not start with a dot.", driverName))
}
} | go | func verifyFilenameExtension(driverName string, d Driver) {
f := d.FilenameExtension()
if f == "" {
panic(fmt.Sprintf("%s.FilenameExtension() returns empty string.", driverName))
}
if f[0:1] == "." {
panic(fmt.Sprintf("%s.FilenameExtension() returned string must not start with a dot.", driverName))
}
} | [
"func",
"verifyFilenameExtension",
"(",
"driverName",
"string",
",",
"d",
"Driver",
")",
"{",
"f",
":=",
"d",
".",
"FilenameExtension",
"(",
")",
"\n",
"if",
"f",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"driv... | // verifyFilenameExtension panics if the driver's filename extension
// is not correct or empty. | [
"verifyFilenameExtension",
"panics",
"if",
"the",
"driver",
"s",
"filename",
"extension",
"is",
"not",
"correct",
"or",
"empty",
"."
] | 30abc3eda21e18208e819aaef77f3cf5d05d4be5 | https://github.com/gemnasium/migrate/blob/30abc3eda21e18208e819aaef77f3cf5d05d4be5/driver/driver.go#L61-L69 |
143,865 | pierrre/archivefile | zip/zip.go | Unarchive | func Unarchive(reader io.ReaderAt, readerSize int64, outFilePath string, progress ProgressFunc) error {
zipReader, err := zip_impl.NewReader(reader, readerSize)
if err != nil {
return err
}
for _, zipFile := range zipReader.File {
err := unarchiveFile(zipFile, outFilePath, progress)
if err != nil {
return... | go | func Unarchive(reader io.ReaderAt, readerSize int64, outFilePath string, progress ProgressFunc) error {
zipReader, err := zip_impl.NewReader(reader, readerSize)
if err != nil {
return err
}
for _, zipFile := range zipReader.File {
err := unarchiveFile(zipFile, outFilePath, progress)
if err != nil {
return... | [
"func",
"Unarchive",
"(",
"reader",
"io",
".",
"ReaderAt",
",",
"readerSize",
"int64",
",",
"outFilePath",
"string",
",",
"progress",
"ProgressFunc",
")",
"error",
"{",
"zipReader",
",",
"err",
":=",
"zip_impl",
".",
"NewReader",
"(",
"reader",
",",
"readerS... | // Unarchive decompresses a reader to a directory
//
// The data's size is required because the zip reader needs it.
//
// The archive's content will be extracted directly to outFilePath.
//
// If progress is not nil, it is called for each file extracted from the archive. | [
"Unarchive",
"decompresses",
"a",
"reader",
"to",
"a",
"directory",
"The",
"data",
"s",
"size",
"is",
"required",
"because",
"the",
"zip",
"reader",
"needs",
"it",
".",
"The",
"archive",
"s",
"content",
"will",
"be",
"extracted",
"directly",
"to",
"outFilePa... | e2d100bc74f58ed7d2f41175cd2cf5fe29446399 | https://github.com/pierrre/archivefile/blob/e2d100bc74f58ed7d2f41175cd2cf5fe29446399/zip/zip.go#L86-L100 |
143,866 | alexcesaro/quotedprintable | encodedword.go | Encode | func (e WordEncoder) Encode(charset, s string) string {
if !needsEncoding(s) {
return s
}
return e.encodeWord(charset, s)
} | go | func (e WordEncoder) Encode(charset, s string) string {
if !needsEncoding(s) {
return s
}
return e.encodeWord(charset, s)
} | [
"func",
"(",
"e",
"WordEncoder",
")",
"Encode",
"(",
"charset",
",",
"s",
"string",
")",
"string",
"{",
"if",
"!",
"needsEncoding",
"(",
"s",
")",
"{",
"return",
"s",
"\n",
"}",
"\n",
"return",
"e",
".",
"encodeWord",
"(",
"charset",
",",
"s",
")",... | // Encode returns the encoded-word form of s. If s is ASCII without special
// characters, it is returned unchanged. The provided charset is the IANA
// charset name of s. It is case insensitive. | [
"Encode",
"returns",
"the",
"encoded",
"-",
"word",
"form",
"of",
"s",
".",
"If",
"s",
"is",
"ASCII",
"without",
"special",
"characters",
"it",
"is",
"returned",
"unchanged",
".",
"The",
"provided",
"charset",
"is",
"the",
"IANA",
"charset",
"name",
"of",
... | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/encodedword.go#L31-L36 |
143,867 | alexcesaro/quotedprintable | encodedword.go | Decode | func (d *WordDecoder) Decode(word string) (string, error) {
fields := strings.Split(word, "?") // TODO: remove allocation?
if len(fields) != 5 || fields[0] != "=" || fields[4] != "=" || len(fields[2]) != 1 {
return "", errInvalidWord
}
content, err := decode(fields[2][0], fields[3])
if err != nil {
return "",... | go | func (d *WordDecoder) Decode(word string) (string, error) {
fields := strings.Split(word, "?") // TODO: remove allocation?
if len(fields) != 5 || fields[0] != "=" || fields[4] != "=" || len(fields[2]) != 1 {
return "", errInvalidWord
}
content, err := decode(fields[2][0], fields[3])
if err != nil {
return "",... | [
"func",
"(",
"d",
"*",
"WordDecoder",
")",
"Decode",
"(",
"word",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"word",
",",
"\"",
"\"",
")",
"// TODO: remove allocation?",
"\n",
"if",
"len",
"(",
... | // Decode decodes an encoded-word. If word is not a valid RFC 2047 encoded-word,
// word is returned unchanged. | [
"Decode",
"decodes",
"an",
"encoded",
"-",
"word",
".",
"If",
"word",
"is",
"not",
"a",
"valid",
"RFC",
"2047",
"encoded",
"-",
"word",
"word",
"is",
"returned",
"unchanged",
"."
] | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/encodedword.go#L98-L117 |
143,868 | alexcesaro/quotedprintable | encodedword.go | DecodeHeader | func (d *WordDecoder) DecodeHeader(header string) (string, error) {
// If there is no encoded-word, returns before creating a buffer.
i := strings.Index(header, "=?")
if i == -1 {
return header, nil
}
buf := getBuffer()
defer putBuffer(buf)
buf.WriteString(header[:i])
header = header[i:]
betweenWords := f... | go | func (d *WordDecoder) DecodeHeader(header string) (string, error) {
// If there is no encoded-word, returns before creating a buffer.
i := strings.Index(header, "=?")
if i == -1 {
return header, nil
}
buf := getBuffer()
defer putBuffer(buf)
buf.WriteString(header[:i])
header = header[i:]
betweenWords := f... | [
"func",
"(",
"d",
"*",
"WordDecoder",
")",
"DecodeHeader",
"(",
"header",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// If there is no encoded-word, returns before creating a buffer.",
"i",
":=",
"strings",
".",
"Index",
"(",
"header",
",",
"\"",
"\"... | // DecodeHeader decodes all encoded-words of the given string. It returns an
// error if and only if CharsetReader of d returns an error. | [
"DecodeHeader",
"decodes",
"all",
"encoded",
"-",
"words",
"of",
"the",
"given",
"string",
".",
"It",
"returns",
"an",
"error",
"if",
"and",
"only",
"if",
"CharsetReader",
"of",
"d",
"returns",
"an",
"error",
"."
] | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/encodedword.go#L121-L194 |
143,869 | alexcesaro/quotedprintable | reader.go | NewReader | func NewReader(r io.Reader) *Reader {
return &Reader{
br: bufio.NewReader(r),
}
} | go | func NewReader(r io.Reader) *Reader {
return &Reader{
br: bufio.NewReader(r),
}
} | [
"func",
"NewReader",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Reader",
"{",
"return",
"&",
"Reader",
"{",
"br",
":",
"bufio",
".",
"NewReader",
"(",
"r",
")",
",",
"}",
"\n",
"}"
] | // NewReader returns a quoted-printable reader, decoding from r. | [
"NewReader",
"returns",
"a",
"quoted",
"-",
"printable",
"reader",
"decoding",
"from",
"r",
"."
] | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/reader.go#L20-L24 |
143,870 | alexcesaro/quotedprintable | reader.go | Read | func (r *Reader) Read(p []byte) (n int, err error) {
// Deviations from RFC 2045:
// 1. in addition to "=\r\n", "=\n" is also treated as soft line break.
// 2. it will pass through a '\r' or '\n' not preceded by '=', consistent
// with other broken QP encoders & decoders.
for len(p) > 0 {
if len(r.line) == 0 ... | go | func (r *Reader) Read(p []byte) (n int, err error) {
// Deviations from RFC 2045:
// 1. in addition to "=\r\n", "=\n" is also treated as soft line break.
// 2. it will pass through a '\r' or '\n' not preceded by '=', consistent
// with other broken QP encoders & decoders.
for len(p) > 0 {
if len(r.line) == 0 ... | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"// Deviations from RFC 2045:",
"// 1. in addition to \"=\\r\\n\", \"=\\n\" is also treated as soft line break.",
"// 2. it will pass through a... | // Read reads and decodes quoted-printable data from the underlying reader. | [
"Read",
"reads",
"and",
"decodes",
"quoted",
"-",
"printable",
"data",
"from",
"the",
"underlying",
"reader",
"."
] | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/reader.go#L66-L121 |
143,871 | alexcesaro/quotedprintable | writer.go | Write | func (w *Writer) Write(p []byte) (n int, err error) {
for i, b := range p {
switch {
// Simple writes are done in batch.
case b >= '!' && b <= '~' && b != '=':
continue
case isWhitespace(b) || !w.Binary && (b == '\n' || b == '\r'):
continue
}
if i > n {
if err := w.write(p[n:i]); err != nil {
... | go | func (w *Writer) Write(p []byte) (n int, err error) {
for i, b := range p {
switch {
// Simple writes are done in batch.
case b >= '!' && b <= '~' && b != '=':
continue
case isWhitespace(b) || !w.Binary && (b == '\n' || b == '\r'):
continue
}
if i > n {
if err := w.write(p[n:i]); err != nil {
... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"for",
"i",
",",
"b",
":=",
"range",
"p",
"{",
"switch",
"{",
"// Simple writes are done in batch.",
"case",
"b",
">=",
... | // Write encodes p using quoted-printable encoding and writes it to the
// underlying io.Writer. It limits line length to 76 characters. The encoded
// bytes are not necessarily flushed until the Writer is closed. | [
"Write",
"encodes",
"p",
"using",
"quoted",
"-",
"printable",
"encoding",
"and",
"writes",
"it",
"to",
"the",
"underlying",
"io",
".",
"Writer",
".",
"It",
"limits",
"line",
"length",
"to",
"76",
"characters",
".",
"The",
"encoded",
"bytes",
"are",
"not",
... | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/writer.go#L27-L59 |
143,872 | alexcesaro/quotedprintable | writer.go | write | func (w *Writer) write(p []byte) error {
for _, b := range p {
if b == '\n' || b == '\r' {
// If the previous byte was \r, the CRLF has already been inserted.
if w.cr && b == '\n' {
w.cr = false
continue
}
if b == '\r' {
w.cr = true
}
if err := w.checkLastByte(); err != nil {
retu... | go | func (w *Writer) write(p []byte) error {
for _, b := range p {
if b == '\n' || b == '\r' {
// If the previous byte was \r, the CRLF has already been inserted.
if w.cr && b == '\n' {
w.cr = false
continue
}
if b == '\r' {
w.cr = true
}
if err := w.checkLastByte(); err != nil {
retu... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"write",
"(",
"p",
"[",
"]",
"byte",
")",
"error",
"{",
"for",
"_",
",",
"b",
":=",
"range",
"p",
"{",
"if",
"b",
"==",
"'\\n'",
"||",
"b",
"==",
"'\\r'",
"{",
"// If the previous byte was \\r, the CRLF has already... | // write limits text encoded in quoted-printable to 76 characters per line. | [
"write",
"limits",
"text",
"encoded",
"in",
"quoted",
"-",
"printable",
"to",
"76",
"characters",
"per",
"line",
"."
] | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/writer.go#L72-L106 |
143,873 | alexcesaro/quotedprintable | writer.go | checkLastByte | func (w *Writer) checkLastByte() error {
if w.i == 0 {
return nil
}
b := w.line[w.i-1]
if isWhitespace(b) {
w.i--
if err := w.encode(b); err != nil {
return err
}
}
return nil
} | go | func (w *Writer) checkLastByte() error {
if w.i == 0 {
return nil
}
b := w.line[w.i-1]
if isWhitespace(b) {
w.i--
if err := w.encode(b); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"checkLastByte",
"(",
")",
"error",
"{",
"if",
"w",
".",
"i",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"b",
":=",
"w",
".",
"line",
"[",
"w",
".",
"i",
"-",
"1",
"]",
"\n",
"if",
"isWhitespace"... | // checkLastByte encodes the last buffered byte if it is a space or a tab. | [
"checkLastByte",
"encodes",
"the",
"last",
"buffered",
"byte",
"if",
"it",
"is",
"a",
"space",
"or",
"a",
"tab",
"."
] | 2caba252f4dc53eaf6b553000885530023f54623 | https://github.com/alexcesaro/quotedprintable/blob/2caba252f4dc53eaf6b553000885530023f54623/writer.go#L124-L138 |
143,874 | xeonx/timeago | timeago.go | FormatReference | func (cfg Config) FormatReference(t time.Time, reference time.Time) string {
d := reference.Sub(t)
if (d >= 0 && d >= cfg.Max) || (d < 0 && -d >= cfg.Max) {
return t.Format(cfg.DefaultLayout)
}
return cfg.FormatRelativeDuration(d)
} | go | func (cfg Config) FormatReference(t time.Time, reference time.Time) string {
d := reference.Sub(t)
if (d >= 0 && d >= cfg.Max) || (d < 0 && -d >= cfg.Max) {
return t.Format(cfg.DefaultLayout)
}
return cfg.FormatRelativeDuration(d)
} | [
"func",
"(",
"cfg",
"Config",
")",
"FormatReference",
"(",
"t",
"time",
".",
"Time",
",",
"reference",
"time",
".",
"Time",
")",
"string",
"{",
"d",
":=",
"reference",
".",
"Sub",
"(",
"t",
")",
"\n\n",
"if",
"(",
"d",
">=",
"0",
"&&",
"d",
">=",... | //FormatReference is the same as Format, but the reference has to be defined by the caller | [
"FormatReference",
"is",
"the",
"same",
"as",
"Format",
"but",
"the",
"reference",
"has",
"to",
"be",
"defined",
"by",
"the",
"caller"
] | 4e7d8c1f9a433881f64a7f87f51e494186857982 | https://github.com/xeonx/timeago/blob/4e7d8c1f9a433881f64a7f87f51e494186857982/timeago.go#L210-L219 |
143,875 | xeonx/timeago | timeago.go | FormatRelativeDuration | func (cfg Config) FormatRelativeDuration(d time.Duration) string {
isPast := d >= 0
if d < 0 {
d = -d
}
s, _ := cfg.getTimeText(d, true)
if isPast {
return strings.Join([]string{cfg.PastPrefix, s, cfg.PastSuffix}, "")
} else {
return strings.Join([]string{cfg.FuturePrefix, s, cfg.FutureSuffix}, "")
}
} | go | func (cfg Config) FormatRelativeDuration(d time.Duration) string {
isPast := d >= 0
if d < 0 {
d = -d
}
s, _ := cfg.getTimeText(d, true)
if isPast {
return strings.Join([]string{cfg.PastPrefix, s, cfg.PastSuffix}, "")
} else {
return strings.Join([]string{cfg.FuturePrefix, s, cfg.FutureSuffix}, "")
}
} | [
"func",
"(",
"cfg",
"Config",
")",
"FormatRelativeDuration",
"(",
"d",
"time",
".",
"Duration",
")",
"string",
"{",
"isPast",
":=",
"d",
">=",
"0",
"\n\n",
"if",
"d",
"<",
"0",
"{",
"d",
"=",
"-",
"d",
"\n",
"}",
"\n\n",
"s",
",",
"_",
":=",
"c... | //FormatRelativeDuration is the same as Format, but for time.Duration.
//Config.Max is not used in this function, as there is no other alternative. | [
"FormatRelativeDuration",
"is",
"the",
"same",
"as",
"Format",
"but",
"for",
"time",
".",
"Duration",
".",
"Config",
".",
"Max",
"is",
"not",
"used",
"in",
"this",
"function",
"as",
"there",
"is",
"no",
"other",
"alternative",
"."
] | 4e7d8c1f9a433881f64a7f87f51e494186857982 | https://github.com/xeonx/timeago/blob/4e7d8c1f9a433881f64a7f87f51e494186857982/timeago.go#L223-L238 |
143,876 | xeonx/timeago | timeago.go | round | func round(d time.Duration, step time.Duration, roundCloser bool) time.Duration {
if roundCloser {
return time.Duration(float64(d)/float64(step) + 0.5)
}
return time.Duration(float64(d) / float64(step))
} | go | func round(d time.Duration, step time.Duration, roundCloser bool) time.Duration {
if roundCloser {
return time.Duration(float64(d)/float64(step) + 0.5)
}
return time.Duration(float64(d) / float64(step))
} | [
"func",
"round",
"(",
"d",
"time",
".",
"Duration",
",",
"step",
"time",
".",
"Duration",
",",
"roundCloser",
"bool",
")",
"time",
".",
"Duration",
"{",
"if",
"roundCloser",
"{",
"return",
"time",
".",
"Duration",
"(",
"float64",
"(",
"d",
")",
"/",
... | //Round the duration d in terms of step. | [
"Round",
"the",
"duration",
"d",
"in",
"terms",
"of",
"step",
"."
] | 4e7d8c1f9a433881f64a7f87f51e494186857982 | https://github.com/xeonx/timeago/blob/4e7d8c1f9a433881f64a7f87f51e494186857982/timeago.go#L241-L248 |
143,877 | xeonx/timeago | timeago.go | nbParamInFormat | func nbParamInFormat(f string) int {
return strings.Count(f, "%") - 2*strings.Count(f, "%%")
} | go | func nbParamInFormat(f string) int {
return strings.Count(f, "%") - 2*strings.Count(f, "%%")
} | [
"func",
"nbParamInFormat",
"(",
"f",
"string",
")",
"int",
"{",
"return",
"strings",
".",
"Count",
"(",
"f",
",",
"\"",
"\"",
")",
"-",
"2",
"*",
"strings",
".",
"Count",
"(",
"f",
",",
"\"",
"\"",
")",
"\n",
"}"
] | //Count the number of parameters in a format string | [
"Count",
"the",
"number",
"of",
"parameters",
"in",
"a",
"format",
"string"
] | 4e7d8c1f9a433881f64a7f87f51e494186857982 | https://github.com/xeonx/timeago/blob/4e7d8c1f9a433881f64a7f87f51e494186857982/timeago.go#L251-L253 |
143,878 | xeonx/timeago | timeago.go | getTimeText | func (cfg Config) getTimeText(d time.Duration, roundCloser bool) (string, time.Duration) {
if len(cfg.Periods) == 0 || d < cfg.Periods[0].D {
return cfg.Zero, 0
}
for i, p := range cfg.Periods {
next := p.D
if i+1 < len(cfg.Periods) {
next = cfg.Periods[i+1].D
}
if i+1 == len(cfg.Periods) || d < next... | go | func (cfg Config) getTimeText(d time.Duration, roundCloser bool) (string, time.Duration) {
if len(cfg.Periods) == 0 || d < cfg.Periods[0].D {
return cfg.Zero, 0
}
for i, p := range cfg.Periods {
next := p.D
if i+1 < len(cfg.Periods) {
next = cfg.Periods[i+1].D
}
if i+1 == len(cfg.Periods) || d < next... | [
"func",
"(",
"cfg",
"Config",
")",
"getTimeText",
"(",
"d",
"time",
".",
"Duration",
",",
"roundCloser",
"bool",
")",
"(",
"string",
",",
"time",
".",
"Duration",
")",
"{",
"if",
"len",
"(",
"cfg",
".",
"Periods",
")",
"==",
"0",
"||",
"d",
"<",
... | //Convert a duration to a text, based on the current config | [
"Convert",
"a",
"duration",
"to",
"a",
"text",
"based",
"on",
"the",
"current",
"config"
] | 4e7d8c1f9a433881f64a7f87f51e494186857982 | https://github.com/xeonx/timeago/blob/4e7d8c1f9a433881f64a7f87f51e494186857982/timeago.go#L256-L294 |
143,879 | xeonx/timeago | timeago.go | WithMax | func WithMax(cfg Config, max time.Duration, defaultLayout string) Config {
n := cfg
n.Max = max
n.DefaultLayout = defaultLayout
return n
} | go | func WithMax(cfg Config, max time.Duration, defaultLayout string) Config {
n := cfg
n.Max = max
n.DefaultLayout = defaultLayout
return n
} | [
"func",
"WithMax",
"(",
"cfg",
"Config",
",",
"max",
"time",
".",
"Duration",
",",
"defaultLayout",
"string",
")",
"Config",
"{",
"n",
":=",
"cfg",
"\n",
"n",
".",
"Max",
"=",
"max",
"\n",
"n",
".",
"DefaultLayout",
"=",
"defaultLayout",
"\n",
"return"... | //WithMax creates an new config with special formatting limited to durations less than max.
//Values greater than max will be formatted by the standard time package using the defaultLayout. | [
"WithMax",
"creates",
"an",
"new",
"config",
"with",
"special",
"formatting",
"limited",
"to",
"durations",
"less",
"than",
"max",
".",
"Values",
"greater",
"than",
"max",
"will",
"be",
"formatted",
"by",
"the",
"standard",
"time",
"package",
"using",
"the",
... | 4e7d8c1f9a433881f64a7f87f51e494186857982 | https://github.com/xeonx/timeago/blob/4e7d8c1f9a433881f64a7f87f51e494186857982/timeago.go#L303-L308 |
143,880 | stvp/roll | stack.go | buildRollbarFrames | func buildRollbarFrames(callers []uintptr) (frames rollbarFrames) {
frames = rollbarFrames{}
// 2016-08-24 - runtime.CallersFrames was added in Go 1.7, which should
// replace the following code when roll is able to require Go 1.7+.
for _, caller := range callers {
frame := rollbarFrame{
Filename: "???",
M... | go | func buildRollbarFrames(callers []uintptr) (frames rollbarFrames) {
frames = rollbarFrames{}
// 2016-08-24 - runtime.CallersFrames was added in Go 1.7, which should
// replace the following code when roll is able to require Go 1.7+.
for _, caller := range callers {
frame := rollbarFrame{
Filename: "???",
M... | [
"func",
"buildRollbarFrames",
"(",
"callers",
"[",
"]",
"uintptr",
")",
"(",
"frames",
"rollbarFrames",
")",
"{",
"frames",
"=",
"rollbarFrames",
"{",
"}",
"\n\n",
"// 2016-08-24 - runtime.CallersFrames was added in Go 1.7, which should",
"// replace the following code when r... | // buildRollbarFrames takes a slice of function pointers and returns a Rollbar
// API payload containing the filename, method name, and line number of each
// function. | [
"buildRollbarFrames",
"takes",
"a",
"slice",
"of",
"function",
"pointers",
"and",
"returns",
"a",
"Rollbar",
"API",
"payload",
"containing",
"the",
"filename",
"method",
"name",
"and",
"line",
"number",
"of",
"each",
"function",
"."
] | 3627a5cbeaeaa68023abd02bb8687925265f2f63 | https://github.com/stvp/roll/blob/3627a5cbeaeaa68023abd02bb8687925265f2f63/stack.go#L40-L60 |
143,881 | stvp/roll | stack.go | fingerprint | func (f rollbarFrames) fingerprint() string {
hash := crc32.NewIEEE()
for _, frame := range f {
fmt.Fprintf(hash, "%s%s%d", frame.Filename, frame.Method, frame.Line)
}
return fmt.Sprintf("%x", hash.Sum32())
} | go | func (f rollbarFrames) fingerprint() string {
hash := crc32.NewIEEE()
for _, frame := range f {
fmt.Fprintf(hash, "%s%s%d", frame.Filename, frame.Method, frame.Line)
}
return fmt.Sprintf("%x", hash.Sum32())
} | [
"func",
"(",
"f",
"rollbarFrames",
")",
"fingerprint",
"(",
")",
"string",
"{",
"hash",
":=",
"crc32",
".",
"NewIEEE",
"(",
")",
"\n",
"for",
"_",
",",
"frame",
":=",
"range",
"f",
"{",
"fmt",
".",
"Fprintf",
"(",
"hash",
",",
"\"",
"\"",
",",
"f... | // fingerprint returns a checksum that uniquely identifies a stacktrace by the
// filename, method name, and line number of every frame in the stack. | [
"fingerprint",
"returns",
"a",
"checksum",
"that",
"uniquely",
"identifies",
"a",
"stacktrace",
"by",
"the",
"filename",
"method",
"name",
"and",
"line",
"number",
"of",
"every",
"frame",
"in",
"the",
"stack",
"."
] | 3627a5cbeaeaa68023abd02bb8687925265f2f63 | https://github.com/stvp/roll/blob/3627a5cbeaeaa68023abd02bb8687925265f2f63/stack.go#L64-L70 |
143,882 | stvp/roll | client.go | send | func (c *rollbarClient) send(item map[string]interface{}) (uuid string, err error) {
if len(c.token) == 0 || len(Endpoint) == 0 {
return "", nil
}
jsonBody, err := json.Marshal(item)
if err != nil {
return "", err
}
resp, err := http.Post(Endpoint, "application/json", bytes.NewReader(jsonBody))
if err != n... | go | func (c *rollbarClient) send(item map[string]interface{}) (uuid string, err error) {
if len(c.token) == 0 || len(Endpoint) == 0 {
return "", nil
}
jsonBody, err := json.Marshal(item)
if err != nil {
return "", err
}
resp, err := http.Post(Endpoint, "application/json", bytes.NewReader(jsonBody))
if err != n... | [
"func",
"(",
"c",
"*",
"rollbarClient",
")",
"send",
"(",
"item",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"uuid",
"string",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"c",
".",
"token",
")",
"==",
"0",
"||",
"len",
"("... | // send reports the given item to Rollbar and returns either a UUID for the
// reported item or an error. | [
"send",
"reports",
"the",
"given",
"item",
"to",
"Rollbar",
"and",
"returns",
"either",
"a",
"UUID",
"for",
"the",
"reported",
"item",
"or",
"an",
"error",
"."
] | 3627a5cbeaeaa68023abd02bb8687925265f2f63 | https://github.com/stvp/roll/blob/3627a5cbeaeaa68023abd02bb8687925265f2f63/client.go#L194-L226 |
143,883 | jpillora/opts | opts.go | New | func New(config interface{}) *Opts {
v := reflect.ValueOf(config)
//nil parent -> root command
o := fork(nil, v)
if o.erred != nil {
//opts has already encounted an error
return o
}
//attempt to infer package name, repo, author
pkgpath := v.Elem().Type().PkgPath()
parts := strings.Split(pkgpath, "/")
if l... | go | func New(config interface{}) *Opts {
v := reflect.ValueOf(config)
//nil parent -> root command
o := fork(nil, v)
if o.erred != nil {
//opts has already encounted an error
return o
}
//attempt to infer package name, repo, author
pkgpath := v.Elem().Type().PkgPath()
parts := strings.Split(pkgpath, "/")
if l... | [
"func",
"New",
"(",
"config",
"interface",
"{",
"}",
")",
"*",
"Opts",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"config",
")",
"\n",
"//nil parent -> root command",
"o",
":=",
"fork",
"(",
"nil",
",",
"v",
")",
"\n",
"if",
"o",
".",
"erred",
... | //New creates a new Opts instance | [
"New",
"creates",
"a",
"new",
"Opts",
"instance"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L75-L97 |
143,884 | jpillora/opts | opts.go | Name | func (o *Opts) Name(name string) *Opts {
o.name = name
return o
} | go | func (o *Opts) Name(name string) *Opts {
o.name = name
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"Name",
"(",
"name",
"string",
")",
"*",
"Opts",
"{",
"o",
".",
"name",
"=",
"name",
"\n",
"return",
"o",
"\n",
"}"
] | //Name sets the name of the program | [
"Name",
"sets",
"the",
"name",
"of",
"the",
"program"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L379-L382 |
143,885 | jpillora/opts | opts.go | Version | func (o *Opts) Version(version string) *Opts {
//add version option
g := reflect.ValueOf(&o.internalOpts).Elem()
o.addOptArg(g.Type().Field(1), g.Field(1))
o.version = version
return o
} | go | func (o *Opts) Version(version string) *Opts {
//add version option
g := reflect.ValueOf(&o.internalOpts).Elem()
o.addOptArg(g.Type().Field(1), g.Field(1))
o.version = version
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"Version",
"(",
"version",
"string",
")",
"*",
"Opts",
"{",
"//add version option",
"g",
":=",
"reflect",
".",
"ValueOf",
"(",
"&",
"o",
".",
"internalOpts",
")",
".",
"Elem",
"(",
")",
"\n",
"o",
".",
"addOptArg",... | //Version sets the version of the program
//and renders the 'version' template in the help text | [
"Version",
"sets",
"the",
"version",
"of",
"the",
"program",
"and",
"renders",
"the",
"version",
"template",
"in",
"the",
"help",
"text"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L386-L392 |
143,886 | jpillora/opts | opts.go | Repo | func (o *Opts) Repo(repo string) *Opts {
o.repo = repo
return o
} | go | func (o *Opts) Repo(repo string) *Opts {
o.repo = repo
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"Repo",
"(",
"repo",
"string",
")",
"*",
"Opts",
"{",
"o",
".",
"repo",
"=",
"repo",
"\n",
"return",
"o",
"\n",
"}"
] | //Repo sets the repository link of the program
//and renders the 'repo' template in the help text | [
"Repo",
"sets",
"the",
"repository",
"link",
"of",
"the",
"program",
"and",
"renders",
"the",
"repo",
"template",
"in",
"the",
"help",
"text"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L396-L399 |
143,887 | jpillora/opts | opts.go | Author | func (o *Opts) Author(author string) *Opts {
o.author = author
return o
} | go | func (o *Opts) Author(author string) *Opts {
o.author = author
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"Author",
"(",
"author",
"string",
")",
"*",
"Opts",
"{",
"o",
".",
"author",
"=",
"author",
"\n",
"return",
"o",
"\n",
"}"
] | //Author sets the author of the program
//and renders the 'author' template in the help text | [
"Author",
"sets",
"the",
"author",
"of",
"the",
"program",
"and",
"renders",
"the",
"author",
"template",
"in",
"the",
"help",
"text"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L414-L417 |
143,888 | jpillora/opts | opts.go | SetPadWidth | func (o *Opts) SetPadWidth(p int) *Opts {
o.PadWidth = p
return o
} | go | func (o *Opts) SetPadWidth(p int) *Opts {
o.PadWidth = p
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"SetPadWidth",
"(",
"p",
"int",
")",
"*",
"Opts",
"{",
"o",
".",
"PadWidth",
"=",
"p",
"\n",
"return",
"o",
"\n",
"}"
] | //Set the padding width | [
"Set",
"the",
"padding",
"width"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L431-L434 |
143,889 | jpillora/opts | opts.go | DocBefore | func (o *Opts) DocBefore(target, newid, template string) *Opts {
return o.docOffset(0, target, newid, template)
} | go | func (o *Opts) DocBefore(target, newid, template string) *Opts {
return o.docOffset(0, target, newid, template)
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"DocBefore",
"(",
"target",
",",
"newid",
",",
"template",
"string",
")",
"*",
"Opts",
"{",
"return",
"o",
".",
"docOffset",
"(",
"0",
",",
"target",
",",
"newid",
",",
"template",
")",
"\n",
"}"
] | //DocBefore inserts a text block before the specified template | [
"DocBefore",
"inserts",
"a",
"text",
"block",
"before",
"the",
"specified",
"template"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L449-L451 |
143,890 | jpillora/opts | opts.go | DocAfter | func (o *Opts) DocAfter(target, newid, template string) *Opts {
return o.docOffset(1, target, newid, template)
} | go | func (o *Opts) DocAfter(target, newid, template string) *Opts {
return o.docOffset(1, target, newid, template)
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"DocAfter",
"(",
"target",
",",
"newid",
",",
"template",
"string",
")",
"*",
"Opts",
"{",
"return",
"o",
".",
"docOffset",
"(",
"1",
",",
"target",
",",
"newid",
",",
"template",
")",
"\n",
"}"
] | //DocAfter inserts a text block after the specified template | [
"DocAfter",
"inserts",
"a",
"text",
"block",
"after",
"the",
"specified",
"template"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L454-L456 |
143,891 | jpillora/opts | opts.go | DocSet | func (o *Opts) DocSet(id, template string) *Opts {
if _, ok := DefaultTemplates[id]; !ok {
if _, ok := o.templates[id]; !ok {
o.errorf("template does not exist: %s", id)
return o
}
}
o.templates[id] = template
return o
} | go | func (o *Opts) DocSet(id, template string) *Opts {
if _, ok := DefaultTemplates[id]; !ok {
if _, ok := o.templates[id]; !ok {
o.errorf("template does not exist: %s", id)
return o
}
}
o.templates[id] = template
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"DocSet",
"(",
"id",
",",
"template",
"string",
")",
"*",
"Opts",
"{",
"if",
"_",
",",
"ok",
":=",
"DefaultTemplates",
"[",
"id",
"]",
";",
"!",
"ok",
"{",
"if",
"_",
",",
"ok",
":=",
"o",
".",
"templates",
... | //DecSet replaces the specified template | [
"DecSet",
"replaces",
"the",
"specified",
"template"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L480-L489 |
143,892 | jpillora/opts | opts.go | ConfigPath | func (o *Opts) ConfigPath(path string) *Opts {
o.cfgPath = path
return o
} | go | func (o *Opts) ConfigPath(path string) *Opts {
o.cfgPath = path
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"ConfigPath",
"(",
"path",
"string",
")",
"*",
"Opts",
"{",
"o",
".",
"cfgPath",
"=",
"path",
"\n",
"return",
"o",
"\n",
"}"
] | //ConfigPath defines a path to a JSON file which matches
//the structure of the provided config. Environment variables
//override JSON Config variables. | [
"ConfigPath",
"defines",
"a",
"path",
"to",
"a",
"JSON",
"file",
"which",
"matches",
"the",
"structure",
"of",
"the",
"provided",
"config",
".",
"Environment",
"variables",
"override",
"JSON",
"Config",
"variables",
"."
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L494-L497 |
143,893 | jpillora/opts | opts.go | ParseArgs | func (o *Opts) ParseArgs(args []string) *Opts {
if err := o.Process(args); err != nil {
fmt.Fprintf(os.Stderr, err.Error()+"\n")
os.Exit(1)
}
return o
} | go | func (o *Opts) ParseArgs(args []string) *Opts {
if err := o.Process(args); err != nil {
fmt.Fprintf(os.Stderr, err.Error()+"\n")
os.Exit(1)
}
return o
} | [
"func",
"(",
"o",
"*",
"Opts",
")",
"ParseArgs",
"(",
"args",
"[",
"]",
"string",
")",
"*",
"Opts",
"{",
"if",
"err",
":=",
"o",
".",
"Process",
"(",
"args",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
... | //ParseArgs with the provided arguments | [
"ParseArgs",
"with",
"the",
"provided",
"arguments"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts.go#L514-L520 |
143,894 | jpillora/opts | opts_help.go | Help | func (o *Opts) Help() string {
var err error
//final attempt at finding the program name
root := o
for root.parent != nil {
root = root.parent
}
if root.name == "" {
if exe, err := osext.Executable(); err == nil {
_, root.name = path.Split(exe)
} else {
root.name = "main"
}
}
//add default templ... | go | func (o *Opts) Help() string {
var err error
//final attempt at finding the program name
root := o
for root.parent != nil {
root = root.parent
}
if root.name == "" {
if exe, err := osext.Executable(); err == nil {
_, root.name = path.Split(exe)
} else {
root.name = "main"
}
}
//add default templ... | [
"func",
"(",
"o",
"*",
"Opts",
")",
"Help",
"(",
")",
"string",
"{",
"var",
"err",
"error",
"\n\n",
"//final attempt at finding the program name",
"root",
":=",
"o",
"\n",
"for",
"root",
".",
"parent",
"!=",
"nil",
"{",
"root",
"=",
"root",
".",
"parent"... | //Help renders the help text as a string | [
"Help",
"renders",
"the",
"help",
"text",
"as",
"a",
"string"
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/opts_help.go#L89-L167 |
143,895 | jpillora/opts | example/separation/foo/foo.go | New | func New(c Config) (*Foo, error) {
//ensure proper initialization of Foo
foo := &Foo{
c: c,
bar: 42 + c.Zip,
bazz: 21 + c.Zop,
}
return foo, nil
} | go | func New(c Config) (*Foo, error) {
//ensure proper initialization of Foo
foo := &Foo{
c: c,
bar: 42 + c.Zip,
bazz: 21 + c.Zop,
}
return foo, nil
} | [
"func",
"New",
"(",
"c",
"Config",
")",
"(",
"*",
"Foo",
",",
"error",
")",
"{",
"//ensure proper initialization of Foo",
"foo",
":=",
"&",
"Foo",
"{",
"c",
":",
"c",
",",
"bar",
":",
"42",
"+",
"c",
".",
"Zip",
",",
"bazz",
":",
"21",
"+",
"c",
... | //use a Config value, not Config pointer.
//this prevents future modification from outside the library. | [
"use",
"a",
"Config",
"value",
"not",
"Config",
"pointer",
".",
"this",
"prevents",
"future",
"modification",
"from",
"outside",
"the",
"library",
"."
] | 3f7962811f238e35bdbd9a74cbfcd45b209dd298 | https://github.com/jpillora/opts/blob/3f7962811f238e35bdbd9a74cbfcd45b209dd298/example/separation/foo/foo.go#L14-L23 |
143,896 | goji/param | error_helpers.go | pebkac | func pebkac(format string, a ...interface{}) {
err := errors.New(errPrefix + fmt.Sprintf(format, a...) + yourFault)
if pebkacTesting {
panic(err)
} else {
log.Fatal(err)
}
} | go | func pebkac(format string, a ...interface{}) {
err := errors.New(errPrefix + fmt.Sprintf(format, a...) + yourFault)
if pebkacTesting {
panic(err)
} else {
log.Fatal(err)
}
} | [
"func",
"pebkac",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"err",
":=",
"errors",
".",
"New",
"(",
"errPrefix",
"+",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"a",
"...",
")",
"+",
"yourFault",
")",
"\n",
"if",
... | // Problem exists between keyboard and chair. This function is used in cases of
// programmer error, i.e. an inappropriate use of the param library, to
// immediately force the program to halt with a hopefully helpful error message. | [
"Problem",
"exists",
"between",
"keyboard",
"and",
"chair",
".",
"This",
"function",
"is",
"used",
"in",
"cases",
"of",
"programmer",
"error",
"i",
".",
"e",
".",
"an",
"inappropriate",
"use",
"of",
"the",
"param",
"library",
"to",
"immediately",
"force",
... | d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2 | https://github.com/goji/param/blob/d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2/error_helpers.go#L18-L25 |
143,897 | goji/param | struct.go | extractName | func extractName(sf reflect.StructField) string {
name := sf.Tag.Get("param")
if name == "" {
name = sf.Tag.Get("json")
idx := strings.IndexRune(name, ',')
if idx >= 0 {
name = name[:idx]
}
}
if name == "" {
name = sf.Name
}
return name
} | go | func extractName(sf reflect.StructField) string {
name := sf.Tag.Get("param")
if name == "" {
name = sf.Tag.Get("json")
idx := strings.IndexRune(name, ',')
if idx >= 0 {
name = name[:idx]
}
}
if name == "" {
name = sf.Name
}
return name
} | [
"func",
"extractName",
"(",
"sf",
"reflect",
".",
"StructField",
")",
"string",
"{",
"name",
":=",
"sf",
".",
"Tag",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"name",
"==",
"\"",
"\"",
"{",
"name",
"=",
"sf",
".",
"Tag",
".",
"Get",
"(",
"\... | // Extract the name of the given struct field, looking at struct tags as
// appropriate. | [
"Extract",
"the",
"name",
"of",
"the",
"given",
"struct",
"field",
"looking",
"at",
"struct",
"tags",
"as",
"appropriate",
"."
] | d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2 | https://github.com/goji/param/blob/d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2/struct.go#L58-L72 |
143,898 | goji/param | param.go | Parse | func Parse(params url.Values, target interface{}) (err error) {
v := reflect.ValueOf(target)
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
panic(err)
}
}
}()
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
pebkac("Target of param.Pars... | go | func Parse(params url.Values, target interface{}) (err error) {
v := reflect.ValueOf(target)
defer func() {
if r := recover(); r != nil {
var ok bool
err, ok = r.(error)
if !ok {
panic(err)
}
}
}()
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
pebkac("Target of param.Pars... | [
"func",
"Parse",
"(",
"params",
"url",
".",
"Values",
",",
"target",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"target",
")",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"re... | // Parse the given arguments into the the given pointer to a struct object. | [
"Parse",
"the",
"given",
"arguments",
"into",
"the",
"the",
"given",
"pointer",
"to",
"a",
"struct",
"object",
"."
] | d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2 | https://github.com/goji/param/blob/d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2/param.go#L29-L60 |
143,899 | goji/param | parse.go | primitive | func primitive(key, keytail string, tipe reflect.Type, values []string) {
if keytail != "" {
panic(NestingError{
Key: kpath(key, keytail),
Type: tipe,
Nesting: keytail,
})
}
if len(values) != 1 {
panic(SingletonError{
Key: kpath(key, keytail),
Type: tipe,
Values: values,
})
}
} | go | func primitive(key, keytail string, tipe reflect.Type, values []string) {
if keytail != "" {
panic(NestingError{
Key: kpath(key, keytail),
Type: tipe,
Nesting: keytail,
})
}
if len(values) != 1 {
panic(SingletonError{
Key: kpath(key, keytail),
Type: tipe,
Values: values,
})
}
} | [
"func",
"primitive",
"(",
"key",
",",
"keytail",
"string",
",",
"tipe",
"reflect",
".",
"Type",
",",
"values",
"[",
"]",
"string",
")",
"{",
"if",
"keytail",
"!=",
"\"",
"\"",
"{",
"panic",
"(",
"NestingError",
"{",
"Key",
":",
"kpath",
"(",
"key",
... | // Helper for validating that a value has been passed exactly once, and that the
// user is not attempting to nest on the key. | [
"Helper",
"for",
"validating",
"that",
"a",
"value",
"has",
"been",
"passed",
"exactly",
"once",
"and",
"that",
"the",
"user",
"is",
"not",
"attempting",
"to",
"nest",
"on",
"the",
"key",
"."
] | d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2 | https://github.com/goji/param/blob/d7f49fd7d1ed53fd562e737a8b5bbcc7e3d925e2/parse.go#L62-L77 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.