id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,900 | reconquest/hierr-go | hierr.go | GetNested | func (err Error) GetNested() []NestedError {
children, ok := err.Nested.([]NestedError)
if !ok {
children = []NestedError{}
if err.Nested != nil {
children = append(children, err.Nested)
}
}
return children
} | go | func (err Error) GetNested() []NestedError {
children, ok := err.Nested.([]NestedError)
if !ok {
children = []NestedError{}
if err.Nested != nil {
children = append(children, err.Nested)
}
}
return children
} | [
"func",
"(",
"err",
"Error",
")",
"GetNested",
"(",
")",
"[",
"]",
"NestedError",
"{",
"children",
",",
"ok",
":=",
"err",
".",
"Nested",
".",
"(",
"[",
"]",
"NestedError",
")",
"\n",
"if",
"!",
"ok",
"{",
"children",
"=",
"[",
"]",
"NestedError",
... | // GetNested returns nested errors, embedded into error. | [
"GetNested",
"returns",
"nested",
"errors",
"embedded",
"into",
"error",
"."
] | 7d09c0176fd2bb7fd71a4349d1253eef9edb2c5c | https://github.com/reconquest/hierr-go/blob/7d09c0176fd2bb7fd71a4349d1253eef9edb2c5c/hierr.go#L152-L162 |
145,901 | reconquest/hierr-go | hierr.go | Push | func Push(topError NestedError, childError ...NestedError) error {
parent, ok := topError.(Error)
if !ok {
parent = Error{
Message: String(topError),
}
}
children := parent.GetNested()
children = append(children, childError...)
return Error{
Message: parent.Message,
Nested: children,
}
} | go | func Push(topError NestedError, childError ...NestedError) error {
parent, ok := topError.(Error)
if !ok {
parent = Error{
Message: String(topError),
}
}
children := parent.GetNested()
children = append(children, childError...)
return Error{
Message: parent.Message,
Nested: children,
}
} | [
"func",
"Push",
"(",
"topError",
"NestedError",
",",
"childError",
"...",
"NestedError",
")",
"error",
"{",
"parent",
",",
"ok",
":=",
"topError",
".",
"(",
"Error",
")",
"\n",
"if",
"!",
"ok",
"{",
"parent",
"=",
"Error",
"{",
"Message",
":",
"String"... | // Push creates new hierarchy error with multiple branches separated by
// separator, delimited by delimiter and prolongated by prolongator. | [
"Push",
"creates",
"new",
"hierarchy",
"error",
"with",
"multiple",
"branches",
"separated",
"by",
"separator",
"delimited",
"by",
"delimiter",
"and",
"prolongated",
"by",
"prolongator",
"."
] | 7d09c0176fd2bb7fd71a4349d1253eef9edb2c5c | https://github.com/reconquest/hierr-go/blob/7d09c0176fd2bb7fd71a4349d1253eef9edb2c5c/hierr.go#L176-L192 |
145,902 | kaneshin/pigeon | cmd/pigeon/flag.go | DetectionsParse | func DetectionsParse(args []string) *Detections {
f := flag.NewFlagSet("Detections", flag.ExitOnError)
faceDetection := f.Bool("face", false, "This flag specifies the face detection of the feature")
landmarkDetection := f.Bool("landmark", false, "This flag specifies the landmark detection of the feature")
logoDetec... | go | func DetectionsParse(args []string) *Detections {
f := flag.NewFlagSet("Detections", flag.ExitOnError)
faceDetection := f.Bool("face", false, "This flag specifies the face detection of the feature")
landmarkDetection := f.Bool("landmark", false, "This flag specifies the landmark detection of the feature")
logoDetec... | [
"func",
"DetectionsParse",
"(",
"args",
"[",
"]",
"string",
")",
"*",
"Detections",
"{",
"f",
":=",
"flag",
".",
"NewFlagSet",
"(",
"\"",
"\"",
",",
"flag",
".",
"ExitOnError",
")",
"\n",
"faceDetection",
":=",
"f",
".",
"Bool",
"(",
"\"",
"\"",
",",... | // DetectionsParse parses the command-line flags from arguments and returns
// a new pointer of a Detections object.. | [
"DetectionsParse",
"parses",
"the",
"command",
"-",
"line",
"flags",
"from",
"arguments",
"and",
"returns",
"a",
"new",
"pointer",
"of",
"a",
"Detections",
"object",
".."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/cmd/pigeon/flag.go#L30-L53 |
145,903 | kaneshin/pigeon | cmd/pigeon/flag.go | Features | func (d *Detections) Features() []*vision.Feature {
list := []int{}
if d.face {
list = append(list, pigeon.FaceDetection)
}
if d.landmark {
list = append(list, pigeon.LandmarkDetection)
}
if d.logo {
list = append(list, pigeon.LogoDetection)
}
if d.label {
list = append(list, pigeon.LabelDetection)
}
... | go | func (d *Detections) Features() []*vision.Feature {
list := []int{}
if d.face {
list = append(list, pigeon.FaceDetection)
}
if d.landmark {
list = append(list, pigeon.LandmarkDetection)
}
if d.logo {
list = append(list, pigeon.LogoDetection)
}
if d.label {
list = append(list, pigeon.LabelDetection)
}
... | [
"func",
"(",
"d",
"*",
"Detections",
")",
"Features",
"(",
")",
"[",
"]",
"*",
"vision",
".",
"Feature",
"{",
"list",
":=",
"[",
"]",
"int",
"{",
"}",
"\n",
"if",
"d",
".",
"face",
"{",
"list",
"=",
"append",
"(",
"list",
",",
"pigeon",
".",
... | // Features returns a slice of pointers of vision.Feature. | [
"Features",
"returns",
"a",
"slice",
"of",
"pointers",
"of",
"vision",
".",
"Feature",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/cmd/pigeon/flag.go#L66-L99 |
145,904 | phrase/phraseapp-go | phraseapp/config.go | ReadConfig | func ReadConfig() (*Config, error) {
cfg := &Config{}
rawCfg := struct{ PhraseApp *Config }{PhraseApp: cfg}
content, err := configContent()
switch {
case err != nil:
return nil, err
case content == nil:
return cfg, nil
default:
return cfg, yaml.Unmarshal(content, rawCfg)
}
} | go | func ReadConfig() (*Config, error) {
cfg := &Config{}
rawCfg := struct{ PhraseApp *Config }{PhraseApp: cfg}
content, err := configContent()
switch {
case err != nil:
return nil, err
case content == nil:
return cfg, nil
default:
return cfg, yaml.Unmarshal(content, rawCfg)
}
} | [
"func",
"ReadConfig",
"(",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"cfg",
":=",
"&",
"Config",
"{",
"}",
"\n",
"rawCfg",
":=",
"struct",
"{",
"PhraseApp",
"*",
"Config",
"}",
"{",
"PhraseApp",
":",
"cfg",
"}",
"\n\n",
"content",
",",
"err"... | // ReadConfig reads a .phraseapp.yml config file | [
"ReadConfig",
"reads",
"a",
".",
"phraseapp",
".",
"yml",
"config",
"file"
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/config.go#L32-L45 |
145,905 | phrase/phraseapp-go | phraseapp/client.go | NewClient | func NewClient(credentials Credentials, debug bool) (*Client, error) {
credentials.init()
client := &Client{
Credentials: credentials,
debug: debug,
}
return client, nil
} | go | func NewClient(credentials Credentials, debug bool) (*Client, error) {
credentials.init()
client := &Client{
Credentials: credentials,
debug: debug,
}
return client, nil
} | [
"func",
"NewClient",
"(",
"credentials",
"Credentials",
",",
"debug",
"bool",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"credentials",
".",
"init",
"(",
")",
"\n",
"client",
":=",
"&",
"Client",
"{",
"Credentials",
":",
"credentials",
",",
"debug"... | // NewClient initializes a new client.
// Uses PHRASEAPP_HOST and PHRASEAPP_ACCESS_TOKEN environment variables for host and access token with specified in environment. | [
"NewClient",
"initializes",
"a",
"new",
"client",
".",
"Uses",
"PHRASEAPP_HOST",
"and",
"PHRASEAPP_ACCESS_TOKEN",
"environment",
"variables",
"for",
"host",
"and",
"access",
"token",
"with",
"specified",
"in",
"environment",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/client.go#L34-L42 |
145,906 | phrase/phraseapp-go | phraseapp/client.go | EnableCaching | func (client *Client) EnableCaching(config CacheConfig) error {
cache, err := newHTTPCacheClient(client.debug, config)
if err != nil {
return err
}
client.Transport = cache
return nil
} | go | func (client *Client) EnableCaching(config CacheConfig) error {
cache, err := newHTTPCacheClient(client.debug, config)
if err != nil {
return err
}
client.Transport = cache
return nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"EnableCaching",
"(",
"config",
"CacheConfig",
")",
"error",
"{",
"cache",
",",
"err",
":=",
"newHTTPCacheClient",
"(",
"client",
".",
"debug",
",",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // EnableCaching for API requests on disk via etags | [
"EnableCaching",
"for",
"API",
"requests",
"on",
"disk",
"via",
"etags"
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/client.go#L45-L53 |
145,907 | kaneshin/pigeon | credentials/application_credentials_provider.go | NewApplicationCredentials | func NewApplicationCredentials(filename string) *Credentials {
return NewCredentials(&ApplicationCredentialsProvider{
Filename: filename,
retrieved: false,
})
} | go | func NewApplicationCredentials(filename string) *Credentials {
return NewCredentials(&ApplicationCredentialsProvider{
Filename: filename,
retrieved: false,
})
} | [
"func",
"NewApplicationCredentials",
"(",
"filename",
"string",
")",
"*",
"Credentials",
"{",
"return",
"NewCredentials",
"(",
"&",
"ApplicationCredentialsProvider",
"{",
"Filename",
":",
"filename",
",",
"retrieved",
":",
"false",
",",
"}",
")",
"\n",
"}"
] | // NewApplicationCredentials returns a pointer to a new Credentials object
// wrapping the file provider. | [
"NewApplicationCredentials",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Credentials",
"object",
"wrapping",
"the",
"file",
"provider",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/credentials/application_credentials_provider.go#L24-L29 |
145,908 | kaneshin/pigeon | credentials/application_credentials_provider.go | filename | func (p *ApplicationCredentialsProvider) filename() (string, error) {
if p.Filename == "" {
if p.Filename = os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"); p.Filename == "" {
return "", fmt.Errorf("Unable to read GOOGLE_APPLICATION_CREDENTIALS")
}
}
return p.Filename, nil
} | go | func (p *ApplicationCredentialsProvider) filename() (string, error) {
if p.Filename == "" {
if p.Filename = os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"); p.Filename == "" {
return "", fmt.Errorf("Unable to read GOOGLE_APPLICATION_CREDENTIALS")
}
}
return p.Filename, nil
} | [
"func",
"(",
"p",
"*",
"ApplicationCredentialsProvider",
")",
"filename",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"p",
".",
"Filename",
"==",
"\"",
"\"",
"{",
"if",
"p",
".",
"Filename",
"=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")"... | // filename returns the filename to use to read google application credentials.
// Will return an error if the user's home directory path cannot be found. | [
"filename",
"returns",
"the",
"filename",
"to",
"use",
"to",
"read",
"google",
"application",
"credentials",
".",
"Will",
"return",
"an",
"error",
"if",
"the",
"user",
"s",
"home",
"directory",
"path",
"cannot",
"be",
"found",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/credentials/application_credentials_provider.go#L58-L65 |
145,909 | phrase/phraseapp-go | phraseapp/lib.go | AccountsList | func (client *Client) AccountsList(page, perPage int) ([]*Account, error) {
retVal := []*Account{}
err := func() error {
url := fmt.Sprintf("/v2/accounts")
rc, err := client.sendRequestPaginated("GET", url, "", nil, 200, page, perPage)
if err != nil {
return err
}
defer rc.Close()
var reader io.Read... | go | func (client *Client) AccountsList(page, perPage int) ([]*Account, error) {
retVal := []*Account{}
err := func() error {
url := fmt.Sprintf("/v2/accounts")
rc, err := client.sendRequestPaginated("GET", url, "", nil, 200, page, perPage)
if err != nil {
return err
}
defer rc.Close()
var reader io.Read... | [
"func",
"(",
"client",
"*",
"Client",
")",
"AccountsList",
"(",
"page",
",",
"perPage",
"int",
")",
"(",
"[",
"]",
"*",
"Account",
",",
"error",
")",
"{",
"retVal",
":=",
"[",
"]",
"*",
"Account",
"{",
"}",
"\n",
"err",
":=",
"func",
"(",
")",
... | // List all accounts the current user has access to. | [
"List",
"all",
"accounts",
"the",
"current",
"user",
"has",
"access",
"to",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L1855-L1878 |
145,910 | phrase/phraseapp-go | phraseapp/lib.go | BitbucketSyncsList | func (client *Client) BitbucketSyncsList(page, perPage int, params *BitbucketSyncParams) ([]*BitbucketSync, error) {
retVal := []*BitbucketSync{}
err := func() error {
url := fmt.Sprintf("/v2/bitbucket_syncs")
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms)
if err != nil ... | go | func (client *Client) BitbucketSyncsList(page, perPage int, params *BitbucketSyncParams) ([]*BitbucketSync, error) {
retVal := []*BitbucketSync{}
err := func() error {
url := fmt.Sprintf("/v2/bitbucket_syncs")
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms)
if err != nil ... | [
"func",
"(",
"client",
"*",
"Client",
")",
"BitbucketSyncsList",
"(",
"page",
",",
"perPage",
"int",
",",
"params",
"*",
"BitbucketSyncParams",
")",
"(",
"[",
"]",
"*",
"BitbucketSync",
",",
"error",
")",
"{",
"retVal",
":=",
"[",
"]",
"*",
"BitbucketSyn... | // List all Bitbucket repositories for which synchronisation with PhraseApp is activated. | [
"List",
"all",
"Bitbucket",
"repositories",
"for",
"which",
"synchronisation",
"with",
"PhraseApp",
"is",
"activated",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L2071-L2100 |
145,911 | phrase/phraseapp-go | phraseapp/lib.go | BranchCompare | func (client *Client) BranchCompare(project_id, id string, params *BranchParams) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/branches/%s/compare", url.QueryEscape(project_id), url.QueryEscape(id))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms)
if er... | go | func (client *Client) BranchCompare(project_id, id string, params *BranchParams) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/branches/%s/compare", url.QueryEscape(project_id), url.QueryEscape(id))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms)
if er... | [
"func",
"(",
"client",
"*",
"Client",
")",
"BranchCompare",
"(",
"project_id",
",",
"id",
"string",
",",
"params",
"*",
"BranchParams",
")",
"error",
"{",
"err",
":=",
"func",
"(",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"... | // Compare branch with main branch. | [
"Compare",
"branch",
"with",
"main",
"branch",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L2237-L2258 |
145,912 | phrase/phraseapp-go | phraseapp/lib.go | BranchDelete | func (client *Client) BranchDelete(project_id, id string) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/branches/%s", url.QueryEscape(project_id), url.QueryEscape(id))
rc, err := client.sendRequest("DELETE", url, "", nil, 204)
if err != nil {
return err
}
defer rc.Close()
return ... | go | func (client *Client) BranchDelete(project_id, id string) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/branches/%s", url.QueryEscape(project_id), url.QueryEscape(id))
rc, err := client.sendRequest("DELETE", url, "", nil, 204)
if err != nil {
return err
}
defer rc.Close()
return ... | [
"func",
"(",
"client",
"*",
"Client",
")",
"BranchDelete",
"(",
"project_id",
",",
"id",
"string",
")",
"error",
"{",
"err",
":=",
"func",
"(",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
... | // Delete an existing branch. | [
"Delete",
"an",
"existing",
"branch",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L2293-L2308 |
145,913 | phrase/phraseapp-go | phraseapp/lib.go | LocaleCreate | func (client *Client) LocaleCreate(project_id string, params *LocaleParams) (*LocaleDetails, error) {
retVal := new(LocaleDetails)
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/locales", url.QueryEscape(project_id))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms... | go | func (client *Client) LocaleCreate(project_id string, params *LocaleParams) (*LocaleDetails, error) {
retVal := new(LocaleDetails)
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/locales", url.QueryEscape(project_id))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms... | [
"func",
"(",
"client",
"*",
"Client",
")",
"LocaleCreate",
"(",
"project_id",
"string",
",",
"params",
"*",
"LocaleParams",
")",
"(",
"*",
"LocaleDetails",
",",
"error",
")",
"{",
"retVal",
":=",
"new",
"(",
"LocaleDetails",
")",
"\n",
"err",
":=",
"func... | // Create a new locale. | [
"Create",
"a",
"new",
"locale",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L5261-L5290 |
145,914 | phrase/phraseapp-go | phraseapp/lib.go | LocaleDownload | func (client *Client) LocaleDownload(project_id, id string, params *LocaleDownloadParams) ([]byte, error) {
retVal := []byte{}
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/locales/%s/download", url.QueryEscape(project_id), url.QueryEscape(id))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEnco... | go | func (client *Client) LocaleDownload(project_id, id string, params *LocaleDownloadParams) ([]byte, error) {
retVal := []byte{}
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/locales/%s/download", url.QueryEscape(project_id), url.QueryEscape(id))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEnco... | [
"func",
"(",
"client",
"*",
"Client",
")",
"LocaleDownload",
"(",
"project_id",
",",
"id",
"string",
",",
"params",
"*",
"LocaleDownloadParams",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"retVal",
":=",
"[",
"]",
"byte",
"{",
"}",
"\n",
"er... | // Download a locale in a specific file format. | [
"Download",
"a",
"locale",
"in",
"a",
"specific",
"file",
"format",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L5469-L5499 |
145,915 | phrase/phraseapp-go | phraseapp/lib.go | ReleaseShow | func (client *Client) ReleaseShow(account_id, distribution_id, id string) (*Release, error) {
retVal := new(Release)
err := func() error {
url := fmt.Sprintf("/v2/accounts/%s/distributions/%s/releases/%s", url.QueryEscape(account_id), url.QueryEscape(distribution_id), url.QueryEscape(id))
rc, err := client.send... | go | func (client *Client) ReleaseShow(account_id, distribution_id, id string) (*Release, error) {
retVal := new(Release)
err := func() error {
url := fmt.Sprintf("/v2/accounts/%s/distributions/%s/releases/%s", url.QueryEscape(account_id), url.QueryEscape(distribution_id), url.QueryEscape(id))
rc, err := client.send... | [
"func",
"(",
"client",
"*",
"Client",
")",
"ReleaseShow",
"(",
"account_id",
",",
"distribution_id",
",",
"id",
"string",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"retVal",
":=",
"new",
"(",
"Release",
")",
"\n",
"err",
":=",
"func",
"(",
")... | // Get details on a single release. | [
"Get",
"details",
"on",
"a",
"single",
"release",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L6352-L6375 |
145,916 | phrase/phraseapp-go | phraseapp/lib.go | ReleasesList | func (client *Client) ReleasesList(account_id, distribution_id string, page, perPage int) ([]*ReleasePreview, error) {
retVal := []*ReleasePreview{}
err := func() error {
url := fmt.Sprintf("/v2/accounts/%s/distributions/%s/releases", url.QueryEscape(account_id), url.QueryEscape(distribution_id))
rc, err := cli... | go | func (client *Client) ReleasesList(account_id, distribution_id string, page, perPage int) ([]*ReleasePreview, error) {
retVal := []*ReleasePreview{}
err := func() error {
url := fmt.Sprintf("/v2/accounts/%s/distributions/%s/releases", url.QueryEscape(account_id), url.QueryEscape(distribution_id))
rc, err := cli... | [
"func",
"(",
"client",
"*",
"Client",
")",
"ReleasesList",
"(",
"account_id",
",",
"distribution_id",
"string",
",",
"page",
",",
"perPage",
"int",
")",
"(",
"[",
"]",
"*",
"ReleasePreview",
",",
"error",
")",
"{",
"retVal",
":=",
"[",
"]",
"*",
"Relea... | // List all releases for the given distribution. | [
"List",
"all",
"releases",
"for",
"the",
"given",
"distribution",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L6410-L6433 |
145,917 | phrase/phraseapp-go | phraseapp/lib.go | ScreenshotCreate | func (client *Client) ScreenshotCreate(project_id string, params *ScreenshotParams) (*Screenshot, error) {
retVal := new(Screenshot)
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/screenshots", url.QueryEscape(project_id))
paramsBuf := bytes.NewBuffer(nil)
writer := multipart.NewWriter(paramsBuf)
... | go | func (client *Client) ScreenshotCreate(project_id string, params *ScreenshotParams) (*Screenshot, error) {
retVal := new(Screenshot)
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/screenshots", url.QueryEscape(project_id))
paramsBuf := bytes.NewBuffer(nil)
writer := multipart.NewWriter(paramsBuf)
... | [
"func",
"(",
"client",
"*",
"Client",
")",
"ScreenshotCreate",
"(",
"project_id",
"string",
",",
"params",
"*",
"ScreenshotParams",
")",
"(",
"*",
"Screenshot",
",",
"error",
")",
"{",
"retVal",
":=",
"new",
"(",
"Screenshot",
")",
"\n",
"err",
":=",
"fu... | // Create a new screenshot. | [
"Create",
"a",
"new",
"screenshot",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L6436-L6498 |
145,918 | phrase/phraseapp-go | phraseapp/lib.go | ScreenshotMarkerDelete | func (client *Client) ScreenshotMarkerDelete(project_id, screenshot_id string) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/screenshots/%s/markers", url.QueryEscape(project_id), url.QueryEscape(screenshot_id))
rc, err := client.sendRequest("DELETE", url, "", nil, 204)
if err != nil {
r... | go | func (client *Client) ScreenshotMarkerDelete(project_id, screenshot_id string) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/screenshots/%s/markers", url.QueryEscape(project_id), url.QueryEscape(screenshot_id))
rc, err := client.sendRequest("DELETE", url, "", nil, 204)
if err != nil {
r... | [
"func",
"(",
"client",
"*",
"Client",
")",
"ScreenshotMarkerDelete",
"(",
"project_id",
",",
"screenshot_id",
"string",
")",
"error",
"{",
"err",
":=",
"func",
"(",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
"."... | // Delete an existing screenshot marker. | [
"Delete",
"an",
"existing",
"screenshot",
"marker",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L6642-L6657 |
145,919 | phrase/phraseapp-go | phraseapp/lib.go | ShowUser | func (client *Client) ShowUser() (*User, error) {
retVal := new(User)
err := func() error {
url := fmt.Sprintf("/v2/user")
rc, err := client.sendRequest("GET", url, "", nil, 200)
if err != nil {
return err
}
defer rc.Close()
var reader io.Reader
if client.debug {
reader = io.TeeReader(rc, os.St... | go | func (client *Client) ShowUser() (*User, error) {
retVal := new(User)
err := func() error {
url := fmt.Sprintf("/v2/user")
rc, err := client.sendRequest("GET", url, "", nil, 200)
if err != nil {
return err
}
defer rc.Close()
var reader io.Reader
if client.debug {
reader = io.TeeReader(rc, os.St... | [
"func",
"(",
"client",
"*",
"Client",
")",
"ShowUser",
"(",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"retVal",
":=",
"new",
"(",
"User",
")",
"\n",
"err",
":=",
"func",
"(",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\""... | // Show details for current User. | [
"Show",
"details",
"for",
"current",
"User",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L6770-L6793 |
145,920 | phrase/phraseapp-go | phraseapp/lib.go | TagDelete | func (client *Client) TagDelete(project_id, name string, params *TagDeleteParams) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/tags/%s", url.QueryEscape(project_id), url.QueryEscape(name))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms)
if err != nil ... | go | func (client *Client) TagDelete(project_id, name string, params *TagDeleteParams) error {
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/tags/%s", url.QueryEscape(project_id), url.QueryEscape(name))
paramsBuf := bytes.NewBuffer(nil)
err := json.NewEncoder(paramsBuf).Encode(¶ms)
if err != nil ... | [
"func",
"(",
"client",
"*",
"Client",
")",
"TagDelete",
"(",
"project_id",
",",
"name",
"string",
",",
"params",
"*",
"TagDeleteParams",
")",
"error",
"{",
"err",
":=",
"func",
"(",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\... | // Delete an existing tag. | [
"Delete",
"an",
"existing",
"tag",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L6984-L7005 |
145,921 | phrase/phraseapp-go | phraseapp/lib.go | TranslationsByKey | func (client *Client) TranslationsByKey(project_id, key_id string, page, perPage int, params *TranslationsByKeyParams) ([]*Translation, error) {
retVal := []*Translation{}
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/keys/%s/translations", url.QueryEscape(project_id), url.QueryEscape(key_id))
param... | go | func (client *Client) TranslationsByKey(project_id, key_id string, page, perPage int, params *TranslationsByKeyParams) ([]*Translation, error) {
retVal := []*Translation{}
err := func() error {
url := fmt.Sprintf("/v2/projects/%s/keys/%s/translations", url.QueryEscape(project_id), url.QueryEscape(key_id))
param... | [
"func",
"(",
"client",
"*",
"Client",
")",
"TranslationsByKey",
"(",
"project_id",
",",
"key_id",
"string",
",",
"page",
",",
"perPage",
"int",
",",
"params",
"*",
"TranslationsByKeyParams",
")",
"(",
"[",
"]",
"*",
"Translation",
",",
"error",
")",
"{",
... | // List translations for a specific key. | [
"List",
"translations",
"for",
"a",
"specific",
"key",
"."
] | 5e14eb4aa27584a866c882648bcaa6197a49f2f9 | https://github.com/phrase/phraseapp-go/blob/5e14eb4aa27584a866c882648bcaa6197a49f2f9/phraseapp/lib.go#L7334-L7363 |
145,922 | kaneshin/pigeon | client.go | New | func New(c *Config, httpClient ...*http.Client) (*Client, error) {
if c == nil {
// Sets a configuration if passed nil value.
c = NewConfig()
}
// Use HTTP Client if assigned
if len(httpClient) > 0 {
srv, err := vision.New(httpClient[0])
if err != nil {
return nil, fmt.Errorf("Unable to retrieve vision ... | go | func New(c *Config, httpClient ...*http.Client) (*Client, error) {
if c == nil {
// Sets a configuration if passed nil value.
c = NewConfig()
}
// Use HTTP Client if assigned
if len(httpClient) > 0 {
srv, err := vision.New(httpClient[0])
if err != nil {
return nil, fmt.Errorf("Unable to retrieve vision ... | [
"func",
"New",
"(",
"c",
"*",
"Config",
",",
"httpClient",
"...",
"*",
"http",
".",
"Client",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"c",
"==",
"nil",
"{",
"// Sets a configuration if passed nil value.",
"c",
"=",
"NewConfig",
"(",
")",
... | // New returns a pointer to a new Client object. | [
"New",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Client",
"object",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/client.go#L34-L78 |
145,923 | kaneshin/pigeon | client.go | NewBatchAnnotateImageRequest | func (c Client) NewBatchAnnotateImageRequest(list []string, features ...*vision.Feature) (*vision.BatchAnnotateImagesRequest, error) {
batch := &vision.BatchAnnotateImagesRequest{}
batch.Requests = []*vision.AnnotateImageRequest{}
for _, v := range list {
req, err := c.NewAnnotateImageRequest(v, features...)
if ... | go | func (c Client) NewBatchAnnotateImageRequest(list []string, features ...*vision.Feature) (*vision.BatchAnnotateImagesRequest, error) {
batch := &vision.BatchAnnotateImagesRequest{}
batch.Requests = []*vision.AnnotateImageRequest{}
for _, v := range list {
req, err := c.NewAnnotateImageRequest(v, features...)
if ... | [
"func",
"(",
"c",
"Client",
")",
"NewBatchAnnotateImageRequest",
"(",
"list",
"[",
"]",
"string",
",",
"features",
"...",
"*",
"vision",
".",
"Feature",
")",
"(",
"*",
"vision",
".",
"BatchAnnotateImagesRequest",
",",
"error",
")",
"{",
"batch",
":=",
"&",... | // NewBatchAnnotateImageRequest returns a pointer to a new vision's BatchAnnotateImagesRequest. | [
"NewBatchAnnotateImageRequest",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"vision",
"s",
"BatchAnnotateImagesRequest",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/client.go#L86-L97 |
145,924 | kaneshin/pigeon | client.go | NewAnnotateImageRequest | func (c Client) NewAnnotateImageRequest(v interface{}, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
switch v.(type) {
case []byte:
// base64
return NewAnnotateImageContentRequest(v.([]byte), features...)
case string:
u, err := url.Parse(v.(string))
if err != nil {
return nil, err
... | go | func (c Client) NewAnnotateImageRequest(v interface{}, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
switch v.(type) {
case []byte:
// base64
return NewAnnotateImageContentRequest(v.([]byte), features...)
case string:
u, err := url.Parse(v.(string))
if err != nil {
return nil, err
... | [
"func",
"(",
"c",
"Client",
")",
"NewAnnotateImageRequest",
"(",
"v",
"interface",
"{",
"}",
",",
"features",
"...",
"*",
"vision",
".",
"Feature",
")",
"(",
"*",
"vision",
".",
"AnnotateImageRequest",
",",
"error",
")",
"{",
"switch",
"v",
".",
"(",
"... | // NewAnnotateImageRequest returns a pointer to a new vision's AnnotateImagesRequest. | [
"NewAnnotateImageRequest",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"vision",
"s",
"AnnotateImagesRequest",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/client.go#L100-L143 |
145,925 | kaneshin/pigeon | client.go | NewAnnotateImageContentRequest | func NewAnnotateImageContentRequest(body []byte, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
req := &vision.AnnotateImageRequest{
Image: NewAnnotateImageContent(body),
Features: features,
}
return req, nil
} | go | func NewAnnotateImageContentRequest(body []byte, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
req := &vision.AnnotateImageRequest{
Image: NewAnnotateImageContent(body),
Features: features,
}
return req, nil
} | [
"func",
"NewAnnotateImageContentRequest",
"(",
"body",
"[",
"]",
"byte",
",",
"features",
"...",
"*",
"vision",
".",
"Feature",
")",
"(",
"*",
"vision",
".",
"AnnotateImageRequest",
",",
"error",
")",
"{",
"req",
":=",
"&",
"vision",
".",
"AnnotateImageReque... | // NewAnnotateImageContentRequest returns a pointer to a new vision's AnnotateImagesRequest. | [
"NewAnnotateImageContentRequest",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"vision",
"s",
"AnnotateImagesRequest",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/client.go#L146-L152 |
145,926 | kaneshin/pigeon | client.go | NewAnnotateImageSourceRequest | func NewAnnotateImageSourceRequest(source string, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
req := &vision.AnnotateImageRequest{
Image: NewAnnotateImageSource(source),
Features: features,
}
return req, nil
} | go | func NewAnnotateImageSourceRequest(source string, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
req := &vision.AnnotateImageRequest{
Image: NewAnnotateImageSource(source),
Features: features,
}
return req, nil
} | [
"func",
"NewAnnotateImageSourceRequest",
"(",
"source",
"string",
",",
"features",
"...",
"*",
"vision",
".",
"Feature",
")",
"(",
"*",
"vision",
".",
"AnnotateImageRequest",
",",
"error",
")",
"{",
"req",
":=",
"&",
"vision",
".",
"AnnotateImageRequest",
"{",... | // NewAnnotateImageSourceRequest returns a pointer to a new vision's AnnotateImagesRequest. | [
"NewAnnotateImageSourceRequest",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"vision",
"s",
"AnnotateImagesRequest",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/client.go#L155-L161 |
145,927 | kaneshin/pigeon | client.go | NewAnnotateImageContent | func NewAnnotateImageContent(body []byte) *vision.Image {
return &vision.Image{
// Content: Image content, represented as a stream of bytes.
Content: base64.StdEncoding.EncodeToString(body),
}
} | go | func NewAnnotateImageContent(body []byte) *vision.Image {
return &vision.Image{
// Content: Image content, represented as a stream of bytes.
Content: base64.StdEncoding.EncodeToString(body),
}
} | [
"func",
"NewAnnotateImageContent",
"(",
"body",
"[",
"]",
"byte",
")",
"*",
"vision",
".",
"Image",
"{",
"return",
"&",
"vision",
".",
"Image",
"{",
"// Content: Image content, represented as a stream of bytes.",
"Content",
":",
"base64",
".",
"StdEncoding",
".",
... | // NewAnnotateImageContent returns a pointer to a new vision's Image.
// It's contained image content, represented as a stream of bytes. | [
"NewAnnotateImageContent",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"vision",
"s",
"Image",
".",
"It",
"s",
"contained",
"image",
"content",
"represented",
"as",
"a",
"stream",
"of",
"bytes",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/client.go#L165-L170 |
145,928 | kaneshin/pigeon | credentials/credentials.go | Get | func (c *Credentials) Get() (Value, error) {
c.m.Lock()
defer c.m.Unlock()
return c.provider.Retrieve()
} | go | func (c *Credentials) Get() (Value, error) {
c.m.Lock()
defer c.m.Unlock()
return c.provider.Retrieve()
} | [
"func",
"(",
"c",
"*",
"Credentials",
")",
"Get",
"(",
")",
"(",
"Value",
",",
"error",
")",
"{",
"c",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"c",
".",
"provider",
".",
"Retriev... | // Get returns the credentials value, or error if the credentials Value failed
// to be retrieved. | [
"Get",
"returns",
"the",
"credentials",
"value",
"or",
"error",
"if",
"the",
"credentials",
"Value",
"failed",
"to",
"be",
"retrieved",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/credentials/credentials.go#L56-L60 |
145,929 | kaneshin/pigeon | feature.go | DetectionType | func DetectionType(d int) string {
switch d {
case TypeUnspecified:
return "TYPE_UNSPECIFIED"
case FaceDetection:
return "FACE_DETECTION"
case LandmarkDetection:
return "LANDMARK_DETECTION"
case LogoDetection:
return "LOGO_DETECTION"
case LabelDetection:
return "LABEL_DETECTION"
case TextDetection:
r... | go | func DetectionType(d int) string {
switch d {
case TypeUnspecified:
return "TYPE_UNSPECIFIED"
case FaceDetection:
return "FACE_DETECTION"
case LandmarkDetection:
return "LANDMARK_DETECTION"
case LogoDetection:
return "LOGO_DETECTION"
case LabelDetection:
return "LABEL_DETECTION"
case TextDetection:
r... | [
"func",
"DetectionType",
"(",
"d",
"int",
")",
"string",
"{",
"switch",
"d",
"{",
"case",
"TypeUnspecified",
":",
"return",
"\"",
"\"",
"\n",
"case",
"FaceDetection",
":",
"return",
"\"",
"\"",
"\n",
"case",
"LandmarkDetection",
":",
"return",
"\"",
"\"",
... | // DetectionType returns a value of detection type. | [
"DetectionType",
"returns",
"a",
"value",
"of",
"detection",
"type",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/feature.go#L29-L51 |
145,930 | kaneshin/pigeon | feature.go | NewFeature | func NewFeature(d int) *vision.Feature {
return &vision.Feature{Type: DetectionType(d)}
} | go | func NewFeature(d int) *vision.Feature {
return &vision.Feature{Type: DetectionType(d)}
} | [
"func",
"NewFeature",
"(",
"d",
"int",
")",
"*",
"vision",
".",
"Feature",
"{",
"return",
"&",
"vision",
".",
"Feature",
"{",
"Type",
":",
"DetectionType",
"(",
"d",
")",
"}",
"\n",
"}"
] | // NewFeature returns a pointer to a new vision's Feature object. | [
"NewFeature",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"vision",
"s",
"Feature",
"object",
"."
] | 7719cd94cfb447e3e60c4e8b5b7501f9f36e4018 | https://github.com/kaneshin/pigeon/blob/7719cd94cfb447e3e60c4e8b5b7501f9f36e4018/feature.go#L54-L56 |
145,931 | jefferai/jsonx | jsonx.go | Marshal | func Marshal(input interface{}) (string, error) {
jsonBytes, err := json.Marshal(input)
if err != nil {
return "", err
}
xmlBytes, err := EncodeJSONBytes(jsonBytes)
if err != nil {
return "", err
}
return fmt.Sprintf("%s%s%s%s", XMLHeader, Header, string(xmlBytes), Footer), nil
} | go | func Marshal(input interface{}) (string, error) {
jsonBytes, err := json.Marshal(input)
if err != nil {
return "", err
}
xmlBytes, err := EncodeJSONBytes(jsonBytes)
if err != nil {
return "", err
}
return fmt.Sprintf("%s%s%s%s", XMLHeader, Header, string(xmlBytes), Footer), nil
} | [
"func",
"Marshal",
"(",
"input",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"jsonBytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"input",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"... | // Marshal marshals the input data into JSONx. | [
"Marshal",
"marshals",
"the",
"input",
"data",
"into",
"JSONx",
"."
] | c32bd0db71409fa22d42d76452191f1516e3c067 | https://github.com/jefferai/jsonx/blob/c32bd0db71409fa22d42d76452191f1516e3c067/jsonx.go#L26-L36 |
145,932 | jefferai/jsonx | jsonx.go | EncodeJSONBytes | func EncodeJSONBytes(input []byte) ([]byte, error) {
o := bytes.NewBuffer(nil)
reader := bytes.NewReader(input)
dec := json.NewDecoder(reader)
dec.UseNumber()
cont, err := gabs.ParseJSONDecoder(dec)
if err != nil {
return nil, err
}
if err := sortAndTransformObject(o, &namedContainer{Container: cont}); err ... | go | func EncodeJSONBytes(input []byte) ([]byte, error) {
o := bytes.NewBuffer(nil)
reader := bytes.NewReader(input)
dec := json.NewDecoder(reader)
dec.UseNumber()
cont, err := gabs.ParseJSONDecoder(dec)
if err != nil {
return nil, err
}
if err := sortAndTransformObject(o, &namedContainer{Container: cont}); err ... | [
"func",
"EncodeJSONBytes",
"(",
"input",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"o",
":=",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
"\n",
"reader",
":=",
"bytes",
".",
"NewReader",
"(",
"input",
")",
"\n",
"dec",
... | // EncodeJSONBytes encodes JSON-formatted bytes into JSONx. It is designed to
// be used for multiple entries so does not prepend the JSONx header tag or
// append the JSONx footer tag. You can use jsonx.Header and jsonx.Footer to
// easily add these when necessary. | [
"EncodeJSONBytes",
"encodes",
"JSON",
"-",
"formatted",
"bytes",
"into",
"JSONx",
".",
"It",
"is",
"designed",
"to",
"be",
"used",
"for",
"multiple",
"entries",
"so",
"does",
"not",
"prepend",
"the",
"JSONx",
"header",
"tag",
"or",
"append",
"the",
"JSONx",
... | c32bd0db71409fa22d42d76452191f1516e3c067 | https://github.com/jefferai/jsonx/blob/c32bd0db71409fa22d42d76452191f1516e3c067/jsonx.go#L42-L58 |
145,933 | jefferai/jsonx | jsonx.go | sortAndTransformObject | func sortAndTransformObject(o *bytes.Buffer, cont *namedContainer) error {
objectChildren, err := cont.ChildrenMap()
if err != nil {
return err
}
sortedNames := make([]string, 0, len(objectChildren))
for name, _ := range objectChildren {
sortedNames = append(sortedNames, name)
}
sort.Strings(sortedNames)
f... | go | func sortAndTransformObject(o *bytes.Buffer, cont *namedContainer) error {
objectChildren, err := cont.ChildrenMap()
if err != nil {
return err
}
sortedNames := make([]string, 0, len(objectChildren))
for name, _ := range objectChildren {
sortedNames = append(sortedNames, name)
}
sort.Strings(sortedNames)
f... | [
"func",
"sortAndTransformObject",
"(",
"o",
"*",
"bytes",
".",
"Buffer",
",",
"cont",
"*",
"namedContainer",
")",
"error",
"{",
"objectChildren",
",",
"err",
":=",
"cont",
".",
"ChildrenMap",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err"... | // sortAndTransformObject sorts object keys to make the output predictable so
// the package can be tested; logic is here to prevent code duplication | [
"sortAndTransformObject",
"sorts",
"object",
"keys",
"to",
"make",
"the",
"output",
"predictable",
"so",
"the",
"package",
"can",
"be",
"tested",
";",
"logic",
"is",
"here",
"to",
"prevent",
"code",
"duplication"
] | c32bd0db71409fa22d42d76452191f1516e3c067 | https://github.com/jefferai/jsonx/blob/c32bd0db71409fa22d42d76452191f1516e3c067/jsonx.go#L114-L132 |
145,934 | tent/http-link-go | link.go | Format | func Format(links []Link) string {
buf := &bytes.Buffer{}
for i, link := range links {
if i > 0 {
buf.Write([]byte(", "))
}
buf.WriteByte('<')
buf.WriteString(link.URI)
buf.WriteByte('>')
writeParam(buf, "rel", link.Rel)
keys := make([]string, 0, len(link.Params))
for k := range link.Params {
... | go | func Format(links []Link) string {
buf := &bytes.Buffer{}
for i, link := range links {
if i > 0 {
buf.Write([]byte(", "))
}
buf.WriteByte('<')
buf.WriteString(link.URI)
buf.WriteByte('>')
writeParam(buf, "rel", link.Rel)
keys := make([]string, 0, len(link.Params))
for k := range link.Params {
... | [
"func",
"Format",
"(",
"links",
"[",
"]",
"Link",
")",
"string",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"for",
"i",
",",
"link",
":=",
"range",
"links",
"{",
"if",
"i",
">",
"0",
"{",
"buf",
".",
"Write",
"(",
"[",
"]"... | // Format serializes a slice of Links into a header value. It does not currently
// implement RFC 2231 handling of non-ASCII character encoding and language
// information. | [
"Format",
"serializes",
"a",
"slice",
"of",
"Links",
"into",
"a",
"header",
"value",
".",
"It",
"does",
"not",
"currently",
"implement",
"RFC",
"2231",
"handling",
"of",
"non",
"-",
"ASCII",
"character",
"encoding",
"and",
"language",
"information",
"."
] | ac974c61c2f990f4115b119354b5e0b47550e888 | https://github.com/tent/http-link-go/blob/ac974c61c2f990f4115b119354b5e0b47550e888/link.go#L21-L45 |
145,935 | tent/http-link-go | link.go | Parse | func Parse(l string) ([]Link, error) {
v := []byte(l)
v = bytes.TrimSpace(v)
if len(v) == 0 {
return nil, nil
}
links := make([]Link, 0, 1)
for len(v) > 0 {
if v[0] != '<' {
return nil, errors.New("link: does not start with <")
}
lend := bytes.IndexByte(v, '>')
if lend == -1 {
return nil, errors.... | go | func Parse(l string) ([]Link, error) {
v := []byte(l)
v = bytes.TrimSpace(v)
if len(v) == 0 {
return nil, nil
}
links := make([]Link, 0, 1)
for len(v) > 0 {
if v[0] != '<' {
return nil, errors.New("link: does not start with <")
}
lend := bytes.IndexByte(v, '>')
if lend == -1 {
return nil, errors.... | [
"func",
"Parse",
"(",
"l",
"string",
")",
"(",
"[",
"]",
"Link",
",",
"error",
")",
"{",
"v",
":=",
"[",
"]",
"byte",
"(",
"l",
")",
"\n",
"v",
"=",
"bytes",
".",
"TrimSpace",
"(",
"v",
")",
"\n",
"if",
"len",
"(",
"v",
")",
"==",
"0",
"{... | // Parse parses a Link header value into a slice of Links. It does not currently
// implement RFC 2231 handling of non-ASCII character encoding and language
// information. | [
"Parse",
"parses",
"a",
"Link",
"header",
"value",
"into",
"a",
"slice",
"of",
"Links",
".",
"It",
"does",
"not",
"currently",
"implement",
"RFC",
"2231",
"handling",
"of",
"non",
"-",
"ASCII",
"character",
"encoding",
"and",
"language",
"information",
"."
] | ac974c61c2f990f4115b119354b5e0b47550e888 | https://github.com/tent/http-link-go/blob/ac974c61c2f990f4115b119354b5e0b47550e888/link.go#L58-L115 |
145,936 | rapito/go-shopify | shopify/shopify.go | createTargetURL | func (shopify *Shopify) createTargetURL(endpoint string) string {
result := fmt.Sprintf("https://%s:%s@%s%s/%s.json", shopify.apiKey, shopify.pass, shopify.store, domain, endpoint)
return result
} | go | func (shopify *Shopify) createTargetURL(endpoint string) string {
result := fmt.Sprintf("https://%s:%s@%s%s/%s.json", shopify.apiKey, shopify.pass, shopify.store, domain, endpoint)
return result
} | [
"func",
"(",
"shopify",
"*",
"Shopify",
")",
"createTargetURL",
"(",
"endpoint",
"string",
")",
"string",
"{",
"result",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"shopify",
".",
"apiKey",
",",
"shopify",
".",
"pass",
",",
"shopify",
".",
"sto... | // Creates target URL for making a Shopify Request
// to a given endpoint | [
"Creates",
"target",
"URL",
"for",
"making",
"a",
"Shopify",
"Request",
"to",
"a",
"given",
"endpoint"
] | 7975333a51795b40bc33714564f15975a3d86dd8 | https://github.com/rapito/go-shopify/blob/7975333a51795b40bc33714564f15975a3d86dd8/shopify/shopify.go#L41-L44 |
145,937 | gobs/pretty | pretty.go | PrintValue | func (p *Pretty) PrintValue(val r.Value, level int) {
if !val.IsValid() {
io.WriteString(p.Out, p.NilString)
return
}
cur := strings.Repeat(p.Indent, level)
next := strings.Repeat(p.Indent, level+1)
nl := "\n"
if len(p.Indent) == 0 {
nl = " "
}
if p.MaxLevel > 0 && level >= p.MaxLevel {
io.WriteStrin... | go | func (p *Pretty) PrintValue(val r.Value, level int) {
if !val.IsValid() {
io.WriteString(p.Out, p.NilString)
return
}
cur := strings.Repeat(p.Indent, level)
next := strings.Repeat(p.Indent, level+1)
nl := "\n"
if len(p.Indent) == 0 {
nl = " "
}
if p.MaxLevel > 0 && level >= p.MaxLevel {
io.WriteStrin... | [
"func",
"(",
"p",
"*",
"Pretty",
")",
"PrintValue",
"(",
"val",
"r",
".",
"Value",
",",
"level",
"int",
")",
"{",
"if",
"!",
"val",
".",
"IsValid",
"(",
")",
"{",
"io",
".",
"WriteString",
"(",
"p",
".",
"Out",
",",
"p",
".",
"NilString",
")",
... | // recursively print the input value | [
"recursively",
"print",
"the",
"input",
"value"
] | 09732c25a95b8e10e85177a3201cf4c7fe35a377 | https://github.com/gobs/pretty/blob/09732c25a95b8e10e85177a3201cf4c7fe35a377/pretty.go#L69-L186 |
145,938 | mackerelio/golib | logging/logger.go | SetLogLevel | func SetLogLevel(lv level) {
if logLv != lv {
logLv = lv
if logLv <= DEBUG {
lgr.SetFlags(log.LstdFlags | log.Lshortfile)
} else {
lgr.SetFlags(log.LstdFlags)
}
}
} | go | func SetLogLevel(lv level) {
if logLv != lv {
logLv = lv
if logLv <= DEBUG {
lgr.SetFlags(log.LstdFlags | log.Lshortfile)
} else {
lgr.SetFlags(log.LstdFlags)
}
}
} | [
"func",
"SetLogLevel",
"(",
"lv",
"level",
")",
"{",
"if",
"logLv",
"!=",
"lv",
"{",
"logLv",
"=",
"lv",
"\n",
"if",
"logLv",
"<=",
"DEBUG",
"{",
"lgr",
".",
"SetFlags",
"(",
"log",
".",
"LstdFlags",
"|",
"log",
".",
"Lshortfile",
")",
"\n",
"}",
... | // SetLogLevel congigure log settings | [
"SetLogLevel",
"congigure",
"log",
"settings"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L24-L33 |
145,939 | mackerelio/golib | logging/logger.go | Criticalf | func (logger *Logger) Criticalf(m string, args ...interface{}) {
logger.log(CRITICAL, m, args...)
} | go | func (logger *Logger) Criticalf(m string, args ...interface{}) {
logger.log(CRITICAL, m, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Criticalf",
"(",
"m",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"CRITICAL",
",",
"m",
",",
"args",
"...",
")",
"\n",
"}"
] | // Criticalf critical log | [
"Criticalf",
"critical",
"log"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L48-L50 |
145,940 | mackerelio/golib | logging/logger.go | Errorf | func (logger *Logger) Errorf(m string, args ...interface{}) {
logger.log(ERROR, m, args...)
} | go | func (logger *Logger) Errorf(m string, args ...interface{}) {
logger.log(ERROR, m, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Errorf",
"(",
"m",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"ERROR",
",",
"m",
",",
"args",
"...",
")",
"\n",
"}"
] | // Errorf error log | [
"Errorf",
"error",
"log"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L53-L55 |
145,941 | mackerelio/golib | logging/logger.go | Warningf | func (logger *Logger) Warningf(m string, args ...interface{}) {
logger.log(WARNING, m, args...)
} | go | func (logger *Logger) Warningf(m string, args ...interface{}) {
logger.log(WARNING, m, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Warningf",
"(",
"m",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"WARNING",
",",
"m",
",",
"args",
"...",
")",
"\n",
"}"
] | // Warningf warning log | [
"Warningf",
"warning",
"log"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L58-L60 |
145,942 | mackerelio/golib | logging/logger.go | Infof | func (logger *Logger) Infof(m string, args ...interface{}) {
logger.log(INFO, m, args...)
} | go | func (logger *Logger) Infof(m string, args ...interface{}) {
logger.log(INFO, m, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Infof",
"(",
"m",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"INFO",
",",
"m",
",",
"args",
"...",
")",
"\n",
"}"
] | // Infof info log | [
"Infof",
"info",
"log"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L63-L65 |
145,943 | mackerelio/golib | logging/logger.go | Debugf | func (logger *Logger) Debugf(m string, args ...interface{}) {
logger.log(DEBUG, m, args...)
} | go | func (logger *Logger) Debugf(m string, args ...interface{}) {
logger.log(DEBUG, m, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Debugf",
"(",
"m",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"DEBUG",
",",
"m",
",",
"args",
"...",
")",
"\n",
"}"
] | // Debugf debug log | [
"Debugf",
"debug",
"log"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L68-L70 |
145,944 | mackerelio/golib | logging/logger.go | Tracef | func (logger *Logger) Tracef(m string, args ...interface{}) {
logger.log(TRACE, m, args...)
} | go | func (logger *Logger) Tracef(m string, args ...interface{}) {
logger.log(TRACE, m, args...)
} | [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Tracef",
"(",
"m",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"TRACE",
",",
"m",
",",
"args",
"...",
")",
"\n",
"}"
] | // Tracef trace log for debugging details | [
"Tracef",
"trace",
"log",
"for",
"debugging",
"details"
] | c87047ca454ec11b68a70b72dcc36eaa4a3a453e | https://github.com/mackerelio/golib/blob/c87047ca454ec11b68a70b72dcc36eaa4a3a453e/logging/logger.go#L73-L75 |
145,945 | gobs/pretty | tabprinter.go | NewTabPrinter | func NewTabPrinter(max int) *TabPrinter {
tp := &TabPrinter{w: new(tabwriter.Writer), max: max}
tp.w.Init(os.Stdout, 0, 8, 1, '\t', 0)
return tp
} | go | func NewTabPrinter(max int) *TabPrinter {
tp := &TabPrinter{w: new(tabwriter.Writer), max: max}
tp.w.Init(os.Stdout, 0, 8, 1, '\t', 0)
return tp
} | [
"func",
"NewTabPrinter",
"(",
"max",
"int",
")",
"*",
"TabPrinter",
"{",
"tp",
":=",
"&",
"TabPrinter",
"{",
"w",
":",
"new",
"(",
"tabwriter",
".",
"Writer",
")",
",",
"max",
":",
"max",
"}",
"\n",
"tp",
".",
"w",
".",
"Init",
"(",
"os",
".",
... | // create a TabPrinter
//
// max specifies the maximum number of 'words' per line | [
"create",
"a",
"TabPrinter",
"max",
"specifies",
"the",
"maximum",
"number",
"of",
"words",
"per",
"line"
] | 09732c25a95b8e10e85177a3201cf4c7fe35a377 | https://github.com/gobs/pretty/blob/09732c25a95b8e10e85177a3201cf4c7fe35a377/tabprinter.go#L19-L24 |
145,946 | gobs/pretty | tabprinter.go | Print | func (tp *TabPrinter) Print(arg interface{}) {
if tp.current > 0 {
if (tp.current % tp.max) == 0 {
fmt.Fprintln(tp.w, "")
tp.w.Flush()
tp.current = 0
} else {
fmt.Fprint(tp.w, "\t")
}
}
tp.current++
fmt.Fprint(tp.w, arg)
} | go | func (tp *TabPrinter) Print(arg interface{}) {
if tp.current > 0 {
if (tp.current % tp.max) == 0 {
fmt.Fprintln(tp.w, "")
tp.w.Flush()
tp.current = 0
} else {
fmt.Fprint(tp.w, "\t")
}
}
tp.current++
fmt.Fprint(tp.w, arg)
} | [
"func",
"(",
"tp",
"*",
"TabPrinter",
")",
"Print",
"(",
"arg",
"interface",
"{",
"}",
")",
"{",
"if",
"tp",
".",
"current",
">",
"0",
"{",
"if",
"(",
"tp",
".",
"current",
"%",
"tp",
".",
"max",
")",
"==",
"0",
"{",
"fmt",
".",
"Fprintln",
"... | // print a 'word'
//
// when the maximum number of words per lines is reached, this will print the formatted line | [
"print",
"a",
"word",
"when",
"the",
"maximum",
"number",
"of",
"words",
"per",
"lines",
"is",
"reached",
"this",
"will",
"print",
"the",
"formatted",
"line"
] | 09732c25a95b8e10e85177a3201cf4c7fe35a377 | https://github.com/gobs/pretty/blob/09732c25a95b8e10e85177a3201cf4c7fe35a377/tabprinter.go#L35-L48 |
145,947 | gobs/pretty | tabprinter.go | Println | func (tp *TabPrinter) Println() {
if tp.current > 0 {
fmt.Fprintln(tp.w, "")
tp.w.Flush()
}
tp.current = 0
} | go | func (tp *TabPrinter) Println() {
if tp.current > 0 {
fmt.Fprintln(tp.w, "")
tp.w.Flush()
}
tp.current = 0
} | [
"func",
"(",
"tp",
"*",
"TabPrinter",
")",
"Println",
"(",
")",
"{",
"if",
"tp",
".",
"current",
">",
"0",
"{",
"fmt",
".",
"Fprintln",
"(",
"tp",
".",
"w",
",",
"\"",
"\"",
")",
"\n",
"tp",
".",
"w",
".",
"Flush",
"(",
")",
"\n",
"}",
"\n\... | // print current line
//
// terminate current line and print - call this after all words have been printed | [
"print",
"current",
"line",
"terminate",
"current",
"line",
"and",
"print",
"-",
"call",
"this",
"after",
"all",
"words",
"have",
"been",
"printed"
] | 09732c25a95b8e10e85177a3201cf4c7fe35a377 | https://github.com/gobs/pretty/blob/09732c25a95b8e10e85177a3201cf4c7fe35a377/tabprinter.go#L53-L60 |
145,948 | gobs/httpclient | httpclient.go | CloseResponse | func CloseResponse(r *http.Response) {
if r != nil && r.Body != nil {
io.Copy(ioutil.Discard, r.Body)
r.Body.Close()
}
} | go | func CloseResponse(r *http.Response) {
if r != nil && r.Body != nil {
io.Copy(ioutil.Discard, r.Body)
r.Body.Close()
}
} | [
"func",
"CloseResponse",
"(",
"r",
"*",
"http",
".",
"Response",
")",
"{",
"if",
"r",
"!=",
"nil",
"&&",
"r",
".",
"Body",
"!=",
"nil",
"{",
"io",
".",
"Copy",
"(",
"ioutil",
".",
"Discard",
",",
"r",
".",
"Body",
")",
"\n",
"r",
".",
"Body",
... | //
// CloseResponse makes sure we close the response body
// | [
"CloseResponse",
"makes",
"sure",
"we",
"close",
"the",
"response",
"body"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L90-L95 |
145,949 | gobs/httpclient | httpclient.go | ResponseError | func (r *HttpResponse) ResponseError() error {
class := r.StatusCode / 100
if class != 2 && class != 3 {
rt := 0
if h := r.Header.Get("Retry-After"); h != "" {
rt, _ = strconv.Atoi(h)
}
var body [256]byte
var blen int
if r.Body != nil {
blen, _ = r.Body.Read(body[:])
}
return HttpError{Code:... | go | func (r *HttpResponse) ResponseError() error {
class := r.StatusCode / 100
if class != 2 && class != 3 {
rt := 0
if h := r.Header.Get("Retry-After"); h != "" {
rt, _ = strconv.Atoi(h)
}
var body [256]byte
var blen int
if r.Body != nil {
blen, _ = r.Body.Read(body[:])
}
return HttpError{Code:... | [
"func",
"(",
"r",
"*",
"HttpResponse",
")",
"ResponseError",
"(",
")",
"error",
"{",
"class",
":=",
"r",
".",
"StatusCode",
"/",
"100",
"\n",
"if",
"class",
"!=",
"2",
"&&",
"class",
"!=",
"3",
"{",
"rt",
":=",
"0",
"\n\n",
"if",
"h",
":=",
"r",
... | //
// ResponseError checks the StatusCode and return an error if needed.
// The error is of type HttpError
// | [
"ResponseError",
"checks",
"the",
"StatusCode",
"and",
"return",
"an",
"error",
"if",
"needed",
".",
"The",
"error",
"is",
"of",
"type",
"HttpError"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L129-L154 |
145,950 | gobs/httpclient | httpclient.go | URLWithPathParams | func URLWithPathParams(base string, path string, params map[string]interface{}) (u *url.URL) {
u, err := url.Parse(base)
if err != nil {
log.Fatal(err)
}
if len(path) > 0 {
u, err = u.Parse(path)
if err != nil {
log.Fatal(err)
}
}
q := u.Query()
for k, v := range params {
val := reflect.ValueOf(... | go | func URLWithPathParams(base string, path string, params map[string]interface{}) (u *url.URL) {
u, err := url.Parse(base)
if err != nil {
log.Fatal(err)
}
if len(path) > 0 {
u, err = u.Parse(path)
if err != nil {
log.Fatal(err)
}
}
q := u.Query()
for k, v := range params {
val := reflect.ValueOf(... | [
"func",
"URLWithPathParams",
"(",
"base",
"string",
",",
"path",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"base",
... | //
// Given a base URL and a bag of parameteters returns the URL with the encoded parameters
// | [
"Given",
"a",
"base",
"URL",
"and",
"a",
"bag",
"of",
"parameteters",
"returns",
"the",
"URL",
"with",
"the",
"encoded",
"parameters"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L189-L236 |
145,951 | gobs/httpclient | httpclient.go | Get | func Get(urlStr string, params map[string]interface{}) (*HttpResponse, error) {
resp, err := DefaultClient.Get(URLWithParams(urlStr, params).String())
if err == nil {
return &HttpResponse{*resp}, nil
} else {
CloseResponse(resp)
return nil, err
}
} | go | func Get(urlStr string, params map[string]interface{}) (*HttpResponse, error) {
resp, err := DefaultClient.Get(URLWithParams(urlStr, params).String())
if err == nil {
return &HttpResponse{*resp}, nil
} else {
CloseResponse(resp)
return nil, err
}
} | [
"func",
"Get",
"(",
"urlStr",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"*",
"HttpResponse",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"DefaultClient",
".",
"Get",
"(",
"URLWithParams",
"(",
"urlStr",
... | //
// http.Get with params
// | [
"http",
".",
"Get",
"with",
"params"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L245-L253 |
145,952 | gobs/httpclient | httpclient.go | Post | func Post(urlStr string, params map[string]interface{}) (*HttpResponse, error) {
resp, err := DefaultClient.PostForm(urlStr, URLWithParams(urlStr, params).Query())
if err == nil {
return &HttpResponse{*resp}, nil
} else {
CloseResponse(resp)
return nil, err
}
} | go | func Post(urlStr string, params map[string]interface{}) (*HttpResponse, error) {
resp, err := DefaultClient.PostForm(urlStr, URLWithParams(urlStr, params).Query())
if err == nil {
return &HttpResponse{*resp}, nil
} else {
CloseResponse(resp)
return nil, err
}
} | [
"func",
"Post",
"(",
"urlStr",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"*",
"HttpResponse",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"DefaultClient",
".",
"PostForm",
"(",
"urlStr",
",",
"URLWithPar... | //
// http.Post with params
// | [
"http",
".",
"Post",
"with",
"params"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L258-L266 |
145,953 | gobs/httpclient | httpclient.go | Content | func (resp *HttpResponse) Content() []byte {
if resp == nil {
return nil
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err, " - read ", len(body), " bytes")
}
resp.Body.Close()
return body
} | go | func (resp *HttpResponse) Content() []byte {
if resp == nil {
return nil
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err, " - read ", len(body), " bytes")
}
resp.Body.Close()
return body
} | [
"func",
"(",
"resp",
"*",
"HttpResponse",
")",
"Content",
"(",
")",
"[",
"]",
"byte",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
... | //
// Read the body
// | [
"Read",
"the",
"body"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L271-L281 |
145,954 | gobs/httpclient | httpclient.go | Json | func (resp *HttpResponse) Json() (json *simplejson.Json) {
json, _ = simplejson.LoadBytes(resp.Content())
return
} | go | func (resp *HttpResponse) Json() (json *simplejson.Json) {
json, _ = simplejson.LoadBytes(resp.Content())
return
} | [
"func",
"(",
"resp",
"*",
"HttpResponse",
")",
"Json",
"(",
")",
"(",
"json",
"*",
"simplejson",
".",
"Json",
")",
"{",
"json",
",",
"_",
"=",
"simplejson",
".",
"LoadBytes",
"(",
"resp",
".",
"Content",
"(",
")",
")",
"\n",
"return",
"\n",
"}"
] | //
// Try to parse the response body as JSON
// | [
"Try",
"to",
"parse",
"the",
"response",
"body",
"as",
"JSON"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L286-L289 |
145,955 | gobs/httpclient | httpclient.go | JsonDecode | func (resp *HttpResponse) JsonDecode(out interface{}, strict bool) error {
dec := json.NewDecoder(resp.Body)
if strict {
dec.DisallowUnknownFields()
}
defer resp.Body.Close()
return dec.Decode(out)
} | go | func (resp *HttpResponse) JsonDecode(out interface{}, strict bool) error {
dec := json.NewDecoder(resp.Body)
if strict {
dec.DisallowUnknownFields()
}
defer resp.Body.Close()
return dec.Decode(out)
} | [
"func",
"(",
"resp",
"*",
"HttpResponse",
")",
"JsonDecode",
"(",
"out",
"interface",
"{",
"}",
",",
"strict",
"bool",
")",
"error",
"{",
"dec",
":=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
"\n",
"if",
"strict",
"{",
"dec",
".",
... | //
// JsonDecode decodes the response body as JSON into specified structure
// | [
"JsonDecode",
"decodes",
"the",
"response",
"body",
"as",
"JSON",
"into",
"specified",
"structure"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L294-L301 |
145,956 | gobs/httpclient | httpclient.go | NewHttpClient | func NewHttpClient(base string) (httpClient *HttpClient) {
httpClient = new(HttpClient)
httpClient.client = &http.Client{CheckRedirect: httpClient.checkRedirect}
httpClient.Headers = make(map[string]string)
httpClient.FollowRedirects = true
if err := httpClient.SetBase(base); err != nil {
log.Fatal(err)
}
re... | go | func NewHttpClient(base string) (httpClient *HttpClient) {
httpClient = new(HttpClient)
httpClient.client = &http.Client{CheckRedirect: httpClient.checkRedirect}
httpClient.Headers = make(map[string]string)
httpClient.FollowRedirects = true
if err := httpClient.SetBase(base); err != nil {
log.Fatal(err)
}
re... | [
"func",
"NewHttpClient",
"(",
"base",
"string",
")",
"(",
"httpClient",
"*",
"HttpClient",
")",
"{",
"httpClient",
"=",
"new",
"(",
"HttpClient",
")",
"\n",
"httpClient",
".",
"client",
"=",
"&",
"http",
".",
"Client",
"{",
"CheckRedirect",
":",
"httpClien... | //
// Create a new HttpClient
// | [
"Create",
"a",
"new",
"HttpClient"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L344-L355 |
145,957 | gobs/httpclient | httpclient.go | SetTimeout | func (self *HttpClient) SetTimeout(t time.Duration) {
self.client.Timeout = t
} | go | func (self *HttpClient) SetTimeout(t time.Duration) {
self.client.Timeout = t
} | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"SetTimeout",
"(",
"t",
"time",
".",
"Duration",
")",
"{",
"self",
".",
"client",
".",
"Timeout",
"=",
"t",
"\n",
"}"
] | //
// Set connection timeout
// | [
"Set",
"connection",
"timeout"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L418-L420 |
145,958 | gobs/httpclient | httpclient.go | checkRedirect | func (self *HttpClient) checkRedirect(req *http.Request, via []*http.Request) error {
if !self.FollowRedirects {
// don't follow redirects if explicitly disabled
return NoRedirect
}
if req.Method == "HEAD" && !self.HeadRedirects {
// don't follow redirects on a HEAD request
return NoRedirect
}
DebugLog(s... | go | func (self *HttpClient) checkRedirect(req *http.Request, via []*http.Request) error {
if !self.FollowRedirects {
// don't follow redirects if explicitly disabled
return NoRedirect
}
if req.Method == "HEAD" && !self.HeadRedirects {
// don't follow redirects on a HEAD request
return NoRedirect
}
DebugLog(s... | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"checkRedirect",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"via",
"[",
"]",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"if",
"!",
"self",
".",
"FollowRedirects",
"{",
"// don't follow redirects if expli... | //
// the callback for CheckRedirect, used to pass along the headers in case of redirection
// | [
"the",
"callback",
"for",
"CheckRedirect",
"used",
"to",
"pass",
"along",
"the",
"headers",
"in",
"case",
"of",
"redirection"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L493-L523 |
145,959 | gobs/httpclient | httpclient.go | Request | func (self *HttpClient) Request(method string, urlpath string, body io.Reader, headers map[string]string) (req *http.Request) {
if u, err := self.BaseURL.Parse(urlpath); err != nil {
log.Fatal(err)
} else {
urlpath = u.String()
}
req, err := http.NewRequest(strings.ToUpper(method), urlpath, body)
if err != ni... | go | func (self *HttpClient) Request(method string, urlpath string, body io.Reader, headers map[string]string) (req *http.Request) {
if u, err := self.BaseURL.Parse(urlpath); err != nil {
log.Fatal(err)
} else {
urlpath = u.String()
}
req, err := http.NewRequest(strings.ToUpper(method), urlpath, body)
if err != ni... | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"Request",
"(",
"method",
"string",
",",
"urlpath",
"string",
",",
"body",
"io",
".",
"Reader",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"{",
... | //
// Create a request object given the method, path, body and extra headers
// | [
"Create",
"a",
"request",
"object",
"given",
"the",
"method",
"path",
"body",
"and",
"extra",
"headers"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L528-L546 |
145,960 | gobs/httpclient | httpclient.go | Method | func Method(m string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
req.Method = strings.ToUpper(m)
return req, nil
}
} | go | func Method(m string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
req.Method = strings.ToUpper(m)
return req, nil
}
} | [
"func",
"Method",
"(",
"m",
"string",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"req",
".",
"Method",
"=",
"strings",
".",
"ToUpper",
"(",
"m... | // Set the request method | [
"Set",
"the",
"request",
"method"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L555-L560 |
145,961 | gobs/httpclient | httpclient.go | URL | func URL(u *url.URL) RequestOption {
return func(req *http.Request) (*http.Request, error) {
req.URL = u
return req, nil
}
} | go | func URL(u *url.URL) RequestOption {
return func(req *http.Request) (*http.Request, error) {
req.URL = u
return req, nil
}
} | [
"func",
"URL",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"req",
".",
"URL",
"=",
"u",
"\n",
"return",
"... | // set the request URL | [
"set",
"the",
"request",
"URL"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L571-L576 |
145,962 | gobs/httpclient | httpclient.go | Path | func Path(path string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
if req.URL != nil {
u, err := req.URL.Parse(path)
if err != nil {
return nil, err
}
req.URL = u
return req, nil
}
u, err := url.Parse(path)
if err != nil {
return nil, err
}
req.URL = u
... | go | func Path(path string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
if req.URL != nil {
u, err := req.URL.Parse(path)
if err != nil {
return nil, err
}
req.URL = u
return req, nil
}
u, err := url.Parse(path)
if err != nil {
return nil, err
}
req.URL = u
... | [
"func",
"Path",
"(",
"path",
"string",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"if",
"req",
".",
"URL",
"!=",
"nil",
"{",
"u",
",",
"err"... | // set the request path | [
"set",
"the",
"request",
"path"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L592-L612 |
145,963 | gobs/httpclient | httpclient.go | Body | func Body(r io.Reader) RequestOption {
return func(req *http.Request) (*http.Request, error) {
if r == nil {
req.Body = http.NoBody
req.ContentLength = 0
return req, nil
}
if rc, ok := r.(io.ReadCloser); ok {
req.Body = rc
} else {
req.Body = ioutil.NopCloser(r)
}
if v, ok := r.(interface{... | go | func Body(r io.Reader) RequestOption {
return func(req *http.Request) (*http.Request, error) {
if r == nil {
req.Body = http.NoBody
req.ContentLength = 0
return req, nil
}
if rc, ok := r.(io.ReadCloser); ok {
req.Body = rc
} else {
req.Body = ioutil.NopCloser(r)
}
if v, ok := r.(interface{... | [
"func",
"Body",
"(",
"r",
"io",
".",
"Reader",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"if",
"r",
"==",
"nil",
"{",
"req",
".",
"Body",
... | // set the request body as an io.Reader | [
"set",
"the",
"request",
"body",
"as",
"an",
"io",
".",
"Reader"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L648-L670 |
145,964 | gobs/httpclient | httpclient.go | JsonBody | func JsonBody(body interface{}) RequestOption {
return func(req *http.Request) (*http.Request, error) {
b, err := simplejson.DumpBytes(body)
if err != nil {
return nil, err
}
req.Body = ioutil.NopCloser(bytes.NewBuffer(b))
req.ContentLength = int64(len(b))
req.Header.Set("Content-Type", "application/jso... | go | func JsonBody(body interface{}) RequestOption {
return func(req *http.Request) (*http.Request, error) {
b, err := simplejson.DumpBytes(body)
if err != nil {
return nil, err
}
req.Body = ioutil.NopCloser(bytes.NewBuffer(b))
req.ContentLength = int64(len(b))
req.Header.Set("Content-Type", "application/jso... | [
"func",
"JsonBody",
"(",
"body",
"interface",
"{",
"}",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"simplejson",
".",
"... | // set the request body as a JSON object | [
"set",
"the",
"request",
"body",
"as",
"a",
"JSON",
"object"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L673-L684 |
145,965 | gobs/httpclient | httpclient.go | Accept | func Accept(ct string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
req.Header.Set("Accept", ct)
return req, nil
}
} | go | func Accept(ct string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
req.Header.Set("Accept", ct)
return req, nil
}
} | [
"func",
"Accept",
"(",
"ct",
"string",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"c... | // set the Accept header | [
"set",
"the",
"Accept",
"header"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L687-L692 |
145,966 | gobs/httpclient | httpclient.go | ContentLength | func ContentLength(l int64) RequestOption {
return func(req *http.Request) (*http.Request, error) {
if l >= 0 {
req.ContentLength = l
}
return req, nil
}
} | go | func ContentLength(l int64) RequestOption {
return func(req *http.Request) (*http.Request, error) {
if l >= 0 {
req.ContentLength = l
}
return req, nil
}
} | [
"func",
"ContentLength",
"(",
"l",
"int64",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"if",
"l",
">=",
"0",
"{",
"req",
".",
"ContentLength",
... | // set the Content-Length header | [
"set",
"the",
"Content",
"-",
"Length",
"header"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L703-L710 |
145,967 | gobs/httpclient | httpclient.go | Header | func Header(headers map[string]string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
for k, v := range headers {
if strings.ToLower(k) == "content-length" {
if len, err := strconv.Atoi(v); err == nil && req.ContentLength <= 0 {
req.ContentLength = int64(len)
}
} else {
... | go | func Header(headers map[string]string) RequestOption {
return func(req *http.Request) (*http.Request, error) {
for k, v := range headers {
if strings.ToLower(k) == "content-length" {
if len, err := strconv.Atoi(v); err == nil && req.ContentLength <= 0 {
req.ContentLength = int64(len)
}
} else {
... | [
"func",
"Header",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"for",
"k",
",",
"v",
":=",
... | // set specified HTTP headers | [
"set",
"specified",
"HTTP",
"headers"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L713-L727 |
145,968 | gobs/httpclient | httpclient.go | Context | func Context(ctx context.Context) RequestOption {
return func(req *http.Request) (*http.Request, error) {
return req.WithContext(ctx), nil
}
} | go | func Context(ctx context.Context) RequestOption {
return func(req *http.Request) (*http.Request, error) {
return req.WithContext(ctx), nil
}
} | [
"func",
"Context",
"(",
"ctx",
"context",
".",
"Context",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"return",
"req",
".",
"WithContext",
"(",
"... | // set request context | [
"set",
"request",
"context"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L730-L734 |
145,969 | gobs/httpclient | httpclient.go | Trace | func Trace(tracer *httptrace.ClientTrace) RequestOption {
return func(req *http.Request) (*http.Request, error) {
return req.WithContext(httptrace.WithClientTrace(req.Context(), tracer)), nil
}
} | go | func Trace(tracer *httptrace.ClientTrace) RequestOption {
return func(req *http.Request) (*http.Request, error) {
return req.WithContext(httptrace.WithClientTrace(req.Context(), tracer)), nil
}
} | [
"func",
"Trace",
"(",
"tracer",
"*",
"httptrace",
".",
"ClientTrace",
")",
"RequestOption",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"return",
"req",
".",
"WithContex... | // set request ClientTrace | [
"set",
"request",
"ClientTrace"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L737-L741 |
145,970 | gobs/httpclient | httpclient.go | Delete | func (self *HttpClient) Delete(path string, headers map[string]string) (*HttpResponse, error) {
req := self.Request("DELETE", path, nil, headers)
return self.Do(req)
} | go | func (self *HttpClient) Delete(path string, headers map[string]string) (*HttpResponse, error) {
req := self.Request("DELETE", path, nil, headers)
return self.Do(req)
} | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"Delete",
"(",
"path",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"HttpResponse",
",",
"error",
")",
"{",
"req",
":=",
"self",
".",
"Request",
"(",
"\"",
"\"",
",",
"pa... | //
// Execute a DELETE request
// | [
"Execute",
"a",
"DELETE",
"request"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L800-L803 |
145,971 | gobs/httpclient | httpclient.go | Head | func (self *HttpClient) Head(path string, params map[string]interface{}, headers map[string]string) (*HttpResponse, error) {
req := self.Request("HEAD", URLWithParams(path, params).String(), nil, headers)
return self.Do(req)
} | go | func (self *HttpClient) Head(path string, params map[string]interface{}, headers map[string]string) (*HttpResponse, error) {
req := self.Request("HEAD", URLWithParams(path, params).String(), nil, headers)
return self.Do(req)
} | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"Head",
"(",
"path",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"HttpResponse",
",",
"error",
")",
"{",
... | //
// Execute a HEAD request
// | [
"Execute",
"a",
"HEAD",
"request"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L808-L811 |
145,972 | gobs/httpclient | httpclient.go | Post | func (self *HttpClient) Post(path string, content io.Reader, headers map[string]string) (*HttpResponse, error) {
req := self.Request("POST", path, content, headers)
return self.Do(req)
} | go | func (self *HttpClient) Post(path string, content io.Reader, headers map[string]string) (*HttpResponse, error) {
req := self.Request("POST", path, content, headers)
return self.Do(req)
} | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"Post",
"(",
"path",
"string",
",",
"content",
"io",
".",
"Reader",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"HttpResponse",
",",
"error",
")",
"{",
"req",
":=",
"self",
".",
"... | //
// Execute a POST request
// | [
"Execute",
"a",
"POST",
"request"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L824-L827 |
145,973 | gobs/httpclient | httpclient.go | UploadFile | func (self *HttpClient) UploadFile(method, path, fileParam, filePath string, payload []byte, params map[string]string, headers map[string]string) (*HttpResponse, error) {
var reader io.Reader
if payload == nil {
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()
reader =... | go | func (self *HttpClient) UploadFile(method, path, fileParam, filePath string, payload []byte, params map[string]string, headers map[string]string) (*HttpResponse, error) {
var reader io.Reader
if payload == nil {
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer file.Close()
reader =... | [
"func",
"(",
"self",
"*",
"HttpClient",
")",
"UploadFile",
"(",
"method",
",",
"path",
",",
"fileParam",
",",
"filePath",
"string",
",",
"payload",
"[",
"]",
"byte",
",",
"params",
"map",
"[",
"string",
"]",
"string",
",",
"headers",
"map",
"[",
"strin... | //
// Upload a file via form
// | [
"Upload",
"a",
"file",
"via",
"form"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpclient.go#L849-L888 |
145,974 | gobs/httpclient | logging.go | LoggedTransport | func LoggedTransport(t *http.Transport, requestBody, responseBody, timing bool) http.RoundTripper {
return &LoggingTransport{t, requestBody, responseBody, timing}
} | go | func LoggedTransport(t *http.Transport, requestBody, responseBody, timing bool) http.RoundTripper {
return &LoggingTransport{t, requestBody, responseBody, timing}
} | [
"func",
"LoggedTransport",
"(",
"t",
"*",
"http",
".",
"Transport",
",",
"requestBody",
",",
"responseBody",
",",
"timing",
"bool",
")",
"http",
".",
"RoundTripper",
"{",
"return",
"&",
"LoggingTransport",
"{",
"t",
",",
"requestBody",
",",
"responseBody",
"... | // Wrap input transport into a LoggingTransport | [
"Wrap",
"input",
"transport",
"into",
"a",
"LoggingTransport"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/logging.go#L95-L97 |
145,975 | gobs/httpclient | httpfile.go | OpenHttpFile | func OpenHttpFile(url string, headers map[string]string) (*HttpFile, error) {
f := HttpFile{Url: url, Headers: headers, client: &http.Client{}, pos: 0, len: -1}
resp, err := f.do("HEAD", nil)
defer CloseResponse(resp)
if err != nil {
return nil, &HttpFileError{Err: err}
}
if resp.StatusCode == http.StatusNotF... | go | func OpenHttpFile(url string, headers map[string]string) (*HttpFile, error) {
f := HttpFile{Url: url, Headers: headers, client: &http.Client{}, pos: 0, len: -1}
resp, err := f.do("HEAD", nil)
defer CloseResponse(resp)
if err != nil {
return nil, &HttpFileError{Err: err}
}
if resp.StatusCode == http.StatusNotF... | [
"func",
"OpenHttpFile",
"(",
"url",
"string",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"HttpFile",
",",
"error",
")",
"{",
"f",
":=",
"HttpFile",
"{",
"Url",
":",
"url",
",",
"Headers",
":",
"headers",
",",
"client",
":",
... | // Creates an HttpFile object. At this point the "file" is "open" | [
"Creates",
"an",
"HttpFile",
"object",
".",
"At",
"this",
"point",
"the",
"file",
"is",
"open"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpfile.go#L32-L50 |
145,976 | gobs/httpclient | httpfile.go | Size | func (f *HttpFile) Size() int64 {
DebugLog(f.Debug).Println("Size", f.len)
return f.len
} | go | func (f *HttpFile) Size() int64 {
DebugLog(f.Debug).Println("Size", f.len)
return f.len
} | [
"func",
"(",
"f",
"*",
"HttpFile",
")",
"Size",
"(",
")",
"int64",
"{",
"DebugLog",
"(",
"f",
".",
"Debug",
")",
".",
"Println",
"(",
"\"",
"\"",
",",
"f",
".",
"len",
")",
"\n",
"return",
"f",
".",
"len",
"\n",
"}"
] | // Returns the file size | [
"Returns",
"the",
"file",
"size"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpfile.go#L72-L75 |
145,977 | gobs/httpclient | httpfile.go | ReadAt | func (f *HttpFile) ReadAt(p []byte, off int64) (int, error) {
DebugLog(f.Debug).Println("ReadAt", off, len(p))
if f.client == nil {
return 0, os.ErrInvalid
}
plen := len(p)
if plen <= 0 {
return plen, nil
}
bytes_range := fmt.Sprintf("bytes=%d-%d", off, off+int64(plen-1))
resp, err := f.do("GET", headers... | go | func (f *HttpFile) ReadAt(p []byte, off int64) (int, error) {
DebugLog(f.Debug).Println("ReadAt", off, len(p))
if f.client == nil {
return 0, os.ErrInvalid
}
plen := len(p)
if plen <= 0 {
return plen, nil
}
bytes_range := fmt.Sprintf("bytes=%d-%d", off, off+int64(plen-1))
resp, err := f.do("GET", headers... | [
"func",
"(",
"f",
"*",
"HttpFile",
")",
"ReadAt",
"(",
"p",
"[",
"]",
"byte",
",",
"off",
"int64",
")",
"(",
"int",
",",
"error",
")",
"{",
"DebugLog",
"(",
"f",
".",
"Debug",
")",
".",
"Println",
"(",
"\"",
"\"",
",",
"off",
",",
"len",
"(",... | // The ReaderAt interface | [
"The",
"ReaderAt",
"interface"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpfile.go#L78-L128 |
145,978 | gobs/httpclient | httpfile.go | Read | func (f *HttpFile) Read(p []byte) (int, error) {
n, err := f.ReadAt(p, f.pos)
if n > 0 {
f.pos += int64(n)
}
DebugLog(f.Debug).Println("Read", n, err)
return n, err
} | go | func (f *HttpFile) Read(p []byte) (int, error) {
n, err := f.ReadAt(p, f.pos)
if n > 0 {
f.pos += int64(n)
}
DebugLog(f.Debug).Println("Read", n, err)
return n, err
} | [
"func",
"(",
"f",
"*",
"HttpFile",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"f",
".",
"ReadAt",
"(",
"p",
",",
"f",
".",
"pos",
")",
"\n",
"if",
"n",
">",
"0",
"{",
"f",
".... | // The Reader interface | [
"The",
"Reader",
"interface"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpfile.go#L131-L140 |
145,979 | gobs/httpclient | httpfile.go | Close | func (f *HttpFile) Close() error {
DebugLog(f.Debug).Println("Close")
f.client = nil
f.pos = -1
f.len = -1
return nil
} | go | func (f *HttpFile) Close() error {
DebugLog(f.Debug).Println("Close")
f.client = nil
f.pos = -1
f.len = -1
return nil
} | [
"func",
"(",
"f",
"*",
"HttpFile",
")",
"Close",
"(",
")",
"error",
"{",
"DebugLog",
"(",
"f",
".",
"Debug",
")",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"f",
".",
"client",
"=",
"nil",
"\n",
"f",
".",
"pos",
"=",
"-",
"1",
"\n",
"f",
"... | // The Closer interface | [
"The",
"Closer",
"interface"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpfile.go#L143-L149 |
145,980 | gobs/httpclient | httpfile.go | Seek | func (f *HttpFile) Seek(offset int64, whence int) (int64, error) {
DebugLog(f.Debug).Println("Seek", offset, whence)
var newpos int64 = -1
if f.client != nil {
switch whence {
case 0: // from 0
newpos = offset
case 1: // from current
newpos = f.pos + offset
case 2: // from end
newpos = f.len + o... | go | func (f *HttpFile) Seek(offset int64, whence int) (int64, error) {
DebugLog(f.Debug).Println("Seek", offset, whence)
var newpos int64 = -1
if f.client != nil {
switch whence {
case 0: // from 0
newpos = offset
case 1: // from current
newpos = f.pos + offset
case 2: // from end
newpos = f.len + o... | [
"func",
"(",
"f",
"*",
"HttpFile",
")",
"Seek",
"(",
"offset",
"int64",
",",
"whence",
"int",
")",
"(",
"int64",
",",
"error",
")",
"{",
"DebugLog",
"(",
"f",
".",
"Debug",
")",
".",
"Println",
"(",
"\"",
"\"",
",",
"offset",
",",
"whence",
")",
... | // The Seeker interface | [
"The",
"Seeker",
"interface"
] | a93d469d8657e74a3d5a8f72bd46b54a19c341f1 | https://github.com/gobs/httpclient/blob/a93d469d8657e74a3d5a8f72bd46b54a19c341f1/httpfile.go#L152-L176 |
145,981 | aead/chacha20poly1305 | chacha20poly1305.go | NewCipher | func NewCipher(key []byte) (cipher.AEAD, error) {
return newCipher(key, chacha.NonceSize)
} | go | func NewCipher(key []byte) (cipher.AEAD, error) {
return newCipher(key, chacha.NonceSize)
} | [
"func",
"NewCipher",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"cipher",
".",
"AEAD",
",",
"error",
")",
"{",
"return",
"newCipher",
"(",
"key",
",",
"chacha",
".",
"NonceSize",
")",
"\n",
"}"
] | // NewCipher returns a cipher.AEAD implementing the
// ChaCha20Poly1305 construction specified in RFC 7539 with a
// 128 bit auth. tag. | [
"NewCipher",
"returns",
"a",
"cipher",
".",
"AEAD",
"implementing",
"the",
"ChaCha20Poly1305",
"construction",
"specified",
"in",
"RFC",
"7539",
"with",
"a",
"128",
"bit",
"auth",
".",
"tag",
"."
] | 233f39982aeb502bfca81558666747bec91cf00c | https://github.com/aead/chacha20poly1305/blob/233f39982aeb502bfca81558666747bec91cf00c/chacha20poly1305.go#L45-L47 |
145,982 | aead/chacha20poly1305 | chacha20poly1305.go | NewIETFCipher | func NewIETFCipher(key []byte) (cipher.AEAD, error) {
return newCipher(key, chacha.INonceSize)
} | go | func NewIETFCipher(key []byte) (cipher.AEAD, error) {
return newCipher(key, chacha.INonceSize)
} | [
"func",
"NewIETFCipher",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"cipher",
".",
"AEAD",
",",
"error",
")",
"{",
"return",
"newCipher",
"(",
"key",
",",
"chacha",
".",
"INonceSize",
")",
"\n",
"}"
] | // NewIETFCipher returns a cipher.AEAD implementing the
// ChaCha20Poly1305 construction specified in RFC 7539 with a
// 128 bit auth. tag. | [
"NewIETFCipher",
"returns",
"a",
"cipher",
".",
"AEAD",
"implementing",
"the",
"ChaCha20Poly1305",
"construction",
"specified",
"in",
"RFC",
"7539",
"with",
"a",
"128",
"bit",
"auth",
".",
"tag",
"."
] | 233f39982aeb502bfca81558666747bec91cf00c | https://github.com/aead/chacha20poly1305/blob/233f39982aeb502bfca81558666747bec91cf00c/chacha20poly1305.go#L52-L54 |
145,983 | aead/chacha20poly1305 | chacha20poly1305.go | NewXCipher | func NewXCipher(key []byte) (cipher.AEAD, error) {
return newCipher(key, chacha.XNonceSize)
} | go | func NewXCipher(key []byte) (cipher.AEAD, error) {
return newCipher(key, chacha.XNonceSize)
} | [
"func",
"NewXCipher",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"cipher",
".",
"AEAD",
",",
"error",
")",
"{",
"return",
"newCipher",
"(",
"key",
",",
"chacha",
".",
"XNonceSize",
")",
"\n",
"}"
] | // NewXCipher returns a cipher.AEAD implementing the
// XChaCha20Poly1305 construction specified in RFC 7539 with a
// 128 bit auth. tag. | [
"NewXCipher",
"returns",
"a",
"cipher",
".",
"AEAD",
"implementing",
"the",
"XChaCha20Poly1305",
"construction",
"specified",
"in",
"RFC",
"7539",
"with",
"a",
"128",
"bit",
"auth",
".",
"tag",
"."
] | 233f39982aeb502bfca81558666747bec91cf00c | https://github.com/aead/chacha20poly1305/blob/233f39982aeb502bfca81558666747bec91cf00c/chacha20poly1305.go#L59-L61 |
145,984 | mvo5/goconfigparser | configparser.go | Sections | func (c *ConfigParser) Sections() (res []string) {
for k, _ := range c.sections {
res = append(res, k)
}
return res
} | go | func (c *ConfigParser) Sections() (res []string) {
for k, _ := range c.sections {
res = append(res, k)
}
return res
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Sections",
"(",
")",
"(",
"res",
"[",
"]",
"string",
")",
"{",
"for",
"k",
",",
"_",
":=",
"range",
"c",
".",
"sections",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"k",
")",
"\n",
"}",
"\n",
"ret... | // Return a string slice of the sections available | [
"Return",
"a",
"string",
"slice",
"of",
"the",
"sections",
"available"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L65-L70 |
145,985 | mvo5/goconfigparser | configparser.go | Options | func (c *ConfigParser) Options(section string) (res []string, err error) {
sect, ok := c.sections[section]
if !ok {
return res, newNoSectionError(section)
}
for k, _ := range sect.options {
res = append(res, k)
}
return res, err
} | go | func (c *ConfigParser) Options(section string) (res []string, err error) {
sect, ok := c.sections[section]
if !ok {
return res, newNoSectionError(section)
}
for k, _ := range sect.options {
res = append(res, k)
}
return res, err
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Options",
"(",
"section",
"string",
")",
"(",
"res",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"sect",
",",
"ok",
":=",
"c",
".",
"sections",
"[",
"section",
"]",
"\n",
"if",
"!",
"ok",
"{",
... | // Return a string slice of the options available in the given section | [
"Return",
"a",
"string",
"slice",
"of",
"the",
"options",
"available",
"in",
"the",
"given",
"section"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L73-L82 |
145,986 | mvo5/goconfigparser | configparser.go | ReadString | func (c *ConfigParser) ReadString(s string) (err error) {
r := strings.NewReader(s)
return c.Read(r)
} | go | func (c *ConfigParser) ReadString(s string) (err error) {
r := strings.NewReader(s)
return c.Read(r)
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"ReadString",
"(",
"s",
"string",
")",
"(",
"err",
"error",
")",
"{",
"r",
":=",
"strings",
".",
"NewReader",
"(",
"s",
")",
"\n",
"return",
"c",
".",
"Read",
"(",
"r",
")",
"\n",
"}"
] | // Attempt to parse the given string as a configuration
// It may return a error if the parsing fails | [
"Attempt",
"to",
"parse",
"the",
"given",
"string",
"as",
"a",
"configuration",
"It",
"may",
"return",
"a",
"error",
"if",
"the",
"parsing",
"fails"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L86-L89 |
145,987 | mvo5/goconfigparser | configparser.go | ReadFile | func (c *ConfigParser) ReadFile(path string) (err error) {
f, err := os.Open(path)
if err != nil {
return err
}
return c.Read(f)
} | go | func (c *ConfigParser) ReadFile(path string) (err error) {
f, err := os.Open(path)
if err != nil {
return err
}
return c.Read(f)
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"ReadFile",
"(",
"path",
"string",
")",
"(",
"err",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n"... | // Attempt to parse the given file as a configuration
// It may return a error if the parsing fails | [
"Attempt",
"to",
"parse",
"the",
"given",
"file",
"as",
"a",
"configuration",
"It",
"may",
"return",
"a",
"error",
"if",
"the",
"parsing",
"fails"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L93-L99 |
145,988 | mvo5/goconfigparser | configparser.go | Read | func (c *ConfigParser) Read(r io.Reader) (err error) {
scanner := bufio.NewScanner(r)
curSect := ""
// we allow files with no [section] header in this mode, by
// default its a error to be aligned with what python configparser
// is doing
if c.AllowNoSectionHeader {
c.sections[""] = Section{
options: make(m... | go | func (c *ConfigParser) Read(r io.Reader) (err error) {
scanner := bufio.NewScanner(r)
curSect := ""
// we allow files with no [section] header in this mode, by
// default its a error to be aligned with what python configparser
// is doing
if c.AllowNoSectionHeader {
c.sections[""] = Section{
options: make(m... | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Read",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"err",
"error",
")",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"r",
")",
"\n\n",
"curSect",
":=",
"\"",
"\"",
"\n",
"// we allow files with no [se... | // Attempt to parse the given io.Reader as a configuration
// It may return a error if the reading fails | [
"Attempt",
"to",
"parse",
"the",
"given",
"io",
".",
"Reader",
"as",
"a",
"configuration",
"It",
"may",
"return",
"a",
"error",
"if",
"the",
"reading",
"fails"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L103-L138 |
145,989 | mvo5/goconfigparser | configparser.go | Get | func (c *ConfigParser) Get(section, option string) (val string, err error) {
if _, ok := c.sections[section]; !ok {
return val, newNoSectionError(section)
}
sec := c.sections[section]
if _, ok := sec.options[option]; !ok {
return val, newNoOptionError(section, option)
}
return sec.options[option], err
} | go | func (c *ConfigParser) Get(section, option string) (val string, err error) {
if _, ok := c.sections[section]; !ok {
return val, newNoSectionError(section)
}
sec := c.sections[section]
if _, ok := sec.options[option]; !ok {
return val, newNoOptionError(section, option)
}
return sec.options[option], err
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Get",
"(",
"section",
",",
"option",
"string",
")",
"(",
"val",
"string",
",",
"err",
"error",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"c",
".",
"sections",
"[",
"section",
"]",
";",
"!",
"ok",
"{",
"r... | // Return the option for the given section as string or an error | [
"Return",
"the",
"option",
"for",
"the",
"given",
"section",
"as",
"string",
"or",
"an",
"error"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L141-L152 |
145,990 | mvo5/goconfigparser | configparser.go | Getint | func (c *ConfigParser) Getint(section, option string) (val int, err error) {
sv, err := c.Get(section, option)
if err != nil {
return val, err
}
return strconv.Atoi(sv)
} | go | func (c *ConfigParser) Getint(section, option string) (val int, err error) {
sv, err := c.Get(section, option)
if err != nil {
return val, err
}
return strconv.Atoi(sv)
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Getint",
"(",
"section",
",",
"option",
"string",
")",
"(",
"val",
"int",
",",
"err",
"error",
")",
"{",
"sv",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"section",
",",
"option",
")",
"\n",
"if",
"err",
... | // Return the option for the given section as integer or an error | [
"Return",
"the",
"option",
"for",
"the",
"given",
"section",
"as",
"integer",
"or",
"an",
"error"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L155-L161 |
145,991 | mvo5/goconfigparser | configparser.go | Getfloat | func (c *ConfigParser) Getfloat(section, option string) (val float64, err error) {
sv, err := c.Get(section, option)
if err != nil {
return val, err
}
return strconv.ParseFloat(sv, 64)
} | go | func (c *ConfigParser) Getfloat(section, option string) (val float64, err error) {
sv, err := c.Get(section, option)
if err != nil {
return val, err
}
return strconv.ParseFloat(sv, 64)
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Getfloat",
"(",
"section",
",",
"option",
"string",
")",
"(",
"val",
"float64",
",",
"err",
"error",
")",
"{",
"sv",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"section",
",",
"option",
")",
"\n",
"if",
"... | // Return the option for the given section as float or an error | [
"Return",
"the",
"option",
"for",
"the",
"given",
"section",
"as",
"float",
"or",
"an",
"error"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L164-L170 |
145,992 | mvo5/goconfigparser | configparser.go | Getbool | func (c *ConfigParser) Getbool(section, option string) (val bool, err error) {
sv, err := c.Get(section, option)
if err != nil {
return val, err
}
val, ok := booleanStates[strings.ToLower(sv)]
if !ok {
return val, errors.New(fmt.Sprintf("No boolean: %s", sv))
}
return val, err
} | go | func (c *ConfigParser) Getbool(section, option string) (val bool, err error) {
sv, err := c.Get(section, option)
if err != nil {
return val, err
}
val, ok := booleanStates[strings.ToLower(sv)]
if !ok {
return val, errors.New(fmt.Sprintf("No boolean: %s", sv))
}
return val, err
} | [
"func",
"(",
"c",
"*",
"ConfigParser",
")",
"Getbool",
"(",
"section",
",",
"option",
"string",
")",
"(",
"val",
"bool",
",",
"err",
"error",
")",
"{",
"sv",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"section",
",",
"option",
")",
"\n",
"if",
"err"... | // Return the option for the given section as boolean or an error | [
"Return",
"the",
"option",
"for",
"the",
"given",
"section",
"as",
"boolean",
"or",
"an",
"error"
] | 6a365a5a3f41851b9e63e1234181bf9b0cf0be8c | https://github.com/mvo5/goconfigparser/blob/6a365a5a3f41851b9e63e1234181bf9b0cf0be8c/configparser.go#L173-L185 |
145,993 | favclip/ucon | swagger/plugin.go | Ignored | func (fiInfo *FieldInfo) Ignored() bool {
tagJSON := ucon.NewTagJSON(fiInfo.Base.Tag)
if tagJSON.Ignored() {
return true
}
return false
} | go | func (fiInfo *FieldInfo) Ignored() bool {
tagJSON := ucon.NewTagJSON(fiInfo.Base.Tag)
if tagJSON.Ignored() {
return true
}
return false
} | [
"func",
"(",
"fiInfo",
"*",
"FieldInfo",
")",
"Ignored",
"(",
")",
"bool",
"{",
"tagJSON",
":=",
"ucon",
".",
"NewTagJSON",
"(",
"fiInfo",
".",
"Base",
".",
"Tag",
")",
"\n",
"if",
"tagJSON",
".",
"Ignored",
"(",
")",
"{",
"return",
"true",
"\n",
"... | // Ignored is an ignored field. | [
"Ignored",
"is",
"an",
"ignored",
"field",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L68-L75 |
145,994 | favclip/ucon | swagger/plugin.go | Name | func (fiInfo *FieldInfo) Name() string {
tagJSON := ucon.NewTagJSON(fiInfo.Base.Tag)
name := tagJSON.Name()
if name == "" {
name = fiInfo.Base.Name
}
return name
} | go | func (fiInfo *FieldInfo) Name() string {
tagJSON := ucon.NewTagJSON(fiInfo.Base.Tag)
name := tagJSON.Name()
if name == "" {
name = fiInfo.Base.Name
}
return name
} | [
"func",
"(",
"fiInfo",
"*",
"FieldInfo",
")",
"Name",
"(",
")",
"string",
"{",
"tagJSON",
":=",
"ucon",
".",
"NewTagJSON",
"(",
"fiInfo",
".",
"Base",
".",
"Tag",
")",
"\n",
"name",
":=",
"tagJSON",
".",
"Name",
"(",
")",
"\n",
"if",
"name",
"==",
... | // Name returns field name on swagger. | [
"Name",
"returns",
"field",
"name",
"on",
"swagger",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L78-L86 |
145,995 | favclip/ucon | swagger/plugin.go | SwaggerSchema | func (ts *TypeSchema) SwaggerSchema() (*Schema, error) {
if ts.AllowRef && ts.RefName != "" {
return &Schema{Ref: fmt.Sprintf("#/definitions/%s", ts.RefName)}, nil
} else if ts.AllowRef {
return nil, errors.New("Name is required")
}
return ts.Schema.ShallowCopy(), nil
} | go | func (ts *TypeSchema) SwaggerSchema() (*Schema, error) {
if ts.AllowRef && ts.RefName != "" {
return &Schema{Ref: fmt.Sprintf("#/definitions/%s", ts.RefName)}, nil
} else if ts.AllowRef {
return nil, errors.New("Name is required")
}
return ts.Schema.ShallowCopy(), nil
} | [
"func",
"(",
"ts",
"*",
"TypeSchema",
")",
"SwaggerSchema",
"(",
")",
"(",
"*",
"Schema",
",",
"error",
")",
"{",
"if",
"ts",
".",
"AllowRef",
"&&",
"ts",
".",
"RefName",
"!=",
"\"",
"\"",
"{",
"return",
"&",
"Schema",
"{",
"Ref",
":",
"fmt",
"."... | // SwaggerSchema returns schema that is can use is swagger.json. | [
"SwaggerSchema",
"returns",
"schema",
"that",
"is",
"can",
"use",
"is",
"swagger",
".",
"json",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L97-L105 |
145,996 | favclip/ucon | swagger/plugin.go | NewPlugin | func NewPlugin(opts *Options) *Plugin {
if opts == nil {
opts = &Options{}
}
so := opts.Object
if so == nil {
so = &Object{}
}
if so.Paths == nil {
so.Paths = make(Paths, 0)
}
if so.Definitions == nil {
so.Definitions = make(Definitions, 0)
}
p := &Plugin{options: opts}
soConstructor := &swaggerOb... | go | func NewPlugin(opts *Options) *Plugin {
if opts == nil {
opts = &Options{}
}
so := opts.Object
if so == nil {
so = &Object{}
}
if so.Paths == nil {
so.Paths = make(Paths, 0)
}
if so.Definitions == nil {
so.Definitions = make(Definitions, 0)
}
p := &Plugin{options: opts}
soConstructor := &swaggerOb... | [
"func",
"NewPlugin",
"(",
"opts",
"*",
"Options",
")",
"*",
"Plugin",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"&",
"Options",
"{",
"}",
"\n",
"}",
"\n\n",
"so",
":=",
"opts",
".",
"Object",
"\n\n",
"if",
"so",
"==",
"nil",
"{",
"so",
... | // NewPlugin returns new swagger plugin configured with the options. | [
"NewPlugin",
"returns",
"new",
"swagger",
"plugin",
"configured",
"with",
"the",
"options",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L140-L169 |
145,997 | favclip/ucon | swagger/plugin.go | HandlersScannerProcess | func (p *Plugin) HandlersScannerProcess(m *ucon.ServeMux, rds []*ucon.RouteDefinition) error {
soConstructor := p.constructor
// construct swagger.json
for _, rd := range rds {
err := soConstructor.processHandler(rd)
if err != nil {
return err
}
}
err := soConstructor.object.finish()
if err != nil {
... | go | func (p *Plugin) HandlersScannerProcess(m *ucon.ServeMux, rds []*ucon.RouteDefinition) error {
soConstructor := p.constructor
// construct swagger.json
for _, rd := range rds {
err := soConstructor.processHandler(rd)
if err != nil {
return err
}
}
err := soConstructor.object.finish()
if err != nil {
... | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"HandlersScannerProcess",
"(",
"m",
"*",
"ucon",
".",
"ServeMux",
",",
"rds",
"[",
"]",
"*",
"ucon",
".",
"RouteDefinition",
")",
"error",
"{",
"soConstructor",
":=",
"p",
".",
"constructor",
"\n\n",
"// construct swag... | // HandlersScannerProcess executes scanning all registered handlers to serve swagger.json. | [
"HandlersScannerProcess",
"executes",
"scanning",
"all",
"registered",
"handlers",
"to",
"serve",
"swagger",
".",
"json",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L172-L194 |
145,998 | favclip/ucon | swagger/plugin.go | AddTag | func (p *Plugin) AddTag(tag *Tag) *Tag {
p.constructor.object.Tags = append(p.constructor.object.Tags, tag)
return tag
} | go | func (p *Plugin) AddTag(tag *Tag) *Tag {
p.constructor.object.Tags = append(p.constructor.object.Tags, tag)
return tag
} | [
"func",
"(",
"p",
"*",
"Plugin",
")",
"AddTag",
"(",
"tag",
"*",
"Tag",
")",
"*",
"Tag",
"{",
"p",
".",
"constructor",
".",
"object",
".",
"Tags",
"=",
"append",
"(",
"p",
".",
"constructor",
".",
"object",
".",
"Tags",
",",
"tag",
")",
"\n\n",
... | // AddTag adds the tag to top-level tags definition. | [
"AddTag",
"adds",
"the",
"tag",
"to",
"top",
"-",
"level",
"tags",
"definition",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L817-L821 |
145,999 | favclip/ucon | swagger/plugin.go | Value | func (wr *HandlerInfo) Value(key interface{}) interface{} {
if key == (swaggerOperationKey{}) {
return &wr.Operation
}
if wr.Context != nil {
return wr.Context.Value(key)
}
return nil
} | go | func (wr *HandlerInfo) Value(key interface{}) interface{} {
if key == (swaggerOperationKey{}) {
return &wr.Operation
}
if wr.Context != nil {
return wr.Context.Value(key)
}
return nil
} | [
"func",
"(",
"wr",
"*",
"HandlerInfo",
")",
"Value",
"(",
"key",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"if",
"key",
"==",
"(",
"swaggerOperationKey",
"{",
"}",
")",
"{",
"return",
"&",
"wr",
".",
"Operation",
"\n",
"}",
"\n",
"if"... | // Value returns the value contained with the key. | [
"Value",
"returns",
"the",
"value",
"contained",
"with",
"the",
"key",
"."
] | f7a2801cdedb602de113d88a0e8561cc34e5f5e4 | https://github.com/favclip/ucon/blob/f7a2801cdedb602de113d88a0e8561cc34e5f5e4/swagger/plugin.go#L944-L952 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.