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
147,000
karrick/goswarm
timedValue.go
StatusAt
func (tv *TimedValue) StatusAt(when time.Time) TimedValueStatus { if tv.IsExpiredAt(when) { return Expired } if tv.IsStaleAt(when) { return Stale } return Fresh }
go
func (tv *TimedValue) StatusAt(when time.Time) TimedValueStatus { if tv.IsExpiredAt(when) { return Expired } if tv.IsStaleAt(when) { return Stale } return Fresh }
[ "func", "(", "tv", "*", "TimedValue", ")", "StatusAt", "(", "when", "time", ".", "Time", ")", "TimedValueStatus", "{", "if", "tv", ".", "IsExpiredAt", "(", "when", ")", "{", "return", "Expired", "\n", "}", "\n", "if", "tv", ".", "IsStaleAt", "(", "wh...
// StatusAt returns Fresh, Stale, or Exired, depending on the status of the // TimedValue item at the specified time.
[ "StatusAt", "returns", "Fresh", "Stale", "or", "Exired", "depending", "on", "the", "status", "of", "the", "TimedValue", "item", "at", "the", "specified", "time", "." ]
23ee89c82398e9cd1690e2ef1183eab732869ed3
https://github.com/karrick/goswarm/blob/23ee89c82398e9cd1690e2ef1183eab732869ed3/timedValue.go#L109-L117
147,001
karrick/goswarm
timedValue.go
newTimedValue
func newTimedValue(value interface{}, err error, staleDuration, expiryDuration time.Duration) *TimedValue { switch val := value.(type) { case TimedValue: if val.Created.IsZero() { val.Created = time.Now() } return &val case *TimedValue: if val.Created.IsZero() { val.Created = time.Now() } return va...
go
func newTimedValue(value interface{}, err error, staleDuration, expiryDuration time.Duration) *TimedValue { switch val := value.(type) { case TimedValue: if val.Created.IsZero() { val.Created = time.Now() } return &val case *TimedValue: if val.Created.IsZero() { val.Created = time.Now() } return va...
[ "func", "newTimedValue", "(", "value", "interface", "{", "}", ",", "err", "error", ",", "staleDuration", ",", "expiryDuration", "time", ".", "Duration", ")", "*", "TimedValue", "{", "switch", "val", ":=", "value", ".", "(", "type", ")", "{", "case", "Tim...
// helper function to wrap non TimedValue items as TimedValue items.
[ "helper", "function", "to", "wrap", "non", "TimedValue", "items", "as", "TimedValue", "items", "." ]
23ee89c82398e9cd1690e2ef1183eab732869ed3
https://github.com/karrick/goswarm/blob/23ee89c82398e9cd1690e2ef1183eab732869ed3/timedValue.go#L120-L146
147,002
mailgun/scroll
handler.go
DecodeParams
func DecodeParams(src map[string]string) map[string]string { results := make(map[string]string, len(src)) for key, param := range src { encoded, err := url.QueryUnescape(param) if err != nil { encoded = param } results[key] = encoded } return results }
go
func DecodeParams(src map[string]string) map[string]string { results := make(map[string]string, len(src)) for key, param := range src { encoded, err := url.QueryUnescape(param) if err != nil { encoded = param } results[key] = encoded } return results }
[ "func", "DecodeParams", "(", "src", "map", "[", "string", "]", "string", ")", "map", "[", "string", "]", "string", "{", "results", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "src", ")", ")", "\n", "for", "key", ",", ...
// Given a map of parameters url decode each parameter
[ "Given", "a", "map", "of", "parameters", "url", "decode", "each", "parameter" ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/handler.go#L61-L71
147,003
mailgun/scroll
handler.go
MakeHandlerWithBody
func MakeHandlerWithBody(app *App, fn HandlerWithBodyFunc, spec Spec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var response interface{} var body []byte var status int var err error start := time.Now() if err = parseForm(r); err != nil { err = fmt.Errorf("Failed to parse ...
go
func MakeHandlerWithBody(app *App, fn HandlerWithBodyFunc, spec Spec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var response interface{} var body []byte var status int var err error start := time.Now() if err = parseForm(r); err != nil { err = fmt.Errorf("Failed to parse ...
[ "func", "MakeHandlerWithBody", "(", "app", "*", "App", ",", "fn", "HandlerWithBodyFunc", ",", "spec", "Spec", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{"...
// Make a handler out of HandlerWithBodyFunc, just like regular MakeHandler function.
[ "Make", "a", "handler", "out", "of", "HandlerWithBodyFunc", "just", "like", "regular", "MakeHandler", "function", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/handler.go#L121-L158
147,004
mailgun/scroll
handler.go
ReplyError
func ReplyError(w http.ResponseWriter, err error) { response, status := responseAndStatusFor(err) Reply(w, response, status) }
go
func ReplyError(w http.ResponseWriter, err error) { response, status := responseAndStatusFor(err) Reply(w, response, status) }
[ "func", "ReplyError", "(", "w", "http", ".", "ResponseWriter", ",", "err", "error", ")", "{", "response", ",", "status", ":=", "responseAndStatusFor", "(", "err", ")", "\n", "Reply", "(", "w", ",", "response", ",", "status", ")", "\n", "}" ]
// ReplyError converts registered error into HTTP response code and writes it back.
[ "ReplyError", "converts", "registered", "error", "into", "HTTP", "response", "code", "and", "writes", "it", "back", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/handler.go#L180-L183
147,005
mailgun/scroll
handler.go
ReplyInternalError
func ReplyInternalError(w http.ResponseWriter, message string) { LogRequest(nil, 500, time.Nanosecond, errors.New(message)) Reply(w, Response{"message": message}, http.StatusInternalServerError) }
go
func ReplyInternalError(w http.ResponseWriter, message string) { LogRequest(nil, 500, time.Nanosecond, errors.New(message)) Reply(w, Response{"message": message}, http.StatusInternalServerError) }
[ "func", "ReplyInternalError", "(", "w", "http", ".", "ResponseWriter", ",", "message", "string", ")", "{", "LogRequest", "(", "nil", ",", "500", ",", "time", ".", "Nanosecond", ",", "errors", ".", "New", "(", "message", ")", ")", "\n", "Reply", "(", "w...
// ReplyInternalError logs the error message and replies with a 500 status code.
[ "ReplyInternalError", "logs", "the", "error", "message", "and", "replies", "with", "a", "500", "status", "code", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/handler.go#L186-L189
147,006
mailgun/scroll
handler.go
GetVarSafe
func GetVarSafe(r *http.Request, variableName string, allowSet AllowSet) (string, error) { vars := mux.Vars(r) variableValue, ok := vars[variableName] if !ok { return "", MissingFieldError{variableName} } err := allowSet.IsSafe(variableValue) if err != nil { return "", UnsafeFieldError{variableName, err.Err...
go
func GetVarSafe(r *http.Request, variableName string, allowSet AllowSet) (string, error) { vars := mux.Vars(r) variableValue, ok := vars[variableName] if !ok { return "", MissingFieldError{variableName} } err := allowSet.IsSafe(variableValue) if err != nil { return "", UnsafeFieldError{variableName, err.Err...
[ "func", "GetVarSafe", "(", "r", "*", "http", ".", "Request", ",", "variableName", "string", ",", "allowSet", "AllowSet", ")", "(", "string", ",", "error", ")", "{", "vars", ":=", "mux", ".", "Vars", "(", "r", ")", "\n", "variableValue", ",", "ok", ":...
// GetVarSafe is a helper function that returns the requested variable from URI with allowSet // providing input sanitization. If an error occurs, returns either a `MissingFieldError` // or an `UnsafeFieldError`.
[ "GetVarSafe", "is", "a", "helper", "function", "that", "returns", "the", "requested", "variable", "from", "URI", "with", "allowSet", "providing", "input", "sanitization", ".", "If", "an", "error", "occurs", "returns", "either", "a", "MissingFieldError", "or", "a...
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/handler.go#L194-L208
147,007
mailgun/scroll
handler.go
parseForm
func parseForm(r *http.Request) error { if isMultipart(r) == true { return r.ParseMultipartForm(0) } else { return r.ParseForm() } }
go
func parseForm(r *http.Request) error { if isMultipart(r) == true { return r.ParseMultipartForm(0) } else { return r.ParseForm() } }
[ "func", "parseForm", "(", "r", "*", "http", ".", "Request", ")", "error", "{", "if", "isMultipart", "(", "r", ")", "==", "true", "{", "return", "r", ".", "ParseMultipartForm", "(", "0", ")", "\n", "}", "else", "{", "return", "r", ".", "ParseForm", ...
// Parse the request data based on its content type.
[ "Parse", "the", "request", "data", "based", "on", "its", "content", "type", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/handler.go#L211-L217
147,008
mailgun/scroll
app.go
NewAppWithConfig
func NewAppWithConfig(config AppConfig) (*App, error) { if err := applyDefaults(&config); err != nil { return nil, errors.Wrap(err, "while applying config defaults") } // Connect to etcd and fetch registration config if err := fetchEtcdConfig(&config); err != nil { return nil, errors.Wrap(err, "while fetching...
go
func NewAppWithConfig(config AppConfig) (*App, error) { if err := applyDefaults(&config); err != nil { return nil, errors.Wrap(err, "while applying config defaults") } // Connect to etcd and fetch registration config if err := fetchEtcdConfig(&config); err != nil { return nil, errors.Wrap(err, "while fetching...
[ "func", "NewAppWithConfig", "(", "config", "AppConfig", ")", "(", "*", "App", ",", "error", ")", "{", "if", "err", ":=", "applyDefaults", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ...
// Create a new app with the provided configuration.
[ "Create", "a", "new", "app", "with", "the", "provided", "configuration", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/app.go#L80-L114
147,009
mailgun/scroll
app.go
AddHandler
func (app *App) AddHandler(spec Spec) error { var handler http.HandlerFunc // make a handler depending on the function provided in the spec if spec.RawHandler != nil { handler = spec.RawHandler } else if spec.Handler != nil { handler = MakeHandler(app, spec.Handler, spec) } else if spec.HandlerWithBody != nil...
go
func (app *App) AddHandler(spec Spec) error { var handler http.HandlerFunc // make a handler depending on the function provided in the spec if spec.RawHandler != nil { handler = spec.RawHandler } else if spec.Handler != nil { handler = MakeHandler(app, spec.Handler, spec) } else if spec.HandlerWithBody != nil...
[ "func", "(", "app", "*", "App", ")", "AddHandler", "(", "spec", "Spec", ")", "error", "{", "var", "handler", "http", ".", "HandlerFunc", "\n\n", "// make a handler depending on the function provided in the spec", "if", "spec", ".", "RawHandler", "!=", "nil", "{", ...
// Register a handler function. // // If vulcan registration is enabled in the both app config and handler spec, // the handler will be registered in the local etcd instance.
[ "Register", "a", "handler", "function", ".", "If", "vulcan", "registration", "is", "enabled", "in", "the", "both", "app", "config", "and", "handler", "spec", "the", "handler", "will", "be", "registered", "in", "the", "local", "etcd", "instance", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/app.go#L120-L145
147,010
mailgun/scroll
app.go
SetNotFoundHandler
func (app *App) SetNotFoundHandler(fn http.HandlerFunc) { app.router.NotFoundHandler = fn }
go
func (app *App) SetNotFoundHandler(fn http.HandlerFunc) { app.router.NotFoundHandler = fn }
[ "func", "(", "app", "*", "App", ")", "SetNotFoundHandler", "(", "fn", "http", ".", "HandlerFunc", ")", "{", "app", ".", "router", ".", "NotFoundHandler", "=", "fn", "\n", "}" ]
// SetNotFoundHandler sets the handler for the case when URL can not be matched by the router.
[ "SetNotFoundHandler", "sets", "the", "handler", "for", "the", "case", "when", "URL", "can", "not", "be", "matched", "by", "the", "router", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/app.go#L153-L155
147,011
mailgun/scroll
app.go
IsPublicRequest
func (app *App) IsPublicRequest(request *http.Request) bool { return request.Host == app.Config.PublicAPIHost }
go
func (app *App) IsPublicRequest(request *http.Request) bool { return request.Host == app.Config.PublicAPIHost }
[ "func", "(", "app", "*", "App", ")", "IsPublicRequest", "(", "request", "*", "http", ".", "Request", ")", "bool", "{", "return", "request", ".", "Host", "==", "app", ".", "Config", ".", "PublicAPIHost", "\n", "}" ]
// IsPublicRequest determines whether the provided request came through the public HTTP endpoint.
[ "IsPublicRequest", "determines", "whether", "the", "provided", "request", "came", "through", "the", "public", "HTTP", "endpoint", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/app.go#L158-L160
147,012
mailgun/scroll
app.go
registerFrontend
func (app *App) registerFrontend(methods []string, path string, scope Scope, middlewares []vulcand.Middleware) error { host, err := app.apiHostForScope(scope) if err != nil { return err } app.vulcandReg.AddFrontend(host, path, methods, middlewares) return nil }
go
func (app *App) registerFrontend(methods []string, path string, scope Scope, middlewares []vulcand.Middleware) error { host, err := app.apiHostForScope(scope) if err != nil { return err } app.vulcandReg.AddFrontend(host, path, methods, middlewares) return nil }
[ "func", "(", "app", "*", "App", ")", "registerFrontend", "(", "methods", "[", "]", "string", ",", "path", "string", ",", "scope", "Scope", ",", "middlewares", "[", "]", "vulcand", ".", "Middleware", ")", "error", "{", "host", ",", "err", ":=", "app", ...
// registerLocation is a helper for registering handlers in vulcan.
[ "registerLocation", "is", "a", "helper", "for", "registering", "handlers", "in", "vulcan", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/app.go#L233-L240
147,013
mailgun/scroll
app.go
apiHostForScope
func (app *App) apiHostForScope(scope Scope) (string, error) { if scope == ScopePublic { return app.Config.PublicAPIHost, nil } else if scope == ScopeProtected { return app.Config.ProtectedAPIHost, nil } else { return "", fmt.Errorf("unknown scope value: %v", scope) } }
go
func (app *App) apiHostForScope(scope Scope) (string, error) { if scope == ScopePublic { return app.Config.PublicAPIHost, nil } else if scope == ScopeProtected { return app.Config.ProtectedAPIHost, nil } else { return "", fmt.Errorf("unknown scope value: %v", scope) } }
[ "func", "(", "app", "*", "App", ")", "apiHostForScope", "(", "scope", "Scope", ")", "(", "string", ",", "error", ")", "{", "if", "scope", "==", "ScopePublic", "{", "return", "app", ".", "Config", ".", "PublicAPIHost", ",", "nil", "\n", "}", "else", "...
// apiHostForScope is a helper that returns an appropriate API hostname for a provided scope.
[ "apiHostForScope", "is", "a", "helper", "that", "returns", "an", "appropriate", "API", "hostname", "for", "a", "provided", "scope", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/app.go#L243-L251
147,014
mailgun/scroll
vulcand/backend.go
makeEndpointURL
func makeEndpointURL(listenIP string, listenPort int) (string, error) { if listenIP != "0.0.0.0" { return fmt.Sprintf("http://%v:%v", listenIP, listenPort), nil } privateIPs, err := iptools.GetPrivateHostIPs() if err != nil { return "", fmt.Errorf("failed to obtain host's private IPs: %v", err) } if len(priva...
go
func makeEndpointURL(listenIP string, listenPort int) (string, error) { if listenIP != "0.0.0.0" { return fmt.Sprintf("http://%v:%v", listenIP, listenPort), nil } privateIPs, err := iptools.GetPrivateHostIPs() if err != nil { return "", fmt.Errorf("failed to obtain host's private IPs: %v", err) } if len(priva...
[ "func", "makeEndpointURL", "(", "listenIP", "string", ",", "listenPort", "int", ")", "(", "string", ",", "error", ")", "{", "if", "listenIP", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "listenIP", ",", "listenPort", "...
// makeEndpointURL constructs a URL by determining the private IP address of // the host.
[ "makeEndpointURL", "constructs", "a", "URL", "by", "determining", "the", "private", "IP", "address", "of", "the", "host", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/vulcand/backend.go#L56-L68
147,015
lytics/go-lytics
segment.go
GetSegmentCollectionList
func (l *Client) GetSegmentCollectionList() ([]SegmentCollection, error) { res := ApiResp{} data := []SegmentCollection{} err := l.Get(parseLyticsURL(segmentCollectionListEndpoint, nil), nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
go
func (l *Client) GetSegmentCollectionList() ([]SegmentCollection, error) { res := ApiResp{} data := []SegmentCollection{} err := l.Get(parseLyticsURL(segmentCollectionListEndpoint, nil), nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
[ "func", "(", "l", "*", "Client", ")", "GetSegmentCollectionList", "(", ")", "(", "[", "]", "SegmentCollection", ",", "error", ")", "{", "res", ":=", "ApiResp", "{", "}", "\n", "data", ":=", "[", "]", "SegmentCollection", "{", "}", "\n\n", "err", ":=", ...
// GetSegmentCollectionList returns a list of all segment // collections for an account
[ "GetSegmentCollectionList", "returns", "a", "list", "of", "all", "segment", "collections", "for", "an", "account" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/segment.go#L282-L292
147,016
mailgun/scroll
fields.go
GetStringField
func GetStringField(r *http.Request, fieldName string) (string, error) { if _, ok := r.Form[fieldName]; !ok { return "", MissingFieldError{fieldName} } return r.FormValue(fieldName), nil }
go
func GetStringField(r *http.Request, fieldName string) (string, error) { if _, ok := r.Form[fieldName]; !ok { return "", MissingFieldError{fieldName} } return r.FormValue(fieldName), nil }
[ "func", "GetStringField", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ")", "(", "string", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "r", ".", "Form", "[", "fieldName", "]", ";", "!", "ok", "{", "return", "\"", "\"...
// Retrieve a POST request field as a string. // Returns `MissingFieldError` if requested field is missing.
[ "Retrieve", "a", "POST", "request", "field", "as", "a", "string", ".", "Returns", "MissingFieldError", "if", "requested", "field", "is", "missing", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L14-L19
147,017
mailgun/scroll
fields.go
GetStringFieldSafe
func GetStringFieldSafe(r *http.Request, fieldName string, allowSet AllowSet) (string, error) { if _, ok := r.Form[fieldName]; !ok { return "", MissingFieldError{fieldName} } fieldValue := r.FormValue(fieldName) err := allowSet.IsSafe(fieldValue) if err != nil { return "", UnsafeFieldError{fieldName, err.Erro...
go
func GetStringFieldSafe(r *http.Request, fieldName string, allowSet AllowSet) (string, error) { if _, ok := r.Form[fieldName]; !ok { return "", MissingFieldError{fieldName} } fieldValue := r.FormValue(fieldName) err := allowSet.IsSafe(fieldValue) if err != nil { return "", UnsafeFieldError{fieldName, err.Erro...
[ "func", "GetStringFieldSafe", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ",", "allowSet", "AllowSet", ")", "(", "string", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "r", ".", "Form", "[", "fieldName", "]", ";", "!", ...
// Retrieves requested field as a string, allowSet provides input sanitization. If an // error occurs, returns either a `MissingFieldError` or an `UnsafeFieldError`.
[ "Retrieves", "requested", "field", "as", "a", "string", "allowSet", "provides", "input", "sanitization", ".", "If", "an", "error", "occurs", "returns", "either", "a", "MissingFieldError", "or", "an", "UnsafeFieldError", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L23-L35
147,018
mailgun/scroll
fields.go
GetStringFieldWithDefault
func GetStringFieldWithDefault(r *http.Request, fieldName, defaultValue string) string { if fieldValue, err := GetStringField(r, fieldName); err == nil { return fieldValue } return defaultValue }
go
func GetStringFieldWithDefault(r *http.Request, fieldName, defaultValue string) string { if fieldValue, err := GetStringField(r, fieldName); err == nil { return fieldValue } return defaultValue }
[ "func", "GetStringFieldWithDefault", "(", "r", "*", "http", ".", "Request", ",", "fieldName", ",", "defaultValue", "string", ")", "string", "{", "if", "fieldValue", ",", "err", ":=", "GetStringField", "(", "r", ",", "fieldName", ")", ";", "err", "==", "nil...
// Retrieve a POST request field as a string. // If the requested field is missing, returns provided default value.
[ "Retrieve", "a", "POST", "request", "field", "as", "a", "string", ".", "If", "the", "requested", "field", "is", "missing", "returns", "provided", "default", "value", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L39-L44
147,019
mailgun/scroll
fields.go
GetMultipleFields
func GetMultipleFields(r *http.Request, fieldName string) ([]string, error) { var values = []string{} for field, value := range r.Form { // Strip the square brackets. if multiParamRegex.ReplaceAllString(field, "$1") == fieldName { values = append(values, value...) } } if len(values) == 0 { return []str...
go
func GetMultipleFields(r *http.Request, fieldName string) ([]string, error) { var values = []string{} for field, value := range r.Form { // Strip the square brackets. if multiParamRegex.ReplaceAllString(field, "$1") == fieldName { values = append(values, value...) } } if len(values) == 0 { return []str...
[ "func", "GetMultipleFields", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "values", "=", "[", "]", "string", "{", "}", "\n\n", "for", "field", ",", "value", ":=", "r...
// Retrieve fields with the same name as an array of strings.
[ "Retrieve", "fields", "with", "the", "same", "name", "as", "an", "array", "of", "strings", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L56-L71
147,020
mailgun/scroll
fields.go
GetIntField
func GetIntField(r *http.Request, fieldName string) (int, error) { stringField, err := GetStringField(r, fieldName) if err != nil { return 0, err } intField, err := strconv.Atoi(stringField) if err != nil { return 0, InvalidFormatError{fieldName, stringField} } return intField, nil }
go
func GetIntField(r *http.Request, fieldName string) (int, error) { stringField, err := GetStringField(r, fieldName) if err != nil { return 0, err } intField, err := strconv.Atoi(stringField) if err != nil { return 0, InvalidFormatError{fieldName, stringField} } return intField, nil }
[ "func", "GetIntField", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ")", "(", "int", ",", "error", ")", "{", "stringField", ",", "err", ":=", "GetStringField", "(", "r", ",", "fieldName", ")", "\n", "if", "err", "!=", "nil", "{"...
// Retrieve a POST request field as an integer. // Returns `MissingFieldError` if requested field is missing.
[ "Retrieve", "a", "POST", "request", "field", "as", "an", "integer", ".", "Returns", "MissingFieldError", "if", "requested", "field", "is", "missing", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L75-L85
147,021
mailgun/scroll
fields.go
GetFloatField
func GetFloatField(r *http.Request, fieldName string) (float64, error) { stringField, err := GetStringField(r, fieldName) if err != nil { return 0, err } floatField, err := strconv.ParseFloat(stringField, 64) if err != nil { return 0, InvalidFormatError{fieldName, stringField} } return floatField, nil }
go
func GetFloatField(r *http.Request, fieldName string) (float64, error) { stringField, err := GetStringField(r, fieldName) if err != nil { return 0, err } floatField, err := strconv.ParseFloat(stringField, 64) if err != nil { return 0, InvalidFormatError{fieldName, stringField} } return floatField, nil }
[ "func", "GetFloatField", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ")", "(", "float64", ",", "error", ")", "{", "stringField", ",", "err", ":=", "GetStringField", "(", "r", ",", "fieldName", ")", "\n", "if", "err", "!=", "nil",...
// Retrieve a request field as a float. // Returns `MissingFieldError` if requested field is missing.
[ "Retrieve", "a", "request", "field", "as", "a", "float", ".", "Returns", "MissingFieldError", "if", "requested", "field", "is", "missing", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L89-L99
147,022
mailgun/scroll
fields.go
GetTimestampField
func GetTimestampField(r *http.Request, fieldName string) (time.Time, error) { if _, ok := r.Form[fieldName]; !ok { return time.Now(), MissingFieldError{fieldName} } parsedTime, err := time.Parse(time.RFC1123, r.FormValue(fieldName)) if err != nil { // Attempt to parse with offset timezone before giving up pa...
go
func GetTimestampField(r *http.Request, fieldName string) (time.Time, error) { if _, ok := r.Form[fieldName]; !ok { return time.Now(), MissingFieldError{fieldName} } parsedTime, err := time.Parse(time.RFC1123, r.FormValue(fieldName)) if err != nil { // Attempt to parse with offset timezone before giving up pa...
[ "func", "GetTimestampField", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "r", ".", "Form", "[", "fieldName", "]", ";", "!", "ok", "{", "retu...
// Helper method to retrieve an optional timestamp from POST request field. // If no timestamp provided, returns current time. // Returns `InvalidFormatError` if provided timestamp can't be parsed.
[ "Helper", "method", "to", "retrieve", "an", "optional", "timestamp", "from", "POST", "request", "field", ".", "If", "no", "timestamp", "provided", "returns", "current", "time", ".", "Returns", "InvalidFormatError", "if", "provided", "timestamp", "can", "t", "be"...
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L104-L118
147,023
mailgun/scroll
fields.go
GetDurationField
func GetDurationField(r *http.Request, fieldName string) (time.Duration, error) { s, err := GetStringField(r, fieldName) if err != nil { return 0, err } d, err := time.ParseDuration(s) if err != nil || d < 0 { return 0, InvalidFormatError{fieldName, s} } return d, nil }
go
func GetDurationField(r *http.Request, fieldName string) (time.Duration, error) { s, err := GetStringField(r, fieldName) if err != nil { return 0, err } d, err := time.ParseDuration(s) if err != nil || d < 0 { return 0, InvalidFormatError{fieldName, s} } return d, nil }
[ "func", "GetDurationField", "(", "r", "*", "http", ".", "Request", ",", "fieldName", "string", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "s", ",", "err", ":=", "GetStringField", "(", "r", ",", "fieldName", ")", "\n", "if", "err", "!=...
// GetDurationField retrieves a request field as a time.Duration, which is not allowed to be negative. // Returns `MissingFieldError` if requested field is missing.
[ "GetDurationField", "retrieves", "a", "request", "field", "as", "a", "time", ".", "Duration", "which", "is", "not", "allowed", "to", "be", "negative", ".", "Returns", "MissingFieldError", "if", "requested", "field", "is", "missing", "." ]
e0f8b9b8e496a675abcb30d8abba7517a07f73d2
https://github.com/mailgun/scroll/blob/e0f8b9b8e496a675abcb30d8abba7517a07f73d2/fields.go#L122-L132
147,024
lytics/go-lytics
campaign.go
GetCampaign
func (l *Client) GetCampaign(id string) (Campaign, error) { res := ApiResp{} data := Campaign{} // make the request err := l.Get(parseLyticsURL(campaignEndpoint, map[string]string{"id": id}), nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
go
func (l *Client) GetCampaign(id string) (Campaign, error) { res := ApiResp{} data := Campaign{} // make the request err := l.Get(parseLyticsURL(campaignEndpoint, map[string]string{"id": id}), nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
[ "func", "(", "l", "*", "Client", ")", "GetCampaign", "(", "id", "string", ")", "(", "Campaign", ",", "error", ")", "{", "res", ":=", "ApiResp", "{", "}", "\n", "data", ":=", "Campaign", "{", "}", "\n\n", "// make the request", "err", ":=", "l", ".", ...
// GetCampaign returns the details for a single personalization campaign
[ "GetCampaign", "returns", "the", "details", "for", "a", "single", "personalization", "campaign" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/campaign.go#L54-L65
147,025
lytics/go-lytics
campaign.go
GetVariation
func (l *Client) GetVariation(id string) (Variation, error) { res := ApiResp{} data := Variation{} // make the request err := l.Get(parseLyticsURL(variationEndpoint, map[string]string{"id": id}), nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
go
func (l *Client) GetVariation(id string) (Variation, error) { res := ApiResp{} data := Variation{} // make the request err := l.Get(parseLyticsURL(variationEndpoint, map[string]string{"id": id}), nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
[ "func", "(", "l", "*", "Client", ")", "GetVariation", "(", "id", "string", ")", "(", "Variation", ",", "error", ")", "{", "res", ":=", "ApiResp", "{", "}", "\n", "data", ":=", "Variation", "{", "}", "\n\n", "// make the request", "err", ":=", "l", "....
// GetVariation returns the details for a single campaign variation
[ "GetVariation", "returns", "the", "details", "for", "a", "single", "campaign", "variation" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/campaign.go#L89-L100
147,026
lytics/go-lytics
campaign.go
GetVariationList
func (l *Client) GetVariationList() ([]Variation, error) { res := ApiResp{} data := []Variation{} // make the request err := l.Get(variationListEndpoint, nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
go
func (l *Client) GetVariationList() ([]Variation, error) { res := ApiResp{} data := []Variation{} // make the request err := l.Get(variationListEndpoint, nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
[ "func", "(", "l", "*", "Client", ")", "GetVariationList", "(", ")", "(", "[", "]", "Variation", ",", "error", ")", "{", "res", ":=", "ApiResp", "{", "}", "\n", "data", ":=", "[", "]", "Variation", "{", "}", "\n\n", "// make the request", "err", ":=",...
// GetVariationList returns the details for all variations of all campaigns in the account
[ "GetVariationList", "returns", "the", "details", "for", "all", "variations", "of", "all", "campaigns", "in", "the", "account" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/campaign.go#L103-L114
147,027
lytics/go-lytics
content.go
GetTopicRollups
func (l *Client) GetTopicRollups() ([]TopicRollup, error) { res := ApiResp{} data := []TopicRollup{} err := l.Get(rollupListEndpoint, nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
go
func (l *Client) GetTopicRollups() ([]TopicRollup, error) { res := ApiResp{} data := []TopicRollup{} err := l.Get(rollupListEndpoint, nil, nil, &res, &data) if err != nil { return data, err } return data, nil }
[ "func", "(", "l", "*", "Client", ")", "GetTopicRollups", "(", ")", "(", "[", "]", "TopicRollup", ",", "error", ")", "{", "res", ":=", "ApiResp", "{", "}", "\n", "data", ":=", "[", "]", "TopicRollup", "{", "}", "\n\n", "err", ":=", "l", ".", "Get"...
// GetTopicRollups returns a list of topic rollups for an account.
[ "GetTopicRollups", "returns", "a", "list", "of", "topic", "rollups", "for", "an", "account", "." ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/content.go#L295-L305
147,028
lytics/go-lytics
lytics.go
NewLytics
func NewLytics(apiKey string, httpclient *http.Client) *Client { l := Client{ baseURL: apiBase, } if httpclient != nil { l.client = httpclient } else { l.client = http.DefaultClient } // set the apikey if not null l.apiKey = apiKey return &l }
go
func NewLytics(apiKey string, httpclient *http.Client) *Client { l := Client{ baseURL: apiBase, } if httpclient != nil { l.client = httpclient } else { l.client = http.DefaultClient } // set the apikey if not null l.apiKey = apiKey return &l }
[ "func", "NewLytics", "(", "apiKey", "string", ",", "httpclient", "*", "http", ".", "Client", ")", "*", "Client", "{", "l", ":=", "Client", "{", "baseURL", ":", "apiBase", ",", "}", "\n\n", "if", "httpclient", "!=", "nil", "{", "l", ".", "client", "="...
// NewLytics creates a new client instance. This contains the segment pager, segment details // and maintains all core data used throughout this SDK
[ "NewLytics", "creates", "a", "new", "client", "instance", ".", "This", "contains", "the", "segment", "pager", "segment", "details", "and", "maintains", "all", "core", "data", "used", "throughout", "this", "SDK" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L72-L87
147,029
lytics/go-lytics
lytics.go
PrepUrl
func (l *Client) PrepUrl(endpoint string, params url.Values, dataKey bool) (string, error) { // parse the url into native http.URL url, err := url.Parse(fmt.Sprintf("%s/%s", l.BaseUrl(), endpoint)) if err != nil { return "", err } values := url.Query() // add the api key if params != nil { for key, val := ...
go
func (l *Client) PrepUrl(endpoint string, params url.Values, dataKey bool) (string, error) { // parse the url into native http.URL url, err := url.Parse(fmt.Sprintf("%s/%s", l.BaseUrl(), endpoint)) if err != nil { return "", err } values := url.Query() // add the api key if params != nil { for key, val := ...
[ "func", "(", "l", "*", "Client", ")", "PrepUrl", "(", "endpoint", "string", ",", "params", "url", ".", "Values", ",", "dataKey", "bool", ")", "(", "string", ",", "error", ")", "{", "// parse the url into native http.URL", "url", ",", "err", ":=", "url", ...
// PrepUrl handles the parsing and setup for all api calls. The encoded url string is passed // along with a set of param. Params are looped and injected into the master url
[ "PrepUrl", "handles", "the", "parsing", "and", "setup", "for", "all", "api", "calls", ".", "The", "encoded", "url", "string", "is", "passed", "along", "with", "a", "set", "of", "param", ".", "Params", "are", "looped", "and", "injected", "into", "the", "m...
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L117-L147
147,030
lytics/go-lytics
lytics.go
Do
func (l *Client) Do(r *http.Request, response, data interface{}) error { // make the request res, err := l.client.Do(r) if err != nil { return err } defer res.Body.Close() // get the response b, err := ioutil.ReadAll(res.Body) if err != nil { return err } // if we have some struct to unmarshal body int...
go
func (l *Client) Do(r *http.Request, response, data interface{}) error { // make the request res, err := l.client.Do(r) if err != nil { return err } defer res.Body.Close() // get the response b, err := ioutil.ReadAll(res.Body) if err != nil { return err } // if we have some struct to unmarshal body int...
[ "func", "(", "l", "*", "Client", ")", "Do", "(", "r", "*", "http", ".", "Request", ",", "response", ",", "data", "interface", "{", "}", ")", "error", "{", "// make the request", "res", ",", "err", ":=", "l", ".", "client", ".", "Do", "(", "r", ")...
// Do handles executing all http requests for the SDK. Takes a httpRequest and parses // the response into the master api struct as well as a specific data type.
[ "Do", "handles", "executing", "all", "http", "requests", "for", "the", "SDK", ".", "Takes", "a", "httpRequest", "and", "parses", "the", "response", "into", "the", "master", "api", "struct", "as", "well", "as", "a", "specific", "data", "type", "." ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L151-L187
147,031
lytics/go-lytics
lytics.go
Get
func (l *Client) Get(endpoint string, params url.Values, body interface{}, response, data interface{}) error { method := "GET" // get the formatted endpoint url path, err := l.PrepUrl(endpoint, params, false) if err != nil { return err } payload, err := prepRequestBody(body) if err != nil { return err } ...
go
func (l *Client) Get(endpoint string, params url.Values, body interface{}, response, data interface{}) error { method := "GET" // get the formatted endpoint url path, err := l.PrepUrl(endpoint, params, false) if err != nil { return err } payload, err := prepRequestBody(body) if err != nil { return err } ...
[ "func", "(", "l", "*", "Client", ")", "Get", "(", "endpoint", "string", ",", "params", "url", ".", "Values", ",", "body", "interface", "{", "}", ",", "response", ",", "data", "interface", "{", "}", ")", "error", "{", "method", ":=", "\"", "\"", "\n...
// Get prepares a get request and then executes using the Do method
[ "Get", "prepares", "a", "get", "request", "and", "then", "executes", "using", "the", "Do", "method" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L190-L214
147,032
lytics/go-lytics
lytics.go
Post
func (l *Client) Post(endpoint string, params url.Values, body interface{}, response, data interface{}) error { return l.PostType("application/json", endpoint, params, body, response, data) }
go
func (l *Client) Post(endpoint string, params url.Values, body interface{}, response, data interface{}) error { return l.PostType("application/json", endpoint, params, body, response, data) }
[ "func", "(", "l", "*", "Client", ")", "Post", "(", "endpoint", "string", ",", "params", "url", ".", "Values", ",", "body", "interface", "{", "}", ",", "response", ",", "data", "interface", "{", "}", ")", "error", "{", "return", "l", ".", "PostType", ...
// Get prepares a post request and then executes using the Do method
[ "Get", "prepares", "a", "post", "request", "and", "then", "executes", "using", "the", "Do", "method" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L217-L219
147,033
lytics/go-lytics
lytics.go
prepRequestBody
func prepRequestBody(body interface{}) (io.Reader, error) { switch val := body.(type) { case string: return strings.NewReader(val), nil case nil: return nil, nil default: b, err := json.Marshal(body) if err != nil { return nil, err } return bytes.NewReader(b), nil } return nil, nil }
go
func prepRequestBody(body interface{}) (io.Reader, error) { switch val := body.(type) { case string: return strings.NewReader(val), nil case nil: return nil, nil default: b, err := json.Marshal(body) if err != nil { return nil, err } return bytes.NewReader(b), nil } return nil, nil }
[ "func", "prepRequestBody", "(", "body", "interface", "{", "}", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "switch", "val", ":=", "body", ".", "(", "type", ")", "{", "case", "string", ":", "return", "strings", ".", "NewReader", "(", "val",...
// prepBodyRequest takes the payload and returns an io.Reader
[ "prepBodyRequest", "takes", "the", "payload", "and", "returns", "an", "io", ".", "Reader" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L252-L269
147,034
lytics/go-lytics
lytics.go
buildRespJSON
func buildRespJSON(b []byte, response, data interface{}) error { var err error err = json.Unmarshal(b, response) if err != nil { return err } switch rt := response.(type) { case *ApiResp: if len(rt.Data) > 0 { err = json.Unmarshal(rt.Data, &data) if err != nil { return err } } } return nil...
go
func buildRespJSON(b []byte, response, data interface{}) error { var err error err = json.Unmarshal(b, response) if err != nil { return err } switch rt := response.(type) { case *ApiResp: if len(rt.Data) > 0 { err = json.Unmarshal(rt.Data, &data) if err != nil { return err } } } return nil...
[ "func", "buildRespJSON", "(", "b", "[", "]", "byte", ",", "response", ",", "data", "interface", "{", "}", ")", "error", "{", "var", "err", "error", "\n\n", "err", "=", "json", ".", "Unmarshal", "(", "b", ",", "response", ")", "\n", "if", "err", "!=...
// buildRespJSON handles the first round of unmarshaling into the master Api Response struct
[ "buildRespJSON", "handles", "the", "first", "round", "of", "unmarshaling", "into", "the", "master", "Api", "Response", "struct" ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L272-L291
147,035
lytics/go-lytics
lytics.go
parseLyticsTime
func parseLyticsTime(ts string) (time.Time, error) { var err error i, err := strconv.ParseInt(ts, 10, 64) if err != nil { return time.Now(), err } tm := time.Unix((i / 1000), 0) return tm, err }
go
func parseLyticsTime(ts string) (time.Time, error) { var err error i, err := strconv.ParseInt(ts, 10, 64) if err != nil { return time.Now(), err } tm := time.Unix((i / 1000), 0) return tm, err }
[ "func", "parseLyticsTime", "(", "ts", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "var", "err", "error", "\n\n", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "ts", ",", "10", ",", "64", ")", "\n", "if", "err", "!="...
// parseLyticsTime translates a timestamp as returned by Lytics into a Go standard timestamp.
[ "parseLyticsTime", "translates", "a", "timestamp", "as", "returned", "by", "Lytics", "into", "a", "Go", "standard", "timestamp", "." ]
889ff81261376f672bbbb680974e0ed968ec6611
https://github.com/lytics/go-lytics/blob/889ff81261376f672bbbb680974e0ed968ec6611/lytics.go#L294-L305
147,036
gxed/hashland
hashtable/hashtable.go
HashQuality
func (ht *HashTable) HashQuality() float64 { if ht.Inserts == 0 { return 0.0 } n := float64(0.0) buckets := 0 entries := 0 for _, v := range ht.Buckets { if v != nil { buckets++ count := float64(len(v)) entries += len(v) n += count * (count + 1.0) } } n *= float64(ht.Size) d := float64(ht.Ins...
go
func (ht *HashTable) HashQuality() float64 { if ht.Inserts == 0 { return 0.0 } n := float64(0.0) buckets := 0 entries := 0 for _, v := range ht.Buckets { if v != nil { buckets++ count := float64(len(v)) entries += len(v) n += count * (count + 1.0) } } n *= float64(ht.Size) d := float64(ht.Ins...
[ "func", "(", "ht", "*", "HashTable", ")", "HashQuality", "(", ")", "float64", "{", "if", "ht", ".", "Inserts", "==", "0", "{", "return", "0.0", "\n", "}", "\n", "n", ":=", "float64", "(", "0.0", ")", "\n", "buckets", ":=", "0", "\n", "entries", "...
// The theoretical metric from "Red Dragon Book"
[ "The", "theoretical", "metric", "from", "Red", "Dragon", "Book" ]
45ac3eb2d3ef19e58394a2d771ac36d3b4141c47
https://github.com/gxed/hashland/blob/45ac3eb2d3ef19e58394a2d771ac36d3b4141c47/hashtable/hashtable.go#L174-L196
147,037
lestrrat-go/jspointer
jspointer.go
New
func New(path string) (*JSPointer, error) { var p JSPointer if err := p.parse(path); err != nil { return nil, err } p.raw = path return &p, nil }
go
func New(path string) (*JSPointer, error) { var p JSPointer if err := p.parse(path); err != nil { return nil, err } p.raw = path return &p, nil }
[ "func", "New", "(", "path", "string", ")", "(", "*", "JSPointer", ",", "error", ")", "{", "var", "p", "JSPointer", "\n\n", "if", "err", ":=", "p", ".", "parse", "(", "path", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// New creates a new JSON pointer for given path spec. If the path fails // to be parsed, an error is returned
[ "New", "creates", "a", "new", "JSON", "pointer", "for", "given", "path", "spec", ".", "If", "the", "path", "fails", "to", "be", "parsed", "an", "error", "is", "returned" ]
82fadba7561c3a8d78133c2b957263c0963bb79d
https://github.com/lestrrat-go/jspointer/blob/82fadba7561c3a8d78133c2b957263c0963bb79d/jspointer.go#L29-L37
147,038
lestrrat-go/jspointer
jspointer.go
Get
func (p JSPointer) Get(item interface{}) (interface{}, error) { var ctx matchCtx ctx.raw = p.raw ctx.tokens = &p.tokens ctx.apply(item) return ctx.result, ctx.err }
go
func (p JSPointer) Get(item interface{}) (interface{}, error) { var ctx matchCtx ctx.raw = p.raw ctx.tokens = &p.tokens ctx.apply(item) return ctx.result, ctx.err }
[ "func", "(", "p", "JSPointer", ")", "Get", "(", "item", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "var", "ctx", "matchCtx", "\n\n", "ctx", ".", "raw", "=", "p", ".", "raw", "\n", "ctx", ".", "tokens", "=", ...
// Get applies the JSON pointer to the given item, and returns // the result.
[ "Get", "applies", "the", "JSON", "pointer", "to", "the", "given", "item", "and", "returns", "the", "result", "." ]
82fadba7561c3a8d78133c2b957263c0963bb79d
https://github.com/lestrrat-go/jspointer/blob/82fadba7561c3a8d78133c2b957263c0963bb79d/jspointer.go#L103-L110
147,039
lestrrat-go/jspointer
jspointer.go
Set
func (p JSPointer) Set(item interface{}, value interface{}) error { var ctx matchCtx ctx.set = true ctx.raw = p.raw ctx.tokens = &p.tokens ctx.setvalue = value ctx.apply(item) return ctx.err }
go
func (p JSPointer) Set(item interface{}, value interface{}) error { var ctx matchCtx ctx.set = true ctx.raw = p.raw ctx.tokens = &p.tokens ctx.setvalue = value ctx.apply(item) return ctx.err }
[ "func", "(", "p", "JSPointer", ")", "Set", "(", "item", "interface", "{", "}", ",", "value", "interface", "{", "}", ")", "error", "{", "var", "ctx", "matchCtx", "\n\n", "ctx", ".", "set", "=", "true", "\n", "ctx", ".", "raw", "=", "p", ".", "raw"...
// Set applies the JSON pointer to the given item, and sets the // value accordingly.
[ "Set", "applies", "the", "JSON", "pointer", "to", "the", "given", "item", "and", "sets", "the", "value", "accordingly", "." ]
82fadba7561c3a8d78133c2b957263c0963bb79d
https://github.com/lestrrat-go/jspointer/blob/82fadba7561c3a8d78133c2b957263c0963bb79d/jspointer.go#L114-L123
147,040
gojuno/generator
generator.go
New
func New(prog *loader.Program) *Generator { gen := &Generator{ header: "Code generated by github.com/gojuno/generator. DO NOT EDIT.", imports: map[string]*importInfo{}, templateFuncs: map[string]interface{}{}, body: bytes.NewBuffer([]byte{}), typeConversions: map[string]string{}...
go
func New(prog *loader.Program) *Generator { gen := &Generator{ header: "Code generated by github.com/gojuno/generator. DO NOT EDIT.", imports: map[string]*importInfo{}, templateFuncs: map[string]interface{}{}, body: bytes.NewBuffer([]byte{}), typeConversions: map[string]string{}...
[ "func", "New", "(", "prog", "*", "loader", ".", "Program", ")", "*", "Generator", "{", "gen", ":=", "&", "Generator", "{", "header", ":", "\"", "\"", ",", "imports", ":", "map", "[", "string", "]", "*", "importInfo", "{", "}", ",", "templateFuncs", ...
//New creates new Generator and returns pointer to it
[ "New", "creates", "new", "Generator", "and", "returns", "pointer", "to", "it" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L61-L84
147,041
gojuno/generator
generator.go
AddBuildTags
func (g *Generator) AddBuildTags(tags ...string) { if g.buildTags == nil { g.buildTags = make([][]string, 0, 1) } g.buildTags = append(g.buildTags, tags) }
go
func (g *Generator) AddBuildTags(tags ...string) { if g.buildTags == nil { g.buildTags = make([][]string, 0, 1) } g.buildTags = append(g.buildTags, tags) }
[ "func", "(", "g", "*", "Generator", ")", "AddBuildTags", "(", "tags", "...", "string", ")", "{", "if", "g", ".", "buildTags", "==", "nil", "{", "g", ".", "buildTags", "=", "make", "(", "[", "]", "[", "]", "string", ",", "0", ",", "1", ")", "\n"...
//AddBuildTags adds build tags for generated files
[ "AddBuildTags", "adds", "build", "tags", "for", "generated", "files" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L92-L97
147,042
gojuno/generator
generator.go
isSelectorTaken
func (g *Generator) isSelectorTaken(path, selector string) bool { for p, imp := range g.imports { if imp.String() == selector && p != path { return true } } return false }
go
func (g *Generator) isSelectorTaken(path, selector string) bool { for p, imp := range g.imports { if imp.String() == selector && p != path { return true } } return false }
[ "func", "(", "g", "*", "Generator", ")", "isSelectorTaken", "(", "path", ",", "selector", "string", ")", "bool", "{", "for", "p", ",", "imp", ":=", "range", "g", ".", "imports", "{", "if", "imp", ".", "String", "(", ")", "==", "selector", "&&", "p"...
//isSelectorTaken checks if given selector was taken by some other package
[ "isSelectorTaken", "checks", "if", "given", "selector", "was", "taken", "by", "some", "other", "package" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L118-L126
147,043
gojuno/generator
generator.go
makeAliasForName
func (g *Generator) makeAliasForName(name string) *string { var prefixesCount int for _, imp := range g.imports { if strings.HasPrefix(imp.String(), name) { prefixesCount++ } } alias := fmt.Sprintf("%s%d", name, prefixesCount+1) return &alias }
go
func (g *Generator) makeAliasForName(name string) *string { var prefixesCount int for _, imp := range g.imports { if strings.HasPrefix(imp.String(), name) { prefixesCount++ } } alias := fmt.Sprintf("%s%d", name, prefixesCount+1) return &alias }
[ "func", "(", "g", "*", "Generator", ")", "makeAliasForName", "(", "name", "string", ")", "*", "string", "{", "var", "prefixesCount", "int", "\n", "for", "_", ",", "imp", ":=", "range", "g", ".", "imports", "{", "if", "strings", ".", "HasPrefix", "(", ...
//makeAliasForName checks selectors of all imported packages and gives //selector with numeric suffix if there's any packages' selectors that starts //with the same name
[ "makeAliasForName", "checks", "selectors", "of", "all", "imported", "packages", "and", "gives", "selector", "with", "numeric", "suffix", "if", "there", "s", "any", "packages", "selectors", "that", "starts", "with", "the", "same", "name" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L131-L142
147,044
gojuno/generator
generator.go
NormalizeImportPath
func NormalizeImportPath(path string) string { chunks := strings.Split(path, "/vendor/") return chunks[len(chunks)-1] }
go
func NormalizeImportPath(path string) string { chunks := strings.Split(path, "/vendor/") return chunks[len(chunks)-1] }
[ "func", "NormalizeImportPath", "(", "path", "string", ")", "string", "{", "chunks", ":=", "strings", ".", "Split", "(", "path", ",", "\"", "\"", ")", "\n", "return", "chunks", "[", "len", "(", "chunks", ")", "-", "1", "]", "\n", "}" ]
//NormalizeImportPath takes path and return import path relative to deepest //nested vendor dir
[ "NormalizeImportPath", "takes", "path", "and", "return", "import", "path", "relative", "to", "deepest", "nested", "vendor", "dir" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L171-L174
147,045
gojuno/generator
generator.go
loadPackage
func (g *Generator) loadPackage(path string) (*loader.PackageInfo, error) { pkg := g.Program.Package(path) if pkg != nil { return pkg, nil } return nil, fmt.Errorf("failed to load package %q", path) }
go
func (g *Generator) loadPackage(path string) (*loader.PackageInfo, error) { pkg := g.Program.Package(path) if pkg != nil { return pkg, nil } return nil, fmt.Errorf("failed to load package %q", path) }
[ "func", "(", "g", "*", "Generator", ")", "loadPackage", "(", "path", "string", ")", "(", "*", "loader", ".", "PackageInfo", ",", "error", ")", "{", "pkg", ":=", "g", ".", "Program", ".", "Package", "(", "path", ")", "\n", "if", "pkg", "!=", "nil", ...
//loadPackage loads package by it's path caches and returns package information
[ "loadPackage", "loads", "package", "by", "it", "s", "path", "caches", "and", "returns", "package", "information" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L177-L184
147,046
gojuno/generator
generator.go
ImportWithAlias
func (g *Generator) ImportWithAlias(pkg interface{}, alias string) (path string, err error) { path, _ = g.Import(pkg) for p, i := range g.imports { if i.Alias != nil { if p == path && *i.Alias != alias { return "", fmt.Errorf("can't set an alias %q for package %q, alias is already set: %q", alias, path, *i....
go
func (g *Generator) ImportWithAlias(pkg interface{}, alias string) (path string, err error) { path, _ = g.Import(pkg) for p, i := range g.imports { if i.Alias != nil { if p == path && *i.Alias != alias { return "", fmt.Errorf("can't set an alias %q for package %q, alias is already set: %q", alias, path, *i....
[ "func", "(", "g", "*", "Generator", ")", "ImportWithAlias", "(", "pkg", "interface", "{", "}", ",", "alias", "string", ")", "(", "path", "string", ",", "err", "error", ")", "{", "path", ",", "_", "=", "g", ".", "Import", "(", "pkg", ")", "\n\n", ...
//ImportWithAlias places given package to the list of imported packages and assigns alias to it. //It can be useful when you want to use certain alias for the package and give generated aliases for //other packages that might have the same name as the given one.
[ "ImportWithAlias", "places", "given", "package", "to", "the", "list", "of", "imported", "packages", "and", "assigns", "alias", "to", "it", ".", "It", "can", "be", "useful", "when", "you", "want", "to", "use", "certain", "alias", "for", "the", "package", "a...
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L189-L207
147,047
gojuno/generator
generator.go
WriteTo
func (g *Generator) WriteTo(w io.Writer) (int64, error) { buf := bytes.NewBuffer([]byte{}) for i, tags := range g.buildTags { eol := "\n" if i == len(g.buildTags)-1 { eol += "\n" } if _, err := fmt.Fprintf(buf, "// +build %s%s", strings.Join(tags, " "), eol); err != nil { return 0, fmt.Errorf("failed t...
go
func (g *Generator) WriteTo(w io.Writer) (int64, error) { buf := bytes.NewBuffer([]byte{}) for i, tags := range g.buildTags { eol := "\n" if i == len(g.buildTags)-1 { eol += "\n" } if _, err := fmt.Fprintf(buf, "// +build %s%s", strings.Join(tags, " "), eol); err != nil { return 0, fmt.Errorf("failed t...
[ "func", "(", "g", "*", "Generator", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "buf", ":=", "bytes", ".", "NewBuffer", "(", "[", "]", "byte", "{", "}", ")", "\n\n", "for", "i", ",", "tags", ":=", ...
//WriteTo generates source and writes result to w
[ "WriteTo", "generates", "source", "and", "writes", "result", "to", "w" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L244-L275
147,048
gojuno/generator
generator.go
writeHeader
func (g *Generator) writeHeader(w io.Writer) error { header := append([]byte("// "), []byte(g.header)...) header = append(header, []byte("\n\n")...) _, err := w.Write(header) return err }
go
func (g *Generator) writeHeader(w io.Writer) error { header := append([]byte("// "), []byte(g.header)...) header = append(header, []byte("\n\n")...) _, err := w.Write(header) return err }
[ "func", "(", "g", "*", "Generator", ")", "writeHeader", "(", "w", "io", ".", "Writer", ")", "error", "{", "header", ":=", "append", "(", "[", "]", "byte", "(", "\"", "\"", ")", ",", "[", "]", "byte", "(", "g", ".", "header", ")", "...", ")", ...
//writeHeader writes header comment to w
[ "writeHeader", "writes", "header", "comment", "to", "w" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L278-L284
147,049
gojuno/generator
generator.go
writeImports
func (g *Generator) writeImports(w io.Writer) error { if len(g.imports) == 0 { return nil } if _, err := fmt.Fprintf(w, "\nimport (\n"); err != nil { return err } for path, alias := range g.imports { if alias.Alias == nil || *alias.Alias != "" { if _, err := fmt.Fprintf(w, "%s %q\n", alias, path); err !...
go
func (g *Generator) writeImports(w io.Writer) error { if len(g.imports) == 0 { return nil } if _, err := fmt.Fprintf(w, "\nimport (\n"); err != nil { return err } for path, alias := range g.imports { if alias.Alias == nil || *alias.Alias != "" { if _, err := fmt.Fprintf(w, "%s %q\n", alias, path); err !...
[ "func", "(", "g", "*", "Generator", ")", "writeImports", "(", "w", "io", ".", "Writer", ")", "error", "{", "if", "len", "(", "g", ".", "imports", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "fmt", ".", ...
//writeImports generates import instructions for all imported packages
[ "writeImports", "generates", "import", "instructions", "for", "all", "imported", "packages" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L287-L310
147,050
gojuno/generator
generator.go
Write
func (g *Generator) Write(b []byte) (int, error) { return g.body.Write(b) }
go
func (g *Generator) Write(b []byte) (int, error) { return g.body.Write(b) }
[ "func", "(", "g", "*", "Generator", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "g", ".", "body", ".", "Write", "(", "b", ")", "\n", "}" ]
//Write implements io.Writer. Performs writing of the byte slice to the //generated source body
[ "Write", "implements", "io", ".", "Writer", ".", "Performs", "writing", "of", "the", "byte", "slice", "to", "the", "generated", "source", "body" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L314-L316
147,051
gojuno/generator
generator.go
ExpressionType
func (g *Generator) ExpressionType(e ast.Expr) (types.Type, error) { for _, info := range g.Program.AllPackages { if typesType := info.TypeOf(e); typesType != nil { return typesType, nil } } return nil, fmt.Errorf("expression not found: %+v", e) }
go
func (g *Generator) ExpressionType(e ast.Expr) (types.Type, error) { for _, info := range g.Program.AllPackages { if typesType := info.TypeOf(e); typesType != nil { return typesType, nil } } return nil, fmt.Errorf("expression not found: %+v", e) }
[ "func", "(", "g", "*", "Generator", ")", "ExpressionType", "(", "e", "ast", ".", "Expr", ")", "(", "types", ".", "Type", ",", "error", ")", "{", "for", "_", ",", "info", ":=", "range", "g", ".", "Program", ".", "AllPackages", "{", "if", "typesType"...
//ExpressionType searches amoung all loaded packages and returns a type of //given ast.Expression
[ "ExpressionType", "searches", "amoung", "all", "loaded", "packages", "and", "returns", "a", "type", "of", "given", "ast", ".", "Expression" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L347-L355
147,052
gojuno/generator
generator.go
typeOf
func (g *Generator) typeOf(tt types.Type) string { switch t := tt.(type) { case *types.Chan: return chanPrefixes[t.Dir()] + g.typeOf(t.Elem()) case *types.Pointer: return "*" + g.typeOf(t.Elem()) case *types.Array: return fmt.Sprintf("[%d]%s", t.Len(), g.typeOf(t.Elem())) case *types.Slice: return "[]" + g...
go
func (g *Generator) typeOf(tt types.Type) string { switch t := tt.(type) { case *types.Chan: return chanPrefixes[t.Dir()] + g.typeOf(t.Elem()) case *types.Pointer: return "*" + g.typeOf(t.Elem()) case *types.Array: return fmt.Sprintf("[%d]%s", t.Len(), g.typeOf(t.Elem())) case *types.Slice: return "[]" + g...
[ "func", "(", "g", "*", "Generator", ")", "typeOf", "(", "tt", "types", ".", "Type", ")", "string", "{", "switch", "t", ":=", "tt", ".", "(", "type", ")", "{", "case", "*", "types", ".", "Chan", ":", "return", "chanPrefixes", "[", "t", ".", "Dir",...
//typeOf returns type name with package selector for the given type
[ "typeOf", "returns", "type", "name", "with", "package", "selector", "for", "the", "given", "type" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L358-L422
147,053
gojuno/generator
generator.go
PackageSelector
func (g *Generator) PackageSelector(pkg interface{}) string { _, selector := g.Import(pkg) return selector }
go
func (g *Generator) PackageSelector(pkg interface{}) string { _, selector := g.Import(pkg) return selector }
[ "func", "(", "g", "*", "Generator", ")", "PackageSelector", "(", "pkg", "interface", "{", "}", ")", "string", "{", "_", ",", "selector", ":=", "g", ".", "Import", "(", "pkg", ")", "\n", "return", "selector", "\n", "}" ]
//PackageSelector returns package selector with respect to packages //imported with aliases and automatically generated aliases
[ "PackageSelector", "returns", "package", "selector", "with", "respect", "to", "packages", "imported", "with", "aliases", "and", "automatically", "generated", "aliases" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L426-L429
147,054
gojuno/generator
generator.go
ProcessTemplate
func (g *Generator) ProcessTemplate(tmplName, tmpl string, data interface{}) error { vars := []string{} for varName, varValue := range g.vars { vars = append(vars, fmt.Sprintf("{{ $%s := %q }}", varName, varValue)) } if len(vars) > 0 { tmpl = strings.Join(vars, "\n") + "\n" + tmpl } t, err := template.New(t...
go
func (g *Generator) ProcessTemplate(tmplName, tmpl string, data interface{}) error { vars := []string{} for varName, varValue := range g.vars { vars = append(vars, fmt.Sprintf("{{ $%s := %q }}", varName, varValue)) } if len(vars) > 0 { tmpl = strings.Join(vars, "\n") + "\n" + tmpl } t, err := template.New(t...
[ "func", "(", "g", "*", "Generator", ")", "ProcessTemplate", "(", "tmplName", ",", "tmpl", "string", ",", "data", "interface", "{", "}", ")", "error", "{", "vars", ":=", "[", "]", "string", "{", "}", "\n", "for", "varName", ",", "varValue", ":=", "ran...
//ProcessTemplate adds declarations of the global variables registered via SetVar. //parses template, registers helper functions to be accessible from //template and executes template
[ "ProcessTemplate", "adds", "declarations", "of", "the", "global", "variables", "registered", "via", "SetVar", ".", "parses", "template", "registers", "helper", "functions", "to", "be", "accessible", "from", "template", "and", "executes", "template" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L434-L454
147,055
gojuno/generator
generator.go
AddTemplateFunc
func (g *Generator) AddTemplateFunc(name string, f interface{}) { g.templateFuncs[name] = f }
go
func (g *Generator) AddTemplateFunc(name string, f interface{}) { g.templateFuncs[name] = f }
[ "func", "(", "g", "*", "Generator", ")", "AddTemplateFunc", "(", "name", "string", ",", "f", "interface", "{", "}", ")", "{", "g", ".", "templateFuncs", "[", "name", "]", "=", "f", "\n", "}" ]
//AddTemplateFunc registers a helper function that can be called from any of //templates that processed via generator
[ "AddTemplateFunc", "registers", "a", "helper", "function", "that", "can", "be", "called", "from", "any", "of", "templates", "that", "processed", "via", "generator" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L458-L460
147,056
gojuno/generator
generator.go
Pass
func (ps ParamSet) Pass() string { names := make([]string, len(ps)) for i := 0; i < len(ps); i++ { names[i] = ps[i].Pass() } return strings.Join(names, ",") }
go
func (ps ParamSet) Pass() string { names := make([]string, len(ps)) for i := 0; i < len(ps); i++ { names[i] = ps[i].Pass() } return strings.Join(names, ",") }
[ "func", "(", "ps", "ParamSet", ")", "Pass", "(", ")", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "ps", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "ps", ")", ";", "i", "++", "{", ...
//Pass returns a string containing parameters list to pass as a list //of arguments to the function that has same signature as a function //that ParamSet is originated from
[ "Pass", "returns", "a", "string", "containing", "parameters", "list", "to", "pass", "as", "a", "list", "of", "arguments", "to", "the", "function", "that", "has", "same", "signature", "as", "a", "function", "that", "ParamSet", "is", "originated", "from" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L529-L536
147,057
gojuno/generator
generator.go
Names
func (ps ParamSet) Names() string { names := make([]string, len(ps)) for i := 0; i < len(ps); i++ { names[i] = ps[i].Name } return strings.Join(names, ",") }
go
func (ps ParamSet) Names() string { names := make([]string, len(ps)) for i := 0; i < len(ps); i++ { names[i] = ps[i].Name } return strings.Join(names, ",") }
[ "func", "(", "ps", "ParamSet", ")", "Names", "(", ")", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "ps", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "ps", ")", ";", "i", "++", "{", ...
//Names returns a list of params names from the ParamSet separated by //commas
[ "Names", "returns", "a", "list", "of", "params", "names", "from", "the", "ParamSet", "separated", "by", "commas" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L540-L547
147,058
gojuno/generator
generator.go
FuncParams
func (g *Generator) FuncParams(f interface{}) (ParamSet, error) { signature, err := g.funcSignature(f) if err != nil { return nil, fmt.Errorf("failed to get func %+v signature", f) } paramSet := g.makeParamSet(g.defaultParamsPrefix, signature.Params()) if signature.Variadic() { paramSet[len(paramSet)-1].Varia...
go
func (g *Generator) FuncParams(f interface{}) (ParamSet, error) { signature, err := g.funcSignature(f) if err != nil { return nil, fmt.Errorf("failed to get func %+v signature", f) } paramSet := g.makeParamSet(g.defaultParamsPrefix, signature.Params()) if signature.Variadic() { paramSet[len(paramSet)-1].Varia...
[ "func", "(", "g", "*", "Generator", ")", "FuncParams", "(", "f", "interface", "{", "}", ")", "(", "ParamSet", ",", "error", ")", "{", "signature", ",", "err", ":=", "g", ".", "funcSignature", "(", "f", ")", "\n", "if", "err", "!=", "nil", "{", "r...
//FuncParams returns a slice of function parameters
[ "FuncParams", "returns", "a", "slice", "of", "function", "parameters" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L563-L575
147,059
gojuno/generator
generator.go
FuncResults
func (g *Generator) FuncResults(f interface{}) (ParamSet, error) { signature, err := g.funcSignature(f) if err != nil { return nil, fmt.Errorf("failed to get func %+v signature", f) } return g.makeParamSet(g.defaultResultsPrefix, signature.Results()), nil }
go
func (g *Generator) FuncResults(f interface{}) (ParamSet, error) { signature, err := g.funcSignature(f) if err != nil { return nil, fmt.Errorf("failed to get func %+v signature", f) } return g.makeParamSet(g.defaultResultsPrefix, signature.Results()), nil }
[ "func", "(", "g", "*", "Generator", ")", "FuncResults", "(", "f", "interface", "{", "}", ")", "(", "ParamSet", ",", "error", ")", "{", "signature", ",", "err", ":=", "g", ".", "funcSignature", "(", "f", ")", "\n", "if", "err", "!=", "nil", "{", "...
//FuncResults returns a slice of function results
[ "FuncResults", "returns", "a", "slice", "of", "function", "results" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L578-L585
147,060
gojuno/generator
generator.go
ConvertType
func (g *Generator) ConvertType(from, to string) { g.typeConversions[from] = to }
go
func (g *Generator) ConvertType(from, to string) { g.typeConversions[from] = to }
[ "func", "(", "g", "*", "Generator", ")", "ConvertType", "(", "from", ",", "to", "string", ")", "{", "g", ".", "typeConversions", "[", "from", "]", "=", "to", "\n", "}" ]
//ConvertType sets type conversion rule that will be applied by generator to //functions' arguments types structs' fields types and so on.
[ "ConvertType", "sets", "type", "conversion", "rule", "that", "will", "be", "applied", "by", "generator", "to", "functions", "arguments", "types", "structs", "fields", "types", "and", "so", "on", "." ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L663-L665
147,061
gojuno/generator
generator.go
SetPackageName
func (g *Generator) SetPackageName(name string) { g.packageName = name g.SetVar("packageName", name) }
go
func (g *Generator) SetPackageName(name string) { g.packageName = name g.SetVar("packageName", name) }
[ "func", "(", "g", "*", "Generator", ")", "SetPackageName", "(", "name", "string", ")", "{", "g", ".", "packageName", "=", "name", "\n", "g", ".", "SetVar", "(", "\"", "\"", ",", "name", ")", "\n", "}" ]
//SetPackageName sets package name of the generated file
[ "SetPackageName", "sets", "package", "name", "of", "the", "generated", "file" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L705-L708
147,062
gojuno/generator
generator.go
SetVar
func (g *Generator) SetVar(varName, varValue string) { g.vars[varName] = varValue }
go
func (g *Generator) SetVar(varName, varValue string) { g.vars[varName] = varValue }
[ "func", "(", "g", "*", "Generator", ")", "SetVar", "(", "varName", ",", "varValue", "string", ")", "{", "g", ".", "vars", "[", "varName", "]", "=", "varValue", "\n", "}" ]
//SetVar sets global variable that will be accessible from all templates //processed with generator
[ "SetVar", "sets", "global", "variable", "that", "will", "be", "accessible", "from", "all", "templates", "processed", "with", "generator" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L712-L714
147,063
gojuno/generator
generator.go
PackageAbsPath
func PackageAbsPath(p interface{}) (string, error) { switch t := p.(type) { case *types.Package: return PackageAbsPath(t.Path()) case *ast.ImportSpec: return PackageAbsPath(t.Path.Value[1 : len(t.Path.Value)-1]) case string: gopath := os.Getenv("GOPATH") for _, path := range filepath.SplitList(gopath) { ...
go
func PackageAbsPath(p interface{}) (string, error) { switch t := p.(type) { case *types.Package: return PackageAbsPath(t.Path()) case *ast.ImportSpec: return PackageAbsPath(t.Path.Value[1 : len(t.Path.Value)-1]) case string: gopath := os.Getenv("GOPATH") for _, path := range filepath.SplitList(gopath) { ...
[ "func", "PackageAbsPath", "(", "p", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "switch", "t", ":=", "p", ".", "(", "type", ")", "{", "case", "*", "types", ".", "Package", ":", "return", "PackageAbsPath", "(", "t", ".", "Path...
//PackageAbsPath parses GOPATH environment variable and returns a first //absolute path matched the package p import path
[ "PackageAbsPath", "parses", "GOPATH", "environment", "variable", "and", "returns", "a", "first", "absolute", "path", "matched", "the", "package", "p", "import", "path" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L718-L744
147,064
gojuno/generator
generator.go
Copy
func (g *Generator) Copy(n interface{}) error { switch v := n.(type) { case *ast.TypeSpec: return g.CopyType(v) case *ast.ValueSpec: return g.CopyVal(v) } return fmt.Errorf("can't copy variable of type: %T", n) }
go
func (g *Generator) Copy(n interface{}) error { switch v := n.(type) { case *ast.TypeSpec: return g.CopyType(v) case *ast.ValueSpec: return g.CopyVal(v) } return fmt.Errorf("can't copy variable of type: %T", n) }
[ "func", "(", "g", "*", "Generator", ")", "Copy", "(", "n", "interface", "{", "}", ")", "error", "{", "switch", "v", ":=", "n", ".", "(", "type", ")", "{", "case", "*", "ast", ".", "TypeSpec", ":", "return", "g", ".", "CopyType", "(", "v", ")", ...
//Copy copies entity source to the generated body applying //type conversion rules and correct packages aliases
[ "Copy", "copies", "entity", "source", "to", "the", "generated", "body", "applying", "type", "conversion", "rules", "and", "correct", "packages", "aliases" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L791-L800
147,065
gojuno/generator
generator.go
CopyType
func (g *Generator) CopyType(typeSpec *ast.TypeSpec) error { switch t := typeSpec.Type.(type) { case *ast.StructType, *ast.MapType, *ast.ChanType, *ast.FuncType, *ast.ArrayType: fmt.Fprintf(g, "type %s %s\n", typeSpec.Name.Name, g.TypeOf(typeSpec.Type)) case *ast.Ident: fmt.Fprintf(g, "type %s %s\n", typeSpec.Na...
go
func (g *Generator) CopyType(typeSpec *ast.TypeSpec) error { switch t := typeSpec.Type.(type) { case *ast.StructType, *ast.MapType, *ast.ChanType, *ast.FuncType, *ast.ArrayType: fmt.Fprintf(g, "type %s %s\n", typeSpec.Name.Name, g.TypeOf(typeSpec.Type)) case *ast.Ident: fmt.Fprintf(g, "type %s %s\n", typeSpec.Na...
[ "func", "(", "g", "*", "Generator", ")", "CopyType", "(", "typeSpec", "*", "ast", ".", "TypeSpec", ")", "error", "{", "switch", "t", ":=", "typeSpec", ".", "Type", ".", "(", "type", ")", "{", "case", "*", "ast", ".", "StructType", ",", "*", "ast", ...
//CopyType copies type declaration to the generated body
[ "CopyType", "copies", "type", "declaration", "to", "the", "generated", "body" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L803-L814
147,066
gojuno/generator
generator.go
CopyVal
func (g *Generator) CopyVal(vSpec *ast.ValueSpec) error { var err error for i, ident := range vSpec.Names { found := false for _, info := range g.Program.AllPackages { if obj, ok := info.Defs[ident]; ok { switch v := obj.(type) { case *types.Const: err = g.copyConst(v) case *types.Var: ...
go
func (g *Generator) CopyVal(vSpec *ast.ValueSpec) error { var err error for i, ident := range vSpec.Names { found := false for _, info := range g.Program.AllPackages { if obj, ok := info.Defs[ident]; ok { switch v := obj.(type) { case *types.Const: err = g.copyConst(v) case *types.Var: ...
[ "func", "(", "g", "*", "Generator", ")", "CopyVal", "(", "vSpec", "*", "ast", ".", "ValueSpec", ")", "error", "{", "var", "err", "error", "\n\n", "for", "i", ",", "ident", ":=", "range", "vSpec", ".", "Names", "{", "found", ":=", "false", "\n\n", "...
//CopyValue copies var or constant declaration to the generated body
[ "CopyValue", "copies", "var", "or", "constant", "declaration", "to", "the", "generated", "body" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L817-L847
147,067
gojuno/generator
generator.go
MixedCaps
func MixedCaps(s string) string { chunks := strings.Split(s, "_") for i, chunk := range chunks { chunks[i] = strings.Title(chunk) } return strings.Join(chunks, "") }
go
func MixedCaps(s string) string { chunks := strings.Split(s, "_") for i, chunk := range chunks { chunks[i] = strings.Title(chunk) } return strings.Join(chunks, "") }
[ "func", "MixedCaps", "(", "s", "string", ")", "string", "{", "chunks", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", "\n", "for", "i", ",", "chunk", ":=", "range", "chunks", "{", "chunks", "[", "i", "]", "=", "strings", ".", "Tit...
//MixedCaps transform underscored string to mixed-caps string
[ "MixedCaps", "transform", "underscored", "string", "to", "mixed", "-", "caps", "string" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L887-L894
147,068
gojuno/generator
generator.go
First
func First(i interface{}) (interface{}, error) { t := reflect.TypeOf(i) v := reflect.ValueOf(i) switch t.Kind() { case reflect.Array, reflect.Slice: default: return nil, fmt.Errorf("value is nither Slice nor Array") } if v.Len() == 0 { return nil, fmt.Errorf("empty array") } return v.Index(0).Interface(...
go
func First(i interface{}) (interface{}, error) { t := reflect.TypeOf(i) v := reflect.ValueOf(i) switch t.Kind() { case reflect.Array, reflect.Slice: default: return nil, fmt.Errorf("value is nither Slice nor Array") } if v.Len() == 0 { return nil, fmt.Errorf("empty array") } return v.Index(0).Interface(...
[ "func", "First", "(", "i", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "i", ")", "\n", "v", ":=", "reflect", ".", "ValueOf", "(", "i", ")", "\n\n", "switch", "t", "."...
//First returns first element of given slice or interface
[ "First", "returns", "first", "element", "of", "given", "slice", "or", "interface" ]
2e3c43d0ee5957332f0088f426fd1d2857b2a228
https://github.com/gojuno/generator/blob/2e3c43d0ee5957332f0088f426fd1d2857b2a228/generator.go#L915-L930
147,069
quobyte/api
quobyte.go
NewQuobyteClient
func NewQuobyteClient(url string, username string, password string) *QuobyteClient { return &QuobyteClient{ client: &http.Client{}, url: url, username: username, password: password, apiRetryPolicy: RetryInteractive, } }
go
func NewQuobyteClient(url string, username string, password string) *QuobyteClient { return &QuobyteClient{ client: &http.Client{}, url: url, username: username, password: password, apiRetryPolicy: RetryInteractive, } }
[ "func", "NewQuobyteClient", "(", "url", "string", ",", "username", "string", ",", "password", "string", ")", "*", "QuobyteClient", "{", "return", "&", "QuobyteClient", "{", "client", ":", "&", "http", ".", "Client", "{", "}", ",", "url", ":", "url", ",",...
// NewQuobyteClient creates a new Quobyte API client
[ "NewQuobyteClient", "creates", "a", "new", "Quobyte", "API", "client" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L36-L44
147,070
quobyte/api
quobyte.go
CreateVolume
func (client QuobyteClient) CreateVolume(request *CreateVolumeRequest) (string, error) { var response volumeUUID tenantUUID, err := client.GetTenantUUID(request.TenantID) if err != nil { return "", err } request.TenantID = tenantUUID if err = client.sendRequest("createVolume", request, &response); err != nil {...
go
func (client QuobyteClient) CreateVolume(request *CreateVolumeRequest) (string, error) { var response volumeUUID tenantUUID, err := client.GetTenantUUID(request.TenantID) if err != nil { return "", err } request.TenantID = tenantUUID if err = client.sendRequest("createVolume", request, &response); err != nil {...
[ "func", "(", "client", "QuobyteClient", ")", "CreateVolume", "(", "request", "*", "CreateVolumeRequest", ")", "(", "string", ",", "error", ")", "{", "var", "response", "volumeUUID", "\n", "tenantUUID", ",", "err", ":=", "client", ".", "GetTenantUUID", "(", "...
// CreateVolume creates a new Quobyte volume. Its root directory will be owned by given user and group
[ "CreateVolume", "creates", "a", "new", "Quobyte", "volume", ".", "Its", "root", "directory", "will", "be", "owned", "by", "given", "user", "and", "group" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L47-L60
147,071
quobyte/api
quobyte.go
GetVolumeUUID
func (client QuobyteClient) GetVolumeUUID(volume, tenant string) (string, error) { if len(volume) != 0 && !IsValidUUID(volume) { tenantUUID, err := client.GetTenantUUID(tenant) if err != nil { return "", err } volUUID, err := client.ResolveVolumeNameToUUID(volume, tenantUUID) if err != nil { return "",...
go
func (client QuobyteClient) GetVolumeUUID(volume, tenant string) (string, error) { if len(volume) != 0 && !IsValidUUID(volume) { tenantUUID, err := client.GetTenantUUID(tenant) if err != nil { return "", err } volUUID, err := client.ResolveVolumeNameToUUID(volume, tenantUUID) if err != nil { return "",...
[ "func", "(", "client", "QuobyteClient", ")", "GetVolumeUUID", "(", "volume", ",", "tenant", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "volume", ")", "!=", "0", "&&", "!", "IsValidUUID", "(", "volume", ")", "{", "tenantUUID...
// GetVolumeUUID resolves the volumeUUID for the given volume and tenant name. // This method should be used when it is not clear if the given string is volume UUID or Name.
[ "GetVolumeUUID", "resolves", "the", "volumeUUID", "for", "the", "given", "volume", "and", "tenant", "name", ".", "This", "method", "should", "be", "used", "when", "it", "is", "not", "clear", "if", "the", "given", "string", "is", "volume", "UUID", "or", "Na...
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L64-L78
147,072
quobyte/api
quobyte.go
GetTenantUUID
func (client QuobyteClient) GetTenantUUID(tenant string) (string, error) { if len(tenant) != 0 && !IsValidUUID(tenant) { tenantUUID, err := client.ResolveTenantNameToUUID(tenant) if err != nil { return "", err } return tenantUUID, nil } return tenant, nil }
go
func (client QuobyteClient) GetTenantUUID(tenant string) (string, error) { if len(tenant) != 0 && !IsValidUUID(tenant) { tenantUUID, err := client.ResolveTenantNameToUUID(tenant) if err != nil { return "", err } return tenantUUID, nil } return tenant, nil }
[ "func", "(", "client", "QuobyteClient", ")", "GetTenantUUID", "(", "tenant", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "tenant", ")", "!=", "0", "&&", "!", "IsValidUUID", "(", "tenant", ")", "{", "tenantUUID", ",", "err", ...
// GetTenantUUID resolves the tenatnUUID for the given name // This method should be used when it is not clear if the given string is Tenant UUID or Name.
[ "GetTenantUUID", "resolves", "the", "tenatnUUID", "for", "the", "given", "name", "This", "method", "should", "be", "used", "when", "it", "is", "not", "clear", "if", "the", "given", "string", "is", "Tenant", "UUID", "or", "Name", "." ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L82-L91
147,073
quobyte/api
quobyte.go
ResolveVolumeNameToUUID
func (client *QuobyteClient) ResolveVolumeNameToUUID(volumeName, tenant string) (string, error) { request := &resolveVolumeNameRequest{ VolumeName: volumeName, TenantDomain: tenant, } var response volumeUUID if err := client.sendRequest("resolveVolumeName", request, &response); err != nil { return "", err ...
go
func (client *QuobyteClient) ResolveVolumeNameToUUID(volumeName, tenant string) (string, error) { request := &resolveVolumeNameRequest{ VolumeName: volumeName, TenantDomain: tenant, } var response volumeUUID if err := client.sendRequest("resolveVolumeName", request, &response); err != nil { return "", err ...
[ "func", "(", "client", "*", "QuobyteClient", ")", "ResolveVolumeNameToUUID", "(", "volumeName", ",", "tenant", "string", ")", "(", "string", ",", "error", ")", "{", "request", ":=", "&", "resolveVolumeNameRequest", "{", "VolumeName", ":", "volumeName", ",", "T...
// ResolveVolumeNameToUUID resolves a volume name to a UUID
[ "ResolveVolumeNameToUUID", "resolves", "a", "volume", "name", "to", "a", "UUID" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L94-L105
147,074
quobyte/api
quobyte.go
DeleteVolumeByResolvingNamesToUUID
func (client *QuobyteClient) DeleteVolumeByResolvingNamesToUUID(volume, tenant string) error { volumeUUID, err := client.GetVolumeUUID(volume, tenant) if err != nil { return err } return client.DeleteVolume(volumeUUID) }
go
func (client *QuobyteClient) DeleteVolumeByResolvingNamesToUUID(volume, tenant string) error { volumeUUID, err := client.GetVolumeUUID(volume, tenant) if err != nil { return err } return client.DeleteVolume(volumeUUID) }
[ "func", "(", "client", "*", "QuobyteClient", ")", "DeleteVolumeByResolvingNamesToUUID", "(", "volume", ",", "tenant", "string", ")", "error", "{", "volumeUUID", ",", "err", ":=", "client", ".", "GetVolumeUUID", "(", "volume", ",", "tenant", ")", "\n", "if", ...
// DeleteVolumeByResolvingNamesToUUID deletes the volume by resolving the volume name and tenant name to // respective UUID if required. // This method should be used if the given volume, tenant information is name or UUID.
[ "DeleteVolumeByResolvingNamesToUUID", "deletes", "the", "volume", "by", "resolving", "the", "volume", "name", "and", "tenant", "name", "to", "respective", "UUID", "if", "required", ".", "This", "method", "should", "be", "used", "if", "the", "given", "volume", "t...
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L110-L117
147,075
quobyte/api
quobyte.go
DeleteVolume
func (client *QuobyteClient) DeleteVolume(UUID string) error { return client.sendRequest( "deleteVolume", &volumeUUID{ VolumeUUID: UUID, }, nil) }
go
func (client *QuobyteClient) DeleteVolume(UUID string) error { return client.sendRequest( "deleteVolume", &volumeUUID{ VolumeUUID: UUID, }, nil) }
[ "func", "(", "client", "*", "QuobyteClient", ")", "DeleteVolume", "(", "UUID", "string", ")", "error", "{", "return", "client", ".", "sendRequest", "(", "\"", "\"", ",", "&", "volumeUUID", "{", "VolumeUUID", ":", "UUID", ",", "}", ",", "nil", ")", "\n"...
// DeleteVolume deletes a Quobyte volume
[ "DeleteVolume", "deletes", "a", "Quobyte", "volume" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L120-L127
147,076
quobyte/api
quobyte.go
DeleteVolumeByName
func (client *QuobyteClient) DeleteVolumeByName(volumeName, tenant string) error { uuid, err := client.ResolveVolumeNameToUUID(volumeName, tenant) if err != nil { return err } return client.DeleteVolume(uuid) }
go
func (client *QuobyteClient) DeleteVolumeByName(volumeName, tenant string) error { uuid, err := client.ResolveVolumeNameToUUID(volumeName, tenant) if err != nil { return err } return client.DeleteVolume(uuid) }
[ "func", "(", "client", "*", "QuobyteClient", ")", "DeleteVolumeByName", "(", "volumeName", ",", "tenant", "string", ")", "error", "{", "uuid", ",", "err", ":=", "client", ".", "ResolveVolumeNameToUUID", "(", "volumeName", ",", "tenant", ")", "\n", "if", "err...
// DeleteVolumeByName deletes a volume by a given name
[ "DeleteVolumeByName", "deletes", "a", "volume", "by", "a", "given", "name" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L130-L137
147,077
quobyte/api
quobyte.go
GetClientList
func (client *QuobyteClient) GetClientList(tenant string) (GetClientListResponse, error) { request := &getClientListRequest{ TenantDomain: tenant, } var response GetClientListResponse if err := client.sendRequest("getClientListRequest", request, &response); err != nil { return response, err } return respons...
go
func (client *QuobyteClient) GetClientList(tenant string) (GetClientListResponse, error) { request := &getClientListRequest{ TenantDomain: tenant, } var response GetClientListResponse if err := client.sendRequest("getClientListRequest", request, &response); err != nil { return response, err } return respons...
[ "func", "(", "client", "*", "QuobyteClient", ")", "GetClientList", "(", "tenant", "string", ")", "(", "GetClientListResponse", ",", "error", ")", "{", "request", ":=", "&", "getClientListRequest", "{", "TenantDomain", ":", "tenant", ",", "}", "\n\n", "var", ...
// GetClientList returns a list of all active clients
[ "GetClientList", "returns", "a", "list", "of", "all", "active", "clients" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L140-L151
147,078
quobyte/api
quobyte.go
SetVolumeQuota
func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64) error { request := &setQuotaRequest{ Quotas: []*quota{ &quota{ Consumer: []*consumingEntity{ &consumingEntity{ Type: "VOLUME", Identifier: volumeUUID, }, }, Limits: []*resource{ &resource{...
go
func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64) error { request := &setQuotaRequest{ Quotas: []*quota{ &quota{ Consumer: []*consumingEntity{ &consumingEntity{ Type: "VOLUME", Identifier: volumeUUID, }, }, Limits: []*resource{ &resource{...
[ "func", "(", "client", "*", "QuobyteClient", ")", "SetVolumeQuota", "(", "volumeUUID", "string", ",", "quotaSize", "uint64", ")", "error", "{", "request", ":=", "&", "setQuotaRequest", "{", "Quotas", ":", "[", "]", "*", "quota", "{", "&", "quota", "{", "...
// SetVolumeQuota sets a Quota to the specified Volume
[ "SetVolumeQuota", "sets", "a", "Quota", "to", "the", "specified", "Volume" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L154-L175
147,079
quobyte/api
quobyte.go
GetTenant
func (client *QuobyteClient) GetTenant(tenantIDs []string) (GetTenantResponse, error) { request := &getTenantRequest{TenantIDs: tenantIDs} var response GetTenantResponse err := client.sendRequest("getTenant", request, &response) if err != nil { return response, err } return response, nil }
go
func (client *QuobyteClient) GetTenant(tenantIDs []string) (GetTenantResponse, error) { request := &getTenantRequest{TenantIDs: tenantIDs} var response GetTenantResponse err := client.sendRequest("getTenant", request, &response) if err != nil { return response, err } return response, nil }
[ "func", "(", "client", "*", "QuobyteClient", ")", "GetTenant", "(", "tenantIDs", "[", "]", "string", ")", "(", "GetTenantResponse", ",", "error", ")", "{", "request", ":=", "&", "getTenantRequest", "{", "TenantIDs", ":", "tenantIDs", "}", "\n\n", "var", "r...
// GetTenant returns the Tenant configuration for all specified tenants
[ "GetTenant", "returns", "the", "Tenant", "configuration", "for", "all", "specified", "tenants" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L178-L188
147,080
quobyte/api
quobyte.go
GetTenantMap
func (client *QuobyteClient) GetTenantMap() (map[string]string, error) { result := map[string]string{} response, err := client.GetTenant([]string{}) if err != nil { return result, err } for _, tenant := range response.Tenants { result[tenant.Name] = tenant.TenantID } return result, nil }
go
func (client *QuobyteClient) GetTenantMap() (map[string]string, error) { result := map[string]string{} response, err := client.GetTenant([]string{}) if err != nil { return result, err } for _, tenant := range response.Tenants { result[tenant.Name] = tenant.TenantID } return result, nil }
[ "func", "(", "client", "*", "QuobyteClient", ")", "GetTenantMap", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "result", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "response", ",", "err", ":=", "client",...
// GetTenantMap returns a map that contains all tenant names and there ID's
[ "GetTenantMap", "returns", "a", "map", "that", "contains", "all", "tenant", "names", "and", "there", "ID", "s" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L191-L204
147,081
quobyte/api
quobyte.go
SetTenant
func (client *QuobyteClient) SetTenant(tenantName string) (string, error) { request := &setTenantRequest{ &TenantDomainConfiguration{ Name: tenantName, }, retryPolicy{client.GetAPIRetryPolicy()}, } var response setTenantResponse err := client.sendRequest("setTenant", request, &response) if err != nil { ...
go
func (client *QuobyteClient) SetTenant(tenantName string) (string, error) { request := &setTenantRequest{ &TenantDomainConfiguration{ Name: tenantName, }, retryPolicy{client.GetAPIRetryPolicy()}, } var response setTenantResponse err := client.sendRequest("setTenant", request, &response) if err != nil { ...
[ "func", "(", "client", "*", "QuobyteClient", ")", "SetTenant", "(", "tenantName", "string", ")", "(", "string", ",", "error", ")", "{", "request", ":=", "&", "setTenantRequest", "{", "&", "TenantDomainConfiguration", "{", "Name", ":", "tenantName", ",", "}",...
// SetTenant creates a Tenant with the specified name
[ "SetTenant", "creates", "a", "Tenant", "with", "the", "specified", "name" ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L207-L222
147,082
quobyte/api
quobyte.go
ResolveTenantNameToUUID
func (client *QuobyteClient) ResolveTenantNameToUUID(name string) (string, error) { request := &resolveTenantNameRequest{ TenantName: name, } var response resolveTenantNameResponse err := client.sendRequest("resolveTenantName", request, &response) if err != nil { return "", err } return response.TenantID, n...
go
func (client *QuobyteClient) ResolveTenantNameToUUID(name string) (string, error) { request := &resolveTenantNameRequest{ TenantName: name, } var response resolveTenantNameResponse err := client.sendRequest("resolveTenantName", request, &response) if err != nil { return "", err } return response.TenantID, n...
[ "func", "(", "client", "*", "QuobyteClient", ")", "ResolveTenantNameToUUID", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "request", ":=", "&", "resolveTenantNameRequest", "{", "TenantName", ":", "name", ",", "}", "\n\n", "var", "respon...
// ResolveTenantNameToUUID Returns UUID for given name, error if not found.
[ "ResolveTenantNameToUUID", "Returns", "UUID", "for", "given", "name", "error", "if", "not", "found", "." ]
40e7d9791586bf7b9302dba92ea2351229a4d8c0
https://github.com/quobyte/api/blob/40e7d9791586bf7b9302dba92ea2351229a4d8c0/quobyte.go#L230-L241
147,083
Financial-Times/transactionid-utils-go
transaction_id.go
GetTransactionIDFromRequest
func GetTransactionIDFromRequest(req *http.Request) string { transactionID := req.Header.Get(TransactionIDHeader) if transactionID == "" { transactionID = NewTransactionID() req.Header.Set(TransactionIDHeader, transactionID) } return transactionID }
go
func GetTransactionIDFromRequest(req *http.Request) string { transactionID := req.Header.Get(TransactionIDHeader) if transactionID == "" { transactionID = NewTransactionID() req.Header.Set(TransactionIDHeader, transactionID) } return transactionID }
[ "func", "GetTransactionIDFromRequest", "(", "req", "*", "http", ".", "Request", ")", "string", "{", "transactionID", ":=", "req", ".", "Header", ".", "Get", "(", "TransactionIDHeader", ")", "\n", "if", "transactionID", "==", "\"", "\"", "{", "transactionID", ...
// GetTransactionIDFromRequest will look on the request // for an 'X-Request-Id' header, and use that value as the returned transactionID. // If none is found, one will be autogenerated, with a 'tid_' prefix and a random // ten character string
[ "GetTransactionIDFromRequest", "will", "look", "on", "the", "request", "for", "an", "X", "-", "Request", "-", "Id", "header", "and", "use", "that", "value", "as", "the", "returned", "transactionID", ".", "If", "none", "is", "found", "one", "will", "be", "a...
df2f00c734957c9dd651ce23ab0e0902504c7636
https://github.com/Financial-Times/transactionid-utils-go/blob/df2f00c734957c9dd651ce23ab0e0902504c7636/transaction_id.go#L30-L37
147,084
Financial-Times/transactionid-utils-go
transaction_id.go
TransactionAwareContext
func TransactionAwareContext(ctx context.Context, transactionID string) context.Context { return context.WithValue(ctx, TransactionIDKey, transactionID) }
go
func TransactionAwareContext(ctx context.Context, transactionID string) context.Context { return context.WithValue(ctx, TransactionIDKey, transactionID) }
[ "func", "TransactionAwareContext", "(", "ctx", "context", ".", "Context", ",", "transactionID", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "TransactionIDKey", ",", "transactionID", ")", "\n", "}" ]
// TransactionAwareContext will take the // context passed in and store the transactionID on it
[ "TransactionAwareContext", "will", "take", "the", "context", "passed", "in", "and", "store", "the", "transactionID", "on", "it" ]
df2f00c734957c9dd651ce23ab0e0902504c7636
https://github.com/Financial-Times/transactionid-utils-go/blob/df2f00c734957c9dd651ce23ab0e0902504c7636/transaction_id.go#L46-L48
147,085
Financial-Times/transactionid-utils-go
transaction_id.go
GetTransactionIDFromContext
func GetTransactionIDFromContext(ctx context.Context) (string, error) { // ctx.Value returns nil if ctx has no value for the key; // string type assertion returns ok=false for nil. transactionID, ok := ctx.Value(TransactionIDKey).(string) if ok { return transactionID, nil } return "", errors.New("No transaction...
go
func GetTransactionIDFromContext(ctx context.Context) (string, error) { // ctx.Value returns nil if ctx has no value for the key; // string type assertion returns ok=false for nil. transactionID, ok := ctx.Value(TransactionIDKey).(string) if ok { return transactionID, nil } return "", errors.New("No transaction...
[ "func", "GetTransactionIDFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "string", ",", "error", ")", "{", "// ctx.Value returns nil if ctx has no value for the key;", "// string type assertion returns ok=false for nil.", "transactionID", ",", "ok", ":=", "ctx"...
// GetTransactionIDFromContext will look for a transactionID // value on the context and return it if found. If none is found, return empty // string and an error
[ "GetTransactionIDFromContext", "will", "look", "for", "a", "transactionID", "value", "on", "the", "context", "and", "return", "it", "if", "found", ".", "If", "none", "is", "found", "return", "empty", "string", "and", "an", "error" ]
df2f00c734957c9dd651ce23ab0e0902504c7636
https://github.com/Financial-Times/transactionid-utils-go/blob/df2f00c734957c9dd651ce23ab0e0902504c7636/transaction_id.go#L53-L61
147,086
bitly/timer_metrics
timer_metrics.go
NewTimerMetrics
func NewTimerMetrics(statusEvery int, prefix string) *TimerMetrics { s := &TimerMetrics{ statusEvery: statusEvery, prefix: prefix, } if statusEvery > 0 { if statusEvery < 100 { log.Printf("Warning: use more than 100 status values for accurate percentiles (configured with %d)", statusEvery) } s.timi...
go
func NewTimerMetrics(statusEvery int, prefix string) *TimerMetrics { s := &TimerMetrics{ statusEvery: statusEvery, prefix: prefix, } if statusEvery > 0 { if statusEvery < 100 { log.Printf("Warning: use more than 100 status values for accurate percentiles (configured with %d)", statusEvery) } s.timi...
[ "func", "NewTimerMetrics", "(", "statusEvery", "int", ",", "prefix", "string", ")", "*", "TimerMetrics", "{", "s", ":=", "&", "TimerMetrics", "{", "statusEvery", ":", "statusEvery", ",", "prefix", ":", "prefix", ",", "}", "\n", "if", "statusEvery", ">", "0...
// start a new TimerMetrics to print out metrics every n times
[ "start", "a", "new", "TimerMetrics", "to", "print", "out", "metrics", "every", "n", "times" ]
b1c65ca7ae6232b456134f3862db0cdc42c929fd
https://github.com/bitly/timer_metrics/blob/b1c65ca7ae6232b456134f3862db0cdc42c929fd/timer_metrics.go#L21-L33
147,087
bitly/timer_metrics
timer_metrics.go
Stats
func (m *TimerMetrics) Stats() *Stats { m.Lock() s := m.getStats() m.Unlock() return s }
go
func (m *TimerMetrics) Stats() *Stats { m.Lock() s := m.getStats() m.Unlock() return s }
[ "func", "(", "m", "*", "TimerMetrics", ")", "Stats", "(", ")", "*", "Stats", "{", "m", ".", "Lock", "(", ")", "\n", "s", ":=", "m", ".", "getStats", "(", ")", "\n", "m", ".", "Unlock", "(", ")", "\n", "return", "s", "\n", "}" ]
// get the current Stats
[ "get", "the", "current", "Stats" ]
b1c65ca7ae6232b456134f3862db0cdc42c929fd
https://github.com/bitly/timer_metrics/blob/b1c65ca7ae6232b456134f3862db0cdc42c929fd/timer_metrics.go#L93-L98
147,088
bitly/timer_metrics
timer_metrics.go
StatusDuration
func (m *TimerMetrics) StatusDuration(duration time.Duration) { if m.statusEvery == 0 { return } m.Lock() m.position++ var looped bool if m.position > m.statusEvery { // loop back around looped = true m.position = 1 } if m.position > len(m.timings) { m.timings = append(m.timings, duration) } else { ...
go
func (m *TimerMetrics) StatusDuration(duration time.Duration) { if m.statusEvery == 0 { return } m.Lock() m.position++ var looped bool if m.position > m.statusEvery { // loop back around looped = true m.position = 1 } if m.position > len(m.timings) { m.timings = append(m.timings, duration) } else { ...
[ "func", "(", "m", "*", "TimerMetrics", ")", "StatusDuration", "(", "duration", "time", ".", "Duration", ")", "{", "if", "m", ".", "statusEvery", "==", "0", "{", "return", "\n", "}", "\n\n", "m", ".", "Lock", "(", ")", "\n", "m", ".", "position", "+...
// Record a duration, printing out stats every statusEvery interval
[ "Record", "a", "duration", "printing", "out", "stats", "every", "statusEvery", "interval" ]
b1c65ca7ae6232b456134f3862db0cdc42c929fd
https://github.com/bitly/timer_metrics/blob/b1c65ca7ae6232b456134f3862db0cdc42c929fd/timer_metrics.go#L109-L137
147,089
getlantern/idletiming
idletiming_conn.go
IsIdled
func IsIdled(conn net.Conn) bool { isIdled := false netx.WalkWrapped(conn, func(wrapped net.Conn) bool { switch t := conn.(type) { case *IdleTimingConn: isIdled = t.Idled() } // Keep looking until we find out we're idled return !isIdled }) return isIdled }
go
func IsIdled(conn net.Conn) bool { isIdled := false netx.WalkWrapped(conn, func(wrapped net.Conn) bool { switch t := conn.(type) { case *IdleTimingConn: isIdled = t.Idled() } // Keep looking until we find out we're idled return !isIdled }) return isIdled }
[ "func", "IsIdled", "(", "conn", "net", ".", "Conn", ")", "bool", "{", "isIdled", ":=", "false", "\n", "netx", ".", "WalkWrapped", "(", "conn", ",", "func", "(", "wrapped", "net", ".", "Conn", ")", "bool", "{", "switch", "t", ":=", "conn", ".", "(",...
// IsIdled indicates whether the given conn represents an idletiming conn that // has idled.
[ "IsIdled", "indicates", "whether", "the", "given", "conn", "represents", "an", "idletiming", "conn", "that", "has", "idled", "." ]
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_conn.go#L28-L39
147,090
getlantern/idletiming
idletiming_conn.go
Conn
func Conn(conn net.Conn, idleTimeout time.Duration, onIdle func()) *IdleTimingConn { c := &IdleTimingConn{ conn: conn, idleTimeout: idleTimeout, halfIdleTimeout: time.Duration(idleTimeout.Nanoseconds() / 2), activeCh: make(chan bool, 1), closedCh: make(chan bool, 1), lastA...
go
func Conn(conn net.Conn, idleTimeout time.Duration, onIdle func()) *IdleTimingConn { c := &IdleTimingConn{ conn: conn, idleTimeout: idleTimeout, halfIdleTimeout: time.Duration(idleTimeout.Nanoseconds() / 2), activeCh: make(chan bool, 1), closedCh: make(chan bool, 1), lastA...
[ "func", "Conn", "(", "conn", "net", ".", "Conn", ",", "idleTimeout", "time", ".", "Duration", ",", "onIdle", "func", "(", ")", ")", "*", "IdleTimingConn", "{", "c", ":=", "&", "IdleTimingConn", "{", "conn", ":", "conn", ",", "idleTimeout", ":", "idleTi...
// Conn creates a new net.Conn wrapping the given net.Conn that times out after // the specified period. Once a connection has timed out, any pending reads or // writes will return io.EOF and the underlying connection will be closed. // // idleTimeout specifies how long to wait for inactivity before considering // conn...
[ "Conn", "creates", "a", "new", "net", ".", "Conn", "wrapping", "the", "given", "net", ".", "Conn", "that", "times", "out", "after", "the", "specified", "period", ".", "Once", "a", "connection", "has", "timed", "out", "any", "pending", "reads", "or", "wri...
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_conn.go#L50-L87
147,091
getlantern/idletiming
idletiming_conn.go
TimesOutIn
func (c *IdleTimingConn) TimesOutIn() time.Duration { return c.idleTimeout - mtime.Now().Sub(mtime.Instant(atomic.LoadUint64(&c.lastActivityTime))) }
go
func (c *IdleTimingConn) TimesOutIn() time.Duration { return c.idleTimeout - mtime.Now().Sub(mtime.Instant(atomic.LoadUint64(&c.lastActivityTime))) }
[ "func", "(", "c", "*", "IdleTimingConn", ")", "TimesOutIn", "(", ")", "time", ".", "Duration", "{", "return", "c", ".", "idleTimeout", "-", "mtime", ".", "Now", "(", ")", ".", "Sub", "(", "mtime", ".", "Instant", "(", "atomic", ".", "LoadUint64", "("...
// TimesOutIn returns how much time is left before this connection will time // out, assuming there is no further activity.
[ "TimesOutIn", "returns", "how", "much", "time", "is", "left", "before", "this", "connection", "will", "time", "out", "assuming", "there", "is", "no", "further", "activity", "." ]
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_conn.go#L112-L114
147,092
getlantern/idletiming
idletiming_conn.go
Read
func (c *IdleTimingConn) Read(b []byte) (int, error) { c.closeMutex.RLock() n, err := c.doRead(b) c.closeMutex.RUnlock() return n, err }
go
func (c *IdleTimingConn) Read(b []byte) (int, error) { c.closeMutex.RLock() n, err := c.doRead(b) c.closeMutex.RUnlock() return n, err }
[ "func", "(", "c", "*", "IdleTimingConn", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "c", ".", "closeMutex", ".", "RLock", "(", ")", "\n", "n", ",", "err", ":=", "c", ".", "doRead", "(", "b", ")", "\n", ...
// Read implements the method from io.Reader
[ "Read", "implements", "the", "method", "from", "io", ".", "Reader" ]
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_conn.go#L117-L122
147,093
getlantern/idletiming
idletiming_conn.go
Write
func (c *IdleTimingConn) Write(b []byte) (int, error) { c.closeMutex.RLock() n, err := c.doWrite(b) c.closeMutex.RUnlock() return n, err }
go
func (c *IdleTimingConn) Write(b []byte) (int, error) { c.closeMutex.RLock() n, err := c.doWrite(b) c.closeMutex.RUnlock() return n, err }
[ "func", "(", "c", "*", "IdleTimingConn", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "c", ".", "closeMutex", ".", "RLock", "(", ")", "\n", "n", ",", "err", ":=", "c", ".", "doWrite", "(", "b", ")", "\n",...
// Write implements the method from io.Writer
[ "Write", "implements", "the", "method", "from", "io", ".", "Writer" ]
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_conn.go#L169-L174
147,094
getlantern/idletiming
idletiming_conn.go
Close
func (c *IdleTimingConn) Close() error { c.closeMutex.Lock() defer c.closeMutex.Unlock() if err := c.checkClosed(); err != nil { return err } c.closed = true select { case c.closedCh <- true: // close accepted default: // already closing, ignore } return c.conn.Close() }
go
func (c *IdleTimingConn) Close() error { c.closeMutex.Lock() defer c.closeMutex.Unlock() if err := c.checkClosed(); err != nil { return err } c.closed = true select { case c.closedCh <- true: // close accepted default: // already closing, ignore } return c.conn.Close() }
[ "func", "(", "c", "*", "IdleTimingConn", ")", "Close", "(", ")", "error", "{", "c", ".", "closeMutex", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "closeMutex", ".", "Unlock", "(", ")", "\n\n", "if", "err", ":=", "c", ".", "checkClosed", "(", ...
// Close this IdleTimingConn. This will close the underlying net.Conn as well, // returning the error from calling its Close method.
[ "Close", "this", "IdleTimingConn", ".", "This", "will", "close", "the", "underlying", "net", ".", "Conn", "as", "well", "returning", "the", "error", "from", "calling", "its", "Close", "method", "." ]
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_conn.go#L222-L239
147,095
getlantern/idletiming
idletiming_listener.go
Listener
func Listener(listener net.Listener, idleTimeout time.Duration, onIdle func(conn net.Conn)) net.Listener { if onIdle == nil { panic("onIdle is required") } return &idleTimingListener{listener, idleTimeout, onIdle} }
go
func Listener(listener net.Listener, idleTimeout time.Duration, onIdle func(conn net.Conn)) net.Listener { if onIdle == nil { panic("onIdle is required") } return &idleTimingListener{listener, idleTimeout, onIdle} }
[ "func", "Listener", "(", "listener", "net", ".", "Listener", ",", "idleTimeout", "time", ".", "Duration", ",", "onIdle", "func", "(", "conn", "net", ".", "Conn", ")", ")", "net", ".", "Listener", "{", "if", "onIdle", "==", "nil", "{", "panic", "(", "...
// Listener creates a net.Listener that wraps the connections obtained from an // original net.Listener with idle timing connections that time out after the // specified duration. // // idleTimeout specifies how long to wait for inactivity before considering // connection idle. Note - the actual timeout may be up to t...
[ "Listener", "creates", "a", "net", ".", "Listener", "that", "wraps", "the", "connections", "obtained", "from", "an", "original", "net", ".", "Listener", "with", "idle", "timing", "connections", "that", "time", "out", "after", "the", "specified", "duration", "....
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/idletiming_listener.go#L18-L24
147,096
getlantern/idletiming
reader.go
NewReader
func NewReader(conn net.Conn, timeout time.Duration) io.Reader { return &reader{ Conn: conn, timeout: timeout, } }
go
func NewReader(conn net.Conn, timeout time.Duration) io.Reader { return &reader{ Conn: conn, timeout: timeout, } }
[ "func", "NewReader", "(", "conn", "net", ".", "Conn", ",", "timeout", "time", ".", "Duration", ")", "io", ".", "Reader", "{", "return", "&", "reader", "{", "Conn", ":", "conn", ",", "timeout", ":", "timeout", ",", "}", "\n", "}" ]
// NewReader creates a Reader whose Read method only blocks up to timeout. If // timeout is hit, it returns whatever was read and no error.
[ "NewReader", "creates", "a", "Reader", "whose", "Read", "method", "only", "blocks", "up", "to", "timeout", ".", "If", "timeout", "is", "hit", "it", "returns", "whatever", "was", "read", "and", "no", "error", "." ]
9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0
https://github.com/getlantern/idletiming/blob/9540d1aeda2b5d50b52e2294fb5e0f2869fb6be0/reader.go#L11-L16
147,097
gorgonia/vecf64
utils.go
Range
func Range(start, end int) []float64 { size := end - start incr := true if start > end { incr = false size = start - end } if size < 0 { panic("Cannot create a float range that is negative in size") } r := make([]float64, size) for i, v := 0, float64(start); i < size; i++ { r[i] = v if incr { v+...
go
func Range(start, end int) []float64 { size := end - start incr := true if start > end { incr = false size = start - end } if size < 0 { panic("Cannot create a float range that is negative in size") } r := make([]float64, size) for i, v := 0, float64(start); i < size; i++ { r[i] = v if incr { v+...
[ "func", "Range", "(", "start", ",", "end", "int", ")", "[", "]", "float64", "{", "size", ":=", "end", "-", "start", "\n", "incr", ":=", "true", "\n", "if", "start", ">", "end", "{", "incr", "=", "false", "\n", "size", "=", "start", "-", "end", ...
// Range is a function to create arithmetic progressions of float32
[ "Range", "is", "a", "function", "to", "create", "arithmetic", "progressions", "of", "float32" ]
d21373a26cc12a37eaab0182a21d0225c3b7ef34
https://github.com/gorgonia/vecf64/blob/d21373a26cc12a37eaab0182a21d0225c3b7ef34/utils.go#L4-L27
147,098
gorgonia/vecf64
utils.go
Reduce
func Reduce(f func(a, b float64) float64, def float64, l ...float64) (retVal float64) { retVal = def if len(l) == 0 { return } for _, v := range l { retVal = f(retVal, v) } return }
go
func Reduce(f func(a, b float64) float64, def float64, l ...float64) (retVal float64) { retVal = def if len(l) == 0 { return } for _, v := range l { retVal = f(retVal, v) } return }
[ "func", "Reduce", "(", "f", "func", "(", "a", ",", "b", "float64", ")", "float64", ",", "def", "float64", ",", "l", "...", "float64", ")", "(", "retVal", "float64", ")", "{", "retVal", "=", "def", "\n", "if", "len", "(", "l", ")", "==", "0", "{...
// Reduce takes a function to reduce by, a defalut, and a splatted list of float64s
[ "Reduce", "takes", "a", "function", "to", "reduce", "by", "a", "defalut", "and", "a", "splatted", "list", "of", "float64s" ]
d21373a26cc12a37eaab0182a21d0225c3b7ef34
https://github.com/gorgonia/vecf64/blob/d21373a26cc12a37eaab0182a21d0225c3b7ef34/utils.go#L30-L40
147,099
dynport/dgtk
dockerclient/container.go
Containers
func (dh *Client) Containers() (containers []*docker.Container, e error) { return dh.ListContainers(nil) }
go
func (dh *Client) Containers() (containers []*docker.Container, e error) { return dh.ListContainers(nil) }
[ "func", "(", "dh", "*", "Client", ")", "Containers", "(", ")", "(", "containers", "[", "]", "*", "docker", ".", "Container", ",", "e", "error", ")", "{", "return", "dh", ".", "ListContainers", "(", "nil", ")", "\n", "}" ]
// Get a list of all ontainers available on the host.
[ "Get", "a", "list", "of", "all", "ontainers", "available", "on", "the", "host", "." ]
267e33d07f1763e0fd6e630517b9636317020881
https://github.com/dynport/dgtk/blob/267e33d07f1763e0fd6e630517b9636317020881/dockerclient/container.go#L46-L48