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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,600 | Azure/go-autorest | autorest/mocks/mocks.go | AppendAndRepeatResponse | func (c *Sender) AppendAndRepeatResponse(resp *http.Response, repeat int) {
c.appendAndRepeat(response{r: resp}, repeat)
} | go | func (c *Sender) AppendAndRepeatResponse(resp *http.Response, repeat int) {
c.appendAndRepeat(response{r: resp}, repeat)
} | [
"func",
"(",
"c",
"*",
"Sender",
")",
"AppendAndRepeatResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"repeat",
"int",
")",
"{",
"c",
".",
"appendAndRepeat",
"(",
"response",
"{",
"r",
":",
"resp",
"}",
",",
"repeat",
")",
"\n",
"}"
] | // AppendAndRepeatResponse adds the passed http.Response to the response stack along with a
// repeat count. A negative repeat count will return the response for all remaining calls to Do. | [
"AppendAndRepeatResponse",
"adds",
"the",
"passed",
"http",
".",
"Response",
"to",
"the",
"response",
"stack",
"along",
"with",
"a",
"repeat",
"count",
".",
"A",
"negative",
"repeat",
"count",
"will",
"return",
"the",
"response",
"for",
"all",
"remaining",
"ca... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/mocks/mocks.go#L164-L166 |
30,601 | Azure/go-autorest | autorest/mocks/mocks.go | AppendAndRepeatResponseWithDelay | func (c *Sender) AppendAndRepeatResponseWithDelay(resp *http.Response, delay time.Duration, repeat int) {
c.appendAndRepeat(response{r: resp, d: delay}, repeat)
} | go | func (c *Sender) AppendAndRepeatResponseWithDelay(resp *http.Response, delay time.Duration, repeat int) {
c.appendAndRepeat(response{r: resp, d: delay}, repeat)
} | [
"func",
"(",
"c",
"*",
"Sender",
")",
"AppendAndRepeatResponseWithDelay",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"delay",
"time",
".",
"Duration",
",",
"repeat",
"int",
")",
"{",
"c",
".",
"appendAndRepeat",
"(",
"response",
"{",
"r",
":",
"resp... | // AppendAndRepeatResponseWithDelay adds the passed http.Response to the response stack with the specified
// delay along with a repeat count. A negative repeat count will return the response for all remaining calls to Do. | [
"AppendAndRepeatResponseWithDelay",
"adds",
"the",
"passed",
"http",
".",
"Response",
"to",
"the",
"response",
"stack",
"with",
"the",
"specified",
"delay",
"along",
"with",
"a",
"repeat",
"count",
".",
"A",
"negative",
"repeat",
"count",
"will",
"return",
"the"... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/mocks/mocks.go#L170-L172 |
30,602 | Azure/go-autorest | autorest/mocks/mocks.go | AppendAndRepeatError | func (c *Sender) AppendAndRepeatError(err error, repeat int) {
c.appendAndRepeat(response{e: err}, repeat)
} | go | func (c *Sender) AppendAndRepeatError(err error, repeat int) {
c.appendAndRepeat(response{e: err}, repeat)
} | [
"func",
"(",
"c",
"*",
"Sender",
")",
"AppendAndRepeatError",
"(",
"err",
"error",
",",
"repeat",
"int",
")",
"{",
"c",
".",
"appendAndRepeat",
"(",
"response",
"{",
"e",
":",
"err",
"}",
",",
"repeat",
")",
"\n",
"}"
] | // AppendAndRepeatError adds the passed error to the response stack along with a repeat
// count. A negative repeat count will return the response for all remaining calls to Do. | [
"AppendAndRepeatError",
"adds",
"the",
"passed",
"error",
"to",
"the",
"response",
"stack",
"along",
"with",
"a",
"repeat",
"count",
".",
"A",
"negative",
"repeat",
"count",
"will",
"return",
"the",
"response",
"for",
"all",
"remaining",
"calls",
"to",
"Do",
... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/mocks/mocks.go#L181-L183 |
30,603 | Azure/go-autorest | autorest/mocks/mocks.go | SetAndRepeatError | func (c *Sender) SetAndRepeatError(err error, repeat int) {
c.err = err
c.repeatError = repeat
} | go | func (c *Sender) SetAndRepeatError(err error, repeat int) {
c.err = err
c.repeatError = repeat
} | [
"func",
"(",
"c",
"*",
"Sender",
")",
"SetAndRepeatError",
"(",
"err",
"error",
",",
"repeat",
"int",
")",
"{",
"c",
".",
"err",
"=",
"err",
"\n",
"c",
".",
"repeatError",
"=",
"repeat",
"\n",
"}"
] | // SetAndRepeatError sets the error Do should return and how many calls to Do will return the error.
// A negative repeat value will return the error for all remaining calls to Do. | [
"SetAndRepeatError",
"sets",
"the",
"error",
"Do",
"should",
"return",
"and",
"how",
"many",
"calls",
"to",
"Do",
"will",
"return",
"the",
"error",
".",
"A",
"negative",
"repeat",
"value",
"will",
"return",
"the",
"error",
"for",
"all",
"remaining",
"calls",... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/mocks/mocks.go#L208-L211 |
30,604 | Azure/go-autorest | autorest/azure/cli/profile.go | ProfilePath | func ProfilePath() (string, error) {
if cfgDir := os.Getenv("AZURE_CONFIG_DIR"); cfgDir != "" {
return filepath.Join(cfgDir, azureProfileJSON), nil
}
return homedir.Expand("~/.azure/" + azureProfileJSON)
} | go | func ProfilePath() (string, error) {
if cfgDir := os.Getenv("AZURE_CONFIG_DIR"); cfgDir != "" {
return filepath.Join(cfgDir, azureProfileJSON), nil
}
return homedir.Expand("~/.azure/" + azureProfileJSON)
} | [
"func",
"ProfilePath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"cfgDir",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"cfgDir",
"!=",
"\"",
"\"",
"{",
"return",
"filepath",
".",
"Join",
"(",
"cfgDir",
",",
"azureProfileJSON",
... | // ProfilePath returns the path where the Azure Profile is stored from the Azure CLI | [
"ProfilePath",
"returns",
"the",
"path",
"where",
"the",
"Azure",
"Profile",
"is",
"stored",
"from",
"the",
"Azure",
"CLI"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/cli/profile.go#L55-L60 |
30,605 | Azure/go-autorest | autorest/azure/cli/profile.go | LoadProfile | func LoadProfile(path string) (result Profile, err error) {
var contents []byte
contents, err = ioutil.ReadFile(path)
if err != nil {
err = fmt.Errorf("failed to open file (%s) while loading token: %v", path, err)
return
}
reader := utfbom.SkipOnly(bytes.NewReader(contents))
dec := json.NewDecoder(reader)
i... | go | func LoadProfile(path string) (result Profile, err error) {
var contents []byte
contents, err = ioutil.ReadFile(path)
if err != nil {
err = fmt.Errorf("failed to open file (%s) while loading token: %v", path, err)
return
}
reader := utfbom.SkipOnly(bytes.NewReader(contents))
dec := json.NewDecoder(reader)
i... | [
"func",
"LoadProfile",
"(",
"path",
"string",
")",
"(",
"result",
"Profile",
",",
"err",
"error",
")",
"{",
"var",
"contents",
"[",
"]",
"byte",
"\n",
"contents",
",",
"err",
"=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
... | // LoadProfile restores a Profile object from a file located at 'path'. | [
"LoadProfile",
"restores",
"a",
"Profile",
"object",
"from",
"a",
"file",
"located",
"at",
"path",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/cli/profile.go#L63-L79 |
30,606 | Azure/go-autorest | autorest/autorest.go | ResponseHasStatusCode | func ResponseHasStatusCode(resp *http.Response, codes ...int) bool {
if resp == nil {
return false
}
return containsInt(codes, resp.StatusCode)
} | go | func ResponseHasStatusCode(resp *http.Response, codes ...int) bool {
if resp == nil {
return false
}
return containsInt(codes, resp.StatusCode)
} | [
"func",
"ResponseHasStatusCode",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"codes",
"...",
"int",
")",
"bool",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"containsInt",
"(",
"codes",
",",
"resp",
".",
"Stat... | // ResponseHasStatusCode returns true if the status code in the HTTP Response is in the passed set
// and false otherwise. | [
"ResponseHasStatusCode",
"returns",
"true",
"if",
"the",
"status",
"code",
"in",
"the",
"HTTP",
"Response",
"is",
"in",
"the",
"passed",
"set",
"and",
"false",
"otherwise",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/autorest.go#L90-L95 |
30,607 | Azure/go-autorest | autorest/autorest.go | GetRetryAfter | func GetRetryAfter(resp *http.Response, defaultDelay time.Duration) time.Duration {
retry := resp.Header.Get(HeaderRetryAfter)
if retry == "" {
return defaultDelay
}
d, err := time.ParseDuration(retry + "s")
if err != nil {
return defaultDelay
}
return d
} | go | func GetRetryAfter(resp *http.Response, defaultDelay time.Duration) time.Duration {
retry := resp.Header.Get(HeaderRetryAfter)
if retry == "" {
return defaultDelay
}
d, err := time.ParseDuration(retry + "s")
if err != nil {
return defaultDelay
}
return d
} | [
"func",
"GetRetryAfter",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"defaultDelay",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"retry",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"HeaderRetryAfter",
")",
"\n",
"if",
"retry",
"=="... | // GetRetryAfter extracts the retry delay from the Retry-After header of the passed response. If
// the header is absent or is malformed, it will return the supplied default delay time.Duration. | [
"GetRetryAfter",
"extracts",
"the",
"retry",
"delay",
"from",
"the",
"Retry",
"-",
"After",
"header",
"of",
"the",
"passed",
"response",
".",
"If",
"the",
"header",
"is",
"absent",
"or",
"is",
"malformed",
"it",
"will",
"return",
"the",
"supplied",
"default"... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/autorest.go#L104-L116 |
30,608 | Azure/go-autorest | autorest/autorest.go | NewPollingRequest | func NewPollingRequest(resp *http.Response, cancel <-chan struct{}) (*http.Request, error) {
location := GetLocation(resp)
if location == "" {
return nil, NewErrorWithResponse("autorest", "NewPollingRequest", resp, "Location header missing from response that requires polling")
}
req, err := Prepare(&http.Request... | go | func NewPollingRequest(resp *http.Response, cancel <-chan struct{}) (*http.Request, error) {
location := GetLocation(resp)
if location == "" {
return nil, NewErrorWithResponse("autorest", "NewPollingRequest", resp, "Location header missing from response that requires polling")
}
req, err := Prepare(&http.Request... | [
"func",
"NewPollingRequest",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"cancel",
"<-",
"chan",
"struct",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"location",
":=",
"GetLocation",
"(",
"resp",
")",
"\n",
"if",
"lo... | // NewPollingRequest allocates and returns a new http.Request to poll for the passed response. | [
"NewPollingRequest",
"allocates",
"and",
"returns",
"a",
"new",
"http",
".",
"Request",
"to",
"poll",
"for",
"the",
"passed",
"response",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/autorest.go#L119-L133 |
30,609 | Azure/go-autorest | autorest/autorest.go | NewPollingRequestWithContext | func NewPollingRequestWithContext(ctx context.Context, resp *http.Response) (*http.Request, error) {
location := GetLocation(resp)
if location == "" {
return nil, NewErrorWithResponse("autorest", "NewPollingRequestWithContext", resp, "Location header missing from response that requires polling")
}
req, err := Pr... | go | func NewPollingRequestWithContext(ctx context.Context, resp *http.Response) (*http.Request, error) {
location := GetLocation(resp)
if location == "" {
return nil, NewErrorWithResponse("autorest", "NewPollingRequestWithContext", resp, "Location header missing from response that requires polling")
}
req, err := Pr... | [
"func",
"NewPollingRequestWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"location",
":=",
"GetLocation",
"(",
"resp",
")",
"\n",
"if",
"locat... | // NewPollingRequestWithContext allocates and returns a new http.Request with the specified context to poll for the passed response. | [
"NewPollingRequestWithContext",
"allocates",
"and",
"returns",
"a",
"new",
"http",
".",
"Request",
"with",
"the",
"specified",
"context",
"to",
"poll",
"for",
"the",
"passed",
"response",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/autorest.go#L136-L150 |
30,610 | Azure/go-autorest | autorest/error.go | NewError | func NewError(packageType string, method string, message string, args ...interface{}) DetailedError {
return NewErrorWithError(nil, packageType, method, nil, message, args...)
} | go | func NewError(packageType string, method string, message string, args ...interface{}) DetailedError {
return NewErrorWithError(nil, packageType, method, nil, message, args...)
} | [
"func",
"NewError",
"(",
"packageType",
"string",
",",
"method",
"string",
",",
"message",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"DetailedError",
"{",
"return",
"NewErrorWithError",
"(",
"nil",
",",
"packageType",
",",
"method",
",",
"nil... | // NewError creates a new Error conforming object from the passed packageType, method, and
// message. message is treated as a format string to which the optional args apply. | [
"NewError",
"creates",
"a",
"new",
"Error",
"conforming",
"object",
"from",
"the",
"passed",
"packageType",
"method",
"and",
"message",
".",
"message",
"is",
"treated",
"as",
"a",
"format",
"string",
"to",
"which",
"the",
"optional",
"args",
"apply",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/error.go#L55-L57 |
30,611 | Azure/go-autorest | autorest/date/utility.go | ParseTime | func ParseTime(format string, t string) (d time.Time, err error) {
return time.Parse(format, strings.ToUpper(t))
} | go | func ParseTime(format string, t string) (d time.Time, err error) {
return time.Parse(format, strings.ToUpper(t))
} | [
"func",
"ParseTime",
"(",
"format",
"string",
",",
"t",
"string",
")",
"(",
"d",
"time",
".",
"Time",
",",
"err",
"error",
")",
"{",
"return",
"time",
".",
"Parse",
"(",
"format",
",",
"strings",
".",
"ToUpper",
"(",
"t",
")",
")",
"\n",
"}"
] | // ParseTime to parse Time string to specified format. | [
"ParseTime",
"to",
"parse",
"Time",
"string",
"to",
"specified",
"format",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/utility.go#L23-L25 |
30,612 | Azure/go-autorest | autorest/adal/config.go | NewOAuthConfig | func NewOAuthConfig(activeDirectoryEndpoint, tenantID string) (*OAuthConfig, error) {
apiVer := "1.0"
return NewOAuthConfigWithAPIVersion(activeDirectoryEndpoint, tenantID, &apiVer)
} | go | func NewOAuthConfig(activeDirectoryEndpoint, tenantID string) (*OAuthConfig, error) {
apiVer := "1.0"
return NewOAuthConfigWithAPIVersion(activeDirectoryEndpoint, tenantID, &apiVer)
} | [
"func",
"NewOAuthConfig",
"(",
"activeDirectoryEndpoint",
",",
"tenantID",
"string",
")",
"(",
"*",
"OAuthConfig",
",",
"error",
")",
"{",
"apiVer",
":=",
"\"",
"\"",
"\n",
"return",
"NewOAuthConfigWithAPIVersion",
"(",
"activeDirectoryEndpoint",
",",
"tenantID",
... | // NewOAuthConfig returns an OAuthConfig with tenant specific urls | [
"NewOAuthConfig",
"returns",
"an",
"OAuthConfig",
"with",
"tenant",
"specific",
"urls"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/adal/config.go#L44-L47 |
30,613 | Azure/go-autorest | autorest/adal/config.go | NewOAuthConfigWithAPIVersion | func NewOAuthConfigWithAPIVersion(activeDirectoryEndpoint, tenantID string, apiVersion *string) (*OAuthConfig, error) {
if err := validateStringParam(activeDirectoryEndpoint, "activeDirectoryEndpoint"); err != nil {
return nil, err
}
api := ""
// it's legal for tenantID to be empty so don't validate it
if apiVer... | go | func NewOAuthConfigWithAPIVersion(activeDirectoryEndpoint, tenantID string, apiVersion *string) (*OAuthConfig, error) {
if err := validateStringParam(activeDirectoryEndpoint, "activeDirectoryEndpoint"); err != nil {
return nil, err
}
api := ""
// it's legal for tenantID to be empty so don't validate it
if apiVer... | [
"func",
"NewOAuthConfigWithAPIVersion",
"(",
"activeDirectoryEndpoint",
",",
"tenantID",
"string",
",",
"apiVersion",
"*",
"string",
")",
"(",
"*",
"OAuthConfig",
",",
"error",
")",
"{",
"if",
"err",
":=",
"validateStringParam",
"(",
"activeDirectoryEndpoint",
",",
... | // NewOAuthConfigWithAPIVersion returns an OAuthConfig with tenant specific urls.
// If apiVersion is not nil the "api-version" query parameter will be appended to the endpoint URLs with the specified value. | [
"NewOAuthConfigWithAPIVersion",
"returns",
"an",
"OAuthConfig",
"with",
"tenant",
"specific",
"urls",
".",
"If",
"apiVersion",
"is",
"not",
"nil",
"the",
"api",
"-",
"version",
"query",
"parameter",
"will",
"be",
"appended",
"to",
"the",
"endpoint",
"URLs",
"wit... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/adal/config.go#L51-L91 |
30,614 | Azure/go-autorest | autorest/adal/devicetoken.go | InitiateDeviceAuth | func InitiateDeviceAuth(sender Sender, oauthConfig OAuthConfig, clientID, resource string) (*DeviceCode, error) {
v := url.Values{
"client_id": []string{clientID},
"resource": []string{resource},
}
s := v.Encode()
body := ioutil.NopCloser(strings.NewReader(s))
req, err := http.NewRequest(http.MethodPost, oa... | go | func InitiateDeviceAuth(sender Sender, oauthConfig OAuthConfig, clientID, resource string) (*DeviceCode, error) {
v := url.Values{
"client_id": []string{clientID},
"resource": []string{resource},
}
s := v.Encode()
body := ioutil.NopCloser(strings.NewReader(s))
req, err := http.NewRequest(http.MethodPost, oa... | [
"func",
"InitiateDeviceAuth",
"(",
"sender",
"Sender",
",",
"oauthConfig",
"OAuthConfig",
",",
"clientID",
",",
"resource",
"string",
")",
"(",
"*",
"DeviceCode",
",",
"error",
")",
"{",
"v",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"[",
"]",
... | // InitiateDeviceAuth initiates a device auth flow. It returns a DeviceCode
// that can be used with CheckForUserCompletion or WaitForUserCompletion. | [
"InitiateDeviceAuth",
"initiates",
"a",
"device",
"auth",
"flow",
".",
"It",
"returns",
"a",
"DeviceCode",
"that",
"can",
"be",
"used",
"with",
"CheckForUserCompletion",
"or",
"WaitForUserCompletion",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/adal/devicetoken.go#L104-L150 |
30,615 | Azure/go-autorest | autorest/adal/devicetoken.go | WaitForUserCompletion | func WaitForUserCompletion(sender Sender, code *DeviceCode) (*Token, error) {
intervalDuration := time.Duration(*code.Interval) * time.Second
waitDuration := intervalDuration
for {
token, err := CheckForUserCompletion(sender, code)
if err == nil {
return token, nil
}
switch err {
case ErrDeviceSlowDo... | go | func WaitForUserCompletion(sender Sender, code *DeviceCode) (*Token, error) {
intervalDuration := time.Duration(*code.Interval) * time.Second
waitDuration := intervalDuration
for {
token, err := CheckForUserCompletion(sender, code)
if err == nil {
return token, nil
}
switch err {
case ErrDeviceSlowDo... | [
"func",
"WaitForUserCompletion",
"(",
"sender",
"Sender",
",",
"code",
"*",
"DeviceCode",
")",
"(",
"*",
"Token",
",",
"error",
")",
"{",
"intervalDuration",
":=",
"time",
".",
"Duration",
"(",
"*",
"code",
".",
"Interval",
")",
"*",
"time",
".",
"Second... | // WaitForUserCompletion calls CheckForUserCompletion repeatedly until a token is granted or an error state occurs.
// This prevents the user from looping and checking against 'ErrDeviceAuthorizationPending'. | [
"WaitForUserCompletion",
"calls",
"CheckForUserCompletion",
"repeatedly",
"until",
"a",
"token",
"is",
"granted",
"or",
"an",
"error",
"state",
"occurs",
".",
"This",
"prevents",
"the",
"user",
"from",
"looping",
"and",
"checking",
"against",
"ErrDeviceAuthorizationPe... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/adal/devicetoken.go#L216-L242 |
30,616 | Azure/go-autorest | autorest/date/unixtime.go | Duration | func (t UnixTime) Duration() time.Duration {
return time.Time(t).Sub(unixEpoch)
} | go | func (t UnixTime) Duration() time.Duration {
return time.Time(t).Sub(unixEpoch)
} | [
"func",
"(",
"t",
"UnixTime",
")",
"Duration",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Time",
"(",
"t",
")",
".",
"Sub",
"(",
"unixEpoch",
")",
"\n",
"}"
] | // Duration returns the time as a Duration since the UnixEpoch. | [
"Duration",
"returns",
"the",
"time",
"as",
"a",
"Duration",
"since",
"the",
"UnixEpoch",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L32-L34 |
30,617 | Azure/go-autorest | autorest/date/unixtime.go | NewUnixTimeFromSeconds | func NewUnixTimeFromSeconds(seconds float64) UnixTime {
return NewUnixTimeFromDuration(time.Duration(seconds * float64(time.Second)))
} | go | func NewUnixTimeFromSeconds(seconds float64) UnixTime {
return NewUnixTimeFromDuration(time.Duration(seconds * float64(time.Second)))
} | [
"func",
"NewUnixTimeFromSeconds",
"(",
"seconds",
"float64",
")",
"UnixTime",
"{",
"return",
"NewUnixTimeFromDuration",
"(",
"time",
".",
"Duration",
"(",
"seconds",
"*",
"float64",
"(",
"time",
".",
"Second",
")",
")",
")",
"\n",
"}"
] | // NewUnixTimeFromSeconds creates a UnixTime as a number of seconds from the UnixEpoch. | [
"NewUnixTimeFromSeconds",
"creates",
"a",
"UnixTime",
"as",
"a",
"number",
"of",
"seconds",
"from",
"the",
"UnixEpoch",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L37-L39 |
30,618 | Azure/go-autorest | autorest/date/unixtime.go | UnmarshalJSON | func (t *UnixTime) UnmarshalJSON(text []byte) error {
dec := json.NewDecoder(bytes.NewReader(text))
var secondsSinceEpoch float64
if err := dec.Decode(&secondsSinceEpoch); err != nil {
return err
}
*t = NewUnixTimeFromSeconds(secondsSinceEpoch)
return nil
} | go | func (t *UnixTime) UnmarshalJSON(text []byte) error {
dec := json.NewDecoder(bytes.NewReader(text))
var secondsSinceEpoch float64
if err := dec.Decode(&secondsSinceEpoch); err != nil {
return err
}
*t = NewUnixTimeFromSeconds(secondsSinceEpoch)
return nil
} | [
"func",
"(",
"t",
"*",
"UnixTime",
")",
"UnmarshalJSON",
"(",
"text",
"[",
"]",
"byte",
")",
"error",
"{",
"dec",
":=",
"json",
".",
"NewDecoder",
"(",
"bytes",
".",
"NewReader",
"(",
"text",
")",
")",
"\n\n",
"var",
"secondsSinceEpoch",
"float64",
"\n... | // UnmarshalJSON reconstitures a UnixTime saved as a JSON number of the number of seconds since
// midnight January 1st, 1970. | [
"UnmarshalJSON",
"reconstitures",
"a",
"UnixTime",
"saved",
"as",
"a",
"JSON",
"number",
"of",
"the",
"number",
"of",
"seconds",
"since",
"midnight",
"January",
"1st",
"1970",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L70-L81 |
30,619 | Azure/go-autorest | autorest/date/unixtime.go | MarshalText | func (t UnixTime) MarshalText() ([]byte, error) {
cast := time.Time(t)
return cast.MarshalText()
} | go | func (t UnixTime) MarshalText() ([]byte, error) {
cast := time.Time(t)
return cast.MarshalText()
} | [
"func",
"(",
"t",
"UnixTime",
")",
"MarshalText",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cast",
":=",
"time",
".",
"Time",
"(",
"t",
")",
"\n",
"return",
"cast",
".",
"MarshalText",
"(",
")",
"\n",
"}"
] | // MarshalText stores the number of seconds since the Unix Epoch as a textual floating point number. | [
"MarshalText",
"stores",
"the",
"number",
"of",
"seconds",
"since",
"the",
"Unix",
"Epoch",
"as",
"a",
"textual",
"floating",
"point",
"number",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L84-L87 |
30,620 | Azure/go-autorest | autorest/date/unixtime.go | UnmarshalText | func (t *UnixTime) UnmarshalText(raw []byte) error {
var unmarshaled time.Time
if err := unmarshaled.UnmarshalText(raw); err != nil {
return err
}
*t = UnixTime(unmarshaled)
return nil
} | go | func (t *UnixTime) UnmarshalText(raw []byte) error {
var unmarshaled time.Time
if err := unmarshaled.UnmarshalText(raw); err != nil {
return err
}
*t = UnixTime(unmarshaled)
return nil
} | [
"func",
"(",
"t",
"*",
"UnixTime",
")",
"UnmarshalText",
"(",
"raw",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"unmarshaled",
"time",
".",
"Time",
"\n\n",
"if",
"err",
":=",
"unmarshaled",
".",
"UnmarshalText",
"(",
"raw",
")",
";",
"err",
"!=",
"n... | // UnmarshalText populates a UnixTime with a value stored textually as a floating point number of seconds since the Unix Epoch. | [
"UnmarshalText",
"populates",
"a",
"UnixTime",
"with",
"a",
"value",
"stored",
"textually",
"as",
"a",
"floating",
"point",
"number",
"of",
"seconds",
"since",
"the",
"Unix",
"Epoch",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L90-L99 |
30,621 | Azure/go-autorest | autorest/date/unixtime.go | MarshalBinary | func (t UnixTime) MarshalBinary() ([]byte, error) {
buf := &bytes.Buffer{}
payload := int64(t.Duration())
if err := binary.Write(buf, binary.LittleEndian, &payload); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | go | func (t UnixTime) MarshalBinary() ([]byte, error) {
buf := &bytes.Buffer{}
payload := int64(t.Duration())
if err := binary.Write(buf, binary.LittleEndian, &payload); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | [
"func",
"(",
"t",
"UnixTime",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n\n",
"payload",
":=",
"int64",
"(",
"t",
".",
"Duration",
"(",
")",
")",
"\n\n",
... | // MarshalBinary converts a UnixTime into a binary.LittleEndian float64 of nanoseconds since the epoch. | [
"MarshalBinary",
"converts",
"a",
"UnixTime",
"into",
"a",
"binary",
".",
"LittleEndian",
"float64",
"of",
"nanoseconds",
"since",
"the",
"epoch",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L102-L112 |
30,622 | Azure/go-autorest | autorest/date/unixtime.go | UnmarshalBinary | func (t *UnixTime) UnmarshalBinary(raw []byte) error {
var nanosecondsSinceEpoch int64
if err := binary.Read(bytes.NewReader(raw), binary.LittleEndian, &nanosecondsSinceEpoch); err != nil {
return err
}
*t = NewUnixTimeFromNanoseconds(nanosecondsSinceEpoch)
return nil
} | go | func (t *UnixTime) UnmarshalBinary(raw []byte) error {
var nanosecondsSinceEpoch int64
if err := binary.Read(bytes.NewReader(raw), binary.LittleEndian, &nanosecondsSinceEpoch); err != nil {
return err
}
*t = NewUnixTimeFromNanoseconds(nanosecondsSinceEpoch)
return nil
} | [
"func",
"(",
"t",
"*",
"UnixTime",
")",
"UnmarshalBinary",
"(",
"raw",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"nanosecondsSinceEpoch",
"int64",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"bytes",
".",
"NewReader",
"(",
"raw",
")",
",",... | // UnmarshalBinary converts a from a binary.LittleEndian float64 of nanoseconds since the epoch into a UnixTime. | [
"UnmarshalBinary",
"converts",
"a",
"from",
"a",
"binary",
".",
"LittleEndian",
"float64",
"of",
"nanoseconds",
"since",
"the",
"epoch",
"into",
"a",
"UnixTime",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/unixtime.go#L115-L123 |
30,623 | Azure/go-autorest | autorest/to/convert.go | StringMap | func StringMap(msp map[string]*string) map[string]string {
ms := make(map[string]string, len(msp))
for k, sp := range msp {
if sp != nil {
ms[k] = *sp
} else {
ms[k] = ""
}
}
return ms
} | go | func StringMap(msp map[string]*string) map[string]string {
ms := make(map[string]string, len(msp))
for k, sp := range msp {
if sp != nil {
ms[k] = *sp
} else {
ms[k] = ""
}
}
return ms
} | [
"func",
"StringMap",
"(",
"msp",
"map",
"[",
"string",
"]",
"*",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"ms",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"msp",
")",
")",
"\n",
"for",
"k",
",",
"sp... | // StringMap returns a map of strings built from the map of string pointers. The empty string is
// used for nil pointers. | [
"StringMap",
"returns",
"a",
"map",
"of",
"strings",
"built",
"from",
"the",
"map",
"of",
"string",
"pointers",
".",
"The",
"empty",
"string",
"is",
"used",
"for",
"nil",
"pointers",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/to/convert.go#L50-L60 |
30,624 | Azure/go-autorest | autorest/to/convert.go | StringMapPtr | func StringMapPtr(ms map[string]string) *map[string]*string {
msp := make(map[string]*string, len(ms))
for k, s := range ms {
msp[k] = StringPtr(s)
}
return &msp
} | go | func StringMapPtr(ms map[string]string) *map[string]*string {
msp := make(map[string]*string, len(ms))
for k, s := range ms {
msp[k] = StringPtr(s)
}
return &msp
} | [
"func",
"StringMapPtr",
"(",
"ms",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"map",
"[",
"string",
"]",
"*",
"string",
"{",
"msp",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"string",
",",
"len",
"(",
"ms",
")",
")",
"\n",
"for",
"... | // StringMapPtr returns a pointer to a map of string pointers built from the passed map of strings. | [
"StringMapPtr",
"returns",
"a",
"pointer",
"to",
"a",
"map",
"of",
"string",
"pointers",
"built",
"from",
"the",
"passed",
"map",
"of",
"strings",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/to/convert.go#L63-L69 |
30,625 | Azure/go-autorest | autorest/azure/cli/token.go | ToADALToken | func (t Token) ToADALToken() (converted adal.Token, err error) {
tokenExpirationDate, err := ParseExpirationDate(t.ExpiresOn)
if err != nil {
err = fmt.Errorf("Error parsing Token Expiration Date %q: %+v", t.ExpiresOn, err)
return
}
difference := tokenExpirationDate.Sub(date.UnixEpoch())
converted = adal.Tok... | go | func (t Token) ToADALToken() (converted adal.Token, err error) {
tokenExpirationDate, err := ParseExpirationDate(t.ExpiresOn)
if err != nil {
err = fmt.Errorf("Error parsing Token Expiration Date %q: %+v", t.ExpiresOn, err)
return
}
difference := tokenExpirationDate.Sub(date.UnixEpoch())
converted = adal.Tok... | [
"func",
"(",
"t",
"Token",
")",
"ToADALToken",
"(",
")",
"(",
"converted",
"adal",
".",
"Token",
",",
"err",
"error",
")",
"{",
"tokenExpirationDate",
",",
"err",
":=",
"ParseExpirationDate",
"(",
"t",
".",
"ExpiresOn",
")",
"\n",
"if",
"err",
"!=",
"n... | // ToADALToken converts an Azure CLI `Token`` to an `adal.Token`` | [
"ToADALToken",
"converts",
"an",
"Azure",
"CLI",
"Token",
"to",
"an",
"adal",
".",
"Token"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/cli/token.go#L48-L66 |
30,626 | Azure/go-autorest | autorest/azure/cli/token.go | ParseExpirationDate | func ParseExpirationDate(input string) (*time.Time, error) {
// CloudShell (and potentially the Azure CLI in future)
expirationDate, cloudShellErr := time.Parse(time.RFC3339, input)
if cloudShellErr != nil {
// Azure CLI (Python) e.g. 2017-08-31 19:48:57.998857 (plus the local timezone)
const cliFormat = "2006-0... | go | func ParseExpirationDate(input string) (*time.Time, error) {
// CloudShell (and potentially the Azure CLI in future)
expirationDate, cloudShellErr := time.Parse(time.RFC3339, input)
if cloudShellErr != nil {
// Azure CLI (Python) e.g. 2017-08-31 19:48:57.998857 (plus the local timezone)
const cliFormat = "2006-0... | [
"func",
"ParseExpirationDate",
"(",
"input",
"string",
")",
"(",
"*",
"time",
".",
"Time",
",",
"error",
")",
"{",
"// CloudShell (and potentially the Azure CLI in future)",
"expirationDate",
",",
"cloudShellErr",
":=",
"time",
".",
"Parse",
"(",
"time",
".",
"RFC... | // ParseExpirationDate parses either a Azure CLI or CloudShell date into a time object | [
"ParseExpirationDate",
"parses",
"either",
"a",
"Azure",
"CLI",
"or",
"CloudShell",
"date",
"into",
"a",
"time",
"object"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/cli/token.go#L85-L100 |
30,627 | Azure/go-autorest | autorest/azure/cli/token.go | LoadTokens | func LoadTokens(path string) ([]Token, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("failed to open file (%s) while loading token: %v", path, err)
}
defer file.Close()
var tokens []Token
dec := json.NewDecoder(file)
if err = dec.Decode(&tokens); err != nil {
return nil, fmt.Er... | go | func LoadTokens(path string) ([]Token, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("failed to open file (%s) while loading token: %v", path, err)
}
defer file.Close()
var tokens []Token
dec := json.NewDecoder(file)
if err = dec.Decode(&tokens); err != nil {
return nil, fmt.Er... | [
"func",
"LoadTokens",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"Token",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(... | // LoadTokens restores a set of Token objects from a file located at 'path'. | [
"LoadTokens",
"restores",
"a",
"set",
"of",
"Token",
"objects",
"from",
"a",
"file",
"located",
"at",
"path",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/cli/token.go#L103-L118 |
30,628 | Azure/go-autorest | autorest/azure/cli/token.go | GetTokenFromCLI | func GetTokenFromCLI(resource string) (*Token, error) {
// This is the path that a developer can set to tell this class what the install path for Azure CLI is.
const azureCLIPath = "AzureCLIPath"
// The default install paths are used to find Azure CLI. This is for security, so that any path in the calling program's... | go | func GetTokenFromCLI(resource string) (*Token, error) {
// This is the path that a developer can set to tell this class what the install path for Azure CLI is.
const azureCLIPath = "AzureCLIPath"
// The default install paths are used to find Azure CLI. This is for security, so that any path in the calling program's... | [
"func",
"GetTokenFromCLI",
"(",
"resource",
"string",
")",
"(",
"*",
"Token",
",",
"error",
")",
"{",
"// This is the path that a developer can set to tell this class what the install path for Azure CLI is.",
"const",
"azureCLIPath",
"=",
"\"",
"\"",
"\n\n",
"// The default i... | // GetTokenFromCLI gets a token using Azure CLI 2.0 for local development scenarios. | [
"GetTokenFromCLI",
"gets",
"a",
"token",
"using",
"Azure",
"CLI",
"2",
".",
"0",
"for",
"local",
"development",
"scenarios",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/cli/token.go#L121-L170 |
30,629 | Azure/go-autorest | autorest/date/date.go | ParseDate | func ParseDate(date string) (d Date, err error) {
return parseDate(date, fullDate)
} | go | func ParseDate(date string) (d Date, err error) {
return parseDate(date, fullDate)
} | [
"func",
"ParseDate",
"(",
"date",
"string",
")",
"(",
"d",
"Date",
",",
"err",
"error",
")",
"{",
"return",
"parseDate",
"(",
"date",
",",
"fullDate",
")",
"\n",
"}"
] | // ParseDate create a new Date from the passed string. | [
"ParseDate",
"create",
"a",
"new",
"Date",
"from",
"the",
"passed",
"string",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/date/date.go#L41-L43 |
30,630 | Azure/go-autorest | autorest/azure/metadata_environment.go | EnvironmentFromURL | func EnvironmentFromURL(resourceManagerEndpoint string, properties ...OverrideProperty) (environment Environment, err error) {
var metadataEnvProperties environmentMetadataInfo
if resourceManagerEndpoint == "" {
return environment, fmt.Errorf("Metadata resource manager endpoint is empty")
}
if metadataEnvProper... | go | func EnvironmentFromURL(resourceManagerEndpoint string, properties ...OverrideProperty) (environment Environment, err error) {
var metadataEnvProperties environmentMetadataInfo
if resourceManagerEndpoint == "" {
return environment, fmt.Errorf("Metadata resource manager endpoint is empty")
}
if metadataEnvProper... | [
"func",
"EnvironmentFromURL",
"(",
"resourceManagerEndpoint",
"string",
",",
"properties",
"...",
"OverrideProperty",
")",
"(",
"environment",
"Environment",
",",
"err",
"error",
")",
"{",
"var",
"metadataEnvProperties",
"environmentMetadataInfo",
"\n\n",
"if",
"resourc... | // EnvironmentFromURL loads an Environment from a URL
// This function is particularly useful in the Hybrid Cloud model, where one may define their own
// endpoints. | [
"EnvironmentFromURL",
"loads",
"an",
"Environment",
"from",
"a",
"URL",
"This",
"function",
"is",
"particularly",
"useful",
"in",
"the",
"Hybrid",
"Cloud",
"model",
"where",
"one",
"may",
"define",
"their",
"own",
"endpoints",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/metadata_environment.go#L96-L141 |
30,631 | Azure/go-autorest | autorest/azure/async.go | NewFutureFromResponse | func NewFutureFromResponse(resp *http.Response) (Future, error) {
pt, err := createPollingTracker(resp)
return Future{pt: pt}, err
} | go | func NewFutureFromResponse(resp *http.Response) (Future, error) {
pt, err := createPollingTracker(resp)
return Future{pt: pt}, err
} | [
"func",
"NewFutureFromResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"Future",
",",
"error",
")",
"{",
"pt",
",",
"err",
":=",
"createPollingTracker",
"(",
"resp",
")",
"\n",
"return",
"Future",
"{",
"pt",
":",
"pt",
"}",
",",
"err",
... | // NewFutureFromResponse returns a new Future object initialized
// with the initial response from an asynchronous operation. | [
"NewFutureFromResponse",
"returns",
"a",
"new",
"Future",
"object",
"initialized",
"with",
"the",
"initial",
"response",
"from",
"an",
"asynchronous",
"operation",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L53-L56 |
30,632 | Azure/go-autorest | autorest/azure/async.go | Response | func (f Future) Response() *http.Response {
if f.pt == nil {
return nil
}
return f.pt.latestResponse()
} | go | func (f Future) Response() *http.Response {
if f.pt == nil {
return nil
}
return f.pt.latestResponse()
} | [
"func",
"(",
"f",
"Future",
")",
"Response",
"(",
")",
"*",
"http",
".",
"Response",
"{",
"if",
"f",
".",
"pt",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"f",
".",
"pt",
".",
"latestResponse",
"(",
")",
"\n",
"}"
] | // Response returns the last HTTP response. | [
"Response",
"returns",
"the",
"last",
"HTTP",
"response",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L59-L64 |
30,633 | Azure/go-autorest | autorest/azure/async.go | Status | func (f Future) Status() string {
if f.pt == nil {
return ""
}
return f.pt.pollingStatus()
} | go | func (f Future) Status() string {
if f.pt == nil {
return ""
}
return f.pt.pollingStatus()
} | [
"func",
"(",
"f",
"Future",
")",
"Status",
"(",
")",
"string",
"{",
"if",
"f",
".",
"pt",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"f",
".",
"pt",
".",
"pollingStatus",
"(",
")",
"\n",
"}"
] | // Status returns the last status message of the operation. | [
"Status",
"returns",
"the",
"last",
"status",
"message",
"of",
"the",
"operation",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L67-L72 |
30,634 | Azure/go-autorest | autorest/azure/async.go | PollingMethod | func (f Future) PollingMethod() PollingMethodType {
if f.pt == nil {
return PollingUnknown
}
return f.pt.pollingMethod()
} | go | func (f Future) PollingMethod() PollingMethodType {
if f.pt == nil {
return PollingUnknown
}
return f.pt.pollingMethod()
} | [
"func",
"(",
"f",
"Future",
")",
"PollingMethod",
"(",
")",
"PollingMethodType",
"{",
"if",
"f",
".",
"pt",
"==",
"nil",
"{",
"return",
"PollingUnknown",
"\n",
"}",
"\n",
"return",
"f",
".",
"pt",
".",
"pollingMethod",
"(",
")",
"\n",
"}"
] | // PollingMethod returns the method used to monitor the status of the asynchronous operation. | [
"PollingMethod",
"returns",
"the",
"method",
"used",
"to",
"monitor",
"the",
"status",
"of",
"the",
"asynchronous",
"operation",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L75-L80 |
30,635 | Azure/go-autorest | autorest/azure/async.go | DoneWithContext | func (f *Future) DoneWithContext(ctx context.Context, sender autorest.Sender) (done bool, err error) {
ctx = tracing.StartSpan(ctx, "github.com/Azure/go-autorest/autorest/azure/async.DoneWithContext")
defer func() {
sc := -1
resp := f.Response()
if resp != nil {
sc = resp.StatusCode
}
tracing.EndSpan(ctx... | go | func (f *Future) DoneWithContext(ctx context.Context, sender autorest.Sender) (done bool, err error) {
ctx = tracing.StartSpan(ctx, "github.com/Azure/go-autorest/autorest/azure/async.DoneWithContext")
defer func() {
sc := -1
resp := f.Response()
if resp != nil {
sc = resp.StatusCode
}
tracing.EndSpan(ctx... | [
"func",
"(",
"f",
"*",
"Future",
")",
"DoneWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"sender",
"autorest",
".",
"Sender",
")",
"(",
"done",
"bool",
",",
"err",
"error",
")",
"{",
"ctx",
"=",
"tracing",
".",
"StartSpan",
"(",
"ctx",
",... | // DoneWithContext queries the service to see if the operation has completed. | [
"DoneWithContext",
"queries",
"the",
"service",
"to",
"see",
"if",
"the",
"operation",
"has",
"completed",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L83-L116 |
30,636 | Azure/go-autorest | autorest/azure/async.go | GetPollingDelay | func (f Future) GetPollingDelay() (time.Duration, bool) {
if f.pt == nil {
return 0, false
}
resp := f.pt.latestResponse()
if resp == nil {
return 0, false
}
retry := resp.Header.Get(autorest.HeaderRetryAfter)
if retry == "" {
return 0, false
}
d, err := time.ParseDuration(retry + "s")
if err != nil {... | go | func (f Future) GetPollingDelay() (time.Duration, bool) {
if f.pt == nil {
return 0, false
}
resp := f.pt.latestResponse()
if resp == nil {
return 0, false
}
retry := resp.Header.Get(autorest.HeaderRetryAfter)
if retry == "" {
return 0, false
}
d, err := time.ParseDuration(retry + "s")
if err != nil {... | [
"func",
"(",
"f",
"Future",
")",
"GetPollingDelay",
"(",
")",
"(",
"time",
".",
"Duration",
",",
"bool",
")",
"{",
"if",
"f",
".",
"pt",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"resp",
":=",
"f",
".",
"pt",
".",
"latestR... | // GetPollingDelay returns a duration the application should wait before checking
// the status of the asynchronous request and true; this value is returned from
// the service via the Retry-After response header. If the header wasn't returned
// then the function returns the zero-value time.Duration and false. | [
"GetPollingDelay",
"returns",
"a",
"duration",
"the",
"application",
"should",
"wait",
"before",
"checking",
"the",
"status",
"of",
"the",
"asynchronous",
"request",
"and",
"true",
";",
"this",
"value",
"is",
"returned",
"from",
"the",
"service",
"via",
"the",
... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L122-L142 |
30,637 | Azure/go-autorest | autorest/azure/async.go | PollingURL | func (f Future) PollingURL() string {
if f.pt == nil {
return ""
}
return f.pt.pollingURL()
} | go | func (f Future) PollingURL() string {
if f.pt == nil {
return ""
}
return f.pt.pollingURL()
} | [
"func",
"(",
"f",
"Future",
")",
"PollingURL",
"(",
")",
"string",
"{",
"if",
"f",
".",
"pt",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"f",
".",
"pt",
".",
"pollingURL",
"(",
")",
"\n",
"}"
] | // PollingURL returns the URL used for retrieving the status of the long-running operation. | [
"PollingURL",
"returns",
"the",
"URL",
"used",
"for",
"retrieving",
"the",
"status",
"of",
"the",
"long",
"-",
"running",
"operation",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L238-L243 |
30,638 | Azure/go-autorest | autorest/azure/async.go | GetResult | func (f Future) GetResult(sender autorest.Sender) (*http.Response, error) {
if f.pt.finalGetURL() == "" {
// we can end up in this situation if the async operation returns a 200
// with no polling URLs. in that case return the response which should
// contain the JSON payload (only do this for successful termin... | go | func (f Future) GetResult(sender autorest.Sender) (*http.Response, error) {
if f.pt.finalGetURL() == "" {
// we can end up in this situation if the async operation returns a 200
// with no polling URLs. in that case return the response which should
// contain the JSON payload (only do this for successful termin... | [
"func",
"(",
"f",
"Future",
")",
"GetResult",
"(",
"sender",
"autorest",
".",
"Sender",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"f",
".",
"pt",
".",
"finalGetURL",
"(",
")",
"==",
"\"",
"\"",
"{",
"// we can end up in th... | // GetResult should be called once polling has completed successfully.
// It makes the final GET call to retrieve the resultant payload. | [
"GetResult",
"should",
"be",
"called",
"once",
"polling",
"has",
"completed",
"successfully",
".",
"It",
"makes",
"the",
"final",
"GET",
"call",
"to",
"retrieve",
"the",
"resultant",
"payload",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L247-L262 |
30,639 | Azure/go-autorest | autorest/azure/async.go | baseCheckForErrors | func (pt pollingTrackerBase) baseCheckForErrors() error {
// for Azure-AsyncOperations the response body cannot be nil or empty
if pt.Pm == PollingAsyncOperation {
if pt.resp.Body == nil || pt.resp.ContentLength == 0 {
return autorest.NewError("pollingTrackerBase", "baseCheckForErrors", "for Azure-AsyncOperation... | go | func (pt pollingTrackerBase) baseCheckForErrors() error {
// for Azure-AsyncOperations the response body cannot be nil or empty
if pt.Pm == PollingAsyncOperation {
if pt.resp.Body == nil || pt.resp.ContentLength == 0 {
return autorest.NewError("pollingTrackerBase", "baseCheckForErrors", "for Azure-AsyncOperation... | [
"func",
"(",
"pt",
"pollingTrackerBase",
")",
"baseCheckForErrors",
"(",
")",
"error",
"{",
"// for Azure-AsyncOperations the response body cannot be nil or empty",
"if",
"pt",
".",
"Pm",
"==",
"PollingAsyncOperation",
"{",
"if",
"pt",
".",
"resp",
".",
"Body",
"==",
... | // error checking common to all trackers | [
"error",
"checking",
"common",
"to",
"all",
"trackers"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L550-L561 |
30,640 | Azure/go-autorest | autorest/azure/async.go | createPollingTracker | func createPollingTracker(resp *http.Response) (pollingTracker, error) {
var pt pollingTracker
switch strings.ToUpper(resp.Request.Method) {
case http.MethodDelete:
pt = &pollingTrackerDelete{pollingTrackerBase: pollingTrackerBase{resp: resp}}
case http.MethodPatch:
pt = &pollingTrackerPatch{pollingTrackerBase:... | go | func createPollingTracker(resp *http.Response) (pollingTracker, error) {
var pt pollingTracker
switch strings.ToUpper(resp.Request.Method) {
case http.MethodDelete:
pt = &pollingTrackerDelete{pollingTrackerBase: pollingTrackerBase{resp: resp}}
case http.MethodPatch:
pt = &pollingTrackerPatch{pollingTrackerBase:... | [
"func",
"createPollingTracker",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"pollingTracker",
",",
"error",
")",
"{",
"var",
"pt",
"pollingTracker",
"\n",
"switch",
"strings",
".",
"ToUpper",
"(",
"resp",
".",
"Request",
".",
"Method",
")",
"{",
... | // creates a polling tracker based on the verb of the original request | [
"creates",
"a",
"polling",
"tracker",
"based",
"on",
"the",
"verb",
"of",
"the",
"original",
"request"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L831-L852 |
30,641 | Azure/go-autorest | autorest/azure/async.go | getURLFromAsyncOpHeader | func getURLFromAsyncOpHeader(resp *http.Response) (string, error) {
s := resp.Header.Get(http.CanonicalHeaderKey(headerAsyncOperation))
if s == "" {
return "", nil
}
if !isValidURL(s) {
return "", autorest.NewError("azure", "getURLFromAsyncOpHeader", "invalid polling URL '%s'", s)
}
return s, nil
} | go | func getURLFromAsyncOpHeader(resp *http.Response) (string, error) {
s := resp.Header.Get(http.CanonicalHeaderKey(headerAsyncOperation))
if s == "" {
return "", nil
}
if !isValidURL(s) {
return "", autorest.NewError("azure", "getURLFromAsyncOpHeader", "invalid polling URL '%s'", s)
}
return s, nil
} | [
"func",
"getURLFromAsyncOpHeader",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"http",
".",
"CanonicalHeaderKey",
"(",
"headerAsyncOperation",
")",
")",
"\n",
"... | // gets the polling URL from the Azure-AsyncOperation header.
// ensures the URL is well-formed and absolute. | [
"gets",
"the",
"polling",
"URL",
"from",
"the",
"Azure",
"-",
"AsyncOperation",
"header",
".",
"ensures",
"the",
"URL",
"is",
"well",
"-",
"formed",
"and",
"absolute",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L856-L865 |
30,642 | Azure/go-autorest | autorest/azure/async.go | getURLFromLocationHeader | func getURLFromLocationHeader(resp *http.Response) (string, error) {
s := resp.Header.Get(http.CanonicalHeaderKey(autorest.HeaderLocation))
if s == "" {
return "", nil
}
if !isValidURL(s) {
return "", autorest.NewError("azure", "getURLFromLocationHeader", "invalid polling URL '%s'", s)
}
return s, nil
} | go | func getURLFromLocationHeader(resp *http.Response) (string, error) {
s := resp.Header.Get(http.CanonicalHeaderKey(autorest.HeaderLocation))
if s == "" {
return "", nil
}
if !isValidURL(s) {
return "", autorest.NewError("azure", "getURLFromLocationHeader", "invalid polling URL '%s'", s)
}
return s, nil
} | [
"func",
"getURLFromLocationHeader",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"http",
".",
"CanonicalHeaderKey",
"(",
"autorest",
".",
"HeaderLocation",
")",
... | // gets the polling URL from the Location header.
// ensures the URL is well-formed and absolute. | [
"gets",
"the",
"polling",
"URL",
"from",
"the",
"Location",
"header",
".",
"ensures",
"the",
"URL",
"is",
"well",
"-",
"formed",
"and",
"absolute",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L869-L878 |
30,643 | Azure/go-autorest | autorest/azure/async.go | isValidURL | func isValidURL(s string) bool {
u, err := url.Parse(s)
return err == nil && u.IsAbs()
} | go | func isValidURL(s string) bool {
u, err := url.Parse(s)
return err == nil && u.IsAbs()
} | [
"func",
"isValidURL",
"(",
"s",
"string",
")",
"bool",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"s",
")",
"\n",
"return",
"err",
"==",
"nil",
"&&",
"u",
".",
"IsAbs",
"(",
")",
"\n",
"}"
] | // verify that the URL is valid and absolute | [
"verify",
"that",
"the",
"URL",
"is",
"valid",
"and",
"absolute"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/azure/async.go#L881-L884 |
30,644 | Azure/go-autorest | autorest/sender.go | Do | func (sf SenderFunc) Do(r *http.Request) (*http.Response, error) {
return sf(r)
} | go | func (sf SenderFunc) Do(r *http.Request) (*http.Response, error) {
return sf(r)
} | [
"func",
"(",
"sf",
"SenderFunc",
")",
"Do",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"sf",
"(",
"r",
")",
"\n",
"}"
] | // Do implements the Sender interface on SenderFunc. | [
"Do",
"implements",
"the",
"Sender",
"interface",
"on",
"SenderFunc",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L39-L41 |
30,645 | Azure/go-autorest | autorest/sender.go | SendWithSender | func SendWithSender(s Sender, r *http.Request, decorators ...SendDecorator) (*http.Response, error) {
return DecorateSender(s, decorators...).Do(r)
} | go | func SendWithSender(s Sender, r *http.Request, decorators ...SendDecorator) (*http.Response, error) {
return DecorateSender(s, decorators...).Do(r)
} | [
"func",
"SendWithSender",
"(",
"s",
"Sender",
",",
"r",
"*",
"http",
".",
"Request",
",",
"decorators",
"...",
"SendDecorator",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"DecorateSender",
"(",
"s",
",",
"decorators",
"..."... | // SendWithSender sends the passed http.Request, through the provided Sender, returning the
// http.Response and possible error. It also accepts a, possibly empty, set of SendDecorators which
// it will apply the http.Client before invoking the Do method.
//
// SendWithSender will not poll or retry requests. | [
"SendWithSender",
"sends",
"the",
"passed",
"http",
".",
"Request",
"through",
"the",
"provided",
"Sender",
"returning",
"the",
"http",
".",
"Response",
"and",
"possible",
"error",
".",
"It",
"also",
"accepts",
"a",
"possibly",
"empty",
"set",
"of",
"SendDecor... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L81-L83 |
30,646 | Azure/go-autorest | autorest/sender.go | AfterDelay | func AfterDelay(d time.Duration) SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
if !DelayForBackoff(d, 0, r.Context().Done()) {
return nil, fmt.Errorf("autorest: AfterDelay canceled before full delay")
}
return s.Do(r)
})
}
} | go | func AfterDelay(d time.Duration) SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
if !DelayForBackoff(d, 0, r.Context().Done()) {
return nil, fmt.Errorf("autorest: AfterDelay canceled before full delay")
}
return s.Do(r)
})
}
} | [
"func",
"AfterDelay",
"(",
"d",
"time",
".",
"Duration",
")",
"SendDecorator",
"{",
"return",
"func",
"(",
"s",
"Sender",
")",
"Sender",
"{",
"return",
"SenderFunc",
"(",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Res... | // AfterDelay returns a SendDecorator that delays for the passed time.Duration before
// invoking the Sender. The delay may be terminated by closing the optional channel on the
// http.Request. If canceled, no further Senders are invoked. | [
"AfterDelay",
"returns",
"a",
"SendDecorator",
"that",
"delays",
"for",
"the",
"passed",
"time",
".",
"Duration",
"before",
"invoking",
"the",
"Sender",
".",
"The",
"delay",
"may",
"be",
"terminated",
"by",
"closing",
"the",
"optional",
"channel",
"on",
"the",... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L88-L97 |
30,647 | Azure/go-autorest | autorest/sender.go | AsIs | func AsIs() SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
return s.Do(r)
})
}
} | go | func AsIs() SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
return s.Do(r)
})
}
} | [
"func",
"AsIs",
"(",
")",
"SendDecorator",
"{",
"return",
"func",
"(",
"s",
"Sender",
")",
"Sender",
"{",
"return",
"SenderFunc",
"(",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"r... | // AsIs returns a SendDecorator that invokes the passed Sender without modifying the http.Request. | [
"AsIs",
"returns",
"a",
"SendDecorator",
"that",
"invokes",
"the",
"passed",
"Sender",
"without",
"modifying",
"the",
"http",
".",
"Request",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L100-L106 |
30,648 | Azure/go-autorest | autorest/sender.go | DoCloseIfError | func DoCloseIfError() SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
resp, err := s.Do(r)
if err != nil {
Respond(resp, ByDiscardingBody(), ByClosing())
}
return resp, err
})
}
} | go | func DoCloseIfError() SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
resp, err := s.Do(r)
if err != nil {
Respond(resp, ByDiscardingBody(), ByClosing())
}
return resp, err
})
}
} | [
"func",
"DoCloseIfError",
"(",
")",
"SendDecorator",
"{",
"return",
"func",
"(",
"s",
"Sender",
")",
"Sender",
"{",
"return",
"SenderFunc",
"(",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
... | // DoCloseIfError returns a SendDecorator that first invokes the passed Sender after which
// it closes the response if the passed Sender returns an error and the response body exists. | [
"DoCloseIfError",
"returns",
"a",
"SendDecorator",
"that",
"first",
"invokes",
"the",
"passed",
"Sender",
"after",
"which",
"it",
"closes",
"the",
"response",
"if",
"the",
"passed",
"Sender",
"returns",
"an",
"error",
"and",
"the",
"response",
"body",
"exists",
... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L110-L120 |
30,649 | Azure/go-autorest | autorest/sender.go | DoErrorUnlessStatusCode | func DoErrorUnlessStatusCode(codes ...int) SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
resp, err := s.Do(r)
if err == nil && !ResponseHasStatusCode(resp, codes...) {
err = NewErrorWithResponse("autorest", "DoErrorUnlessStatusCode", resp, ... | go | func DoErrorUnlessStatusCode(codes ...int) SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
resp, err := s.Do(r)
if err == nil && !ResponseHasStatusCode(resp, codes...) {
err = NewErrorWithResponse("autorest", "DoErrorUnlessStatusCode", resp, ... | [
"func",
"DoErrorUnlessStatusCode",
"(",
"codes",
"...",
"int",
")",
"SendDecorator",
"{",
"return",
"func",
"(",
"s",
"Sender",
")",
"Sender",
"{",
"return",
"SenderFunc",
"(",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
... | // DoErrorUnlessStatusCode returns a SendDecorator that emits an error unless the response
// StatusCode is among the set passed. Since these are artificial errors, the response body
// may still require closing. | [
"DoErrorUnlessStatusCode",
"returns",
"a",
"SendDecorator",
"that",
"emits",
"an",
"error",
"unless",
"the",
"response",
"StatusCode",
"is",
"among",
"the",
"set",
"passed",
".",
"Since",
"these",
"are",
"artificial",
"errors",
"the",
"response",
"body",
"may",
... | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L143-L156 |
30,650 | Azure/go-autorest | autorest/sender.go | DelayWithRetryAfter | func DelayWithRetryAfter(resp *http.Response, cancel <-chan struct{}) bool {
if resp == nil {
return false
}
retryAfter, _ := strconv.Atoi(resp.Header.Get("Retry-After"))
if resp.StatusCode == http.StatusTooManyRequests && retryAfter > 0 {
select {
case <-time.After(time.Duration(retryAfter) * time.Second):
... | go | func DelayWithRetryAfter(resp *http.Response, cancel <-chan struct{}) bool {
if resp == nil {
return false
}
retryAfter, _ := strconv.Atoi(resp.Header.Get("Retry-After"))
if resp.StatusCode == http.StatusTooManyRequests && retryAfter > 0 {
select {
case <-time.After(time.Duration(retryAfter) * time.Second):
... | [
"func",
"DelayWithRetryAfter",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"cancel",
"<-",
"chan",
"struct",
"{",
"}",
")",
"bool",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"retryAfter",
",",
"_",
":=",
"strconv",
... | // DelayWithRetryAfter invokes time.After for the duration specified in the "Retry-After" header in
// responses with status code 429 | [
"DelayWithRetryAfter",
"invokes",
"time",
".",
"After",
"for",
"the",
"duration",
"specified",
"in",
"the",
"Retry",
"-",
"After",
"header",
"in",
"responses",
"with",
"status",
"code",
"429"
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L253-L267 |
30,651 | Azure/go-autorest | autorest/sender.go | WithLogging | func WithLogging(logger *log.Logger) SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
logger.Printf("Sending %s %s", r.Method, r.URL)
resp, err := s.Do(r)
if err != nil {
logger.Printf("%s %s received error '%v'", r.Method, r.URL, err)
}... | go | func WithLogging(logger *log.Logger) SendDecorator {
return func(s Sender) Sender {
return SenderFunc(func(r *http.Request) (*http.Response, error) {
logger.Printf("Sending %s %s", r.Method, r.URL)
resp, err := s.Do(r)
if err != nil {
logger.Printf("%s %s received error '%v'", r.Method, r.URL, err)
}... | [
"func",
"WithLogging",
"(",
"logger",
"*",
"log",
".",
"Logger",
")",
"SendDecorator",
"{",
"return",
"func",
"(",
"s",
"Sender",
")",
"Sender",
"{",
"return",
"SenderFunc",
"(",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
"... | // WithLogging returns a SendDecorator that implements simple before and after logging of the
// request. | [
"WithLogging",
"returns",
"a",
"SendDecorator",
"that",
"implements",
"simple",
"before",
"and",
"after",
"logging",
"of",
"the",
"request",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/sender.go#L298-L311 |
30,652 | Azure/go-autorest | autorest/validation/error.go | Error | func (e Error) Error() string {
return fmt.Sprintf("%s#%s: Invalid input: %s", e.PackageType, e.Method, e.Message)
} | go | func (e Error) Error() string {
return fmt.Sprintf("%s#%s: Invalid input: %s", e.PackageType, e.Method, e.Message)
} | [
"func",
"(",
"e",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"PackageType",
",",
"e",
".",
"Method",
",",
"e",
".",
"Message",
")",
"\n",
"}"
] | // Error returns a string containing the details of the validation failure. | [
"Error",
"returns",
"a",
"string",
"containing",
"the",
"details",
"of",
"the",
"validation",
"failure",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/validation/error.go#L36-L38 |
30,653 | Azure/go-autorest | autorest/validation/error.go | NewError | func NewError(packageType string, method string, message string, args ...interface{}) Error {
return Error{
PackageType: packageType,
Method: method,
Message: fmt.Sprintf(message, args...),
}
} | go | func NewError(packageType string, method string, message string, args ...interface{}) Error {
return Error{
PackageType: packageType,
Method: method,
Message: fmt.Sprintf(message, args...),
}
} | [
"func",
"NewError",
"(",
"packageType",
"string",
",",
"method",
"string",
",",
"message",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"Error",
"{",
"return",
"Error",
"{",
"PackageType",
":",
"packageType",
",",
"Method",
":",
"method",
",",... | // NewError creates a new Error object with the specified parameters.
// message is treated as a format string to which the optional args apply. | [
"NewError",
"creates",
"a",
"new",
"Error",
"object",
"with",
"the",
"specified",
"parameters",
".",
"message",
"is",
"treated",
"as",
"a",
"format",
"string",
"to",
"which",
"the",
"optional",
"args",
"apply",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/validation/error.go#L42-L48 |
30,654 | Azure/go-autorest | autorest/validation/validation.go | Validate | func Validate(m []Validation) error {
for _, item := range m {
v := reflect.ValueOf(item.TargetValue)
for _, constraint := range item.Constraints {
var err error
switch v.Kind() {
case reflect.Ptr:
err = validatePtr(v, constraint)
case reflect.String:
err = validateString(v, constraint)
case... | go | func Validate(m []Validation) error {
for _, item := range m {
v := reflect.ValueOf(item.TargetValue)
for _, constraint := range item.Constraints {
var err error
switch v.Kind() {
case reflect.Ptr:
err = validatePtr(v, constraint)
case reflect.String:
err = validateString(v, constraint)
case... | [
"func",
"Validate",
"(",
"m",
"[",
"]",
"Validation",
")",
"error",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"m",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"item",
".",
"TargetValue",
")",
"\n",
"for",
"_",
",",
"constraint",
":=",
"range... | // Validate method validates constraints on parameter
// passed in validation array. | [
"Validate",
"method",
"validates",
"constraints",
"on",
"parameter",
"passed",
"in",
"validation",
"array",
"."
] | da8db3a19ec5aba5d01f6032407abf1bb1cc15d3 | https://github.com/Azure/go-autorest/blob/da8db3a19ec5aba5d01f6032407abf1bb1cc15d3/autorest/validation/validation.go#L70-L98 |
30,655 | alexedwards/scs | postgresstore/postgresstore.go | Find | func (p *PostgresStore) Find(token string) (b []byte, exists bool, err error) {
row := p.db.QueryRow("SELECT data FROM sessions WHERE token = $1 AND current_timestamp < expiry", token)
err = row.Scan(&b)
if err == sql.ErrNoRows {
return nil, false, nil
} else if err != nil {
return nil, false, err
}
return b,... | go | func (p *PostgresStore) Find(token string) (b []byte, exists bool, err error) {
row := p.db.QueryRow("SELECT data FROM sessions WHERE token = $1 AND current_timestamp < expiry", token)
err = row.Scan(&b)
if err == sql.ErrNoRows {
return nil, false, nil
} else if err != nil {
return nil, false, err
}
return b,... | [
"func",
"(",
"p",
"*",
"PostgresStore",
")",
"Find",
"(",
"token",
"string",
")",
"(",
"b",
"[",
"]",
"byte",
",",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"row",
":=",
"p",
".",
"db",
".",
"QueryRow",
"(",
"\"",
"\"",
",",
"token",
")"... | // Find returns the data for a given session token from the PostgresStore instance.
// If the session token is not found or is expired, the returned exists flag will
// be set to false. | [
"Find",
"returns",
"the",
"data",
"for",
"a",
"given",
"session",
"token",
"from",
"the",
"PostgresStore",
"instance",
".",
"If",
"the",
"session",
"token",
"is",
"not",
"found",
"or",
"is",
"expired",
"the",
"returned",
"exists",
"flag",
"will",
"be",
"se... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/postgresstore/postgresstore.go#L36-L45 |
30,656 | alexedwards/scs | postgresstore/postgresstore.go | Commit | func (p *PostgresStore) Commit(token string, b []byte, expiry time.Time) error {
_, err := p.db.Exec("INSERT INTO sessions (token, data, expiry) VALUES ($1, $2, $3) ON CONFLICT (token) DO UPDATE SET data = EXCLUDED.data, expiry = EXCLUDED.expiry", token, b, expiry)
if err != nil {
return err
}
return nil
} | go | func (p *PostgresStore) Commit(token string, b []byte, expiry time.Time) error {
_, err := p.db.Exec("INSERT INTO sessions (token, data, expiry) VALUES ($1, $2, $3) ON CONFLICT (token) DO UPDATE SET data = EXCLUDED.data, expiry = EXCLUDED.expiry", token, b, expiry)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"p",
"*",
"PostgresStore",
")",
"Commit",
"(",
"token",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"expiry",
"time",
".",
"Time",
")",
"error",
"{",
"_",
",",
"err",
":=",
"p",
".",
"db",
".",
"Exec",
"(",
"\"",
"\"",
",",
"token",... | // Commit adds a session token and data to the PostgresStore instance with the
// given expiry time. If the session token already exists, then the data and expiry
// time are updated. | [
"Commit",
"adds",
"a",
"session",
"token",
"and",
"data",
"to",
"the",
"PostgresStore",
"instance",
"with",
"the",
"given",
"expiry",
"time",
".",
"If",
"the",
"session",
"token",
"already",
"exists",
"then",
"the",
"data",
"and",
"expiry",
"time",
"are",
... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/postgresstore/postgresstore.go#L50-L56 |
30,657 | alexedwards/scs | postgresstore/postgresstore.go | Delete | func (p *PostgresStore) Delete(token string) error {
_, err := p.db.Exec("DELETE FROM sessions WHERE token = $1", token)
return err
} | go | func (p *PostgresStore) Delete(token string) error {
_, err := p.db.Exec("DELETE FROM sessions WHERE token = $1", token)
return err
} | [
"func",
"(",
"p",
"*",
"PostgresStore",
")",
"Delete",
"(",
"token",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"p",
".",
"db",
".",
"Exec",
"(",
"\"",
"\"",
",",
"token",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Delete removes a session token and corresponding data from the PostgresStore
// instance. | [
"Delete",
"removes",
"a",
"session",
"token",
"and",
"corresponding",
"data",
"from",
"the",
"PostgresStore",
"instance",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/postgresstore/postgresstore.go#L60-L63 |
30,658 | alexedwards/scs | memstore/memstore.go | Find | func (m *MemStore) Find(token string) ([]byte, bool, error) {
m.mu.RLock()
defer m.mu.RUnlock()
item, found := m.items[token]
if !found {
return nil, false, nil
}
if time.Now().UnixNano() > item.expiration {
return nil, false, nil
}
b, ok := item.object.([]byte)
if !ok {
return nil, true, errTypeAssert... | go | func (m *MemStore) Find(token string) ([]byte, bool, error) {
m.mu.RLock()
defer m.mu.RUnlock()
item, found := m.items[token]
if !found {
return nil, false, nil
}
if time.Now().UnixNano() > item.expiration {
return nil, false, nil
}
b, ok := item.object.([]byte)
if !ok {
return nil, true, errTypeAssert... | [
"func",
"(",
"m",
"*",
"MemStore",
")",
"Find",
"(",
"token",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
",",
"error",
")",
"{",
"m",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // Find returns the data for a given session token from the MemStore instance.
// If the session token is not found or is expired, the returned exists flag will
// be set to false. | [
"Find",
"returns",
"the",
"data",
"for",
"a",
"given",
"session",
"token",
"from",
"the",
"MemStore",
"instance",
".",
"If",
"the",
"session",
"token",
"is",
"not",
"found",
"or",
"is",
"expired",
"the",
"returned",
"exists",
"flag",
"will",
"be",
"set",
... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/memstore/memstore.go#L48-L66 |
30,659 | alexedwards/scs | memstore/memstore.go | Commit | func (m *MemStore) Commit(token string, b []byte, expiry time.Time) error {
m.mu.Lock()
m.items[token] = item{
object: b,
expiration: expiry.UnixNano(),
}
m.mu.Unlock()
return nil
} | go | func (m *MemStore) Commit(token string, b []byte, expiry time.Time) error {
m.mu.Lock()
m.items[token] = item{
object: b,
expiration: expiry.UnixNano(),
}
m.mu.Unlock()
return nil
} | [
"func",
"(",
"m",
"*",
"MemStore",
")",
"Commit",
"(",
"token",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"expiry",
"time",
".",
"Time",
")",
"error",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"items",
"[",
"token",
"]",
"=... | // Commit adds a session token and data to the MemStore instance with the given
// expiry time. If the session token already exists, then the data and expiry
// time are updated. | [
"Commit",
"adds",
"a",
"session",
"token",
"and",
"data",
"to",
"the",
"MemStore",
"instance",
"with",
"the",
"given",
"expiry",
"time",
".",
"If",
"the",
"session",
"token",
"already",
"exists",
"then",
"the",
"data",
"and",
"expiry",
"time",
"are",
"upda... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/memstore/memstore.go#L71-L80 |
30,660 | alexedwards/scs | memstore/memstore.go | Delete | func (m *MemStore) Delete(token string) error {
m.mu.Lock()
delete(m.items, token)
m.mu.Unlock()
return nil
} | go | func (m *MemStore) Delete(token string) error {
m.mu.Lock()
delete(m.items, token)
m.mu.Unlock()
return nil
} | [
"func",
"(",
"m",
"*",
"MemStore",
")",
"Delete",
"(",
"token",
"string",
")",
"error",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"m",
".",
"items",
",",
"token",
")",
"\n",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\... | // Delete removes a session token and corresponding data from the MemStore
// instance. | [
"Delete",
"removes",
"a",
"session",
"token",
"and",
"corresponding",
"data",
"from",
"the",
"MemStore",
"instance",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/memstore/memstore.go#L84-L90 |
30,661 | alexedwards/scs | redisstore/redisstore.go | NewWithPrefix | func NewWithPrefix(pool *redis.Pool, prefix string) *RedisStore {
return &RedisStore{
pool: pool,
prefix: prefix,
}
} | go | func NewWithPrefix(pool *redis.Pool, prefix string) *RedisStore {
return &RedisStore{
pool: pool,
prefix: prefix,
}
} | [
"func",
"NewWithPrefix",
"(",
"pool",
"*",
"redis",
".",
"Pool",
",",
"prefix",
"string",
")",
"*",
"RedisStore",
"{",
"return",
"&",
"RedisStore",
"{",
"pool",
":",
"pool",
",",
"prefix",
":",
"prefix",
",",
"}",
"\n",
"}"
] | // New returns a new RedisStore instance. The pool parameter should be a pointer
// to a redigo connection pool. The prefix parameter controls the Redis key
// prefix, which can be used to avoid naming clashes if necessary. | [
"New",
"returns",
"a",
"new",
"RedisStore",
"instance",
".",
"The",
"pool",
"parameter",
"should",
"be",
"a",
"pointer",
"to",
"a",
"redigo",
"connection",
"pool",
".",
"The",
"prefix",
"parameter",
"controls",
"the",
"Redis",
"key",
"prefix",
"which",
"can"... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/redisstore/redisstore.go#L24-L29 |
30,662 | alexedwards/scs | redisstore/redisstore.go | Find | func (r *RedisStore) Find(token string) (b []byte, exists bool, err error) {
conn := r.pool.Get()
defer conn.Close()
b, err = redis.Bytes(conn.Do("GET", r.prefix+token))
if err == redis.ErrNil {
return nil, false, nil
} else if err != nil {
return nil, false, err
}
return b, true, nil
} | go | func (r *RedisStore) Find(token string) (b []byte, exists bool, err error) {
conn := r.pool.Get()
defer conn.Close()
b, err = redis.Bytes(conn.Do("GET", r.prefix+token))
if err == redis.ErrNil {
return nil, false, nil
} else if err != nil {
return nil, false, err
}
return b, true, nil
} | [
"func",
"(",
"r",
"*",
"RedisStore",
")",
"Find",
"(",
"token",
"string",
")",
"(",
"b",
"[",
"]",
"byte",
",",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
... | // Find returns the data for a given session token from the RedisStore instance.
// If the session token is not found or is expired, the returned exists flag
// will be set to false. | [
"Find",
"returns",
"the",
"data",
"for",
"a",
"given",
"session",
"token",
"from",
"the",
"RedisStore",
"instance",
".",
"If",
"the",
"session",
"token",
"is",
"not",
"found",
"or",
"is",
"expired",
"the",
"returned",
"exists",
"flag",
"will",
"be",
"set",... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/redisstore/redisstore.go#L34-L45 |
30,663 | alexedwards/scs | redisstore/redisstore.go | Commit | func (r *RedisStore) Commit(token string, b []byte, expiry time.Time) error {
conn := r.pool.Get()
defer conn.Close()
err := conn.Send("MULTI")
if err != nil {
return err
}
err = conn.Send("SET", r.prefix+token, b)
if err != nil {
return err
}
err = conn.Send("PEXPIREAT", r.prefix+token, makeMillisecondTi... | go | func (r *RedisStore) Commit(token string, b []byte, expiry time.Time) error {
conn := r.pool.Get()
defer conn.Close()
err := conn.Send("MULTI")
if err != nil {
return err
}
err = conn.Send("SET", r.prefix+token, b)
if err != nil {
return err
}
err = conn.Send("PEXPIREAT", r.prefix+token, makeMillisecondTi... | [
"func",
"(",
"r",
"*",
"RedisStore",
")",
"Commit",
"(",
"token",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"expiry",
"time",
".",
"Time",
")",
"error",
"{",
"conn",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Cl... | // Commit adds a session token and data to the RedisStore instance with the
// given expiry time. If the session token already exists then the data and
// expiry time are updated. | [
"Commit",
"adds",
"a",
"session",
"token",
"and",
"data",
"to",
"the",
"RedisStore",
"instance",
"with",
"the",
"given",
"expiry",
"time",
".",
"If",
"the",
"session",
"token",
"already",
"exists",
"then",
"the",
"data",
"and",
"expiry",
"time",
"are",
"up... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/redisstore/redisstore.go#L50-L68 |
30,664 | alexedwards/scs | redisstore/redisstore.go | Delete | func (r *RedisStore) Delete(token string) error {
conn := r.pool.Get()
defer conn.Close()
_, err := conn.Do("DEL", r.prefix+token)
return err
} | go | func (r *RedisStore) Delete(token string) error {
conn := r.pool.Get()
defer conn.Close()
_, err := conn.Do("DEL", r.prefix+token)
return err
} | [
"func",
"(",
"r",
"*",
"RedisStore",
")",
"Delete",
"(",
"token",
"string",
")",
"error",
"{",
"conn",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"conn",
".",
"Do"... | // Delete removes a session token and corresponding data from the RedisStore
// instance. | [
"Delete",
"removes",
"a",
"session",
"token",
"and",
"corresponding",
"data",
"from",
"the",
"RedisStore",
"instance",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/redisstore/redisstore.go#L72-L78 |
30,665 | alexedwards/scs | mysqlstore/mysqlstore.go | Find | func (m *MySQLStore) Find(token string) ([]byte, bool, error) {
var b []byte
var stmt string
if compareVersion("5.6.4", m.version) >= 0 {
stmt = "SELECT data FROM sessions WHERE token = ? AND UTC_TIMESTAMP(6) < expiry"
} else {
stmt = "SELECT data FROM sessions WHERE token = ? AND UTC_TIMESTAMP < expiry"
}
... | go | func (m *MySQLStore) Find(token string) ([]byte, bool, error) {
var b []byte
var stmt string
if compareVersion("5.6.4", m.version) >= 0 {
stmt = "SELECT data FROM sessions WHERE token = ? AND UTC_TIMESTAMP(6) < expiry"
} else {
stmt = "SELECT data FROM sessions WHERE token = ? AND UTC_TIMESTAMP < expiry"
}
... | [
"func",
"(",
"m",
"*",
"MySQLStore",
")",
"Find",
"(",
"token",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
",",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"var",
"stmt",
"string",
"\n\n",
"if",
"compareVersion",
"(",
"\"",
"\"... | // Find returns the data for a given session token from the MySQLStore instance.
// If the session token is not found or is expired, the returned exists flag will
// be set to false. | [
"Find",
"returns",
"the",
"data",
"for",
"a",
"given",
"session",
"token",
"from",
"the",
"MySQLStore",
"instance",
".",
"If",
"the",
"session",
"token",
"is",
"not",
"found",
"or",
"is",
"expired",
"the",
"returned",
"exists",
"flag",
"will",
"be",
"set",... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/mysqlstore/mysqlstore.go#L44-L62 |
30,666 | alexedwards/scs | mysqlstore/mysqlstore.go | Commit | func (m *MySQLStore) Commit(token string, b []byte, expiry time.Time) error {
_, err := m.DB.Exec("INSERT INTO sessions (token, data, expiry) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data), expiry = VALUES(expiry)", token, b, expiry.UTC())
if err != nil {
return err
}
return nil
} | go | func (m *MySQLStore) Commit(token string, b []byte, expiry time.Time) error {
_, err := m.DB.Exec("INSERT INTO sessions (token, data, expiry) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data), expiry = VALUES(expiry)", token, b, expiry.UTC())
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"m",
"*",
"MySQLStore",
")",
"Commit",
"(",
"token",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"expiry",
"time",
".",
"Time",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"DB",
".",
"Exec",
"(",
"\"",
"\"",
",",
"token",
... | // Commit adds a session token and data to the MySQLStore instance with the given
// expiry time. If the session token already exists, then the data and expiry
// time are updated. | [
"Commit",
"adds",
"a",
"session",
"token",
"and",
"data",
"to",
"the",
"MySQLStore",
"instance",
"with",
"the",
"given",
"expiry",
"time",
".",
"If",
"the",
"session",
"token",
"already",
"exists",
"then",
"the",
"data",
"and",
"expiry",
"time",
"are",
"up... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/mysqlstore/mysqlstore.go#L67-L73 |
30,667 | alexedwards/scs | mysqlstore/mysqlstore.go | Delete | func (m *MySQLStore) Delete(token string) error {
_, err := m.DB.Exec("DELETE FROM sessions WHERE token = ?", token)
return err
} | go | func (m *MySQLStore) Delete(token string) error {
_, err := m.DB.Exec("DELETE FROM sessions WHERE token = ?", token)
return err
} | [
"func",
"(",
"m",
"*",
"MySQLStore",
")",
"Delete",
"(",
"token",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"DB",
".",
"Exec",
"(",
"\"",
"\"",
",",
"token",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Delete removes a session token and corresponding data from the MySQLStore
// instance. | [
"Delete",
"removes",
"a",
"session",
"token",
"and",
"corresponding",
"data",
"from",
"the",
"MySQLStore",
"instance",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/mysqlstore/mysqlstore.go#L77-L80 |
30,668 | alexedwards/scs | data.go | Destroy | func (s *Session) Destroy(ctx context.Context) error {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
err := s.Store.Delete(sd.token)
if err != nil {
return err
}
sd.status = Destroyed
// Reset everything else to defaults.
sd.token = ""
sd.Deadline = time.Now().Add(s.Lifetime).... | go | func (s *Session) Destroy(ctx context.Context) error {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
err := s.Store.Delete(sd.token)
if err != nil {
return err
}
sd.status = Destroyed
// Reset everything else to defaults.
sd.token = ""
sd.Deadline = time.Now().Add(s.Lifetime).... | [
"func",
"(",
"s",
"*",
"Session",
")",
"Destroy",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"sd",
":=",
"s",
".",
"getSessionDataFromContext",
"(",
"ctx",
")",
"\n\n",
"sd",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sd",
"."... | // Destroy deletes the session data from the session store and sets the session
// status to Destroyed. Any futher operations in the same request cycle will
// result in a new session being created. | [
"Destroy",
"deletes",
"the",
"session",
"data",
"from",
"the",
"session",
"store",
"and",
"sets",
"the",
"session",
"status",
"to",
"Destroyed",
".",
"Any",
"futher",
"operations",
"in",
"the",
"same",
"request",
"cycle",
"will",
"result",
"in",
"a",
"new",
... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L131-L152 |
30,669 | alexedwards/scs | data.go | Put | func (s *Session) Put(ctx context.Context, key string, val interface{}) {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
sd.Values[key] = val
sd.status = Modified
sd.mu.Unlock()
} | go | func (s *Session) Put(ctx context.Context, key string, val interface{}) {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
sd.Values[key] = val
sd.status = Modified
sd.mu.Unlock()
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Put",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
",",
"val",
"interface",
"{",
"}",
")",
"{",
"sd",
":=",
"s",
".",
"getSessionDataFromContext",
"(",
"ctx",
")",
"\n\n",
"sd",
".",
"mu",
"."... | // Put adds a key and corresponding value to the session data. Any existing
// value for the key will be replaced. The session data status will be set to
// Modified. | [
"Put",
"adds",
"a",
"key",
"and",
"corresponding",
"value",
"to",
"the",
"session",
"data",
".",
"Any",
"existing",
"value",
"for",
"the",
"key",
"will",
"be",
"replaced",
".",
"The",
"session",
"data",
"status",
"will",
"be",
"set",
"to",
"Modified",
".... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L157-L164 |
30,670 | alexedwards/scs | data.go | Remove | func (s *Session) Remove(ctx context.Context, key string) {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
_, exists := sd.Values[key]
if !exists {
return
}
delete(sd.Values, key)
sd.status = Modified
} | go | func (s *Session) Remove(ctx context.Context, key string) {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
_, exists := sd.Values[key]
if !exists {
return
}
delete(sd.Values, key)
sd.status = Modified
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"{",
"sd",
":=",
"s",
".",
"getSessionDataFromContext",
"(",
"ctx",
")",
"\n\n",
"sd",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer... | // Remove deletes the given key and corresponding value from the session data.
// The session data status will be set to Modified. If the key is not present
// this operation is a no-op. | [
"Remove",
"deletes",
"the",
"given",
"key",
"and",
"corresponding",
"value",
"from",
"the",
"session",
"data",
".",
"The",
"session",
"data",
"status",
"will",
"be",
"set",
"to",
"Modified",
".",
"If",
"the",
"key",
"is",
"not",
"present",
"this",
"operati... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L209-L222 |
30,671 | alexedwards/scs | data.go | Exists | func (s *Session) Exists(ctx context.Context, key string) bool {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
_, exists := sd.Values[key]
sd.mu.Unlock()
return exists
} | go | func (s *Session) Exists(ctx context.Context, key string) bool {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
_, exists := sd.Values[key]
sd.mu.Unlock()
return exists
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"bool",
"{",
"sd",
":=",
"s",
".",
"getSessionDataFromContext",
"(",
"ctx",
")",
"\n\n",
"sd",
".",
"mu",
".",
"Lock",
"(",
")",
"\n"... | // Exists returns true if the given key is present in the session data. | [
"Exists",
"returns",
"true",
"if",
"the",
"given",
"key",
"is",
"present",
"in",
"the",
"session",
"data",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L225-L233 |
30,672 | alexedwards/scs | data.go | Keys | func (s *Session) Keys(ctx context.Context) []string {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
keys := make([]string, len(sd.Values))
i := 0
for key := range sd.Values {
keys[i] = key
i++
}
sd.mu.Unlock()
sort.Strings(keys)
return keys
} | go | func (s *Session) Keys(ctx context.Context) []string {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
keys := make([]string, len(sd.Values))
i := 0
for key := range sd.Values {
keys[i] = key
i++
}
sd.mu.Unlock()
sort.Strings(keys)
return keys
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Keys",
"(",
"ctx",
"context",
".",
"Context",
")",
"[",
"]",
"string",
"{",
"sd",
":=",
"s",
".",
"getSessionDataFromContext",
"(",
"ctx",
")",
"\n\n",
"sd",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"keys",
... | // Keys returns a slice of all key names present in the session data, sorted
// alphabetically. If the data contains no data then an empty slice will be
// returned. | [
"Keys",
"returns",
"a",
"slice",
"of",
"all",
"key",
"names",
"present",
"in",
"the",
"session",
"data",
"sorted",
"alphabetically",
".",
"If",
"the",
"data",
"contains",
"no",
"data",
"then",
"an",
"empty",
"slice",
"will",
"be",
"returned",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L238-L252 |
30,673 | alexedwards/scs | data.go | Status | func (s *Session) Status(ctx context.Context) Status {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
return sd.status
} | go | func (s *Session) Status(ctx context.Context) Status {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
return sd.status
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Status",
"(",
"ctx",
"context",
".",
"Context",
")",
"Status",
"{",
"sd",
":=",
"s",
".",
"getSessionDataFromContext",
"(",
"ctx",
")",
"\n\n",
"sd",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sd",
"."... | // Status returns the current status of the session data. | [
"Status",
"returns",
"the",
"current",
"status",
"of",
"the",
"session",
"data",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L288-L295 |
30,674 | alexedwards/scs | data.go | PopTime | func (s *Session) PopTime(ctx context.Context, key string) time.Time {
val := s.Pop(ctx, key)
t, ok := val.(time.Time)
if !ok {
return time.Time{}
}
return t
} | go | func (s *Session) PopTime(ctx context.Context, key string) time.Time {
val := s.Pop(ctx, key)
t, ok := val.(time.Time)
if !ok {
return time.Time{}
}
return t
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"PopTime",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"time",
".",
"Time",
"{",
"val",
":=",
"s",
".",
"Pop",
"(",
"ctx",
",",
"key",
")",
"\n",
"t",
",",
"ok",
":=",
"val",
".",
"... | // PopTime returns the time.Time value for a given key and then deletes it from
// the session data. The session data status will be set to Modified. The zero
// value for a time.Time object is returned if the key does not exist or the
// value could not be type asserted to a time.Time. | [
"PopTime",
"returns",
"the",
"time",
".",
"Time",
"value",
"for",
"a",
"given",
"key",
"and",
"then",
"deletes",
"it",
"from",
"the",
"session",
"data",
".",
"The",
"session",
"data",
"status",
"will",
"be",
"set",
"to",
"Modified",
".",
"The",
"zero",
... | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/data.go#L439-L446 |
30,675 | alexedwards/scs | session.go | NewSession | func NewSession() *Session {
s := &Session{
IdleTimeout: 0,
Lifetime: 24 * time.Hour,
Store: memstore.New(),
contextKey: generateContextKey(),
Cookie: SessionCookie{
Name: "session",
Domain: "",
HttpOnly: true,
Path: "/",
Persist: true,
Secure: false,
SameSite: htt... | go | func NewSession() *Session {
s := &Session{
IdleTimeout: 0,
Lifetime: 24 * time.Hour,
Store: memstore.New(),
contextKey: generateContextKey(),
Cookie: SessionCookie{
Name: "session",
Domain: "",
HttpOnly: true,
Path: "/",
Persist: true,
Secure: false,
SameSite: htt... | [
"func",
"NewSession",
"(",
")",
"*",
"Session",
"{",
"s",
":=",
"&",
"Session",
"{",
"IdleTimeout",
":",
"0",
",",
"Lifetime",
":",
"24",
"*",
"time",
".",
"Hour",
",",
"Store",
":",
"memstore",
".",
"New",
"(",
")",
",",
"contextKey",
":",
"genera... | // NewSession returns a new session manager with the default options. It is
// safe for concurrent use. | [
"NewSession",
"returns",
"a",
"new",
"session",
"manager",
"with",
"the",
"default",
"options",
".",
"It",
"is",
"safe",
"for",
"concurrent",
"use",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/session.go#L80-L97 |
30,676 | alexedwards/scs | session.go | LoadAndSave | func (s *Session) LoadAndSave(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var token string
cookie, err := r.Cookie(s.Cookie.Name)
if err == nil {
token = cookie.Value
}
ctx, err := s.Load(r.Context(), token)
if err != nil {
log.Output(2, e... | go | func (s *Session) LoadAndSave(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var token string
cookie, err := r.Cookie(s.Cookie.Name)
if err == nil {
token = cookie.Value
}
ctx, err := s.Load(r.Context(), token)
if err != nil {
log.Output(2, e... | [
"func",
"(",
"s",
"*",
"Session",
")",
"LoadAndSave",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Requ... | // LoadAndSave provides middleware which automatically loads and saves session
// data for the current request, and communicates the session token to and from
// the client in a cookie. | [
"LoadAndSave",
"provides",
"middleware",
"which",
"automatically",
"loads",
"and",
"saves",
"session",
"data",
"for",
"the",
"current",
"request",
"and",
"communicates",
"the",
"session",
"token",
"to",
"and",
"from",
"the",
"client",
"in",
"a",
"cookie",
"."
] | 7591275b1edfd53a361e4bdbe42148cbd1b00ac1 | https://github.com/alexedwards/scs/blob/7591275b1edfd53a361e4bdbe42148cbd1b00ac1/session.go#L102-L139 |
30,677 | rogpeppe/godef | go/ast/resolve.go | NewPackage | func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer, universe *Scope) (*Package, error) {
var p pkgBuilder
p.fset = fset
// complete package scope
pkgName := ""
pkgScope := NewScope(universe)
for _, file := range files {
// package names must match
switch name := file.Name.Name; {
... | go | func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer, universe *Scope) (*Package, error) {
var p pkgBuilder
p.fset = fset
// complete package scope
pkgName := ""
pkgScope := NewScope(universe)
for _, file := range files {
// package names must match
switch name := file.Name.Name; {
... | [
"func",
"NewPackage",
"(",
"fset",
"*",
"token",
".",
"FileSet",
",",
"files",
"map",
"[",
"string",
"]",
"*",
"File",
",",
"importer",
"Importer",
",",
"universe",
"*",
"Scope",
")",
"(",
"*",
"Package",
",",
"error",
")",
"{",
"var",
"p",
"pkgBuild... | // NewPackage creates a new Package node from a set of File nodes. It resolves
// unresolved identifiers across files and updates each file's Unresolved list
// accordingly. If a non-nil importer and universe scope are provided, they are
// used to resolve identifiers not declared in any of the package files. Any
// re... | [
"NewPackage",
"creates",
"a",
"new",
"Package",
"node",
"from",
"a",
"set",
"of",
"File",
"nodes",
".",
"It",
"resolves",
"unresolved",
"identifiers",
"across",
"files",
"and",
"updates",
"each",
"file",
"s",
"Unresolved",
"list",
"accordingly",
".",
"If",
"... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/ast/resolve.go#L75-L174 |
30,678 | rogpeppe/godef | go/printer/printer.go | nlines | func (p *printer) nlines(n, min int) int {
const max = 2 // max. number of newlines
switch {
case n < min:
return min
case n > max:
return max
}
return n
} | go | func (p *printer) nlines(n, min int) int {
const max = 2 // max. number of newlines
switch {
case n < min:
return min
case n > max:
return max
}
return n
} | [
"func",
"(",
"p",
"*",
"printer",
")",
"nlines",
"(",
"n",
",",
"min",
"int",
")",
"int",
"{",
"const",
"max",
"=",
"2",
"// max. number of newlines",
"\n",
"switch",
"{",
"case",
"n",
"<",
"min",
":",
"return",
"min",
"\n",
"case",
"n",
">",
"max"... | // nlines returns the adjusted number of linebreaks given the desired number
// of breaks n such that min <= result <= max.
// | [
"nlines",
"returns",
"the",
"adjusted",
"number",
"of",
"linebreaks",
"given",
"the",
"desired",
"number",
"of",
"breaks",
"n",
"such",
"that",
"min",
"<",
"=",
"result",
"<",
"=",
"max",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L127-L136 |
30,679 | rogpeppe/godef | go/printer/printer.go | write | func (p *printer) write(data []byte) {
i0 := 0
for i, b := range data {
switch b {
case '\n', '\f':
// write segment ending in b
p.write0(data[i0 : i+1])
// update p.pos
p.pos.Offset += i + 1 - i0
p.pos.Line++
p.pos.Column = 1
if p.mode&inLiteral == 0 {
// write indentation
// use "... | go | func (p *printer) write(data []byte) {
i0 := 0
for i, b := range data {
switch b {
case '\n', '\f':
// write segment ending in b
p.write0(data[i0 : i+1])
// update p.pos
p.pos.Offset += i + 1 - i0
p.pos.Line++
p.pos.Column = 1
if p.mode&inLiteral == 0 {
// write indentation
// use "... | [
"func",
"(",
"p",
"*",
"printer",
")",
"write",
"(",
"data",
"[",
"]",
"byte",
")",
"{",
"i0",
":=",
"0",
"\n",
"for",
"i",
",",
"b",
":=",
"range",
"data",
"{",
"switch",
"b",
"{",
"case",
"'\\n'",
",",
"'\\f'",
":",
"// write segment ending in b"... | // write interprets data and writes it to p.output. It inserts indentation
// after a line break unless in a tabwriter escape sequence.
// It updates p.pos as a side-effect.
// | [
"write",
"interprets",
"data",
"and",
"writes",
"it",
"to",
"p",
".",
"output",
".",
"It",
"inserts",
"indentation",
"after",
"a",
"line",
"break",
"unless",
"in",
"a",
"tabwriter",
"escape",
"sequence",
".",
"It",
"updates",
"p",
".",
"pos",
"as",
"a",
... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L156-L204 |
30,680 | rogpeppe/godef | go/printer/printer.go | writeWhitespace | func (p *printer) writeWhitespace(n int) {
// write entries
var data [1]byte
for i := 0; i < n; i++ {
switch ch := p.wsbuf[i]; ch {
case ignore:
// ignore!
case indent:
p.indent++
case unindent:
p.indent--
if p.indent < 0 {
p.internalError("negative indentation:", p.indent)
p.indent = 0
... | go | func (p *printer) writeWhitespace(n int) {
// write entries
var data [1]byte
for i := 0; i < n; i++ {
switch ch := p.wsbuf[i]; ch {
case ignore:
// ignore!
case indent:
p.indent++
case unindent:
p.indent--
if p.indent < 0 {
p.internalError("negative indentation:", p.indent)
p.indent = 0
... | [
"func",
"(",
"p",
"*",
"printer",
")",
"writeWhitespace",
"(",
"n",
"int",
")",
"{",
"// write entries",
"var",
"data",
"[",
"1",
"]",
"byte",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"switch",
"ch",
":=",
"p",
".",... | // whiteWhitespace writes the first n whitespace entries. | [
"whiteWhitespace",
"writes",
"the",
"first",
"n",
"whitespace",
"entries",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L628-L674 |
30,681 | rogpeppe/godef | go/printer/printer.go | commentBefore | func (p *printer) commentBefore(next token.Position) bool {
return p.cindex < len(p.comments) && p.fset.Position(p.comments[p.cindex].List[0].Pos()).Offset < next.Offset
} | go | func (p *printer) commentBefore(next token.Position) bool {
return p.cindex < len(p.comments) && p.fset.Position(p.comments[p.cindex].List[0].Pos()).Offset < next.Offset
} | [
"func",
"(",
"p",
"*",
"printer",
")",
"commentBefore",
"(",
"next",
"token",
".",
"Position",
")",
"bool",
"{",
"return",
"p",
".",
"cindex",
"<",
"len",
"(",
"p",
".",
"comments",
")",
"&&",
"p",
".",
"fset",
".",
"Position",
"(",
"p",
".",
"co... | // commentBefore returns true iff the current comment occurs
// before the next position in the source code.
// | [
"commentBefore",
"returns",
"true",
"iff",
"the",
"current",
"comment",
"occurs",
"before",
"the",
"next",
"position",
"in",
"the",
"source",
"code",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L789-L791 |
30,682 | rogpeppe/godef | go/printer/printer.go | flush | func (p *printer) flush(next token.Position, tok token.Token) (droppedFF bool) {
if p.commentBefore(next) {
// if there are comments before the next item, intersperse them
droppedFF = p.intersperseComments(next, tok)
} else {
// otherwise, write any leftover whitespace
p.writeWhitespace(len(p.wsbuf))
}
retu... | go | func (p *printer) flush(next token.Position, tok token.Token) (droppedFF bool) {
if p.commentBefore(next) {
// if there are comments before the next item, intersperse them
droppedFF = p.intersperseComments(next, tok)
} else {
// otherwise, write any leftover whitespace
p.writeWhitespace(len(p.wsbuf))
}
retu... | [
"func",
"(",
"p",
"*",
"printer",
")",
"flush",
"(",
"next",
"token",
".",
"Position",
",",
"tok",
"token",
".",
"Token",
")",
"(",
"droppedFF",
"bool",
")",
"{",
"if",
"p",
".",
"commentBefore",
"(",
"next",
")",
"{",
"// if there are comments before th... | // Flush prints any pending comments and whitespace occurring
// textually before the position of the next token tok. Flush
// returns true if a pending formfeed character was dropped
// from the whitespace buffer as a result of interspersing
// comments.
// | [
"Flush",
"prints",
"any",
"pending",
"comments",
"and",
"whitespace",
"occurring",
"textually",
"before",
"the",
"position",
"of",
"the",
"next",
"token",
"tok",
".",
"Flush",
"returns",
"true",
"if",
"a",
"pending",
"formfeed",
"character",
"was",
"dropped",
... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L799-L808 |
30,683 | rogpeppe/godef | go/printer/printer.go | fprint | func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node interface{}, nodeSizes map[ast.Node]int) (int, error) {
// redirect output through a trimmer to eliminate trailing whitespace
// (Input to a tabwriter must be untrimmed since trailing tabs provide
// formatting information. The tabwriter could pro... | go | func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node interface{}, nodeSizes map[ast.Node]int) (int, error) {
// redirect output through a trimmer to eliminate trailing whitespace
// (Input to a tabwriter must be untrimmed since trailing tabs provide
// formatting information. The tabwriter could pro... | [
"func",
"(",
"cfg",
"*",
"Config",
")",
"fprint",
"(",
"output",
"io",
".",
"Writer",
",",
"fset",
"*",
"token",
".",
"FileSet",
",",
"node",
"interface",
"{",
"}",
",",
"nodeSizes",
"map",
"[",
"ast",
".",
"Node",
"]",
"int",
")",
"(",
"int",
",... | // fprint implements Fprint and takes a nodesSizes map for setting up the printer state. | [
"fprint",
"implements",
"Fprint",
"and",
"takes",
"a",
"nodesSizes",
"map",
"for",
"setting",
"up",
"the",
"printer",
"state",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L927-L995 |
30,684 | rogpeppe/godef | go/printer/printer.go | Fprint | func Fprint(output io.Writer, fset *token.FileSet, node interface{}) error {
_, err := (&Config{Tabwidth: 8}).Fprint(output, fset, node) // don't care about number of bytes written
return err
} | go | func Fprint(output io.Writer, fset *token.FileSet, node interface{}) error {
_, err := (&Config{Tabwidth: 8}).Fprint(output, fset, node) // don't care about number of bytes written
return err
} | [
"func",
"Fprint",
"(",
"output",
"io",
".",
"Writer",
",",
"fset",
"*",
"token",
".",
"FileSet",
",",
"node",
"interface",
"{",
"}",
")",
"error",
"{",
"_",
",",
"err",
":=",
"(",
"&",
"Config",
"{",
"Tabwidth",
":",
"8",
"}",
")",
".",
"Fprint",... | // Fprint "pretty-prints" an AST node to output.
// It calls Config.Fprint with default settings.
// | [
"Fprint",
"pretty",
"-",
"prints",
"an",
"AST",
"node",
"to",
"output",
".",
"It",
"calls",
"Config",
".",
"Fprint",
"with",
"default",
"settings",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/printer.go#L1010-L1013 |
30,685 | rogpeppe/godef | go/scanner/scanner.go | next | func (S *Scanner) next() {
if S.rdOffset < len(S.src) {
S.offset = S.rdOffset
if S.ch == '\n' {
S.lineOffset = S.offset
S.file.AddLine(S.offset)
}
r, w := rune(S.src[S.rdOffset]), 1
switch {
case r == 0:
S.error(S.offset, "illegal character NUL")
case r >= 0x80:
// not ASCII
r, w = utf8.De... | go | func (S *Scanner) next() {
if S.rdOffset < len(S.src) {
S.offset = S.rdOffset
if S.ch == '\n' {
S.lineOffset = S.offset
S.file.AddLine(S.offset)
}
r, w := rune(S.src[S.rdOffset]), 1
switch {
case r == 0:
S.error(S.offset, "illegal character NUL")
case r >= 0x80:
// not ASCII
r, w = utf8.De... | [
"func",
"(",
"S",
"*",
"Scanner",
")",
"next",
"(",
")",
"{",
"if",
"S",
".",
"rdOffset",
"<",
"len",
"(",
"S",
".",
"src",
")",
"{",
"S",
".",
"offset",
"=",
"S",
".",
"rdOffset",
"\n",
"if",
"S",
".",
"ch",
"==",
"'\\n'",
"{",
"S",
".",
... | // Read the next Unicode char into S.ch.
// S.ch < 0 means end-of-file.
// | [
"Read",
"the",
"next",
"Unicode",
"char",
"into",
"S",
".",
"ch",
".",
"S",
".",
"ch",
"<",
"0",
"means",
"end",
"-",
"of",
"-",
"file",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/scanner/scanner.go#L60-L88 |
30,686 | rogpeppe/godef | go/scanner/scanner.go | Init | func (S *Scanner) Init(file *token.File, src []byte, err ErrorHandler, mode uint) {
// Explicitly initialize all fields since a scanner may be reused.
if file.Size() != len(src) {
panic("file size does not match src len")
}
S.file = file
S.dir, _ = filepath.Split(file.Name())
S.src = src
S.err = err
S.mode = ... | go | func (S *Scanner) Init(file *token.File, src []byte, err ErrorHandler, mode uint) {
// Explicitly initialize all fields since a scanner may be reused.
if file.Size() != len(src) {
panic("file size does not match src len")
}
S.file = file
S.dir, _ = filepath.Split(file.Name())
S.src = src
S.err = err
S.mode = ... | [
"func",
"(",
"S",
"*",
"Scanner",
")",
"Init",
"(",
"file",
"*",
"token",
".",
"File",
",",
"src",
"[",
"]",
"byte",
",",
"err",
"ErrorHandler",
",",
"mode",
"uint",
")",
"{",
"// Explicitly initialize all fields since a scanner may be reused.",
"if",
"file",
... | // Init prepares the scanner S to tokenize the text src by setting the
// scanner at the beginning of src. The scanner uses the file set file
// for position information and it adds line information for each line.
// It is ok to re-use the same file when re-scanning the same file as
// line information which is already... | [
"Init",
"prepares",
"the",
"scanner",
"S",
"to",
"tokenize",
"the",
"text",
"src",
"by",
"setting",
"the",
"scanner",
"at",
"the",
"beginning",
"of",
"src",
".",
"The",
"scanner",
"uses",
"the",
"file",
"set",
"file",
"for",
"position",
"information",
"and... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/scanner/scanner.go#L114-L133 |
30,687 | rogpeppe/godef | go/scanner/scanner.go | switch2 | func (S *Scanner) switch2(tok0, tok1 token.Token) token.Token {
if S.ch == '=' {
S.next()
return tok1
}
return tok0
} | go | func (S *Scanner) switch2(tok0, tok1 token.Token) token.Token {
if S.ch == '=' {
S.next()
return tok1
}
return tok0
} | [
"func",
"(",
"S",
"*",
"Scanner",
")",
"switch2",
"(",
"tok0",
",",
"tok1",
"token",
".",
"Token",
")",
"token",
".",
"Token",
"{",
"if",
"S",
".",
"ch",
"==",
"'='",
"{",
"S",
".",
"next",
"(",
")",
"\n",
"return",
"tok1",
"\n",
"}",
"\n",
"... | // Helper functions for scanning multi-byte tokens such as >> += >>= .
// Different routines recognize different length tok_i based on matches
// of ch_i. If a token ends in '=', the result is tok1 or tok3
// respectively. Otherwise, the result is tok0 if there was no other
// matching character, or tok2 if the matchin... | [
"Helper",
"functions",
"for",
"scanning",
"multi",
"-",
"byte",
"tokens",
"such",
"as",
">>",
"+",
"=",
">>",
"=",
".",
"Different",
"routines",
"recognize",
"different",
"length",
"tok_i",
"based",
"on",
"matches",
"of",
"ch_i",
".",
"If",
"a",
"token",
... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/scanner/scanner.go#L459-L465 |
30,688 | rogpeppe/godef | go/sym/sym.go | Import | func (ctxt *Context) Import(path, srcDir string) *ast.Package {
// TODO return error.
return ctxt.importer(path, srcDir)
} | go | func (ctxt *Context) Import(path, srcDir string) *ast.Package {
// TODO return error.
return ctxt.importer(path, srcDir)
} | [
"func",
"(",
"ctxt",
"*",
"Context",
")",
"Import",
"(",
"path",
",",
"srcDir",
"string",
")",
"*",
"ast",
".",
"Package",
"{",
"// TODO return error.",
"return",
"ctxt",
".",
"importer",
"(",
"path",
",",
"srcDir",
")",
"\n",
"}"
] | // Import imports and parses the package with the given path.
// It returns nil if it fails. | [
"Import",
"imports",
"and",
"parses",
"the",
"package",
"with",
"the",
"given",
"path",
".",
"It",
"returns",
"nil",
"if",
"it",
"fails",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/sym/sym.go#L61-L64 |
30,689 | rogpeppe/godef | go/sym/sym.go | IterateSyms | func (ctxt *Context) IterateSyms(f *ast.File, visitf func(info *Info) bool) {
var visit astVisitor
ok := true
local := false // TODO set to true inside function body
visit = func(n ast.Node) bool {
if !ok {
return false
}
switch n := n.(type) {
case *ast.ImportSpec:
// If the file imports a package to... | go | func (ctxt *Context) IterateSyms(f *ast.File, visitf func(info *Info) bool) {
var visit astVisitor
ok := true
local := false // TODO set to true inside function body
visit = func(n ast.Node) bool {
if !ok {
return false
}
switch n := n.(type) {
case *ast.ImportSpec:
// If the file imports a package to... | [
"func",
"(",
"ctxt",
"*",
"Context",
")",
"IterateSyms",
"(",
"f",
"*",
"ast",
".",
"File",
",",
"visitf",
"func",
"(",
"info",
"*",
"Info",
")",
"bool",
")",
"{",
"var",
"visit",
"astVisitor",
"\n",
"ok",
":=",
"true",
"\n",
"local",
":=",
"false"... | // IterateSyms calls visitf for each identifier in the given file. If
// visitf returns false, the iteration stops. If visitf changes
// info.Ident.Name, the file is added to ctxt.ChangedFiles. | [
"IterateSyms",
"calls",
"visitf",
"for",
"each",
"identifier",
"in",
"the",
"given",
"file",
".",
"If",
"visitf",
"returns",
"false",
"the",
"iteration",
"stops",
".",
"If",
"visitf",
"changes",
"info",
".",
"Ident",
".",
"Name",
"the",
"file",
"is",
"adde... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/sym/sym.go#L123-L200 |
30,690 | rogpeppe/godef | go/sym/sym.go | WriteFiles | func (ctxt *Context) WriteFiles(files map[string]*ast.File) error {
// TODO should we try to continue changing files even after an error?
for _, f := range files {
name := ctxt.filename(f)
newSrc, err := ctxt.gofmtFile(f)
if err != nil {
return fmt.Errorf("cannot format %q: %v", name, err)
}
err = ioutil... | go | func (ctxt *Context) WriteFiles(files map[string]*ast.File) error {
// TODO should we try to continue changing files even after an error?
for _, f := range files {
name := ctxt.filename(f)
newSrc, err := ctxt.gofmtFile(f)
if err != nil {
return fmt.Errorf("cannot format %q: %v", name, err)
}
err = ioutil... | [
"func",
"(",
"ctxt",
"*",
"Context",
")",
"WriteFiles",
"(",
"files",
"map",
"[",
"string",
"]",
"*",
"ast",
".",
"File",
")",
"error",
"{",
"// TODO should we try to continue changing files even after an error?",
"for",
"_",
",",
"f",
":=",
"range",
"files",
... | // WriteFiles writes the given files, formatted as with gofmt. | [
"WriteFiles",
"writes",
"the",
"given",
"files",
"formatted",
"as",
"with",
"gofmt",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/sym/sym.go#L249-L263 |
30,691 | rogpeppe/godef | go/ast/scope.go | NewScope | func NewScope(outer *Scope) *Scope {
const n = 4 // initial scope capacity
return &Scope{outer, make(map[string]*Object, n)}
} | go | func NewScope(outer *Scope) *Scope {
const n = 4 // initial scope capacity
return &Scope{outer, make(map[string]*Object, n)}
} | [
"func",
"NewScope",
"(",
"outer",
"*",
"Scope",
")",
"*",
"Scope",
"{",
"const",
"n",
"=",
"4",
"// initial scope capacity",
"\n",
"return",
"&",
"Scope",
"{",
"outer",
",",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Object",
",",
"n",
")",
"}",
... | // NewScope creates a new scope nested in the outer scope. | [
"NewScope",
"creates",
"a",
"new",
"scope",
"nested",
"in",
"the",
"outer",
"scope",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/ast/scope.go#L26-L29 |
30,692 | rogpeppe/godef | go/ast/scope.go | Insert | func (s *Scope) Insert(obj *Object) (alt *Object) {
if alt = s.Objects[obj.Name]; alt == nil {
s.Objects[obj.Name] = obj
}
return
} | go | func (s *Scope) Insert(obj *Object) (alt *Object) {
if alt = s.Objects[obj.Name]; alt == nil {
s.Objects[obj.Name] = obj
}
return
} | [
"func",
"(",
"s",
"*",
"Scope",
")",
"Insert",
"(",
"obj",
"*",
"Object",
")",
"(",
"alt",
"*",
"Object",
")",
"{",
"if",
"alt",
"=",
"s",
".",
"Objects",
"[",
"obj",
".",
"Name",
"]",
";",
"alt",
"==",
"nil",
"{",
"s",
".",
"Objects",
"[",
... | // Insert attempts to insert a named object obj into the scope s.
// If the scope already contains an object alt with the same name,
// Insert leaves the scope unchanged and returns alt. Otherwise
// it inserts obj and returns nil."
// | [
"Insert",
"attempts",
"to",
"insert",
"a",
"named",
"object",
"obj",
"into",
"the",
"scope",
"s",
".",
"If",
"the",
"scope",
"already",
"contains",
"an",
"object",
"alt",
"with",
"the",
"same",
"name",
"Insert",
"leaves",
"the",
"scope",
"unchanged",
"and"... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/ast/scope.go#L44-L49 |
30,693 | rogpeppe/godef | go/ast/scope.go | NewObj | func NewObj(kind ObjKind, name string) *Object {
return &Object{Kind: kind, Name: name}
} | go | func NewObj(kind ObjKind, name string) *Object {
return &Object{Kind: kind, Name: name}
} | [
"func",
"NewObj",
"(",
"kind",
"ObjKind",
",",
"name",
"string",
")",
"*",
"Object",
"{",
"return",
"&",
"Object",
"{",
"Kind",
":",
"kind",
",",
"Name",
":",
"name",
"}",
"\n",
"}"
] | // NewObj creates a new object of a given kind and name. | [
"NewObj",
"creates",
"a",
"new",
"object",
"of",
"a",
"given",
"kind",
"and",
"name",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/ast/scope.go#L90-L92 |
30,694 | rogpeppe/godef | go/ast/ast.go | Pos | func (s *ImportSpec) Pos() token.Pos {
if s.Name != nil {
return s.Name.Pos()
}
return s.Path.Pos()
} | go | func (s *ImportSpec) Pos() token.Pos {
if s.Name != nil {
return s.Name.Pos()
}
return s.Path.Pos()
} | [
"func",
"(",
"s",
"*",
"ImportSpec",
")",
"Pos",
"(",
")",
"token",
".",
"Pos",
"{",
"if",
"s",
".",
"Name",
"!=",
"nil",
"{",
"return",
"s",
".",
"Name",
".",
"Pos",
"(",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"Path",
".",
"Pos",
"(",
"... | // Pos and End implementations for spec nodes.
// | [
"Pos",
"and",
"End",
"implementations",
"for",
"spec",
"nodes",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/ast/ast.go#L783-L788 |
30,695 | rogpeppe/godef | go/token/token.go | Precedence | func (op Token) Precedence() int {
switch op {
case LOR:
return 1
case LAND:
return 2
case EQL, NEQ, LSS, LEQ, GTR, GEQ:
return 3
case ADD, SUB, OR, XOR:
return 4
case MUL, QUO, REM, SHL, SHR, AND, AND_NOT:
return 5
}
return LowestPrec
} | go | func (op Token) Precedence() int {
switch op {
case LOR:
return 1
case LAND:
return 2
case EQL, NEQ, LSS, LEQ, GTR, GEQ:
return 3
case ADD, SUB, OR, XOR:
return 4
case MUL, QUO, REM, SHL, SHR, AND, AND_NOT:
return 5
}
return LowestPrec
} | [
"func",
"(",
"op",
"Token",
")",
"Precedence",
"(",
")",
"int",
"{",
"switch",
"op",
"{",
"case",
"LOR",
":",
"return",
"1",
"\n",
"case",
"LAND",
":",
"return",
"2",
"\n",
"case",
"EQL",
",",
"NEQ",
",",
"LSS",
",",
"LEQ",
",",
"GTR",
",",
"GE... | // Precedence returns the operator precedence of the binary
// operator op. If op is not a binary operator, the result
// is LowestPrecedence.
// | [
"Precedence",
"returns",
"the",
"operator",
"precedence",
"of",
"the",
"binary",
"operator",
"op",
".",
"If",
"op",
"is",
"not",
"a",
"binary",
"operator",
"the",
"result",
"is",
"LowestPrecedence",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/token/token.go#L260-L274 |
30,696 | rogpeppe/godef | go/types/types.go | DefaultImporter | func DefaultImporter(path string, srcDir string) *ast.Package {
bpkg, err := build.Default.Import(path, srcDir, 0)
if err != nil {
return nil
}
goFiles := make(map[string]bool)
for _, f := range bpkg.GoFiles {
goFiles[f] = true
}
for _, f := range bpkg.CgoFiles {
goFiles[f] = true
}
shouldInclude := func... | go | func DefaultImporter(path string, srcDir string) *ast.Package {
bpkg, err := build.Default.Import(path, srcDir, 0)
if err != nil {
return nil
}
goFiles := make(map[string]bool)
for _, f := range bpkg.GoFiles {
goFiles[f] = true
}
for _, f := range bpkg.CgoFiles {
goFiles[f] = true
}
shouldInclude := func... | [
"func",
"DefaultImporter",
"(",
"path",
"string",
",",
"srcDir",
"string",
")",
"*",
"ast",
".",
"Package",
"{",
"bpkg",
",",
"err",
":=",
"build",
".",
"Default",
".",
"Import",
"(",
"path",
",",
"srcDir",
",",
"0",
")",
"\n",
"if",
"err",
"!=",
"... | // DefaultImporter looks for the package; if it finds it,
// it parses and returns it. If no package was found, it returns nil. | [
"DefaultImporter",
"looks",
"for",
"the",
"package",
";",
"if",
"it",
"finds",
"it",
"it",
"parses",
"and",
"returns",
"it",
".",
"If",
"no",
"package",
"was",
"found",
"it",
"returns",
"nil",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/types/types.go#L80-L116 |
30,697 | rogpeppe/godef | go/types/types.go | String | func (t Type) String() string {
return fmt.Sprintf("Type{%v %q %T %v}", t.Kind, t.Pkg, t.Node, pretty{t.Node})
} | go | func (t Type) String() string {
return fmt.Sprintf("Type{%v %q %T %v}", t.Kind, t.Pkg, t.Node, pretty{t.Node})
} | [
"func",
"(",
"t",
"Type",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"t",
".",
"Kind",
",",
"t",
".",
"Pkg",
",",
"t",
".",
"Node",
",",
"pretty",
"{",
"t",
".",
"Node",
"}",
")",
"\n",
"}... | // String is for debugging purposes. | [
"String",
"is",
"for",
"debugging",
"purposes",
"."
] | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/types/types.go#L144-L146 |
30,698 | rogpeppe/godef | go/printer/nodes.go | setComment | func (p *printer) setComment(g *ast.CommentGroup) {
if g == nil || !p.useNodeComments {
return
}
if p.comments == nil {
// initialize p.comments lazily
p.comments = make([]*ast.CommentGroup, 1)
} else if p.cindex < len(p.comments) {
// for some reason there are pending comments; this
// should never happe... | go | func (p *printer) setComment(g *ast.CommentGroup) {
if g == nil || !p.useNodeComments {
return
}
if p.comments == nil {
// initialize p.comments lazily
p.comments = make([]*ast.CommentGroup, 1)
} else if p.cindex < len(p.comments) {
// for some reason there are pending comments; this
// should never happe... | [
"func",
"(",
"p",
"*",
"printer",
")",
"setComment",
"(",
"g",
"*",
"ast",
".",
"CommentGroup",
")",
"{",
"if",
"g",
"==",
"nil",
"||",
"!",
"p",
".",
"useNodeComments",
"{",
"return",
"\n",
"}",
"\n",
"if",
"p",
".",
"comments",
"==",
"nil",
"{"... | // setComment sets g as the next comment if g != nil and if node comments
// are enabled - this mode is used when printing source code fragments such
// as exports only. It assumes that there are no other pending comments to
// intersperse. | [
"setComment",
"sets",
"g",
"as",
"the",
"next",
"comment",
"if",
"g",
"!",
"=",
"nil",
"and",
"if",
"node",
"comments",
"are",
"enabled",
"-",
"this",
"mode",
"is",
"used",
"when",
"printing",
"source",
"code",
"fragments",
"such",
"as",
"exports",
"only... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/nodes.go#L62-L77 |
30,699 | rogpeppe/godef | go/printer/nodes.go | identList | func (p *printer) identList(list []*ast.Ident, indent bool, multiLine *bool) {
// convert into an expression list so we can re-use exprList formatting
xlist := make([]ast.Expr, len(list))
for i, x := range list {
xlist[i] = x
}
mode := commaSep
if !indent {
mode |= noIndent
}
p.exprList(token.NoPos, xlist, ... | go | func (p *printer) identList(list []*ast.Ident, indent bool, multiLine *bool) {
// convert into an expression list so we can re-use exprList formatting
xlist := make([]ast.Expr, len(list))
for i, x := range list {
xlist[i] = x
}
mode := commaSep
if !indent {
mode |= noIndent
}
p.exprList(token.NoPos, xlist, ... | [
"func",
"(",
"p",
"*",
"printer",
")",
"identList",
"(",
"list",
"[",
"]",
"*",
"ast",
".",
"Ident",
",",
"indent",
"bool",
",",
"multiLine",
"*",
"bool",
")",
"{",
"// convert into an expression list so we can re-use exprList formatting",
"xlist",
":=",
"make",... | // Sets multiLine to true if the identifier list spans multiple lines.
// If indent is set, a multi-line identifier list is indented after the
// first linebreak encountered. | [
"Sets",
"multiLine",
"to",
"true",
"if",
"the",
"identifier",
"list",
"spans",
"multiple",
"lines",
".",
"If",
"indent",
"is",
"set",
"a",
"multi",
"-",
"line",
"identifier",
"list",
"is",
"indented",
"after",
"the",
"first",
"linebreak",
"encountered",
"."
... | 5784335da72394c8f53d9036c26fcc876718879b | https://github.com/rogpeppe/godef/blob/5784335da72394c8f53d9036c26fcc876718879b/go/printer/nodes.go#L93-L104 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.