id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,100 | coreos/go-omaha | omaha/client/client.go | doReq | func (ac *AppClient) doReq(url string, req *omaha.Request) (*omaha.AppResponse, error) {
if len(req.Apps) != 1 {
panic(fmt.Errorf("unexpected number of apps: %d", len(req.Apps)))
}
appID := req.Apps[0].ID
resp, err := ac.apiClient.Omaha(url, req)
if err != nil {
return nil, err
}
appResp := resp.GetApp(appI... | go | func (ac *AppClient) doReq(url string, req *omaha.Request) (*omaha.AppResponse, error) {
if len(req.Apps) != 1 {
panic(fmt.Errorf("unexpected number of apps: %d", len(req.Apps)))
}
appID := req.Apps[0].ID
resp, err := ac.apiClient.Omaha(url, req)
if err != nil {
return nil, err
}
appResp := resp.GetApp(appI... | [
"func",
"(",
"ac",
"*",
"AppClient",
")",
"doReq",
"(",
"url",
"string",
",",
"req",
"*",
"omaha",
".",
"Request",
")",
"(",
"*",
"omaha",
".",
"AppResponse",
",",
"error",
")",
"{",
"if",
"len",
"(",
"req",
".",
"Apps",
")",
"!=",
"1",
"{",
"p... | // doReq posts an omaha request. It may be called in its own goroutine so
// it should not touch any mutable data in AppClient, but apiClient is ok. | [
"doReq",
"posts",
"an",
"omaha",
"request",
".",
"It",
"may",
"be",
"called",
"in",
"its",
"own",
"goroutine",
"so",
"it",
"should",
"not",
"touch",
"any",
"mutable",
"data",
"in",
"AppClient",
"but",
"apiClient",
"is",
"ok",
"."
] | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/client/client.go#L345-L368 |
145,101 | coreos/go-omaha | omaha/client/machine_linux.go | NewMachineClient | func NewMachineClient(serverURL string) (*Client, error) {
machineID, err := ioutil.ReadFile(machineIDPath)
if err != nil {
fmt.Errorf("omaha: failed to read machine id: %v", err)
}
machineID = bytes.TrimSpace(machineID)
// Although machineID should be a UUID, it is formatted as a
// plain hex string, omitting... | go | func NewMachineClient(serverURL string) (*Client, error) {
machineID, err := ioutil.ReadFile(machineIDPath)
if err != nil {
fmt.Errorf("omaha: failed to read machine id: %v", err)
}
machineID = bytes.TrimSpace(machineID)
// Although machineID should be a UUID, it is formatted as a
// plain hex string, omitting... | [
"func",
"NewMachineClient",
"(",
"serverURL",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"machineID",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"machineIDPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Errorf",
"("... | // NewMachineClient creates a machine-wide client, updating applications
// that may be used by multiple users. On Linux the system's machine id
// is used as the user id, and boot id is used as the omaha session id. | [
"NewMachineClient",
"creates",
"a",
"machine",
"-",
"wide",
"client",
"updating",
"applications",
"that",
"may",
"be",
"used",
"by",
"multiple",
"users",
".",
"On",
"Linux",
"the",
"system",
"s",
"machine",
"id",
"is",
"used",
"as",
"the",
"user",
"id",
"a... | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/client/machine_linux.go#L33-L75 |
145,102 | coreos/go-omaha | omaha/client/http.go | doPost | func (hc *httpClient) doPost(url string, reqBody []byte) (*omaha.Response, error) {
resp, err := hc.Post(url, "text/xml; charset=utf-8", bytes.NewReader(reqBody))
if err != nil {
return nil, &omahaError{err, ExitCodeOmahaRequestError}
}
defer resp.Body.Close()
// A response over 1M in size is certainly bogus.
... | go | func (hc *httpClient) doPost(url string, reqBody []byte) (*omaha.Response, error) {
resp, err := hc.Post(url, "text/xml; charset=utf-8", bytes.NewReader(reqBody))
if err != nil {
return nil, &omahaError{err, ExitCodeOmahaRequestError}
}
defer resp.Body.Close()
// A response over 1M in size is certainly bogus.
... | [
"func",
"(",
"hc",
"*",
"httpClient",
")",
"doPost",
"(",
"url",
"string",
",",
"reqBody",
"[",
"]",
"byte",
")",
"(",
"*",
"omaha",
".",
"Response",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"hc",
".",
"Post",
"(",
"url",
",",
"\"",
"\... | // doPost sends a single HTTP POST, returning a parsed omaha response. | [
"doPost",
"sends",
"a",
"single",
"HTTP",
"POST",
"returning",
"a",
"parsed",
"omaha",
"response",
"."
] | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/client/http.go#L45-L72 |
145,103 | coreos/go-omaha | omaha/client/http.go | Omaha | func (hc *httpClient) Omaha(url string, req *omaha.Request) (resp *omaha.Response, err error) {
buf := bytes.NewBufferString(xml.Header)
enc := xml.NewEncoder(buf)
if err := enc.Encode(req); err != nil {
return nil, fmt.Errorf("omaha: failed to encode request: %v", err)
}
expNetBackoff(func() error {
resp, er... | go | func (hc *httpClient) Omaha(url string, req *omaha.Request) (resp *omaha.Response, err error) {
buf := bytes.NewBufferString(xml.Header)
enc := xml.NewEncoder(buf)
if err := enc.Encode(req); err != nil {
return nil, fmt.Errorf("omaha: failed to encode request: %v", err)
}
expNetBackoff(func() error {
resp, er... | [
"func",
"(",
"hc",
"*",
"httpClient",
")",
"Omaha",
"(",
"url",
"string",
",",
"req",
"*",
"omaha",
".",
"Request",
")",
"(",
"resp",
"*",
"omaha",
".",
"Response",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"NewBufferString",
"(",
"... | // Omaha encodes and sends an omaha request, retrying on any transient errors. | [
"Omaha",
"encodes",
"and",
"sends",
"an",
"omaha",
"request",
"retrying",
"on",
"any",
"transient",
"errors",
"."
] | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/client/http.go#L75-L88 |
145,104 | coreos/go-omaha | omaha/client/update_engine_events.go | NewErrorEvent | func NewErrorEvent(e ExitCode) *omaha.EventRequest {
return &omaha.EventRequest{
Type: omaha.EventTypeUpdateComplete,
Result: omaha.EventResultError,
ErrorCode: int(e),
}
} | go | func NewErrorEvent(e ExitCode) *omaha.EventRequest {
return &omaha.EventRequest{
Type: omaha.EventTypeUpdateComplete,
Result: omaha.EventResultError,
ErrorCode: int(e),
}
} | [
"func",
"NewErrorEvent",
"(",
"e",
"ExitCode",
")",
"*",
"omaha",
".",
"EventRequest",
"{",
"return",
"&",
"omaha",
".",
"EventRequest",
"{",
"Type",
":",
"omaha",
".",
"EventTypeUpdateComplete",
",",
"Result",
":",
"omaha",
".",
"EventResultError",
",",
"Er... | // NewErrorEvent creates an EventRequest for reporting errors. | [
"NewErrorEvent",
"creates",
"an",
"EventRequest",
"for",
"reporting",
"errors",
"."
] | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/client/update_engine_events.go#L204-L210 |
145,105 | coreos/go-omaha | omaha/client/update_engine_events.go | EventString | func EventString(e *omaha.EventRequest) string {
s := fmt.Sprintf("omaha event: %s: %s", e.Type, e.Result)
if e.ErrorCode != 0 {
s = fmt.Sprintf("%s (%d - %s)", s,
e.ErrorCode, ExitCode(e.ErrorCode))
}
return s
} | go | func EventString(e *omaha.EventRequest) string {
s := fmt.Sprintf("omaha event: %s: %s", e.Type, e.Result)
if e.ErrorCode != 0 {
s = fmt.Sprintf("%s (%d - %s)", s,
e.ErrorCode, ExitCode(e.ErrorCode))
}
return s
} | [
"func",
"EventString",
"(",
"e",
"*",
"omaha",
".",
"EventRequest",
")",
"string",
"{",
"s",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Type",
",",
"e",
".",
"Result",
")",
"\n",
"if",
"e",
".",
"ErrorCode",
"!=",
"0",
"{",
"... | // EventString allows for easily logging events in a readable format. | [
"EventString",
"allows",
"for",
"easily",
"logging",
"events",
"in",
"a",
"readable",
"format",
"."
] | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/client/update_engine_events.go#L213-L220 |
145,106 | coreos/go-omaha | omaha/protocol.go | ParseRequest | func ParseRequest(contentType string, body io.Reader) (*Request, error) {
if err := checkContentType(contentType); err != nil {
return nil, err
}
r := &Request{}
if err := parseReqOrResp(body, r); err != nil {
return nil, err
}
return r, nil
} | go | func ParseRequest(contentType string, body io.Reader) (*Request, error) {
if err := checkContentType(contentType); err != nil {
return nil, err
}
r := &Request{}
if err := parseReqOrResp(body, r); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"ParseRequest",
"(",
"contentType",
"string",
",",
"body",
"io",
".",
"Reader",
")",
"(",
"*",
"Request",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContentType",
"(",
"contentType",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
","... | // ParseRequest verifies and returns the parsed Request document.
// The MIME Content-Type header may be provided to sanity check its
// value; if blank it is assumed to be XML in UTF-8. | [
"ParseRequest",
"verifies",
"and",
"returns",
"the",
"parsed",
"Request",
"document",
".",
"The",
"MIME",
"Content",
"-",
"Type",
"header",
"may",
"be",
"provided",
"to",
"sanity",
"check",
"its",
"value",
";",
"if",
"blank",
"it",
"is",
"assumed",
"to",
"... | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/protocol.go#L63-L74 |
145,107 | coreos/go-omaha | omaha/protocol.go | ParseResponse | func ParseResponse(contentType string, body io.Reader) (*Response, error) {
if err := checkContentType(contentType); err != nil {
return nil, err
}
r := &Response{}
if err := parseReqOrResp(body, r); err != nil {
return nil, err
}
return r, nil
} | go | func ParseResponse(contentType string, body io.Reader) (*Response, error) {
if err := checkContentType(contentType); err != nil {
return nil, err
}
r := &Response{}
if err := parseReqOrResp(body, r); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"ParseResponse",
"(",
"contentType",
"string",
",",
"body",
"io",
".",
"Reader",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkContentType",
"(",
"contentType",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"... | // ParseResponse verifies and returns the parsed Response document.
// The MIME Content-Type header may be provided to sanity check its
// value; if blank it is assumed to be XML in UTF-8. | [
"ParseResponse",
"verifies",
"and",
"returns",
"the",
"parsed",
"Response",
"document",
".",
"The",
"MIME",
"Content",
"-",
"Type",
"header",
"may",
"be",
"provided",
"to",
"sanity",
"check",
"its",
"value",
";",
"if",
"blank",
"it",
"is",
"assumed",
"to",
... | e409d983eb60842452f0fb6245137458ca45201a | https://github.com/coreos/go-omaha/blob/e409d983eb60842452f0fb6245137458ca45201a/omaha/protocol.go#L170-L181 |
145,108 | lytics/confl | lex.go | lexQuotedKey | func lexQuotedKey(lx *lexer) stateFn {
r := lx.peek()
if r == sqStringEnd {
lx.emit(itemKey)
lx.next()
return lexSkip(lx, lexKeyEnd)
}
lx.next()
return lexQuotedKey
} | go | func lexQuotedKey(lx *lexer) stateFn {
r := lx.peek()
if r == sqStringEnd {
lx.emit(itemKey)
lx.next()
return lexSkip(lx, lexKeyEnd)
}
lx.next()
return lexQuotedKey
} | [
"func",
"lexQuotedKey",
"(",
"lx",
"*",
"lexer",
")",
"stateFn",
"{",
"r",
":=",
"lx",
".",
"peek",
"(",
")",
"\n",
"if",
"r",
"==",
"sqStringEnd",
"{",
"lx",
".",
"emit",
"(",
"itemKey",
")",
"\n",
"lx",
".",
"next",
"(",
")",
"\n",
"return",
... | // lexQuotedKey consumes the text of a key between quotes. | [
"lexQuotedKey",
"consumes",
"the",
"text",
"of",
"a",
"key",
"between",
"quotes",
"."
] | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/lex.go#L310-L319 |
145,109 | lytics/confl | lex.go | lexArrayEnd | func lexArrayEnd(lx *lexer) stateFn {
lx.ignore()
lx.emit(itemArrayEnd)
lx.isEnd = isEndNormal
return lx.pop()
} | go | func lexArrayEnd(lx *lexer) stateFn {
lx.ignore()
lx.emit(itemArrayEnd)
lx.isEnd = isEndNormal
return lx.pop()
} | [
"func",
"lexArrayEnd",
"(",
"lx",
"*",
"lexer",
")",
"stateFn",
"{",
"lx",
".",
"ignore",
"(",
")",
"\n",
"lx",
".",
"emit",
"(",
"itemArrayEnd",
")",
"\n",
"lx",
".",
"isEnd",
"=",
"isEndNormal",
"\n",
"return",
"lx",
".",
"pop",
"(",
")",
"\n",
... | // lexArrayEnd finishes the lexing of an array. It assumes that a ']' has
// just been consumed. | [
"lexArrayEnd",
"finishes",
"the",
"lexing",
"of",
"an",
"array",
".",
"It",
"assumes",
"that",
"a",
"]",
"has",
"just",
"been",
"consumed",
"."
] | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/lex.go#L461-L466 |
145,110 | lytics/confl | lex.go | lexMapKeyStart | func lexMapKeyStart(lx *lexer) stateFn {
r := lx.peek()
switch {
case r == eof:
return lx.errorf("Un terminated map")
case isKeySeparator(r):
return lx.errorf("Unexpected key separator '%v'.", r)
case isWhitespace(r) || isNL(r):
lx.next()
return lexSkip(lx, lexMapKeyStart)
case r == mapEnd:
lx.next()
... | go | func lexMapKeyStart(lx *lexer) stateFn {
r := lx.peek()
switch {
case r == eof:
return lx.errorf("Un terminated map")
case isKeySeparator(r):
return lx.errorf("Unexpected key separator '%v'.", r)
case isWhitespace(r) || isNL(r):
lx.next()
return lexSkip(lx, lexMapKeyStart)
case r == mapEnd:
lx.next()
... | [
"func",
"lexMapKeyStart",
"(",
"lx",
"*",
"lexer",
")",
"stateFn",
"{",
"r",
":=",
"lx",
".",
"peek",
"(",
")",
"\n",
"switch",
"{",
"case",
"r",
"==",
"eof",
":",
"return",
"lx",
".",
"errorf",
"(",
"\"",
"\"",
")",
"\n",
"case",
"isKeySeparator",... | // lexMapKeyStart consumes a key name up until the first non-whitespace
// character.
// lexMapKeyStart will ignore whitespace. | [
"lexMapKeyStart",
"consumes",
"a",
"key",
"name",
"up",
"until",
"the",
"first",
"non",
"-",
"whitespace",
"character",
".",
"lexMapKeyStart",
"will",
"ignore",
"whitespace",
"."
] | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/lex.go#L471-L506 |
145,111 | lytics/confl | lex.go | lexDubString | func lexDubString(lx *lexer) stateFn {
r := lx.next()
switch {
case r == '\\':
return lexStringEscape
// Termination of non-quoted strings
case isNL(r) || r == eof || r == optValTerm || isWhitespace(r):
lx.backup()
if lx.isBool() {
lx.emit(itemBool)
} else {
lx.emit(itemString)
}
return lx.pop()
... | go | func lexDubString(lx *lexer) stateFn {
r := lx.next()
switch {
case r == '\\':
return lexStringEscape
// Termination of non-quoted strings
case isNL(r) || r == eof || r == optValTerm || isWhitespace(r):
lx.backup()
if lx.isBool() {
lx.emit(itemBool)
} else {
lx.emit(itemString)
}
return lx.pop()
... | [
"func",
"lexDubString",
"(",
"lx",
"*",
"lexer",
")",
"stateFn",
"{",
"r",
":=",
"lx",
".",
"next",
"(",
")",
"\n",
"switch",
"{",
"case",
"r",
"==",
"'\\\\'",
":",
"return",
"lexStringEscape",
"\n",
"// Termination of non-quoted strings",
"case",
"isNL",
... | // lexDubString consumes the inner contents of a string. It assumes that the
// beginning '"' has already been consumed and ignored. | [
"lexDubString",
"consumes",
"the",
"inner",
"contents",
"of",
"a",
"string",
".",
"It",
"assumes",
"that",
"the",
"beginning",
"has",
"already",
"been",
"consumed",
"and",
"ignored",
"."
] | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/lex.go#L692-L714 |
145,112 | lytics/confl | encode.go | Marshal | func Marshal(v interface{}) ([]byte, error) {
buf := bytes.Buffer{}
enc := NewEncoder(&buf)
err := enc.Encode(v)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
} | go | func Marshal(v interface{}) ([]byte, error) {
buf := bytes.Buffer{}
enc := NewEncoder(&buf)
err := enc.Encode(v)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
} | [
"func",
"Marshal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"enc",
":=",
"NewEncoder",
"(",
"&",
"buf",
")",
"\n",
"err",
":=",
"enc",
".",
"Encode... | // Marshall a go struct into bytes | [
"Marshall",
"a",
"go",
"struct",
"into",
"bytes"
] | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/encode.go#L39-L47 |
145,113 | lytics/confl | parse.go | maybeRemoveIndents | func maybeRemoveIndents(s string) string {
if !strings.Contains(s, "\n") {
return s
}
lines := strings.Split(s, "\n")
indent := 0
findIndent:
for idx, r := range lines[0] {
switch r {
case '\t', ' ':
// keep consuming
default:
// first non-whitespace we are going to break
// and use this as indent... | go | func maybeRemoveIndents(s string) string {
if !strings.Contains(s, "\n") {
return s
}
lines := strings.Split(s, "\n")
indent := 0
findIndent:
for idx, r := range lines[0] {
switch r {
case '\t', ' ':
// keep consuming
default:
// first non-whitespace we are going to break
// and use this as indent... | [
"func",
"maybeRemoveIndents",
"(",
"s",
"string",
")",
"string",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"s",
",",
"\"",
"\\n",
"\"",
")",
"{",
"return",
"s",
"\n",
"}",
"\n",
"lines",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
... | // for multi-line text comments lets remove the Indent | [
"for",
"multi",
"-",
"line",
"text",
"comments",
"lets",
"remove",
"the",
"Indent"
] | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/parse.go#L282-L309 |
145,114 | lytics/confl | type_check.go | typeOfArray | func (p *parser) typeOfArray(types []confType) confType {
// Empty arrays are cool.
if len(types) == 0 {
return confArray
}
theType := types[0]
for _, t := range types[1:] {
if !typeEqual(theType, t) {
p.panicf("Array contains values of type '%s' and '%s', but arrays "+
"must be homogeneous.", theType,... | go | func (p *parser) typeOfArray(types []confType) confType {
// Empty arrays are cool.
if len(types) == 0 {
return confArray
}
theType := types[0]
for _, t := range types[1:] {
if !typeEqual(theType, t) {
p.panicf("Array contains values of type '%s' and '%s', but arrays "+
"must be homogeneous.", theType,... | [
"func",
"(",
"p",
"*",
"parser",
")",
"typeOfArray",
"(",
"types",
"[",
"]",
"confType",
")",
"confType",
"{",
"// Empty arrays are cool.",
"if",
"len",
"(",
"types",
")",
"==",
"0",
"{",
"return",
"confArray",
"\n",
"}",
"\n\n",
"theType",
":=",
"types"... | // typeOfArray returns a confType for an array given a list of types of its
// values.
//
// In the current spec, if an array is homogeneous, then its type is always
// "Array". If the array is not homogeneous, an error is generated. | [
"typeOfArray",
"returns",
"a",
"confType",
"for",
"an",
"array",
"given",
"a",
"list",
"of",
"types",
"of",
"its",
"values",
".",
"In",
"the",
"current",
"spec",
"if",
"an",
"array",
"is",
"homogeneous",
"then",
"its",
"type",
"is",
"always",
"Array",
".... | 9b876add7d3ed837ff9750496dca8507dcf4d9f7 | https://github.com/lytics/confl/blob/9b876add7d3ed837ff9750496dca8507dcf4d9f7/type_check.go#L68-L82 |
145,115 | bakins/logrus-middleware | middleware.go | Write | func (h *Handler) Write(b []byte) (int, error) {
if h.responseData.status == 0 {
// The status will be StatusOK if WriteHeader has not been called yet
h.responseData.status = http.StatusOK
}
size, err := h.ResponseWriter.Write(b)
h.responseData.size += size
return size, err
} | go | func (h *Handler) Write(b []byte) (int, error) {
if h.responseData.status == 0 {
// The status will be StatusOK if WriteHeader has not been called yet
h.responseData.status = http.StatusOK
}
size, err := h.ResponseWriter.Write(b)
h.responseData.size += size
return size, err
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"h",
".",
"responseData",
".",
"status",
"==",
"0",
"{",
"// The status will be StatusOK if WriteHeader has not been called yet",
"h",
... | // Write is a wrapper for the "real" ResponseWriter.Write | [
"Write",
"is",
"a",
"wrapper",
"for",
"the",
"real",
"ResponseWriter",
".",
"Write"
] | ce4c6f8deb07b5854d2fe0069c84f9640f0ed185 | https://github.com/bakins/logrus-middleware/blob/ce4c6f8deb07b5854d2fe0069c84f9640f0ed185/middleware.go#L53-L61 |
145,116 | bakins/logrus-middleware | middleware.go | WriteHeader | func (h *Handler) WriteHeader(s int) {
h.ResponseWriter.WriteHeader(s)
h.responseData.status = s
} | go | func (h *Handler) WriteHeader(s int) {
h.ResponseWriter.WriteHeader(s)
h.responseData.status = s
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"WriteHeader",
"(",
"s",
"int",
")",
"{",
"h",
".",
"ResponseWriter",
".",
"WriteHeader",
"(",
"s",
")",
"\n",
"h",
".",
"responseData",
".",
"status",
"=",
"s",
"\n",
"}"
] | // WriteHeader is a wrapper around ResponseWriter.WriteHeader | [
"WriteHeader",
"is",
"a",
"wrapper",
"around",
"ResponseWriter",
".",
"WriteHeader"
] | ce4c6f8deb07b5854d2fe0069c84f9640f0ed185 | https://github.com/bakins/logrus-middleware/blob/ce4c6f8deb07b5854d2fe0069c84f9640f0ed185/middleware.go#L64-L67 |
145,117 | bakins/logrus-middleware | middleware.go | ServeHTTP | func (h *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
start := time.Now()
h = h.m.Handler(h.handler, h.component)
h.ResponseWriter = rw
h.responseData = h.newResponseData()
h.handler.ServeHTTP(h, r)
latency := time.Since(start)
status := h.responseData.status
if status == 0 {
status = 200
... | go | func (h *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
start := time.Now()
h = h.m.Handler(h.handler, h.component)
h.ResponseWriter = rw
h.responseData = h.newResponseData()
h.handler.ServeHTTP(h, r)
latency := time.Since(start)
status := h.responseData.status
if status == 0 {
status = 200
... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"ServeHTTP",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"h",
"=",
"h",
".",
"m",
".",
"Handler",
"(",
"h... | // ServeHTTP calls the "real" handler and logs using the logger | [
"ServeHTTP",
"calls",
"the",
"real",
"handler",
"and",
"logs",
"using",
"the",
"logger"
] | ce4c6f8deb07b5854d2fe0069c84f9640f0ed185 | https://github.com/bakins/logrus-middleware/blob/ce4c6f8deb07b5854d2fe0069c84f9640f0ed185/middleware.go#L75-L114 |
145,118 | fiorix/go-redis | redis/commands.go | blbrPop | func (c *Client) blbrPop(cmd string, timeout int, keys ...string) (k, v string, err error) {
var r interface{}
r, err = c.execWithKeyTimeout(
true,
timeout,
cmd,
keys[0],
append(vstr2iface(keys[1:]), timeout)...,
)
if err != nil {
return "", "", err
}
if r == nil {
return "", "", ErrTimedOut
}
swi... | go | func (c *Client) blbrPop(cmd string, timeout int, keys ...string) (k, v string, err error) {
var r interface{}
r, err = c.execWithKeyTimeout(
true,
timeout,
cmd,
keys[0],
append(vstr2iface(keys[1:]), timeout)...,
)
if err != nil {
return "", "", err
}
if r == nil {
return "", "", ErrTimedOut
}
swi... | [
"func",
"(",
"c",
"*",
"Client",
")",
"blbrPop",
"(",
"cmd",
"string",
",",
"timeout",
"int",
",",
"keys",
"...",
"string",
")",
"(",
"k",
",",
"v",
"string",
",",
"err",
"error",
")",
"{",
"var",
"r",
"interface",
"{",
"}",
"\n",
"r",
",",
"er... | // blbrPop implements both BLPop and BRPop. | [
"blbrPop",
"implements",
"both",
"BLPop",
"and",
"BRPop",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/commands.go#L117-L144 |
145,119 | fiorix/go-redis | redis/commands.go | scanCommandList | func (c *Client) scanCommandList(cmd string, key string, cursor string, options ...interface{}) (string, []string, error) {
empty := []string{}
resp := []interface{}{}
newCursor := "0"
var v interface{}
var err error
if len(key) > 0 { // SSCAN
x := []interface{}{cursor}
v, err = c.execWithKey(true, cmd, key... | go | func (c *Client) scanCommandList(cmd string, key string, cursor string, options ...interface{}) (string, []string, error) {
empty := []string{}
resp := []interface{}{}
newCursor := "0"
var v interface{}
var err error
if len(key) > 0 { // SSCAN
x := []interface{}{cursor}
v, err = c.execWithKey(true, cmd, key... | [
"func",
"(",
"c",
"*",
"Client",
")",
"scanCommandList",
"(",
"cmd",
"string",
",",
"key",
"string",
",",
"cursor",
"string",
",",
"options",
"...",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"empty",
... | // SCAN and SSCAN | [
"SCAN",
"and",
"SSCAN"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/commands.go#L529-L566 |
145,120 | fiorix/go-redis | redis/commands.go | scanCommandMap | func (c *Client) scanCommandMap(cmd string, key string, cursor string, options ...interface{}) (string, map[string]string, error) {
empty := map[string]string{}
resp := []interface{}{}
newCursor := "0"
x := []interface{}{cursor}
v, err := c.execWithKey(true, cmd, key, append(x, options...)...)
if err != nil {
... | go | func (c *Client) scanCommandMap(cmd string, key string, cursor string, options ...interface{}) (string, map[string]string, error) {
empty := map[string]string{}
resp := []interface{}{}
newCursor := "0"
x := []interface{}{cursor}
v, err := c.execWithKey(true, cmd, key, append(x, options...)...)
if err != nil {
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"scanCommandMap",
"(",
"cmd",
"string",
",",
"key",
"string",
",",
"cursor",
"string",
",",
"options",
"...",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")"... | // ZSCAN and HSCAN | [
"ZSCAN",
"and",
"HSCAN"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/commands.go#L569-L598 |
145,121 | fiorix/go-redis | redis/types.go | vstr2iface | func vstr2iface(a []string) (r []interface{}) {
r = make([]interface{}, len(a))
for n, item := range a {
r[n] = item
}
return
} | go | func vstr2iface(a []string) (r []interface{}) {
r = make([]interface{}, len(a))
for n, item := range a {
r[n] = item
}
return
} | [
"func",
"vstr2iface",
"(",
"a",
"[",
"]",
"string",
")",
"(",
"r",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"r",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"a",
")",
")",
"\n",
"for",
"n",
",",
"item",
":=",
"rang... | // vstr2iface converts an array of strings to an array of empty interfaces | [
"vstr2iface",
"converts",
"an",
"array",
"of",
"strings",
"to",
"an",
"array",
"of",
"empty",
"interfaces"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/types.go#L23-L29 |
145,122 | fiorix/go-redis | redis/types.go | iface2vstr | func iface2vstr(a interface{}) []string {
r := []string{}
switch a.(type) {
case []interface{}:
for _, item := range a.([]interface{}) {
switch item.(type) {
case string:
r = append(r, item.(string))
}
}
}
return r
} | go | func iface2vstr(a interface{}) []string {
r := []string{}
switch a.(type) {
case []interface{}:
for _, item := range a.([]interface{}) {
switch item.(type) {
case string:
r = append(r, item.(string))
}
}
}
return r
} | [
"func",
"iface2vstr",
"(",
"a",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"r",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"switch",
"a",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"interface",
"{",
"}",
":",
"for",
"_",
",",
"ite... | // iface2vstr converts an interface to an array of strings | [
"iface2vstr",
"converts",
"an",
"interface",
"to",
"an",
"array",
"of",
"strings"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/types.go#L32-L44 |
145,123 | fiorix/go-redis | redis/types.go | iface2strmap | func iface2strmap(a interface{}) map[string]string {
tmp := iface2vstr(a)
m := make(map[string]string)
for n := 0; n < len(tmp)/2; n++ {
m[tmp[n*2]] = tmp[(n*2)+1]
}
return m
} | go | func iface2strmap(a interface{}) map[string]string {
tmp := iface2vstr(a)
m := make(map[string]string)
for n := 0; n < len(tmp)/2; n++ {
m[tmp[n*2]] = tmp[(n*2)+1]
}
return m
} | [
"func",
"iface2strmap",
"(",
"a",
"interface",
"{",
"}",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"tmp",
":=",
"iface2vstr",
"(",
"a",
")",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"n",
":=",
"0",... | // iface2strmap converts an interface to map of strings | [
"iface2strmap",
"converts",
"an",
"interface",
"to",
"map",
"of",
"strings"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/types.go#L47-L54 |
145,124 | fiorix/go-redis | redis/types.go | iface2int | func iface2int(a interface{}) (int, error) {
switch a.(type) {
case int:
return a.(int), nil
}
return 0, fmt.Errorf("redis: %#v is not integer", a)
} | go | func iface2int(a interface{}) (int, error) {
switch a.(type) {
case int:
return a.(int), nil
}
return 0, fmt.Errorf("redis: %#v is not integer", a)
} | [
"func",
"iface2int",
"(",
"a",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"switch",
"a",
".",
"(",
"type",
")",
"{",
"case",
"int",
":",
"return",
"a",
".",
"(",
"int",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"0",
","... | // iface2int validates and converts interface to int | [
"iface2int",
"validates",
"and",
"converts",
"interface",
"to",
"int"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/types.go#L69-L75 |
145,125 | fiorix/go-redis | redis/types.go | iface2str | func iface2str(a interface{}) (string, error) {
switch a.(type) {
case string:
return a.(string), nil
}
return "", fmt.Errorf("redis: %#v is not string", a)
} | go | func iface2str(a interface{}) (string, error) {
switch a.(type) {
case string:
return a.(string), nil
}
return "", fmt.Errorf("redis: %#v is not string", a)
} | [
"func",
"iface2str",
"(",
"a",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"switch",
"a",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"return",
"a",
".",
"(",
"string",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"... | // iface2str validates and converts interface to string | [
"iface2str",
"validates",
"and",
"converts",
"interface",
"to",
"string"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/types.go#L78-L84 |
145,126 | fiorix/go-redis | redis/selector.go | SetServers | func (ss *ServerList) SetServers(servers ...string) error {
var err error
var fs, addr net.Addr
nsrv := make([]ServerInfo, len(servers))
for i, server := range servers {
// addr db=N passwd=foobar
items := strings.Split(server, " ")
if strings.Contains(items[0], "/") {
addr, err = net.ResolveUnixAddr("unix... | go | func (ss *ServerList) SetServers(servers ...string) error {
var err error
var fs, addr net.Addr
nsrv := make([]ServerInfo, len(servers))
for i, server := range servers {
// addr db=N passwd=foobar
items := strings.Split(server, " ")
if strings.Contains(items[0], "/") {
addr, err = net.ResolveUnixAddr("unix... | [
"func",
"(",
"ss",
"*",
"ServerList",
")",
"SetServers",
"(",
"servers",
"...",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"var",
"fs",
",",
"addr",
"net",
".",
"Addr",
"\n",
"nsrv",
":=",
"make",
"(",
"[",
"]",
"ServerInfo",
",",
"l... | // SetServers changes a ServerList's set of servers at runtime and is
// threadsafe.
//
// Each server is given equal weight. A server is given more weight
// if it's listed multiple times.
//
// SetServers returns an error if any of the server names fail to
// resolve. No attempt is made to connect to the server. If a... | [
"SetServers",
"changes",
"a",
"ServerList",
"s",
"set",
"of",
"servers",
"at",
"runtime",
"and",
"is",
"threadsafe",
".",
"Each",
"server",
"is",
"given",
"equal",
"weight",
".",
"A",
"server",
"is",
"given",
"more",
"weight",
"if",
"it",
"s",
"listed",
... | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/selector.go#L84-L120 |
145,127 | fiorix/go-redis | redis/selector.go | PickServer | func (ss *ServerList) PickServer(key string) (srv ServerInfo, err error) {
ss.lk.RLock()
defer ss.lk.RUnlock()
if len(ss.servers) == 0 {
err = ErrNoServers
return
}
if key == "" {
return ss.servers[0], nil
}
return ss.servers[crc32.ChecksumIEEE([]byte(key))%uint32(len(ss.servers))], nil
} | go | func (ss *ServerList) PickServer(key string) (srv ServerInfo, err error) {
ss.lk.RLock()
defer ss.lk.RUnlock()
if len(ss.servers) == 0 {
err = ErrNoServers
return
}
if key == "" {
return ss.servers[0], nil
}
return ss.servers[crc32.ChecksumIEEE([]byte(key))%uint32(len(ss.servers))], nil
} | [
"func",
"(",
"ss",
"*",
"ServerList",
")",
"PickServer",
"(",
"key",
"string",
")",
"(",
"srv",
"ServerInfo",
",",
"err",
"error",
")",
"{",
"ss",
".",
"lk",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ss",
".",
"lk",
".",
"RUnlock",
"(",
")",
"\n",
... | // PickServer implements the ServerSelector interface. | [
"PickServer",
"implements",
"the",
"ServerSelector",
"interface",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/selector.go#L128-L139 |
145,128 | fiorix/go-redis | redis/redis.go | NewClient | func NewClient(server ...string) (*Client, error) {
ss := new(ServerList)
if len(server) == 0 {
server = []string{"localhost:6379"}
}
if err := ss.SetServers(server...); err != nil {
return nil, err
}
return NewFromSelector(ss), nil
} | go | func NewClient(server ...string) (*Client, error) {
ss := new(ServerList)
if len(server) == 0 {
server = []string{"localhost:6379"}
}
if err := ss.SetServers(server...); err != nil {
return nil, err
}
return NewFromSelector(ss), nil
} | [
"func",
"NewClient",
"(",
"server",
"...",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"ss",
":=",
"new",
"(",
"ServerList",
")",
"\n",
"if",
"len",
"(",
"server",
")",
"==",
"0",
"{",
"server",
"=",
"[",
"]",
"string",
"{",
"\"",
... | // NewClient is like New, but returns an error in case of failure. | [
"NewClient",
"is",
"like",
"New",
"but",
"returns",
"an",
"error",
"in",
"case",
"of",
"failure",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L86-L95 |
145,129 | fiorix/go-redis | redis/redis.go | release | func (cn *conn) release() {
cn.c.putFreeConn(cn.srv.Addr, cn)
} | go | func (cn *conn) release() {
cn.c.putFreeConn(cn.srv.Addr, cn)
} | [
"func",
"(",
"cn",
"*",
"conn",
")",
"release",
"(",
")",
"{",
"cn",
".",
"c",
".",
"putFreeConn",
"(",
"cn",
".",
"srv",
".",
"Addr",
",",
"cn",
")",
"\n",
"}"
] | // release returns this connection back to the client's free pool | [
"release",
"returns",
"this",
"connection",
"back",
"to",
"the",
"client",
"s",
"free",
"pool"
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L125-L127 |
145,130 | fiorix/go-redis | redis/redis.go | Close | func (c *Client) Close() {
for _, cns := range c.freeconn {
for _, cn := range cns {
c.cleanupFreeConn(cn.nc)
}
}
} | go | func (c *Client) Close() {
for _, cns := range c.freeconn {
for _, cn := range cns {
c.cleanupFreeConn(cn.nc)
}
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Close",
"(",
")",
"{",
"for",
"_",
",",
"cns",
":=",
"range",
"c",
".",
"freeconn",
"{",
"for",
"_",
",",
"cn",
":=",
"range",
"cns",
"{",
"c",
".",
"cleanupFreeConn",
"(",
"cn",
".",
"nc",
")",
"\n",
"}... | // Close closes all connections in the pool. | [
"Close",
"closes",
"all",
"connections",
"in",
"the",
"pool",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L289-L295 |
145,131 | fiorix/go-redis | redis/redis.go | execWithKey | func (c *Client) execWithKey(urp bool, cmd, key string, a ...interface{}) (interface{}, error) {
srv, err := c.selector.PickServer(key)
if err != nil {
return nil, err
}
x := []interface{}{cmd, key}
return c.execWithAddr(urp, srv, append(x, a...)...)
} | go | func (c *Client) execWithKey(urp bool, cmd, key string, a ...interface{}) (interface{}, error) {
srv, err := c.selector.PickServer(key)
if err != nil {
return nil, err
}
x := []interface{}{cmd, key}
return c.execWithAddr(urp, srv, append(x, a...)...)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"execWithKey",
"(",
"urp",
"bool",
",",
"cmd",
",",
"key",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"srv",
",",
"err",
":=",
"c",
".",
"sele... | // execWithKey picks a server based on the key, and executes a command in redis. | [
"execWithKey",
"picks",
"a",
"server",
"based",
"on",
"the",
"key",
"and",
"executes",
"a",
"command",
"in",
"redis",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L298-L305 |
145,132 | fiorix/go-redis | redis/redis.go | execWithKeyTimeout | func (c *Client) execWithKeyTimeout(urp bool, timeout int, cmd, key string, a ...interface{}) (interface{}, error) {
srv, err := c.selector.PickServer(key)
if err != nil {
return nil, err
}
x := []interface{}{cmd, key}
return c.execWithAddrTimeout(urp, srv, timeout, append(x, a...)...)
} | go | func (c *Client) execWithKeyTimeout(urp bool, timeout int, cmd, key string, a ...interface{}) (interface{}, error) {
srv, err := c.selector.PickServer(key)
if err != nil {
return nil, err
}
x := []interface{}{cmd, key}
return c.execWithAddrTimeout(urp, srv, timeout, append(x, a...)...)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"execWithKeyTimeout",
"(",
"urp",
"bool",
",",
"timeout",
"int",
",",
"cmd",
",",
"key",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"srv",
",",
... | // execWithKeyTimeout picks a server based on the key, and executes a command
// in redis, extending the connection timeout for the given command. | [
"execWithKeyTimeout",
"picks",
"a",
"server",
"based",
"on",
"the",
"key",
"and",
"executes",
"a",
"command",
"in",
"redis",
"extending",
"the",
"connection",
"timeout",
"for",
"the",
"given",
"command",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L309-L316 |
145,133 | fiorix/go-redis | redis/redis.go | execWithKeys | func (c *Client) execWithKeys(urp bool, cmd string, keys []string, a ...interface{}) ([]interface{}, error) {
var v []interface{}
for _, k := range keys {
tmp, err := c.execWithKey(urp, cmd, k, a...)
if err != nil {
return nil, err
}
v = append(v, tmp)
}
return v, nil
} | go | func (c *Client) execWithKeys(urp bool, cmd string, keys []string, a ...interface{}) ([]interface{}, error) {
var v []interface{}
for _, k := range keys {
tmp, err := c.execWithKey(urp, cmd, k, a...)
if err != nil {
return nil, err
}
v = append(v, tmp)
}
return v, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"execWithKeys",
"(",
"urp",
"bool",
",",
"cmd",
"string",
",",
"keys",
"[",
"]",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"... | // execWithKeys calls execWithKey for each key, returns an array of results. | [
"execWithKeys",
"calls",
"execWithKey",
"for",
"each",
"key",
"returns",
"an",
"array",
"of",
"results",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L319-L329 |
145,134 | fiorix/go-redis | redis/redis.go | execWithAddr | func (c *Client) execWithAddr(urp bool, srv ServerInfo, a ...interface{}) (v interface{}, err error) {
cn, err := c.getConn(srv)
if err != nil {
return nil, err
}
defer cn.condRelease(&err)
if urp {
v, err = c.executeURP(cn.rw, a...)
} else {
v, err = c.execute(cn.rw, a...)
}
return v, err
} | go | func (c *Client) execWithAddr(urp bool, srv ServerInfo, a ...interface{}) (v interface{}, err error) {
cn, err := c.getConn(srv)
if err != nil {
return nil, err
}
defer cn.condRelease(&err)
if urp {
v, err = c.executeURP(cn.rw, a...)
} else {
v, err = c.execute(cn.rw, a...)
}
return v, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"execWithAddr",
"(",
"urp",
"bool",
",",
"srv",
"ServerInfo",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"v",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"cn",
",",
"err",
":=",
"c",
".",
"... | // execWithAddr executes a command in a specific redis server. | [
"execWithAddr",
"executes",
"a",
"command",
"in",
"a",
"specific",
"redis",
"server",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L342-L354 |
145,135 | fiorix/go-redis | redis/redis.go | execWithAddrTimeout | func (c *Client) execWithAddrTimeout(urp bool, srv ServerInfo, timeout int, a ...interface{}) (v interface{}, err error) {
cn, err := c.getConn(srv)
if err != nil {
return nil, err
}
cn.extendDeadline(time.Duration(timeout) * time.Second)
defer cn.condRelease(&err)
if urp {
v, err = c.executeURP(cn.rw, a...)
... | go | func (c *Client) execWithAddrTimeout(urp bool, srv ServerInfo, timeout int, a ...interface{}) (v interface{}, err error) {
cn, err := c.getConn(srv)
if err != nil {
return nil, err
}
cn.extendDeadline(time.Duration(timeout) * time.Second)
defer cn.condRelease(&err)
if urp {
v, err = c.executeURP(cn.rw, a...)
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"execWithAddrTimeout",
"(",
"urp",
"bool",
",",
"srv",
"ServerInfo",
",",
"timeout",
"int",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"v",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"cn",
","... | // execWithAddrTimeout executes a command in a specific redis server,
// extending the connection timeout for the given command. | [
"execWithAddrTimeout",
"executes",
"a",
"command",
"in",
"a",
"specific",
"redis",
"server",
"extending",
"the",
"connection",
"timeout",
"for",
"the",
"given",
"command",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L358-L371 |
145,136 | fiorix/go-redis | redis/redis.go | parseResponse | func (c *Client) parseResponse(r *bufio.Reader) (interface{}, error) {
line, err := r.ReadString('\n')
if err != nil {
if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
err = ErrTimedOut
}
return nil, err
}
//log.Printf("line=%#v %x\n", line, &r)
if len(line) < 1 {
return nil, ErrServerError
}... | go | func (c *Client) parseResponse(r *bufio.Reader) (interface{}, error) {
line, err := r.ReadString('\n')
if err != nil {
if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
err = ErrTimedOut
}
return nil, err
}
//log.Printf("line=%#v %x\n", line, &r)
if len(line) < 1 {
return nil, ErrServerError
}... | [
"func",
"(",
"c",
"*",
"Client",
")",
"parseResponse",
"(",
"r",
"*",
"bufio",
".",
"Reader",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"line",
",",
"err",
":=",
"r",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
... | // parseResponse reads and parses a single response from redis. | [
"parseResponse",
"reads",
"and",
"parses",
"a",
"single",
"response",
"from",
"redis",
"."
] | d987058b55eb470a35e9e18169011cd44bb20cc9 | https://github.com/fiorix/go-redis/blob/d987058b55eb470a35e9e18169011cd44bb20cc9/redis/redis.go#L414-L484 |
145,137 | shurcooL/octicon | octicon.go | SetSize | func SetSize(icon *html.Node, size int) *html.Node {
icon.Attr[1].Val = strconv.Itoa(size)
icon.Attr[2].Val = strconv.Itoa(size)
return icon
} | go | func SetSize(icon *html.Node, size int) *html.Node {
icon.Attr[1].Val = strconv.Itoa(size)
icon.Attr[2].Val = strconv.Itoa(size)
return icon
} | [
"func",
"SetSize",
"(",
"icon",
"*",
"html",
".",
"Node",
",",
"size",
"int",
")",
"*",
"html",
".",
"Node",
"{",
"icon",
".",
"Attr",
"[",
"1",
"]",
".",
"Val",
"=",
"strconv",
".",
"Itoa",
"(",
"size",
")",
"\n",
"icon",
".",
"Attr",
"[",
"... | // SetSize sets size of icon, and returns a reference to it. | [
"SetSize",
"sets",
"size",
"of",
"icon",
"and",
"returns",
"a",
"reference",
"to",
"it",
"."
] | 9ff1a4cf27f4a918862c3ffbd24371b3aed18f9d | https://github.com/shurcooL/octicon/blob/9ff1a4cf27f4a918862c3ffbd24371b3aed18f9d/octicon.go#L376-L380 |
145,138 | shurcooL/octicon | octicon.go | Alert | func Alert() *html.Node {
return &html.Node{
Parent: (*html.Node)(nil),
FirstChild: &html.Node{
Parent: (*html.Node)(nil),
FirstChild: (*html.Node)(nil),
LastChild: (*html.Node)(nil),
PrevSibling: (*html.Node)(nil),
NextSibling: (*html.Node)(nil),
Type: (html.NodeType)(3),
DataA... | go | func Alert() *html.Node {
return &html.Node{
Parent: (*html.Node)(nil),
FirstChild: &html.Node{
Parent: (*html.Node)(nil),
FirstChild: (*html.Node)(nil),
LastChild: (*html.Node)(nil),
PrevSibling: (*html.Node)(nil),
NextSibling: (*html.Node)(nil),
Type: (html.NodeType)(3),
DataA... | [
"func",
"Alert",
"(",
")",
"*",
"html",
".",
"Node",
"{",
"return",
"&",
"html",
".",
"Node",
"{",
"Parent",
":",
"(",
"*",
"html",
".",
"Node",
")",
"(",
"nil",
")",
",",
"FirstChild",
":",
"&",
"html",
".",
"Node",
"{",
"Parent",
":",
"(",
... | // Alert returns an "alert" Octicon SVG node. | [
"Alert",
"returns",
"an",
"alert",
"Octicon",
"SVG",
"node",
"."
] | 9ff1a4cf27f4a918862c3ffbd24371b3aed18f9d | https://github.com/shurcooL/octicon/blob/9ff1a4cf27f4a918862c3ffbd24371b3aed18f9d/octicon.go#L383-L439 |
145,139 | libp2p/go-addr-util | filter.go | SubtractFilter | func SubtractFilter(addrs ...ma.Multiaddr) func(ma.Multiaddr) bool {
addrmap := make(map[string]bool, len(addrs))
for _, a := range addrs {
addrmap[string(a.Bytes())] = true
}
return func(a ma.Multiaddr) bool {
return !addrmap[string(a.Bytes())]
}
} | go | func SubtractFilter(addrs ...ma.Multiaddr) func(ma.Multiaddr) bool {
addrmap := make(map[string]bool, len(addrs))
for _, a := range addrs {
addrmap[string(a.Bytes())] = true
}
return func(a ma.Multiaddr) bool {
return !addrmap[string(a.Bytes())]
}
} | [
"func",
"SubtractFilter",
"(",
"addrs",
"...",
"ma",
".",
"Multiaddr",
")",
"func",
"(",
"ma",
".",
"Multiaddr",
")",
"bool",
"{",
"addrmap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
",",
"len",
"(",
"addrs",
")",
")",
"\n",
"for",
"_"... | // SubtractFilter returns a filter func that filters all of the given addresses | [
"SubtractFilter",
"returns",
"a",
"filter",
"func",
"that",
"filters",
"all",
"of",
"the",
"given",
"addresses"
] | b65fcf0b7ef1fce74562f8ccd3107b103951c6a5 | https://github.com/libp2p/go-addr-util/blob/b65fcf0b7ef1fce74562f8ccd3107b103951c6a5/filter.go#L8-L17 |
145,140 | libp2p/go-addr-util | filter.go | IsFDCostlyTransport | func IsFDCostlyTransport(a ma.Multiaddr) bool {
res := false
ma.ForEach(a, func(c ma.Component) bool {
if c.Protocol().Code == ma.P_TCP {
res = true
return false
}
return true
})
return res
} | go | func IsFDCostlyTransport(a ma.Multiaddr) bool {
res := false
ma.ForEach(a, func(c ma.Component) bool {
if c.Protocol().Code == ma.P_TCP {
res = true
return false
}
return true
})
return res
} | [
"func",
"IsFDCostlyTransport",
"(",
"a",
"ma",
".",
"Multiaddr",
")",
"bool",
"{",
"res",
":=",
"false",
"\n\n",
"ma",
".",
"ForEach",
"(",
"a",
",",
"func",
"(",
"c",
"ma",
".",
"Component",
")",
"bool",
"{",
"if",
"c",
".",
"Protocol",
"(",
")",
... | // IsFDCostlyTransport returns true for transports that require a new file
// descriptor per connection created | [
"IsFDCostlyTransport",
"returns",
"true",
"for",
"transports",
"that",
"require",
"a",
"new",
"file",
"descriptor",
"per",
"connection",
"created"
] | b65fcf0b7ef1fce74562f8ccd3107b103951c6a5 | https://github.com/libp2p/go-addr-util/blob/b65fcf0b7ef1fce74562f8ccd3107b103951c6a5/filter.go#L21-L32 |
145,141 | libp2p/go-addr-util | filter.go | FilterNeg | func FilterNeg(f func(ma.Multiaddr) bool) func(ma.Multiaddr) bool {
return func(a ma.Multiaddr) bool {
return !f(a)
}
} | go | func FilterNeg(f func(ma.Multiaddr) bool) func(ma.Multiaddr) bool {
return func(a ma.Multiaddr) bool {
return !f(a)
}
} | [
"func",
"FilterNeg",
"(",
"f",
"func",
"(",
"ma",
".",
"Multiaddr",
")",
"bool",
")",
"func",
"(",
"ma",
".",
"Multiaddr",
")",
"bool",
"{",
"return",
"func",
"(",
"a",
"ma",
".",
"Multiaddr",
")",
"bool",
"{",
"return",
"!",
"f",
"(",
"a",
")",
... | // FilterNeg returns a negated version of the passed in filter | [
"FilterNeg",
"returns",
"a",
"negated",
"version",
"of",
"the",
"passed",
"in",
"filter"
] | b65fcf0b7ef1fce74562f8ccd3107b103951c6a5 | https://github.com/libp2p/go-addr-util/blob/b65fcf0b7ef1fce74562f8ccd3107b103951c6a5/filter.go#L35-L39 |
145,142 | dchest/safefile | safefile.go | Create | func Create(filename string, perm os.FileMode) (*File, error) {
for {
tempname, err := makeTempName(filename, "sf")
if err != nil {
return nil, err
}
f, err := os.OpenFile(tempname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
if err != nil {
if os.IsExist(err) {
continue
}
return nil, err
}
re... | go | func Create(filename string, perm os.FileMode) (*File, error) {
for {
tempname, err := makeTempName(filename, "sf")
if err != nil {
return nil, err
}
f, err := os.OpenFile(tempname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
if err != nil {
if os.IsExist(err) {
continue
}
return nil, err
}
re... | [
"func",
"Create",
"(",
"filename",
"string",
",",
"perm",
"os",
".",
"FileMode",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"for",
"{",
"tempname",
",",
"err",
":=",
"makeTempName",
"(",
"filename",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!="... | // Create creates a temporary file in the same directory as filename,
// which will be renamed to the given filename when calling Commit. | [
"Create",
"creates",
"a",
"temporary",
"file",
"in",
"the",
"same",
"directory",
"as",
"filename",
"which",
"will",
"be",
"renamed",
"to",
"the",
"given",
"filename",
"when",
"calling",
"Commit",
"."
] | 855e8d98f1852d48dde521e0522408d1fe7e836a | https://github.com/dchest/safefile/blob/855e8d98f1852d48dde521e0522408d1fe7e836a/safefile.go#L75-L94 |
145,143 | dchest/safefile | safefile.go | WriteFile | func WriteFile(filename string, data []byte, perm os.FileMode) error {
f, err := Create(filename, perm)
if err != nil {
return err
}
defer f.Close()
n, err := f.Write(data)
if err != nil {
return err
}
if err == nil && n < len(data) {
err = io.ErrShortWrite
return err
}
return f.Commit()
} | go | func WriteFile(filename string, data []byte, perm os.FileMode) error {
f, err := Create(filename, perm)
if err != nil {
return err
}
defer f.Close()
n, err := f.Write(data)
if err != nil {
return err
}
if err == nil && n < len(data) {
err = io.ErrShortWrite
return err
}
return f.Commit()
} | [
"func",
"WriteFile",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"f",
",",
"err",
":=",
"Create",
"(",
"filename",
",",
"perm",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // WriteFile is a safe analog of ioutil.WriteFile. | [
"WriteFile",
"is",
"a",
"safe",
"analog",
"of",
"ioutil",
".",
"WriteFile",
"."
] | 855e8d98f1852d48dde521e0522408d1fe7e836a | https://github.com/dchest/safefile/blob/855e8d98f1852d48dde521e0522408d1fe7e836a/safefile.go#L182-L197 |
145,144 | xyproto/simpleredis | simpleredis.go | twoFields | func twoFields(s, delim string) (string, string, bool) {
if strings.Count(s, delim) != 1 {
return s, "", false
}
fields := strings.Split(s, delim)
return fields[0], fields[1], true
} | go | func twoFields(s, delim string) (string, string, bool) {
if strings.Count(s, delim) != 1 {
return s, "", false
}
fields := strings.Split(s, delim)
return fields[0], fields[1], true
} | [
"func",
"twoFields",
"(",
"s",
",",
"delim",
"string",
")",
"(",
"string",
",",
"string",
",",
"bool",
")",
"{",
"if",
"strings",
".",
"Count",
"(",
"s",
",",
"delim",
")",
"!=",
"1",
"{",
"return",
"s",
",",
"\"",
"\"",
",",
"false",
"\n",
"}"... | // Split a string into two parts, given a delimiter.
// Returns the two parts and true if it works out. | [
"Split",
"a",
"string",
"into",
"two",
"parts",
"given",
"a",
"delimiter",
".",
"Returns",
"the",
"two",
"parts",
"and",
"true",
"if",
"it",
"works",
"out",
"."
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L117-L123 |
145,145 | xyproto/simpleredis | simpleredis.go | Get | func (pool *ConnectionPool) Get(dbindex int) redis.Conn {
redisPool := redis.Pool(*pool)
conn := redisPool.Get()
// The default database index is 0
if dbindex != 0 {
// SELECT is not critical, ignore the return values
conn.Do("SELECT", strconv.Itoa(dbindex))
}
return conn
} | go | func (pool *ConnectionPool) Get(dbindex int) redis.Conn {
redisPool := redis.Pool(*pool)
conn := redisPool.Get()
// The default database index is 0
if dbindex != 0 {
// SELECT is not critical, ignore the return values
conn.Do("SELECT", strconv.Itoa(dbindex))
}
return conn
} | [
"func",
"(",
"pool",
"*",
"ConnectionPool",
")",
"Get",
"(",
"dbindex",
"int",
")",
"redis",
".",
"Conn",
"{",
"redisPool",
":=",
"redis",
".",
"Pool",
"(",
"*",
"pool",
")",
"\n",
"conn",
":=",
"redisPool",
".",
"Get",
"(",
")",
"\n",
"// The defaul... | // Get one of the available connections from the connection pool, given a database index | [
"Get",
"one",
"of",
"the",
"available",
"connections",
"from",
"the",
"connection",
"pool",
"given",
"a",
"database",
"index"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L164-L173 |
145,146 | xyproto/simpleredis | simpleredis.go | Ping | func (pool *ConnectionPool) Ping() error {
redisPool := redis.Pool(*pool)
conn := redisPool.Get()
_, err := conn.Do("PING")
return err
} | go | func (pool *ConnectionPool) Ping() error {
redisPool := redis.Pool(*pool)
conn := redisPool.Get()
_, err := conn.Do("PING")
return err
} | [
"func",
"(",
"pool",
"*",
"ConnectionPool",
")",
"Ping",
"(",
")",
"error",
"{",
"redisPool",
":=",
"redis",
".",
"Pool",
"(",
"*",
"pool",
")",
"\n",
"conn",
":=",
"redisPool",
".",
"Get",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"conn",
".",
"Do"... | // Ping the server by sending a PING command | [
"Ping",
"the",
"server",
"by",
"sending",
"a",
"PING",
"command"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L176-L181 |
145,147 | xyproto/simpleredis | simpleredis.go | Get | func (rl *List) Get(index int64) (string, error) {
conn := rl.pool.Get(rl.dbindex)
result, err := conn.Do("LINDEX", rl.id)
if err != nil {
panic(err)
}
return redis.String(result, err)
} | go | func (rl *List) Get(index int64) (string, error) {
conn := rl.pool.Get(rl.dbindex)
result, err := conn.Do("LINDEX", rl.id)
if err != nil {
panic(err)
}
return redis.String(result, err)
} | [
"func",
"(",
"rl",
"*",
"List",
")",
"Get",
"(",
"index",
"int64",
")",
"(",
"string",
",",
"error",
")",
"{",
"conn",
":=",
"rl",
".",
"pool",
".",
"Get",
"(",
"rl",
".",
"dbindex",
")",
"\n",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"... | // Returns the element at index index in the list | [
"Returns",
"the",
"element",
"at",
"index",
"index",
"in",
"the",
"list"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L202-L209 |
145,148 | xyproto/simpleredis | simpleredis.go | Size | func (rl *List) Size() (int64, error) {
conn := rl.pool.Get(rl.dbindex)
size, err := conn.Do("LLEN", rl.id)
if err != nil {
panic(err)
}
return redis.Int64(size, err)
} | go | func (rl *List) Size() (int64, error) {
conn := rl.pool.Get(rl.dbindex)
size, err := conn.Do("LLEN", rl.id)
if err != nil {
panic(err)
}
return redis.Int64(size, err)
} | [
"func",
"(",
"rl",
"*",
"List",
")",
"Size",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"conn",
":=",
"rl",
".",
"pool",
".",
"Get",
"(",
"rl",
".",
"dbindex",
")",
"\n",
"size",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"\"",
"\"",
",... | // Get the size of the list | [
"Get",
"the",
"size",
"of",
"the",
"list"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L212-L219 |
145,149 | xyproto/simpleredis | simpleredis.go | RemoveElement | func (rl *List) RemoveElement(value string) error {
conn := rl.pool.Get(rl.dbindex)
_, err := conn.Do("LREM", rl.id, value)
return err
} | go | func (rl *List) RemoveElement(value string) error {
conn := rl.pool.Get(rl.dbindex)
_, err := conn.Do("LREM", rl.id, value)
return err
} | [
"func",
"(",
"rl",
"*",
"List",
")",
"RemoveElement",
"(",
"value",
"string",
")",
"error",
"{",
"conn",
":=",
"rl",
".",
"pool",
".",
"Get",
"(",
"rl",
".",
"dbindex",
")",
"\n",
"_",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"\"",
"\"",
",",
... | // Remove the first occurrence of an element from the list | [
"Remove",
"the",
"first",
"occurrence",
"of",
"an",
"element",
"from",
"the",
"list"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L308-L312 |
145,150 | xyproto/simpleredis | simpleredis.go | Set | func (rl *List) Set(index int64, value string) error {
conn := rl.pool.Get(rl.dbindex)
_, err := conn.Do("LSET", rl.id, index, value)
return err
} | go | func (rl *List) Set(index int64, value string) error {
conn := rl.pool.Get(rl.dbindex)
_, err := conn.Do("LSET", rl.id, index, value)
return err
} | [
"func",
"(",
"rl",
"*",
"List",
")",
"Set",
"(",
"index",
"int64",
",",
"value",
"string",
")",
"error",
"{",
"conn",
":=",
"rl",
".",
"pool",
".",
"Get",
"(",
"rl",
".",
"dbindex",
")",
"\n",
"_",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"\... | // Set element of list at index n to value | [
"Set",
"element",
"of",
"list",
"at",
"index",
"n",
"to",
"value"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L315-L319 |
145,151 | xyproto/simpleredis | simpleredis.go | Trim | func (rl *List) Trim(start, stop int64) error {
conn := rl.pool.Get(rl.dbindex)
_, err := conn.Do("LTRIM", rl.id, start, stop)
return err
} | go | func (rl *List) Trim(start, stop int64) error {
conn := rl.pool.Get(rl.dbindex)
_, err := conn.Do("LTRIM", rl.id, start, stop)
return err
} | [
"func",
"(",
"rl",
"*",
"List",
")",
"Trim",
"(",
"start",
",",
"stop",
"int64",
")",
"error",
"{",
"conn",
":=",
"rl",
".",
"pool",
".",
"Get",
"(",
"rl",
".",
"dbindex",
")",
"\n",
"_",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"\"",
"\"",
... | // Trim an existing list so that it will contain only the specified range of
// elements specified. | [
"Trim",
"an",
"existing",
"list",
"so",
"that",
"it",
"will",
"contain",
"only",
"the",
"specified",
"range",
"of",
"elements",
"specified",
"."
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L323-L327 |
145,152 | xyproto/simpleredis | simpleredis.go | Pop | func (rs *Set) Pop() (string, error) {
conn := rs.pool.Get(rs.dbindex)
result, err := conn.Do("SPOP", rs.id)
if err != nil {
panic(err)
}
return redis.String(result, err)
} | go | func (rs *Set) Pop() (string, error) {
conn := rs.pool.Get(rs.dbindex)
result, err := conn.Do("SPOP", rs.id)
if err != nil {
panic(err)
}
return redis.String(result, err)
} | [
"func",
"(",
"rs",
"*",
"Set",
")",
"Pop",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"conn",
":=",
"rs",
".",
"pool",
".",
"Get",
"(",
"rs",
".",
"dbindex",
")",
"\n",
"result",
",",
"err",
":=",
"conn",
".",
"Do",
"(",
"\"",
"\"",
"... | // Remove a random member from the set | [
"Remove",
"a",
"random",
"member",
"from",
"the",
"set"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L397-L404 |
145,153 | xyproto/simpleredis | simpleredis.go | SetExpire | func (rh *HashMap) SetExpire(elementid, key, value string, expire time.Duration) error {
conn := rh.pool.Get(rh.dbindex)
if _, err := conn.Do("HSET", rh.id+":"+elementid, key, value); err != nil {
return err
}
// No EXPIRE in Redis for hash keys, as far as I can tell from the documentation.
// This is the manual... | go | func (rh *HashMap) SetExpire(elementid, key, value string, expire time.Duration) error {
conn := rh.pool.Get(rh.dbindex)
if _, err := conn.Do("HSET", rh.id+":"+elementid, key, value); err != nil {
return err
}
// No EXPIRE in Redis for hash keys, as far as I can tell from the documentation.
// This is the manual... | [
"func",
"(",
"rh",
"*",
"HashMap",
")",
"SetExpire",
"(",
"elementid",
",",
"key",
",",
"value",
"string",
",",
"expire",
"time",
".",
"Duration",
")",
"error",
"{",
"conn",
":=",
"rh",
".",
"pool",
".",
"Get",
"(",
"rh",
".",
"dbindex",
")",
"\n",... | // Given an element id, set a key and a value together with an expiration time | [
"Given",
"an",
"element",
"id",
"set",
"a",
"key",
"and",
"a",
"value",
"together",
"with",
"an",
"expiration",
"time"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L455-L472 |
145,154 | xyproto/simpleredis | simpleredis.go | All | func (rh *HashMap) All() ([]string, error) {
conn := rh.pool.Get(rh.dbindex)
result, err := redis.Values(conn.Do("KEYS", rh.id+":*"))
strs := make([]string, len(result))
idlen := len(rh.id)
for i := 0; i < len(result); i++ {
strs[i] = getString(result, i)[idlen+1:]
}
return strs, err
} | go | func (rh *HashMap) All() ([]string, error) {
conn := rh.pool.Get(rh.dbindex)
result, err := redis.Values(conn.Do("KEYS", rh.id+":*"))
strs := make([]string, len(result))
idlen := len(rh.id)
for i := 0; i < len(result); i++ {
strs[i] = getString(result, i)[idlen+1:]
}
return strs, err
} | [
"func",
"(",
"rh",
"*",
"HashMap",
")",
"All",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"conn",
":=",
"rh",
".",
"pool",
".",
"Get",
"(",
"rh",
".",
"dbindex",
")",
"\n",
"result",
",",
"err",
":=",
"redis",
".",
"Values",
"... | // Get all elementid's for all hash elements | [
"Get",
"all",
"elementid",
"s",
"for",
"all",
"hash",
"elements"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L525-L534 |
145,155 | xyproto/simpleredis | simpleredis.go | SetExpire | func (rkv *KeyValue) SetExpire(key, value string, expire time.Duration) error {
conn := rkv.pool.Get(rkv.dbindex)
// Convert from nanoseconds to milliseconds
expireMilliseconds := expire.Nanoseconds() / 1000000
// Set the value, together with an expiry time, given in milliseconds
_, err := conn.Do("SET", rkv.id+":... | go | func (rkv *KeyValue) SetExpire(key, value string, expire time.Duration) error {
conn := rkv.pool.Get(rkv.dbindex)
// Convert from nanoseconds to milliseconds
expireMilliseconds := expire.Nanoseconds() / 1000000
// Set the value, together with an expiry time, given in milliseconds
_, err := conn.Do("SET", rkv.id+":... | [
"func",
"(",
"rkv",
"*",
"KeyValue",
")",
"SetExpire",
"(",
"key",
",",
"value",
"string",
",",
"expire",
"time",
".",
"Duration",
")",
"error",
"{",
"conn",
":=",
"rkv",
".",
"pool",
".",
"Get",
"(",
"rkv",
".",
"dbindex",
")",
"\n",
"// Convert fro... | // Set a key and value, with expiry | [
"Set",
"a",
"key",
"and",
"value",
"with",
"expiry"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L598-L605 |
145,156 | xyproto/simpleredis | simpleredis.go | TimeToLive | func (rkv *KeyValue) TimeToLive(key string) (time.Duration, error) {
conn := rkv.pool.Get(rkv.dbindex)
ttlSecondsInterface, err := conn.Do("TTL", rkv.id+":"+key)
if err != nil || ttlSecondsInterface.(int64) <= 0 {
return time.Duration(0), err
}
ns := time.Duration(ttlSecondsInterface.(int64)) * time.Second
retu... | go | func (rkv *KeyValue) TimeToLive(key string) (time.Duration, error) {
conn := rkv.pool.Get(rkv.dbindex)
ttlSecondsInterface, err := conn.Do("TTL", rkv.id+":"+key)
if err != nil || ttlSecondsInterface.(int64) <= 0 {
return time.Duration(0), err
}
ns := time.Duration(ttlSecondsInterface.(int64)) * time.Second
retu... | [
"func",
"(",
"rkv",
"*",
"KeyValue",
")",
"TimeToLive",
"(",
"key",
"string",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"conn",
":=",
"rkv",
".",
"pool",
".",
"Get",
"(",
"rkv",
".",
"dbindex",
")",
"\n",
"ttlSecondsInterface",
",",
... | // TimeToLive returns how long a key has to live until it expires
// Returns a duration of 0 when the time has passed | [
"TimeToLive",
"returns",
"how",
"long",
"a",
"key",
"has",
"to",
"live",
"until",
"it",
"expires",
"Returns",
"a",
"duration",
"of",
"0",
"when",
"the",
"time",
"has",
"passed"
] | f2c3a2cf62d069ecdc9b49bd1512cefac318e33d | https://github.com/xyproto/simpleredis/blob/f2c3a2cf62d069ecdc9b49bd1512cefac318e33d/simpleredis.go#L609-L617 |
145,157 | kurrik/oauth1a | oauth1a.go | Sign | func (s *Service) Sign(request *http.Request, userConfig *UserConfig) error {
return s.Signer.Sign(request, s.ClientConfig, userConfig)
} | go | func (s *Service) Sign(request *http.Request, userConfig *UserConfig) error {
return s.Signer.Sign(request, s.ClientConfig, userConfig)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"Sign",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"userConfig",
"*",
"UserConfig",
")",
"error",
"{",
"return",
"s",
".",
"Signer",
".",
"Sign",
"(",
"request",
",",
"s",
".",
"ClientConfig",
",",
"userC... | // Signs an HTTP request with the needed OAuth parameters. | [
"Signs",
"an",
"HTTP",
"request",
"with",
"the",
"needed",
"OAuth",
"parameters",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/oauth1a.go#L55-L57 |
145,158 | kurrik/oauth1a | oauth1a.go | generateNonce | func (HmacSha1Signer) generateNonce() string {
nonce := make([]byte, 16)
_, err := io.ReadFull(rand.Reader, nonce)
if err != nil {
panic("unable to read from crypto/rand.Reader; process is insecure: " + err.Error())
}
return hex.EncodeToString(nonce)
} | go | func (HmacSha1Signer) generateNonce() string {
nonce := make([]byte, 16)
_, err := io.ReadFull(rand.Reader, nonce)
if err != nil {
panic("unable to read from crypto/rand.Reader; process is insecure: " + err.Error())
}
return hex.EncodeToString(nonce)
} | [
"func",
"(",
"HmacSha1Signer",
")",
"generateNonce",
"(",
")",
"string",
"{",
"nonce",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
")",
"\n",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"rand",
".",
"Reader",
",",
"nonce",
")",
"\n",
"... | // Generate a unique nonce value. | [
"Generate",
"a",
"unique",
"nonce",
"value",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/oauth1a.go#L68-L75 |
145,159 | kurrik/oauth1a | oauth1a.go | GetSignature | func (s *HmacSha1Signer) GetSignature(consumerSecret string, tokenSecret string, signatureBase string) string {
signingKey := consumerSecret + "&" + tokenSecret
signer := hmac.New(sha1.New, []byte(signingKey))
signer.Write([]byte(signatureBase))
oauthSignature := base64.StdEncoding.EncodeToString(signer.Sum(nil))
... | go | func (s *HmacSha1Signer) GetSignature(consumerSecret string, tokenSecret string, signatureBase string) string {
signingKey := consumerSecret + "&" + tokenSecret
signer := hmac.New(sha1.New, []byte(signingKey))
signer.Write([]byte(signatureBase))
oauthSignature := base64.StdEncoding.EncodeToString(signer.Sum(nil))
... | [
"func",
"(",
"s",
"*",
"HmacSha1Signer",
")",
"GetSignature",
"(",
"consumerSecret",
"string",
",",
"tokenSecret",
"string",
",",
"signatureBase",
"string",
")",
"string",
"{",
"signingKey",
":=",
"consumerSecret",
"+",
"\"",
"\"",
"+",
"tokenSecret",
"\n",
"s... | // Calculates the HMAC-SHA1 signature of a base string, given a consumer and
// token secret. | [
"Calculates",
"the",
"HMAC",
"-",
"SHA1",
"signature",
"of",
"a",
"base",
"string",
"given",
"a",
"consumer",
"and",
"token",
"secret",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/oauth1a.go#L129-L135 |
145,160 | kurrik/oauth1a | oauth1a.go | Sign | func (s *HmacSha1Signer) Sign(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig) error {
var (
nonce string
timestamp string
)
if nonce = request.Header.Get("X-OAuth-Nonce"); nonce != "" {
request.Header.Del("X-OAuth-Nonce")
} else {
nonce = s.generateNonce()
}
if timestamp = r... | go | func (s *HmacSha1Signer) Sign(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig) error {
var (
nonce string
timestamp string
)
if nonce = request.Header.Get("X-OAuth-Nonce"); nonce != "" {
request.Header.Del("X-OAuth-Nonce")
} else {
nonce = s.generateNonce()
}
if timestamp = r... | [
"func",
"(",
"s",
"*",
"HmacSha1Signer",
")",
"Sign",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"clientConfig",
"*",
"ClientConfig",
",",
"userConfig",
"*",
"UserConfig",
")",
"error",
"{",
"var",
"(",
"nonce",
"string",
"\n",
"timestamp",
"string"... | // Given an unsigned request, add the appropriate OAuth Authorization header
// using the HMAC-SHA1 algorithm. | [
"Given",
"an",
"unsigned",
"request",
"add",
"the",
"appropriate",
"OAuth",
"Authorization",
"header",
"using",
"the",
"HMAC",
"-",
"SHA1",
"algorithm",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/oauth1a.go#L139-L167 |
145,161 | kurrik/oauth1a | oauth1a.go | Rfc3986Escape | func Rfc3986Escape(input string) string {
firstEsc := -1
b := []byte(input)
for i, c := range b {
if !isSafeChar(c) {
firstEsc = i
break
}
}
// If nothing needed to be escaped, then the input is clean and
// we're done.
if firstEsc == -1 {
return input
}
// If something did need to be escaped, wr... | go | func Rfc3986Escape(input string) string {
firstEsc := -1
b := []byte(input)
for i, c := range b {
if !isSafeChar(c) {
firstEsc = i
break
}
}
// If nothing needed to be escaped, then the input is clean and
// we're done.
if firstEsc == -1 {
return input
}
// If something did need to be escaped, wr... | [
"func",
"Rfc3986Escape",
"(",
"input",
"string",
")",
"string",
"{",
"firstEsc",
":=",
"-",
"1",
"\n",
"b",
":=",
"[",
"]",
"byte",
"(",
"input",
")",
"\n",
"for",
"i",
",",
"c",
":=",
"range",
"b",
"{",
"if",
"!",
"isSafeChar",
"(",
"c",
")",
... | // Escapes a string more in line with Rfc3986 than http.URLEscape.
// URLEscape was converting spaces to "+" instead of "%20", which was messing up
// the signing of requests. | [
"Escapes",
"a",
"string",
"more",
"in",
"line",
"with",
"Rfc3986",
"than",
"http",
".",
"URLEscape",
".",
"URLEscape",
"was",
"converting",
"spaces",
"to",
"+",
"instead",
"of",
"%20",
"which",
"was",
"messing",
"up",
"the",
"signing",
"of",
"requests",
".... | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/oauth1a.go#L218-L247 |
145,162 | kurrik/oauth1a | userconfig.go | NewAuthorizedConfig | func NewAuthorizedConfig(token string, secret string) *UserConfig {
return &UserConfig{AccessTokenKey: token, AccessTokenSecret: secret}
} | go | func NewAuthorizedConfig(token string, secret string) *UserConfig {
return &UserConfig{AccessTokenKey: token, AccessTokenSecret: secret}
} | [
"func",
"NewAuthorizedConfig",
"(",
"token",
"string",
",",
"secret",
"string",
")",
"*",
"UserConfig",
"{",
"return",
"&",
"UserConfig",
"{",
"AccessTokenKey",
":",
"token",
",",
"AccessTokenSecret",
":",
"secret",
"}",
"\n",
"}"
] | // Creates a UserConfig object with existing access token credentials. For
// users where an access token has been obtained through other means than
// the authz flows provided by this library. | [
"Creates",
"a",
"UserConfig",
"object",
"with",
"existing",
"access",
"token",
"credentials",
".",
"For",
"users",
"where",
"an",
"access",
"token",
"has",
"been",
"obtained",
"through",
"other",
"means",
"than",
"the",
"authz",
"flows",
"provided",
"by",
"thi... | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L41-L43 |
145,163 | kurrik/oauth1a | userconfig.go | send | func (c *UserConfig) send(request *http.Request, service *Service, client *http.Client) (*http.Response, error) {
if err := service.Sign(request, c); err != nil {
return nil, err
}
response, err := client.Do(request)
if err != nil {
return nil, err
}
if response.StatusCode != 200 {
body, _ := ioutil.ReadAll... | go | func (c *UserConfig) send(request *http.Request, service *Service, client *http.Client) (*http.Response, error) {
if err := service.Sign(request, c); err != nil {
return nil, err
}
response, err := client.Do(request)
if err != nil {
return nil, err
}
if response.StatusCode != 200 {
body, _ := ioutil.ReadAll... | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"send",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"service",
"*",
"Service",
",",
"client",
"*",
"http",
".",
"Client",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"err",
... | // Sign and send a Request using the current configuration. | [
"Sign",
"and",
"send",
"a",
"Request",
"using",
"the",
"current",
"configuration",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L46-L59 |
145,164 | kurrik/oauth1a | userconfig.go | GetRequestToken | func (c *UserConfig) GetRequestToken(service *Service, client *http.Client) error {
data := url.Values{}
if service.ClientConfig.CallbackURL != "" {
data.Set("oauth_callback", service.ClientConfig.CallbackURL)
}
body := strings.NewReader(data.Encode())
request, err := http.NewRequest("POST", service.RequestURL, ... | go | func (c *UserConfig) GetRequestToken(service *Service, client *http.Client) error {
data := url.Values{}
if service.ClientConfig.CallbackURL != "" {
data.Set("oauth_callback", service.ClientConfig.CallbackURL)
}
body := strings.NewReader(data.Encode())
request, err := http.NewRequest("POST", service.RequestURL, ... | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"GetRequestToken",
"(",
"service",
"*",
"Service",
",",
"client",
"*",
"http",
".",
"Client",
")",
"error",
"{",
"data",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"if",
"service",
".",
"ClientConfig",
".",
... | // Issue a request to obtain a Request token. | [
"Issue",
"a",
"request",
"to",
"obtain",
"a",
"Request",
"token",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L62-L79 |
145,165 | kurrik/oauth1a | userconfig.go | parseRequestToken | func (c *UserConfig) parseRequestToken(response *http.Response) error {
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return err
}
params, err := url.ParseQuery(string(body))
tokenKey := params.Get("oauth_token")
tokenSecret := params.Get("oauth_token_secret")
if token... | go | func (c *UserConfig) parseRequestToken(response *http.Response) error {
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return err
}
params, err := url.ParseQuery(string(body))
tokenKey := params.Get("oauth_token")
tokenSecret := params.Get("oauth_token_secret")
if token... | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"parseRequestToken",
"(",
"response",
"*",
"http",
".",
"Response",
")",
"error",
"{",
"defer",
"response",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
... | // Given the returned response from a Request token request, parse out the
// appropriate request token and secret fields. | [
"Given",
"the",
"returned",
"response",
"from",
"a",
"Request",
"token",
"request",
"parse",
"out",
"the",
"appropriate",
"request",
"token",
"and",
"secret",
"fields",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L83-L101 |
145,166 | kurrik/oauth1a | userconfig.go | GetAuthorizeURL | func (c *UserConfig) GetAuthorizeURL(service *Service) (string, error) {
if c.RequestTokenKey == "" || c.RequestTokenSecret == "" {
return "", fmt.Errorf("No configured request token")
}
token := url.QueryEscape(c.RequestTokenKey)
return service.AuthorizeURL + "?oauth_token=" + token, nil
} | go | func (c *UserConfig) GetAuthorizeURL(service *Service) (string, error) {
if c.RequestTokenKey == "" || c.RequestTokenSecret == "" {
return "", fmt.Errorf("No configured request token")
}
token := url.QueryEscape(c.RequestTokenKey)
return service.AuthorizeURL + "?oauth_token=" + token, nil
} | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"GetAuthorizeURL",
"(",
"service",
"*",
"Service",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"RequestTokenKey",
"==",
"\"",
"\"",
"||",
"c",
".",
"RequestTokenSecret",
"==",
"\"",
"\"",
"{",
... | // Obtain a URL which will allow the current user to authorize access to their
// OAuth-protected data. | [
"Obtain",
"a",
"URL",
"which",
"will",
"allow",
"the",
"current",
"user",
"to",
"authorize",
"access",
"to",
"their",
"OAuth",
"-",
"protected",
"data",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L105-L111 |
145,167 | kurrik/oauth1a | userconfig.go | ParseAuthorize | func (c *UserConfig) ParseAuthorize(request *http.Request, service *Service) (string, string, error) {
request.ParseForm()
urlParts := request.URL.Query()
token := urlParts.Get("oauth_token")
verifier := urlParts.Get("oauth_verifier")
if token == "" {
token = request.Form.Get("oauth_token")
}
if verifier == ""... | go | func (c *UserConfig) ParseAuthorize(request *http.Request, service *Service) (string, string, error) {
request.ParseForm()
urlParts := request.URL.Query()
token := urlParts.Get("oauth_token")
verifier := urlParts.Get("oauth_verifier")
if token == "" {
token = request.Form.Get("oauth_token")
}
if verifier == ""... | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"ParseAuthorize",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"service",
"*",
"Service",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"request",
".",
"ParseForm",
"(",
")",
"\n",
"urlParts",... | // Parses an access token and verifier from a redirected authorize request. | [
"Parses",
"an",
"access",
"token",
"and",
"verifier",
"from",
"a",
"redirected",
"authorize",
"request",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L114-L129 |
145,168 | kurrik/oauth1a | userconfig.go | GetAccessToken | func (c *UserConfig) GetAccessToken(token string, verifier string, service *Service, client *http.Client) error {
// This code used to error out if RequestTokenKey were empty, but
// in the interest of being able to operate in a stateless manner this
// has been removed. If you want to make sure that the request to... | go | func (c *UserConfig) GetAccessToken(token string, verifier string, service *Service, client *http.Client) error {
// This code used to error out if RequestTokenKey were empty, but
// in the interest of being able to operate in a stateless manner this
// has been removed. If you want to make sure that the request to... | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"GetAccessToken",
"(",
"token",
"string",
",",
"verifier",
"string",
",",
"service",
"*",
"Service",
",",
"client",
"*",
"http",
".",
"Client",
")",
"error",
"{",
"// This code used to error out if RequestTokenKey were emp... | // Issue a request to exchange the current request token for an access token. | [
"Issue",
"a",
"request",
"to",
"exchange",
"the",
"current",
"request",
"token",
"for",
"an",
"access",
"token",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L132-L159 |
145,169 | kurrik/oauth1a | userconfig.go | GetToken | func (c *UserConfig) GetToken() (string, string) {
if c.AccessTokenKey != "" {
return c.AccessTokenKey, c.AccessTokenSecret
}
if c.RequestTokenKey != "" {
return c.RequestTokenKey, c.RequestTokenSecret
}
return "", ""
} | go | func (c *UserConfig) GetToken() (string, string) {
if c.AccessTokenKey != "" {
return c.AccessTokenKey, c.AccessTokenSecret
}
if c.RequestTokenKey != "" {
return c.RequestTokenKey, c.RequestTokenSecret
}
return "", ""
} | [
"func",
"(",
"c",
"*",
"UserConfig",
")",
"GetToken",
"(",
")",
"(",
"string",
",",
"string",
")",
"{",
"if",
"c",
".",
"AccessTokenKey",
"!=",
"\"",
"\"",
"{",
"return",
"c",
".",
"AccessTokenKey",
",",
"c",
".",
"AccessTokenSecret",
"\n",
"}",
"\n"... | // Returns a token and secret corresponding to where in the OAuth flow this
// config is currently in. The priority is Access token, Request token, empty
// string. | [
"Returns",
"a",
"token",
"and",
"secret",
"corresponding",
"to",
"where",
"in",
"the",
"OAuth",
"flow",
"this",
"config",
"is",
"currently",
"in",
".",
"The",
"priority",
"is",
"Access",
"token",
"Request",
"token",
"empty",
"string",
"."
] | cb1b80e32dd4385099f8d09312e4bcf6bdc993ec | https://github.com/kurrik/oauth1a/blob/cb1b80e32dd4385099f8d09312e4bcf6bdc993ec/userconfig.go#L186-L194 |
145,170 | knq/pemutil | util.go | ParsePKCSPrivateKey | func ParsePKCSPrivateKey(buf []byte) (interface{}, error) {
// attempt PKCS1 parsing
key, err := x509.ParsePKCS1PrivateKey(buf)
if err == nil {
return key, nil
}
// attempt PKCS8 parsing
return x509.ParsePKCS8PrivateKey(buf)
} | go | func ParsePKCSPrivateKey(buf []byte) (interface{}, error) {
// attempt PKCS1 parsing
key, err := x509.ParsePKCS1PrivateKey(buf)
if err == nil {
return key, nil
}
// attempt PKCS8 parsing
return x509.ParsePKCS8PrivateKey(buf)
} | [
"func",
"ParsePKCSPrivateKey",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// attempt PKCS1 parsing",
"key",
",",
"err",
":=",
"x509",
".",
"ParsePKCS1PrivateKey",
"(",
"buf",
")",
"\n",
"if",
"err",
"==",
"nil... | // ParsePKCSPrivateKey attempts to decode a RSA private key first using PKCS1
// encoding, and then PKCS8 encoding. | [
"ParsePKCSPrivateKey",
"attempts",
"to",
"decode",
"a",
"RSA",
"private",
"key",
"first",
"using",
"PKCS1",
"encoding",
"and",
"then",
"PKCS8",
"encoding",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/util.go#L34-L43 |
145,171 | knq/pemutil | pemutil.go | Decode | func Decode(s Store, buf []byte) error {
var err error
var block *pem.Block
// loop over pem encoded data
for len(buf) > 0 {
block, buf = pem.Decode(buf)
if block == nil {
return errors.New("invalid PEM data")
}
err = s.DecodeBlock(block)
if err != nil {
return err
}
}
if len(s) == 0 {
retu... | go | func Decode(s Store, buf []byte) error {
var err error
var block *pem.Block
// loop over pem encoded data
for len(buf) > 0 {
block, buf = pem.Decode(buf)
if block == nil {
return errors.New("invalid PEM data")
}
err = s.DecodeBlock(block)
if err != nil {
return err
}
}
if len(s) == 0 {
retu... | [
"func",
"Decode",
"(",
"s",
"Store",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"var",
"block",
"*",
"pem",
".",
"Block",
"\n\n",
"// loop over pem encoded data",
"for",
"len",
"(",
"buf",
")",
">",
"0",
"{",
"block... | // Decode parses and decodes PEM-encoded data from buf, storing any resulting
// crypto primitives encountered into the Store. The decoded PEM BlockType will
// be used as the map key for each primitive. | [
"Decode",
"parses",
"and",
"decodes",
"PEM",
"-",
"encoded",
"data",
"from",
"buf",
"storing",
"any",
"resulting",
"crypto",
"primitives",
"encountered",
"into",
"the",
"Store",
".",
"The",
"decoded",
"PEM",
"BlockType",
"will",
"be",
"used",
"as",
"the",
"m... | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/pemutil.go#L30-L52 |
145,172 | knq/pemutil | pemutil.go | DecodeBytes | func DecodeBytes(buf []byte) (Store, error) {
s := Store{}
err := Decode(s, buf)
if err != nil {
return nil, err
}
return s, nil
} | go | func DecodeBytes(buf []byte) (Store, error) {
s := Store{}
err := Decode(s, buf)
if err != nil {
return nil, err
}
return s, nil
} | [
"func",
"DecodeBytes",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"Store",
",",
"error",
")",
"{",
"s",
":=",
"Store",
"{",
"}",
"\n",
"err",
":=",
"Decode",
"(",
"s",
",",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"... | // DecodeBytes decodes the supplied buf into a store. | [
"DecodeBytes",
"decodes",
"the",
"supplied",
"buf",
"into",
"a",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/pemutil.go#L55-L63 |
145,173 | knq/pemutil | pemutil.go | EncodePrimitive | func EncodePrimitive(p interface{}) ([]byte, error) {
var err error
var typ BlockType
var buf []byte
switch v := p.(type) {
case []byte:
typ, buf = PrivateKey, v
case *rsa.PrivateKey:
typ, buf = RSAPrivateKey, x509.MarshalPKCS1PrivateKey(v)
case *ecdsa.PrivateKey:
typ = ECPrivateKey
buf, err = x509.Ma... | go | func EncodePrimitive(p interface{}) ([]byte, error) {
var err error
var typ BlockType
var buf []byte
switch v := p.(type) {
case []byte:
typ, buf = PrivateKey, v
case *rsa.PrivateKey:
typ, buf = RSAPrivateKey, x509.MarshalPKCS1PrivateKey(v)
case *ecdsa.PrivateKey:
typ = ECPrivateKey
buf, err = x509.Ma... | [
"func",
"EncodePrimitive",
"(",
"p",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"typ",
"BlockType",
"\n",
"var",
"buf",
"[",
"]",
"byte",
"\n\n",
"switch",
"v",
":=",
"p",
".",
"... | // EncodePrimitive encodes the crypto primitive p into PEM-encoded data. | [
"EncodePrimitive",
"encodes",
"the",
"crypto",
"primitive",
"p",
"into",
"PEM",
"-",
"encoded",
"data",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/pemutil.go#L66-L101 |
145,174 | knq/pemutil | pemutil.go | GenerateSymmetricKeySet | func GenerateSymmetricKeySet(keyLen int) (Store, error) {
// generate random bytes
buf := make([]byte, keyLen)
c, err := rand.Read(buf)
if err != nil {
return nil, err
} else if c != keyLen {
return nil, fmt.Errorf("could not generate %d random key bits", keyLen)
}
return Store{
PrivateKey: buf,
}, nil
} | go | func GenerateSymmetricKeySet(keyLen int) (Store, error) {
// generate random bytes
buf := make([]byte, keyLen)
c, err := rand.Read(buf)
if err != nil {
return nil, err
} else if c != keyLen {
return nil, fmt.Errorf("could not generate %d random key bits", keyLen)
}
return Store{
PrivateKey: buf,
}, nil
} | [
"func",
"GenerateSymmetricKeySet",
"(",
"keyLen",
"int",
")",
"(",
"Store",
",",
"error",
")",
"{",
"// generate random bytes",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"keyLen",
")",
"\n",
"c",
",",
"err",
":=",
"rand",
".",
"Read",
"(",
"buf"... | // GenerateSymmetricKeySet generates a private key crypto primitive, returning
// it as a Store. | [
"GenerateSymmetricKeySet",
"generates",
"a",
"private",
"key",
"crypto",
"primitive",
"returning",
"it",
"as",
"a",
"Store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/pemutil.go#L105-L118 |
145,175 | knq/pemutil | pemutil.go | GenerateRSAKeySet | func GenerateRSAKeySet(bitLen int) (Store, error) {
key, err := rsa.GenerateKey(rand.Reader, bitLen)
if err != nil {
return nil, err
}
return Store{
RSAPrivateKey: key,
PublicKey: key.Public(),
}, nil
} | go | func GenerateRSAKeySet(bitLen int) (Store, error) {
key, err := rsa.GenerateKey(rand.Reader, bitLen)
if err != nil {
return nil, err
}
return Store{
RSAPrivateKey: key,
PublicKey: key.Public(),
}, nil
} | [
"func",
"GenerateRSAKeySet",
"(",
"bitLen",
"int",
")",
"(",
"Store",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"rsa",
".",
"GenerateKey",
"(",
"rand",
".",
"Reader",
",",
"bitLen",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // GenerateRSAKeySet generates a RSA private and public key crypto primitives,
// returning them as a Store. | [
"GenerateRSAKeySet",
"generates",
"a",
"RSA",
"private",
"and",
"public",
"key",
"crypto",
"primitives",
"returning",
"them",
"as",
"a",
"Store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/pemutil.go#L122-L132 |
145,176 | knq/pemutil | pemutil.go | GenerateECKeySet | func GenerateECKeySet(curve elliptic.Curve) (Store, error) {
key, err := ecdsa.GenerateKey(curve, rand.Reader)
if err != nil {
return nil, err
}
return Store{
ECPrivateKey: key,
PublicKey: key.Public(),
}, nil
} | go | func GenerateECKeySet(curve elliptic.Curve) (Store, error) {
key, err := ecdsa.GenerateKey(curve, rand.Reader)
if err != nil {
return nil, err
}
return Store{
ECPrivateKey: key,
PublicKey: key.Public(),
}, nil
} | [
"func",
"GenerateECKeySet",
"(",
"curve",
"elliptic",
".",
"Curve",
")",
"(",
"Store",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"ecdsa",
".",
"GenerateKey",
"(",
"curve",
",",
"rand",
".",
"Reader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // GenerateECKeySet generates a EC private and public key crypto primitives,
// returning them as a Store. | [
"GenerateECKeySet",
"generates",
"a",
"EC",
"private",
"and",
"public",
"key",
"crypto",
"primitives",
"returning",
"them",
"as",
"a",
"Store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/pemutil.go#L136-L146 |
145,177 | knq/pemutil | store.go | Bytes | func (s Store) Bytes() ([]byte, error) {
if len(s) == 0 {
return nil, errors.New("store is empty")
}
// encode
var res bytes.Buffer
for _, k := range encOrder {
if p, ok := s[k]; ok {
buf, err := EncodePrimitive(p)
if err != nil {
return nil, err
}
_, err = res.Write(buf)
if err != nil {
... | go | func (s Store) Bytes() ([]byte, error) {
if len(s) == 0 {
return nil, errors.New("store is empty")
}
// encode
var res bytes.Buffer
for _, k := range encOrder {
if p, ok := s[k]; ok {
buf, err := EncodePrimitive(p)
if err != nil {
return nil, err
}
_, err = res.Write(buf)
if err != nil {
... | [
"func",
"(",
"s",
"Store",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// encode",
... | // Bytes returns all crypto primitives in the store as a single byte slice
// containing the PEM-encoded versions of the crypto primitives. | [
"Bytes",
"returns",
"all",
"crypto",
"primitives",
"in",
"the",
"store",
"as",
"a",
"single",
"byte",
"slice",
"containing",
"the",
"PEM",
"-",
"encoded",
"versions",
"of",
"the",
"crypto",
"primitives",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L35-L57 |
145,178 | knq/pemutil | store.go | DecodeBlock | func (s Store) DecodeBlock(block *pem.Block) error {
switch BlockType(block.Type) {
case PrivateKey:
// try pkcs1 and then pkcs8 decoding
key, err := ParsePKCSPrivateKey(block.Bytes)
if err == nil {
return s.add(RSAPrivateKey, key)
}
// must be a raw key (ie, use decoded b64 value as key)
return s.add... | go | func (s Store) DecodeBlock(block *pem.Block) error {
switch BlockType(block.Type) {
case PrivateKey:
// try pkcs1 and then pkcs8 decoding
key, err := ParsePKCSPrivateKey(block.Bytes)
if err == nil {
return s.add(RSAPrivateKey, key)
}
// must be a raw key (ie, use decoded b64 value as key)
return s.add... | [
"func",
"(",
"s",
"Store",
")",
"DecodeBlock",
"(",
"block",
"*",
"pem",
".",
"Block",
")",
"error",
"{",
"switch",
"BlockType",
"(",
"block",
".",
"Type",
")",
"{",
"case",
"PrivateKey",
":",
"// try pkcs1 and then pkcs8 decoding",
"key",
",",
"err",
":="... | // DecodeBlock decodes PEM block data, adding any crypto primitive encountered the
// store. | [
"DecodeBlock",
"decodes",
"PEM",
"block",
"data",
"adding",
"any",
"crypto",
"primitive",
"encountered",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L89-L133 |
145,179 | knq/pemutil | store.go | add | func (s Store) add(typ BlockType, v interface{}) error {
if _, ok := s[typ]; ok {
return fmt.Errorf("block type %s already present", typ)
}
s[typ] = v
return nil
} | go | func (s Store) add(typ BlockType, v interface{}) error {
if _, ok := s[typ]; ok {
return fmt.Errorf("block type %s already present", typ)
}
s[typ] = v
return nil
} | [
"func",
"(",
"s",
"Store",
")",
"add",
"(",
"typ",
"BlockType",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"s",
"[",
"typ",
"]",
";",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"typ",... | // add adds a crypto primitive to the store, returning an error if the defined
// block is already present. | [
"add",
"adds",
"a",
"crypto",
"primitive",
"to",
"the",
"store",
"returning",
"an",
"error",
"if",
"the",
"defined",
"block",
"is",
"already",
"present",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L137-L143 |
145,180 | knq/pemutil | store.go | PublicKey | func (s Store) PublicKey() (crypto.PublicKey, bool) {
v, ok := s[PublicKey]
if !ok {
return nil, false
}
z, ok := v.(crypto.PublicKey)
return z, ok
} | go | func (s Store) PublicKey() (crypto.PublicKey, bool) {
v, ok := s[PublicKey]
if !ok {
return nil, false
}
z, ok := v.(crypto.PublicKey)
return z, ok
} | [
"func",
"(",
"s",
"Store",
")",
"PublicKey",
"(",
")",
"(",
"crypto",
".",
"PublicKey",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"s",
"[",
"PublicKey",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n",
"z",
... | // PublicKey returns the public key contained within the store. | [
"PublicKey",
"returns",
"the",
"public",
"key",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L146-L153 |
145,181 | knq/pemutil | store.go | PrivateKey | func (s Store) PrivateKey() (crypto.PrivateKey, bool) {
for _, typ := range []BlockType{PrivateKey, RSAPrivateKey, ECPrivateKey} {
v, ok := s[typ]
if ok {
z, ok := v.(crypto.PrivateKey)
return z, ok
}
}
return nil, false
} | go | func (s Store) PrivateKey() (crypto.PrivateKey, bool) {
for _, typ := range []BlockType{PrivateKey, RSAPrivateKey, ECPrivateKey} {
v, ok := s[typ]
if ok {
z, ok := v.(crypto.PrivateKey)
return z, ok
}
}
return nil, false
} | [
"func",
"(",
"s",
"Store",
")",
"PrivateKey",
"(",
")",
"(",
"crypto",
".",
"PrivateKey",
",",
"bool",
")",
"{",
"for",
"_",
",",
"typ",
":=",
"range",
"[",
"]",
"BlockType",
"{",
"PrivateKey",
",",
"RSAPrivateKey",
",",
"ECPrivateKey",
"}",
"{",
"v"... | // PrivateKey returns the private key contained within the store. | [
"PrivateKey",
"returns",
"the",
"private",
"key",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L156-L166 |
145,182 | knq/pemutil | store.go | RSAPublicKey | func (s Store) RSAPublicKey() (*rsa.PublicKey, bool) {
v, ok := s[PublicKey]
if !ok {
return nil, false
}
z, ok := v.(*rsa.PublicKey)
return z, ok
} | go | func (s Store) RSAPublicKey() (*rsa.PublicKey, bool) {
v, ok := s[PublicKey]
if !ok {
return nil, false
}
z, ok := v.(*rsa.PublicKey)
return z, ok
} | [
"func",
"(",
"s",
"Store",
")",
"RSAPublicKey",
"(",
")",
"(",
"*",
"rsa",
".",
"PublicKey",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"s",
"[",
"PublicKey",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n",
... | // RSAPublicKey returns the RSA public key contained within the store. | [
"RSAPublicKey",
"returns",
"the",
"RSA",
"public",
"key",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L169-L176 |
145,183 | knq/pemutil | store.go | RSAPrivateKey | func (s Store) RSAPrivateKey() (*rsa.PrivateKey, bool) {
v, ok := s[RSAPrivateKey]
if !ok {
return nil, false
}
z, ok := v.(*rsa.PrivateKey)
return z, ok
} | go | func (s Store) RSAPrivateKey() (*rsa.PrivateKey, bool) {
v, ok := s[RSAPrivateKey]
if !ok {
return nil, false
}
z, ok := v.(*rsa.PrivateKey)
return z, ok
} | [
"func",
"(",
"s",
"Store",
")",
"RSAPrivateKey",
"(",
")",
"(",
"*",
"rsa",
".",
"PrivateKey",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"s",
"[",
"RSAPrivateKey",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\... | // RSAPrivateKey returns the RSA private key contained within the store. | [
"RSAPrivateKey",
"returns",
"the",
"RSA",
"private",
"key",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L179-L186 |
145,184 | knq/pemutil | store.go | ECPublicKey | func (s Store) ECPublicKey() (*ecdsa.PublicKey, bool) {
v, ok := s[PublicKey]
if !ok {
return nil, false
}
z, ok := v.(*ecdsa.PublicKey)
return z, ok
} | go | func (s Store) ECPublicKey() (*ecdsa.PublicKey, bool) {
v, ok := s[PublicKey]
if !ok {
return nil, false
}
z, ok := v.(*ecdsa.PublicKey)
return z, ok
} | [
"func",
"(",
"s",
"Store",
")",
"ECPublicKey",
"(",
")",
"(",
"*",
"ecdsa",
".",
"PublicKey",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"s",
"[",
"PublicKey",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n",
... | // ECPublicKey returns the ECDSA public key contained within the store. | [
"ECPublicKey",
"returns",
"the",
"ECDSA",
"public",
"key",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L189-L196 |
145,185 | knq/pemutil | store.go | ECPrivateKey | func (s Store) ECPrivateKey() (*ecdsa.PrivateKey, bool) {
v, ok := s[ECPrivateKey]
if !ok {
return nil, false
}
z, ok := v.(*ecdsa.PrivateKey)
return z, ok
} | go | func (s Store) ECPrivateKey() (*ecdsa.PrivateKey, bool) {
v, ok := s[ECPrivateKey]
if !ok {
return nil, false
}
z, ok := v.(*ecdsa.PrivateKey)
return z, ok
} | [
"func",
"(",
"s",
"Store",
")",
"ECPrivateKey",
"(",
")",
"(",
"*",
"ecdsa",
".",
"PrivateKey",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"s",
"[",
"ECPrivateKey",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\... | // ECPrivateKey returns the ECDSA private key contained within the store. | [
"ECPrivateKey",
"returns",
"the",
"ECDSA",
"private",
"key",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L199-L206 |
145,186 | knq/pemutil | store.go | Certificate | func (s Store) Certificate() (*x509.Certificate, bool) {
v, ok := s[Certificate]
if !ok {
return nil, false
}
z, ok := v.(*x509.Certificate)
return z, ok
} | go | func (s Store) Certificate() (*x509.Certificate, bool) {
v, ok := s[Certificate]
if !ok {
return nil, false
}
z, ok := v.(*x509.Certificate)
return z, ok
} | [
"func",
"(",
"s",
"Store",
")",
"Certificate",
"(",
")",
"(",
"*",
"x509",
".",
"Certificate",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"s",
"[",
"Certificate",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n"... | // Certificate returns the X509 certificate contained within the store. | [
"Certificate",
"returns",
"the",
"X509",
"certificate",
"contained",
"within",
"the",
"store",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L209-L216 |
145,187 | knq/pemutil | store.go | LoadFile | func (s Store) LoadFile(filename string) error {
buf, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
return Decode(s, buf)
} | go | func (s Store) LoadFile(filename string) error {
buf, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
return Decode(s, buf)
} | [
"func",
"(",
"s",
"Store",
")",
"LoadFile",
"(",
"filename",
"string",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"... | // LoadFile loads crypto primitives from PEM encoded data stored in filename. | [
"LoadFile",
"loads",
"crypto",
"primitives",
"from",
"PEM",
"encoded",
"data",
"stored",
"in",
"filename",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L219-L226 |
145,188 | knq/pemutil | store.go | WriteFile | func (s Store) WriteFile(filename string) error {
buf, err := s.Bytes()
if err != nil {
return err
}
return ioutil.WriteFile(filename, buf, 0600)
} | go | func (s Store) WriteFile(filename string) error {
buf, err := s.Bytes()
if err != nil {
return err
}
return ioutil.WriteFile(filename, buf, 0600)
} | [
"func",
"(",
"s",
"Store",
")",
"WriteFile",
"(",
"filename",
"string",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"s",
".",
"Bytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"ioutil",
".",
"Wr... | // WriteFile writes the crypto primitives in the store to filename with mode
// 0600. | [
"WriteFile",
"writes",
"the",
"crypto",
"primitives",
"in",
"the",
"store",
"to",
"filename",
"with",
"mode",
"0600",
"."
] | fb6fad722528d308d5fbc9f39e0a9644905ee1cb | https://github.com/knq/pemutil/blob/fb6fad722528d308d5fbc9f39e0a9644905ee1cb/store.go#L245-L252 |
145,189 | tj/go-elastic | batch/batch.go | Add | func (b *Batch) Add(doc interface{}) {
b.Docs = append(b.Docs, doc)
} | go | func (b *Batch) Add(doc interface{}) {
b.Docs = append(b.Docs, doc)
} | [
"func",
"(",
"b",
"*",
"Batch",
")",
"Add",
"(",
"doc",
"interface",
"{",
"}",
")",
"{",
"b",
".",
"Docs",
"=",
"append",
"(",
"b",
".",
"Docs",
",",
"doc",
")",
"\n",
"}"
] | // Add document. | [
"Add",
"document",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/batch/batch.go#L40-L42 |
145,190 | tj/go-elastic | batch/batch.go | Bytes | func (b *Batch) Bytes() (*bytes.Buffer, error) {
buf := new(bytes.Buffer)
enc := json.NewEncoder(buf)
op := IndexOp{
Index: Index{
Index: b.Index,
Type: b.Type,
},
}
for _, doc := range b.Docs {
if err := enc.Encode(op); err != nil {
return nil, err
}
if err := enc.Encode(doc); err != nil {
... | go | func (b *Batch) Bytes() (*bytes.Buffer, error) {
buf := new(bytes.Buffer)
enc := json.NewEncoder(buf)
op := IndexOp{
Index: Index{
Index: b.Index,
Type: b.Type,
},
}
for _, doc := range b.Docs {
if err := enc.Encode(op); err != nil {
return nil, err
}
if err := enc.Encode(doc); err != nil {
... | [
"func",
"(",
"b",
"*",
"Batch",
")",
"Bytes",
"(",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"enc",
":=",
"json",
".",
"NewEncoder",
"(",
"buf",
")",
"\n\n",
"op",... | // Bytes returns the request body. | [
"Bytes",
"returns",
"the",
"request",
"body",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/batch/batch.go#L50-L72 |
145,191 | tj/go-elastic | batch/batch.go | Flush | func (b *Batch) Flush() (err error) {
if b.Size() == 0 {
return nil
}
buf, err := b.Bytes()
if err != nil {
return err
}
b.Docs = nil
return b.Elastic.Bulk(buf)
} | go | func (b *Batch) Flush() (err error) {
if b.Size() == 0 {
return nil
}
buf, err := b.Bytes()
if err != nil {
return err
}
b.Docs = nil
return b.Elastic.Bulk(buf)
} | [
"func",
"(",
"b",
"*",
"Batch",
")",
"Flush",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"b",
".",
"Size",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"buf",
",",
"err",
":=",
"b",
".",
"Bytes",
"(",
")",
"\n",
"if",
... | // Flush checks in bulk. | [
"Flush",
"checks",
"in",
"bulk",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/batch/batch.go#L75-L88 |
145,192 | tj/go-elastic | aliases/aliases.go | Names | func (i Indexes) Names() (v []string) {
for k := range i {
v = append(v, k)
}
return
} | go | func (i Indexes) Names() (v []string) {
for k := range i {
v = append(v, k)
}
return
} | [
"func",
"(",
"i",
"Indexes",
")",
"Names",
"(",
")",
"(",
"v",
"[",
"]",
"string",
")",
"{",
"for",
"k",
":=",
"range",
"i",
"{",
"v",
"=",
"append",
"(",
"v",
",",
"k",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Names returns the index names. | [
"Names",
"returns",
"the",
"index",
"names",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/aliases/aliases.go#L17-L22 |
145,193 | tj/go-elastic | aliases/aliases.go | Matching | func (i Indexes) Matching(layout string) Indexes {
out := make(Indexes)
for k, v := range i {
if _, err := time.Parse(layout, k); err != nil {
continue
}
out[k] = v
}
return out
} | go | func (i Indexes) Matching(layout string) Indexes {
out := make(Indexes)
for k, v := range i {
if _, err := time.Parse(layout, k); err != nil {
continue
}
out[k] = v
}
return out
} | [
"func",
"(",
"i",
"Indexes",
")",
"Matching",
"(",
"layout",
"string",
")",
"Indexes",
"{",
"out",
":=",
"make",
"(",
"Indexes",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"i",
"{",
"if",
"_",
",",
"err",
":=",
"time",
".",
"Parse",
"(",
... | // Matching returns aliases matching the given time `layout`. | [
"Matching",
"returns",
"aliases",
"matching",
"the",
"given",
"time",
"layout",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/aliases/aliases.go#L25-L37 |
145,194 | tj/go-elastic | aliases/aliases.go | MatchingOlderThan | func (i Indexes) MatchingOlderThan(layout string, n int, now time.Time) Indexes {
out := make(Indexes)
old := now.AddDate(0, 0, -n)
for k, v := range i {
t, err := time.Parse(layout, k)
if err != nil {
continue
}
if !t.Before(old) {
continue
}
out[k] = v
}
return out
} | go | func (i Indexes) MatchingOlderThan(layout string, n int, now time.Time) Indexes {
out := make(Indexes)
old := now.AddDate(0, 0, -n)
for k, v := range i {
t, err := time.Parse(layout, k)
if err != nil {
continue
}
if !t.Before(old) {
continue
}
out[k] = v
}
return out
} | [
"func",
"(",
"i",
"Indexes",
")",
"MatchingOlderThan",
"(",
"layout",
"string",
",",
"n",
"int",
",",
"now",
"time",
".",
"Time",
")",
"Indexes",
"{",
"out",
":=",
"make",
"(",
"Indexes",
")",
"\n",
"old",
":=",
"now",
".",
"AddDate",
"(",
"0",
","... | // MatchingOlderThan returns aliases matching the given `layout` which are older
// than `n` days relative to time `now`. | [
"MatchingOlderThan",
"returns",
"aliases",
"matching",
"the",
"given",
"layout",
"which",
"are",
"older",
"than",
"n",
"days",
"relative",
"to",
"time",
"now",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/aliases/aliases.go#L41-L59 |
145,195 | tj/go-elastic | aliases/aliases.go | RemoveOlderThan | func (i Indexes) RemoveOlderThan(layout, alias string, n int, now time.Time) []byte {
var actions Actions
for index := range i.MatchingOlderThan(layout, n, now) {
action := Action{}
action.Remove.Alias = alias
action.Remove.Index = index
actions.Actions = append(actions.Actions, action)
}
if len(actions.A... | go | func (i Indexes) RemoveOlderThan(layout, alias string, n int, now time.Time) []byte {
var actions Actions
for index := range i.MatchingOlderThan(layout, n, now) {
action := Action{}
action.Remove.Alias = alias
action.Remove.Index = index
actions.Actions = append(actions.Actions, action)
}
if len(actions.A... | [
"func",
"(",
"i",
"Indexes",
")",
"RemoveOlderThan",
"(",
"layout",
",",
"alias",
"string",
",",
"n",
"int",
",",
"now",
"time",
".",
"Time",
")",
"[",
"]",
"byte",
"{",
"var",
"actions",
"Actions",
"\n\n",
"for",
"index",
":=",
"range",
"i",
".",
... | // RemoveOlderThan returns json for removing index from `alias` matching the given `layout`
// which are older than `n` days relative to `now`. | [
"RemoveOlderThan",
"returns",
"json",
"for",
"removing",
"index",
"from",
"alias",
"matching",
"the",
"given",
"layout",
"which",
"are",
"older",
"than",
"n",
"days",
"relative",
"to",
"now",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/aliases/aliases.go#L76-L92 |
145,196 | tj/go-elastic | elastic.go | SetAWSCredentials | func (c *Client) SetAWSCredentials(credentials AWSCredentials) {
c.awsCredentials = &credentials
c.authCredentials = nil
} | go | func (c *Client) SetAWSCredentials(credentials AWSCredentials) {
c.awsCredentials = &credentials
c.authCredentials = nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetAWSCredentials",
"(",
"credentials",
"AWSCredentials",
")",
"{",
"c",
".",
"awsCredentials",
"=",
"&",
"credentials",
"\n",
"c",
".",
"authCredentials",
"=",
"nil",
"\n",
"}"
] | // SetAWSCredentials for connection to an AWS ElasticSearch instance | [
"SetAWSCredentials",
"for",
"connection",
"to",
"an",
"AWS",
"ElasticSearch",
"instance"
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L74-L77 |
145,197 | tj/go-elastic | elastic.go | Bulk | func (c *Client) Bulk(body io.Reader) error {
return c.Request("POST", "/_bulk", body, nil)
} | go | func (c *Client) Bulk(body io.Reader) error {
return c.Request("POST", "/_bulk", body, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Bulk",
"(",
"body",
"io",
".",
"Reader",
")",
"error",
"{",
"return",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"body",
",",
"nil",
")",
"\n",
"}"
] | // Bulk POST request with the given body. | [
"Bulk",
"POST",
"request",
"with",
"the",
"given",
"body",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L89-L91 |
145,198 | tj/go-elastic | elastic.go | BulkResponse | func (c *Client) BulkResponse(body io.Reader) (res *BulkResponse, err error) {
res = new(BulkResponse)
err = c.Request("POST", "/_bulk", body, res)
return
} | go | func (c *Client) BulkResponse(body io.Reader) (res *BulkResponse, err error) {
res = new(BulkResponse)
err = c.Request("POST", "/_bulk", body, res)
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"BulkResponse",
"(",
"body",
"io",
".",
"Reader",
")",
"(",
"res",
"*",
"BulkResponse",
",",
"err",
"error",
")",
"{",
"res",
"=",
"new",
"(",
"BulkResponse",
")",
"\n",
"err",
"=",
"c",
".",
"Request",
"(",
... | // BulkResponse POST request with the given body and return response. | [
"BulkResponse",
"POST",
"request",
"with",
"the",
"given",
"body",
"and",
"return",
"response",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L94-L98 |
145,199 | tj/go-elastic | elastic.go | DeleteIndex | func (c *Client) DeleteIndex(index string) error {
return c.Request("DELETE", fmt.Sprintf("/%s", index), nil, nil)
} | go | func (c *Client) DeleteIndex(index string) error {
return c.Request("DELETE", fmt.Sprintf("/%s", index), nil, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteIndex",
"(",
"index",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"index",
")",
",",
"nil",
",",
"nil",
")",
"\n",
"... | // DeleteIndex deletes `index`. | [
"DeleteIndex",
"deletes",
"index",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L101-L103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.