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
148,400
drewlanenga/govector
vectors.go
Max
func (x Vector) Max() float64 { max := x[0] for _, v := range x { if v > max { max = v } } return max }
go
func (x Vector) Max() float64 { max := x[0] for _, v := range x { if v > max { max = v } } return max }
[ "func", "(", "x", "Vector", ")", "Max", "(", ")", "float64", "{", "max", ":=", "x", "[", "0", "]", "\n", "for", "_", ",", "v", ":=", "range", "x", "{", "if", "v", ">", "max", "{", "max", "=", "v", "\n", "}", "\n", "}", "\n", "return", "ma...
// Max returns the maximum value of the vector
[ "Max", "returns", "the", "maximum", "value", "of", "the", "vector" ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L178-L186
148,401
drewlanenga/govector
vectors.go
Min
func (x Vector) Min() float64 { min := x[0] for _, v := range x { if v < min { min = v } } return min }
go
func (x Vector) Min() float64 { min := x[0] for _, v := range x { if v < min { min = v } } return min }
[ "func", "(", "x", "Vector", ")", "Min", "(", ")", "float64", "{", "min", ":=", "x", "[", "0", "]", "\n", "for", "_", ",", "v", ":=", "range", "x", "{", "if", "v", "<", "min", "{", "min", "=", "v", "\n", "}", "\n", "}", "\n", "return", "mi...
// Min returns the minimum value of the vector
[ "Min", "returns", "the", "minimum", "value", "of", "the", "vector" ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L189-L197
148,402
drewlanenga/govector
vectors.go
Ecdf
func (x Vector) Ecdf() func(float64) float64 { y := x.Copy() y.Sort() n := len(y) empirical := func(q float64) float64 { i := 0 for i < n { if q < y[i] { return float64(i) / float64(n) } i++ } return 1.0 } return empirical }
go
func (x Vector) Ecdf() func(float64) float64 { y := x.Copy() y.Sort() n := len(y) empirical := func(q float64) float64 { i := 0 for i < n { if q < y[i] { return float64(i) / float64(n) } i++ } return 1.0 } return empirical }
[ "func", "(", "x", "Vector", ")", "Ecdf", "(", ")", "func", "(", "float64", ")", "float64", "{", "y", ":=", "x", ".", "Copy", "(", ")", "\n\n", "y", ".", "Sort", "(", ")", "\n", "n", ":=", "len", "(", "y", ")", "\n\n", "empirical", ":=", "func...
// Ecdf returns the empirical cumulative distribution function. The ECDF function // will return the percentile of a given value relative to the vector.
[ "Ecdf", "returns", "the", "empirical", "cumulative", "distribution", "function", ".", "The", "ECDF", "function", "will", "return", "the", "percentile", "of", "a", "given", "value", "relative", "to", "the", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L201-L219
148,403
drewlanenga/govector
vectors.go
Apply
func (x Vector) Apply(f func(float64) float64) Vector { y := make(Vector, len(x)) for i, v := range x { y[i] = f(v) } return y }
go
func (x Vector) Apply(f func(float64) float64) Vector { y := make(Vector, len(x)) for i, v := range x { y[i] = f(v) } return y }
[ "func", "(", "x", "Vector", ")", "Apply", "(", "f", "func", "(", "float64", ")", "float64", ")", "Vector", "{", "y", ":=", "make", "(", "Vector", ",", "len", "(", "x", ")", ")", "\n\n", "for", "i", ",", "v", ":=", "range", "x", "{", "y", "[",...
// Apply returns the values of the vector applied to an arbitrary function, which must // return a float64, since a Vector will be returned.
[ "Apply", "returns", "the", "values", "of", "the", "vector", "applied", "to", "an", "arbitrary", "function", "which", "must", "return", "a", "float64", "since", "a", "Vector", "will", "be", "returned", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L223-L230
148,404
drewlanenga/govector
vectors.go
Quantiles
func (x Vector) Quantiles(q Vector) Vector { y := x.Copy() y.Sort() n := float64(len(y)) output := make(Vector, len(q)) for i, quantile := range q { if n == 0.0 { output[i] = 0 continue } fuzzyQuantile := quantile * n // the quantile lies directly on the value if fuzzyQuantile-math.Floor(fuzzy...
go
func (x Vector) Quantiles(q Vector) Vector { y := x.Copy() y.Sort() n := float64(len(y)) output := make(Vector, len(q)) for i, quantile := range q { if n == 0.0 { output[i] = 0 continue } fuzzyQuantile := quantile * n // the quantile lies directly on the value if fuzzyQuantile-math.Floor(fuzzy...
[ "func", "(", "x", "Vector", ")", "Quantiles", "(", "q", "Vector", ")", "Vector", "{", "y", ":=", "x", ".", "Copy", "(", ")", "\n\n", "y", ".", "Sort", "(", ")", "\n\n", "n", ":=", "float64", "(", "len", "(", "y", ")", ")", "\n", "output", ":=...
// Quantiles returns the quantiles of a vector corresponding to input quantiles using a // weighted average approach for index interpolation.
[ "Quantiles", "returns", "the", "quantiles", "of", "a", "vector", "corresponding", "to", "input", "quantiles", "using", "a", "weighted", "average", "approach", "for", "index", "interpolation", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L248-L289
148,405
drewlanenga/govector
vectors.go
Sample
func (x Vector) Sample(n int) Vector { // unprotected access to custom rand.Rand objects can cause panics // https://github.com/golang/go/issues/3611 rndMutex.Lock() perm := rnd.Perm(len(x)) rndMutex.Unlock() // sample n elements perm = perm[:n] y := make(Vector, n) for yi, permi := range perm { y[yi] = x[...
go
func (x Vector) Sample(n int) Vector { // unprotected access to custom rand.Rand objects can cause panics // https://github.com/golang/go/issues/3611 rndMutex.Lock() perm := rnd.Perm(len(x)) rndMutex.Unlock() // sample n elements perm = perm[:n] y := make(Vector, n) for yi, permi := range perm { y[yi] = x[...
[ "func", "(", "x", "Vector", ")", "Sample", "(", "n", "int", ")", "Vector", "{", "// unprotected access to custom rand.Rand objects can cause panics", "// https://github.com/golang/go/issues/3611", "rndMutex", ".", "Lock", "(", ")", "\n", "perm", ":=", "rnd", ".", "Per...
// Sample returns a sample of n elements of the original input vector.
[ "Sample", "returns", "a", "sample", "of", "n", "elements", "of", "the", "original", "input", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L328-L344
148,406
drewlanenga/govector
vectors.go
Rank
func (x Vector) Rank() Vector { y := x.Copy() y.Sort() // equivalent to a minimum rank (tie) method rank := 0 ranks := make(Vector, len(x)) for i, _ := range ranks { ranks[i] = -1 } for i, _ := range y { for j, _ := range x { if y[i] == x[j] && ranks[j] == -1 { ranks[j] = float64(rank) } } r...
go
func (x Vector) Rank() Vector { y := x.Copy() y.Sort() // equivalent to a minimum rank (tie) method rank := 0 ranks := make(Vector, len(x)) for i, _ := range ranks { ranks[i] = -1 } for i, _ := range y { for j, _ := range x { if y[i] == x[j] && ranks[j] == -1 { ranks[j] = float64(rank) } } r...
[ "func", "(", "x", "Vector", ")", "Rank", "(", ")", "Vector", "{", "y", ":=", "x", ".", "Copy", "(", ")", "\n", "y", ".", "Sort", "(", ")", "\n\n", "// equivalent to a minimum rank (tie) method", "rank", ":=", "0", "\n", "ranks", ":=", "make", "(", "V...
// Rank returns a vector of the ranked values of the input vector.
[ "Rank", "returns", "a", "vector", "of", "the", "ranked", "values", "of", "the", "input", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L373-L394
148,407
drewlanenga/govector
vectors.go
Order
func (x Vector) Order() Vector { y := x.Copy() y.Sort() rank := 0 order := make(Vector, len(x)) for i, _ := range order { order[i] = -1 } for i, _ := range y { for j, _ := range x { if y[i] == x[j] && order[j] == -1 { order[j] = float64(rank) rank++ break } } } return order }
go
func (x Vector) Order() Vector { y := x.Copy() y.Sort() rank := 0 order := make(Vector, len(x)) for i, _ := range order { order[i] = -1 } for i, _ := range y { for j, _ := range x { if y[i] == x[j] && order[j] == -1 { order[j] = float64(rank) rank++ break } } } return order }
[ "func", "(", "x", "Vector", ")", "Order", "(", ")", "Vector", "{", "y", ":=", "x", ".", "Copy", "(", ")", "\n", "y", ".", "Sort", "(", ")", "\n\n", "rank", ":=", "0", "\n", "order", ":=", "make", "(", "Vector", ",", "len", "(", "x", ")", ")...
// Order returns a vector of untied ranks of the input vector.
[ "Order", "returns", "a", "vector", "of", "untied", "ranks", "of", "the", "input", "vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L397-L416
148,408
drewlanenga/govector
vectors.go
PushFixed
func (x *Vector) PushFixed(y float64) error { lenx := len(*x) if lenx <= cap(*x) { slicex := (*x)[1:] z := make([]float64, lenx, lenx) copy(z, slicex) z[lenx-1] = y *x = z return nil } else { return fmt.Errorf("GoVector length greater than capacity!? len: %d cap: %d\n%#v", len(*x), cap(*x), x) } }
go
func (x *Vector) PushFixed(y float64) error { lenx := len(*x) if lenx <= cap(*x) { slicex := (*x)[1:] z := make([]float64, lenx, lenx) copy(z, slicex) z[lenx-1] = y *x = z return nil } else { return fmt.Errorf("GoVector length greater than capacity!? len: %d cap: %d\n%#v", len(*x), cap(*x), x) } }
[ "func", "(", "x", "*", "Vector", ")", "PushFixed", "(", "y", "float64", ")", "error", "{", "lenx", ":=", "len", "(", "*", "x", ")", "\n", "if", "lenx", "<=", "cap", "(", "*", "x", ")", "{", "slicex", ":=", "(", "*", "x", ")", "[", "1", ":",...
//Append values to an array. Array size will not grow if unnecessary. //It will grow if the cap has been extended by external modification.
[ "Append", "values", "to", "an", "array", ".", "Array", "size", "will", "not", "grow", "if", "unnecessary", ".", "It", "will", "grow", "if", "the", "cap", "has", "been", "extended", "by", "external", "modification", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/vectors.go#L426-L438
148,409
pivotal-cf-experimental/warrant
tokens_service.go
Decode
func (ts TokensService) Decode(token string) (Token, error) { segments := strings.Split(token, ".") if len(segments) != 3 { return Token{}, InvalidTokenError{fmt.Errorf("invalid number of segments in token (%d/3)", len(segments))} } claims, err := jwt.DecodeSegment(segments[1]) if err != nil { return Token{},...
go
func (ts TokensService) Decode(token string) (Token, error) { segments := strings.Split(token, ".") if len(segments) != 3 { return Token{}, InvalidTokenError{fmt.Errorf("invalid number of segments in token (%d/3)", len(segments))} } claims, err := jwt.DecodeSegment(segments[1]) if err != nil { return Token{},...
[ "func", "(", "ts", "TokensService", ")", "Decode", "(", "token", "string", ")", "(", "Token", ",", "error", ")", "{", "segments", ":=", "strings", ".", "Split", "(", "token", ",", "\"", "\"", ")", "\n", "if", "len", "(", "segments", ")", "!=", "3",...
// Decode returns a decoded token value. The returned value represents the // token's claims section.
[ "Decode", "returns", "a", "decoded", "token", "value", ".", "The", "returned", "value", "represents", "the", "token", "s", "claims", "section", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/tokens_service.go#L44-L62
148,410
pivotal-cf-experimental/warrant
tokens_service.go
GetSigningKey
func (ts TokensService) GetSigningKey() (SigningKey, error) { resp, err := newNetworkClient(ts.config).MakeRequest(network.Request{ Method: "GET", Path: "/token_key", AcceptableStatusCodes: []int{http.StatusOK}, }) if err != nil { return SigningKey{}, translateError(err) } var response documents.TokenKe...
go
func (ts TokensService) GetSigningKey() (SigningKey, error) { resp, err := newNetworkClient(ts.config).MakeRequest(network.Request{ Method: "GET", Path: "/token_key", AcceptableStatusCodes: []int{http.StatusOK}, }) if err != nil { return SigningKey{}, translateError(err) } var response documents.TokenKe...
[ "func", "(", "ts", "TokensService", ")", "GetSigningKey", "(", ")", "(", "SigningKey", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "ts", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Request", "{", "Method",...
// GetSigningKey makes a request to UAA to retrieve the SigningKey used to // generate valid tokens.
[ "GetSigningKey", "makes", "a", "request", "to", "UAA", "to", "retrieve", "the", "SigningKey", "used", "to", "generate", "valid", "tokens", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/tokens_service.go#L66-L89
148,411
pivotal-cf-experimental/warrant
tokens_service.go
GetSigningKeys
func (ts *TokensService) GetSigningKeys() ([]SigningKey, error) { resp, err := newNetworkClient(ts.config).MakeRequest(network.Request{ Method: "GET", Path: "/token_keys", AcceptableStatusCodes: []int{http.StatusOK}, }) if err != nil { return []SigningKey{}, translateError(err) } var response documents....
go
func (ts *TokensService) GetSigningKeys() ([]SigningKey, error) { resp, err := newNetworkClient(ts.config).MakeRequest(network.Request{ Method: "GET", Path: "/token_keys", AcceptableStatusCodes: []int{http.StatusOK}, }) if err != nil { return []SigningKey{}, translateError(err) } var response documents....
[ "func", "(", "ts", "*", "TokensService", ")", "GetSigningKeys", "(", ")", "(", "[", "]", "SigningKey", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "ts", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Reques...
// GetSigningKeys makes a request to UAA to retrieve the SigningKeys used to // generate valid tokens.
[ "GetSigningKeys", "makes", "a", "request", "to", "UAA", "to", "retrieve", "the", "SigningKeys", "used", "to", "generate", "valid", "tokens", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/tokens_service.go#L93-L120
148,412
pivotal-cf-experimental/warrant
clients_service.go
Create
func (cs ClientsService) Create(client Client, secret, token string) error { _, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "POST", Path: "/oauth/clients", Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(client.toDocumen...
go
func (cs ClientsService) Create(client Client, secret, token string) error { _, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "POST", Path: "/oauth/clients", Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(client.toDocumen...
[ "func", "(", "cs", "ClientsService", ")", "Create", "(", "client", "Client", ",", "secret", ",", "token", "string", ")", "error", "{", "_", ",", "err", ":=", "newNetworkClient", "(", "cs", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "R...
// Create will make a request to UAA to register a client with the given client resource and // A token with the "clients.write" or "clients.admin" scope is required.
[ "Create", "will", "make", "a", "request", "to", "UAA", "to", "register", "a", "client", "with", "the", "given", "client", "resource", "and", "A", "token", "with", "the", "clients", ".", "write", "or", "clients", ".", "admin", "scope", "is", "required", "...
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/clients_service.go#L36-L49
148,413
pivotal-cf-experimental/warrant
clients_service.go
Get
func (cs ClientsService) Get(id, token string) (Client, error) { resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/oauth/clients/%s", id), Authorization: network.NewTokenAuthorization(token), AcceptableStatusCodes: [...
go
func (cs ClientsService) Get(id, token string) (Client, error) { resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/oauth/clients/%s", id), Authorization: network.NewTokenAuthorization(token), AcceptableStatusCodes: [...
[ "func", "(", "cs", "ClientsService", ")", "Get", "(", "id", ",", "token", "string", ")", "(", "Client", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "cs", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Req...
// Get will make a request to UAA to fetch the client matching the given id. // A token with the "clients.read" scope is required.
[ "Get", "will", "make", "a", "request", "to", "UAA", "to", "fetch", "the", "client", "matching", "the", "given", "id", ".", "A", "token", "with", "the", "clients", ".", "read", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/clients_service.go#L53-L71
148,414
pivotal-cf-experimental/warrant
clients_service.go
List
func (cs ClientsService) List(query Query, token string) ([]Client, error) { requestPath := url.URL{ Path: "/oauth/clients", RawQuery: url.Values{ "filter": []string{query.Filter}, "sortBy": []string{query.SortBy}, }.Encode(), } resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Met...
go
func (cs ClientsService) List(query Query, token string) ([]Client, error) { requestPath := url.URL{ Path: "/oauth/clients", RawQuery: url.Values{ "filter": []string{query.Filter}, "sortBy": []string{query.SortBy}, }.Encode(), } resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Met...
[ "func", "(", "cs", "ClientsService", ")", "List", "(", "query", "Query", ",", "token", "string", ")", "(", "[", "]", "Client", ",", "error", ")", "{", "requestPath", ":=", "url", ".", "URL", "{", "Path", ":", "\"", "\"", ",", "RawQuery", ":", "url"...
// List will make a request to UAA to retrieve all client resources matching the given query. // A token with the "clients.read" or "clients.admin" scope is required.
[ "List", "will", "make", "a", "request", "to", "UAA", "to", "retrieve", "all", "client", "resources", "matching", "the", "given", "query", ".", "A", "token", "with", "the", "clients", ".", "read", "or", "clients", ".", "admin", "scope", "is", "required", ...
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/clients_service.go#L75-L106
148,415
pivotal-cf-experimental/warrant
clients_service.go
Update
func (cs ClientsService) Update(client Client, token string) error { _, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/oauth/clients/%s", client.ID), Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBod...
go
func (cs ClientsService) Update(client Client, token string) error { _, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/oauth/clients/%s", client.ID), Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBod...
[ "func", "(", "cs", "ClientsService", ")", "Update", "(", "client", "Client", ",", "token", "string", ")", "error", "{", "_", ",", "err", ":=", "newNetworkClient", "(", "cs", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Request", "{", "...
// Update will make a request to UAA to update the matching client resource. // A token with the "clients.write" or "clients.admin" scope is required.
[ "Update", "will", "make", "a", "request", "to", "UAA", "to", "update", "the", "matching", "client", "resource", ".", "A", "token", "with", "the", "clients", ".", "write", "or", "clients", ".", "admin", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/clients_service.go#L110-L123
148,416
pivotal-cf-experimental/warrant
clients_service.go
GetToken
func (cs ClientsService) GetToken(id, secret string) (string, error) { resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "POST", Path: "/oauth/token", Authorization: network.NewBasicAuthorization(id, secret), Body: network.NewFormRequestBody(url.Values{ "client_id...
go
func (cs ClientsService) GetToken(id, secret string) (string, error) { resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{ Method: "POST", Path: "/oauth/token", Authorization: network.NewBasicAuthorization(id, secret), Body: network.NewFormRequestBody(url.Values{ "client_id...
[ "func", "(", "cs", "ClientsService", ")", "GetToken", "(", "id", ",", "secret", "string", ")", "(", "string", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "cs", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", ...
// GetToken will make a request to UAA to retrieve a client token using the // "client_credentials" grant type. A client id and secret are required.
[ "GetToken", "will", "make", "a", "request", "to", "UAA", "to", "retrieve", "a", "client", "token", "using", "the", "client_credentials", "grant", "type", ".", "A", "client", "id", "and", "secret", "are", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/clients_service.go#L143-L165
148,417
Clever/go-utils
sort/byint/byint.go
DefaultID
func DefaultID(i interface{}) int { intVal, err := strconv.Atoi(fmt.Sprint(i)) if err != nil { log.Fatalf(err.Error()) } return intVal }
go
func DefaultID(i interface{}) int { intVal, err := strconv.Atoi(fmt.Sprint(i)) if err != nil { log.Fatalf(err.Error()) } return intVal }
[ "func", "DefaultID", "(", "i", "interface", "{", "}", ")", "int", "{", "intVal", ",", "err", ":=", "strconv", ".", "Atoi", "(", "fmt", ".", "Sprint", "(", "i", ")", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "err", "."...
// DefaultID will use the stringer interface
[ "DefaultID", "will", "use", "the", "stringer", "interface" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/sort/byint/byint.go#L43-L49
148,418
Clever/go-utils
sort/byint/byint.go
Sort
func Sort(data interface{}, identifier ...func(interface{}) int) { val := reflect.ValueOf(data) identifier = append(identifier, DefaultID) sortable := byInt{ Data: val, Indices: make([]int, val.Len()), Identifier: identifier[0], } for i := 0; i < val.Len(); i++ { sortable.Indices[i] = i } sort.S...
go
func Sort(data interface{}, identifier ...func(interface{}) int) { val := reflect.ValueOf(data) identifier = append(identifier, DefaultID) sortable := byInt{ Data: val, Indices: make([]int, val.Len()), Identifier: identifier[0], } for i := 0; i < val.Len(); i++ { sortable.Indices[i] = i } sort.S...
[ "func", "Sort", "(", "data", "interface", "{", "}", ",", "identifier", "...", "func", "(", "interface", "{", "}", ")", "int", ")", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "data", ")", "\n", "identifier", "=", "append", "(", "identifier", ",...
// Sort is a stable sort that takes a slice as first argument. Will panic if data is not a slice.
[ "Sort", "is", "a", "stable", "sort", "that", "takes", "a", "slice", "as", "first", "argument", ".", "Will", "panic", "if", "data", "is", "not", "a", "slice", "." ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/sort/byint/byint.go#L52-L65
148,419
drewlanenga/govector
algebra.go
Product
func Product(x, y Vector) (Vector, error) { if len(x) != len(y) { return nil, fmt.Errorf("x and y have unequal lengths: %d / %d", len(x), len(y)) } p := make(Vector, len(x)) for i, _ := range x { p[i] = x[i] * y[i] } return p, nil }
go
func Product(x, y Vector) (Vector, error) { if len(x) != len(y) { return nil, fmt.Errorf("x and y have unequal lengths: %d / %d", len(x), len(y)) } p := make(Vector, len(x)) for i, _ := range x { p[i] = x[i] * y[i] } return p, nil }
[ "func", "Product", "(", "x", ",", "y", "Vector", ")", "(", "Vector", ",", "error", ")", "{", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "x", ")"...
// Product returns a vector of element-wise products of two input vectors.
[ "Product", "returns", "a", "vector", "of", "element", "-", "wise", "products", "of", "two", "input", "vectors", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/algebra.go#L9-L19
148,420
drewlanenga/govector
algebra.go
Norm
func Norm(x Vector, pow float64) float64 { s := 0.0 for _, xval := range x { s += math.Pow(xval, pow) } return math.Pow(s, 1/pow) }
go
func Norm(x Vector, pow float64) float64 { s := 0.0 for _, xval := range x { s += math.Pow(xval, pow) } return math.Pow(s, 1/pow) }
[ "func", "Norm", "(", "x", "Vector", ",", "pow", "float64", ")", "float64", "{", "s", ":=", "0.0", "\n\n", "for", "_", ",", "xval", ":=", "range", "x", "{", "s", "+=", "math", ".", "Pow", "(", "xval", ",", "pow", ")", "\n", "}", "\n\n", "return"...
// Norm returns the vector norm. Use pow = 2.0 for Euclidean.
[ "Norm", "returns", "the", "vector", "norm", ".", "Use", "pow", "=", "2", ".", "0", "for", "Euclidean", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/algebra.go#L31-L39
148,421
drewlanenga/govector
algebra.go
Cosine
func Cosine(x, y Vector) (float64, error) { d, err := DotProduct(x, y) if err != nil { return NA, err } xnorm := Norm(x, 2.0) ynorm := Norm(y, 2.0) return d / (xnorm * ynorm), nil }
go
func Cosine(x, y Vector) (float64, error) { d, err := DotProduct(x, y) if err != nil { return NA, err } xnorm := Norm(x, 2.0) ynorm := Norm(y, 2.0) return d / (xnorm * ynorm), nil }
[ "func", "Cosine", "(", "x", ",", "y", "Vector", ")", "(", "float64", ",", "error", ")", "{", "d", ",", "err", ":=", "DotProduct", "(", "x", ",", "y", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NA", ",", "err", "\n", "}", "\n\n", "xn...
// Cosine returns the cosine similarity between two vectors.
[ "Cosine", "returns", "the", "cosine", "similarity", "between", "two", "vectors", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/algebra.go#L42-L52
148,422
drewlanenga/govector
algebra.go
Cor
func Cor(x, y Vector) (float64, error) { n := float64(len(x)) xy, err := Product(x, y) if err != nil { return NA, err } sx := x.Sd() sy := y.Sd() mx := x.Mean() my := y.Mean() r := (xy.Sum() - n*mx*my) / ((n - 1) * sx * sy) return r, nil }
go
func Cor(x, y Vector) (float64, error) { n := float64(len(x)) xy, err := Product(x, y) if err != nil { return NA, err } sx := x.Sd() sy := y.Sd() mx := x.Mean() my := y.Mean() r := (xy.Sum() - n*mx*my) / ((n - 1) * sx * sy) return r, nil }
[ "func", "Cor", "(", "x", ",", "y", "Vector", ")", "(", "float64", ",", "error", ")", "{", "n", ":=", "float64", "(", "len", "(", "x", ")", ")", "\n", "xy", ",", "err", ":=", "Product", "(", "x", ",", "y", ")", "\n", "if", "err", "!=", "nil"...
// Cor returns the Pearson correlation between two vectors.
[ "Cor", "returns", "the", "Pearson", "correlation", "between", "two", "vectors", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/algebra.go#L55-L70
148,423
pivotal-cf-experimental/warrant
errors.go
Error
func (e BadRequestError) Error() string { return fmt.Sprintf("bad request: %s", e.err.(network.UnexpectedStatusError).Body) }
go
func (e BadRequestError) Error() string { return fmt.Sprintf("bad request: %s", e.err.(network.UnexpectedStatusError).Body) }
[ "func", "(", "e", "BadRequestError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "err", ".", "(", "network", ".", "UnexpectedStatusError", ")", ".", "Body", ")", "\n", "}" ]
// Error returns a string representation of the BadRequestError.
[ "Error", "returns", "a", "string", "representation", "of", "the", "BadRequestError", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/errors.go#L93-L95
148,424
pivotal-cf-experimental/warrant
internal/documents/meta.go
MarshalJSON
func (m Meta) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]interface{}{ "version": m.Version, "created": m.Created.Format("2006-01-02T15:04:05.000Z"), "lastModified": m.LastModified.Format("2006-01-02T15:04:05.000Z"), }) }
go
func (m Meta) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]interface{}{ "version": m.Version, "created": m.Created.Format("2006-01-02T15:04:05.000Z"), "lastModified": m.LastModified.Format("2006-01-02T15:04:05.000Z"), }) }
[ "func", "(", "m", "Meta", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "json", ".", "Marshal", "(", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "m", ".", "Version", ",", "\""...
// MarshalJSON converts the Meta struct into a JSON representation.
[ "MarshalJSON", "converts", "the", "Meta", "struct", "into", "a", "JSON", "representation", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/internal/documents/meta.go#L24-L30
148,425
pivotal-cf-experimental/warrant
internal/network/authorization.go
NewBasicAuthorization
func NewBasicAuthorization(username, password string) BasicAuthorization { return BasicAuthorization{ username: username, password: password, } }
go
func NewBasicAuthorization(username, password string) BasicAuthorization { return BasicAuthorization{ username: username, password: password, } }
[ "func", "NewBasicAuthorization", "(", "username", ",", "password", "string", ")", "BasicAuthorization", "{", "return", "BasicAuthorization", "{", "username", ":", "username", ",", "password", ":", "password", ",", "}", "\n", "}" ]
// NewBasicAuthorization returns a BasicAuthorization initialized // with the given username and password.
[ "NewBasicAuthorization", "returns", "a", "BasicAuthorization", "initialized", "with", "the", "given", "username", "and", "password", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/internal/network/authorization.go#L31-L36
148,426
pivotal-cf-experimental/warrant
internal/network/authorization.go
Authorization
func (b BasicAuthorization) Authorization() string { auth := b.username + ":" + b.password return fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(auth))) }
go
func (b BasicAuthorization) Authorization() string { auth := b.username + ":" + b.password return fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(auth))) }
[ "func", "(", "b", "BasicAuthorization", ")", "Authorization", "(", ")", "string", "{", "auth", ":=", "b", ".", "username", "+", "\"", "\"", "+", "b", ".", "password", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "base64", ".", "StdEnc...
// Authorization returns a string that can be used as the value of // an Authorization HTTP header.
[ "Authorization", "returns", "a", "string", "that", "can", "be", "used", "as", "the", "value", "of", "an", "Authorization", "HTTP", "header", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/internal/network/authorization.go#L48-L51
148,427
pivotal-cf-experimental/warrant
groups_service.go
Create
func (gs GroupsService) Create(displayName, token string) (Group, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "POST", Path: "/Groups", Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(documents.CreateGroupRequest{ ...
go
func (gs GroupsService) Create(displayName, token string) (Group, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "POST", Path: "/Groups", Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(documents.CreateGroupRequest{ ...
[ "func", "(", "gs", "GroupsService", ")", "Create", "(", "displayName", ",", "token", "string", ")", "(", "Group", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", ".", "MakeRequest", "(", "network", "...
// Create will make a request to UAA to create a new group resource with the given // DisplayName. A token with the "scim.write" scope is required.
[ "Create", "will", "make", "a", "request", "to", "UAA", "to", "create", "a", "new", "group", "resource", "with", "the", "given", "DisplayName", ".", "A", "token", "with", "the", "scim", ".", "write", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L31-L52
148,428
pivotal-cf-experimental/warrant
groups_service.go
Update
func (gs GroupsService) Update(group Group, token string) (Group, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/Groups/%s", group.ID), Authorization: network.NewTokenAuthorization(token), IfMatch: strconv.Itoa(group.Versi...
go
func (gs GroupsService) Update(group Group, token string) (Group, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/Groups/%s", group.ID), Authorization: network.NewTokenAuthorization(token), IfMatch: strconv.Itoa(group.Versi...
[ "func", "(", "gs", "GroupsService", ")", "Update", "(", "group", "Group", ",", "token", "string", ")", "(", "Group", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", ".", "MakeRequest", "(", "network"...
// Update will make a request to UAA to update the matching group resource. // A token with the "scim.write" or "groups.update" scope is required.
[ "Update", "will", "make", "a", "request", "to", "UAA", "to", "update", "the", "matching", "group", "resource", ".", "A", "token", "with", "the", "scim", ".", "write", "or", "groups", ".", "update", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L56-L76
148,429
pivotal-cf-experimental/warrant
groups_service.go
AddMember
func (gs GroupsService) AddMember(groupID, memberID, token string) (Member, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "POST", Path: fmt.Sprintf("/Groups/%s/members", groupID), Authorization: network.NewTokenAuthorization(token), Body: network.NewJSON...
go
func (gs GroupsService) AddMember(groupID, memberID, token string) (Member, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "POST", Path: fmt.Sprintf("/Groups/%s/members", groupID), Authorization: network.NewTokenAuthorization(token), Body: network.NewJSON...
[ "func", "(", "gs", "GroupsService", ")", "AddMember", "(", "groupID", ",", "memberID", ",", "token", "string", ")", "(", "Member", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", ".", "MakeRequest", ...
// AddMember will make a request to UAA to add a member to the group resource with the matching id. // A token with the "scim.write" scope is required.
[ "AddMember", "will", "make", "a", "request", "to", "UAA", "to", "add", "a", "member", "to", "the", "group", "resource", "with", "the", "matching", "id", ".", "A", "token", "with", "the", "scim", ".", "write", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L80-L103
148,430
pivotal-cf-experimental/warrant
groups_service.go
CheckMembership
func (gs GroupsService) CheckMembership(groupID, memberID, token string) (Member, bool, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/Groups/%s/members/%s", groupID, memberID), Authorization: network.NewTo...
go
func (gs GroupsService) CheckMembership(groupID, memberID, token string) (Member, bool, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/Groups/%s/members/%s", groupID, memberID), Authorization: network.NewTo...
[ "func", "(", "gs", "GroupsService", ")", "CheckMembership", "(", "groupID", ",", "memberID", ",", "token", "string", ")", "(", "Member", ",", "bool", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", "...
// CheckMembership will make a request to UAA to fetch a member resource from a group resource. // A token with the "scim.read" scope is required.
[ "CheckMembership", "will", "make", "a", "request", "to", "UAA", "to", "fetch", "a", "member", "resource", "from", "a", "group", "resource", ".", "A", "token", "with", "the", "scim", ".", "read", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L107-L129
148,431
pivotal-cf-experimental/warrant
groups_service.go
ListMembers
func (gs GroupsService) ListMembers(groupID, token string) ([]Member, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/Groups/%s/members", groupID), Authorization: network.NewTokenAuthorization(token), Acce...
go
func (gs GroupsService) ListMembers(groupID, token string) ([]Member, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/Groups/%s/members", groupID), Authorization: network.NewTokenAuthorization(token), Acce...
[ "func", "(", "gs", "GroupsService", ")", "ListMembers", "(", "groupID", ",", "token", "string", ")", "(", "[", "]", "Member", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", ".", "MakeRequest", "(", ...
// ListMembers will make a request to UAA to fetch the members of a group resource with the matching id. // A token with the "scim.read" scope is required.
[ "ListMembers", "will", "make", "a", "request", "to", "UAA", "to", "fetch", "the", "members", "of", "a", "group", "resource", "with", "the", "matching", "id", ".", "A", "token", "with", "the", "scim", ".", "read", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L133-L156
148,432
pivotal-cf-experimental/warrant
groups_service.go
RemoveMember
func (gs GroupsService) RemoveMember(groupID, memberID, token string) error { _, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "DELETE", Path: fmt.Sprintf("/Groups/%s/members/%s", groupID, memberID), Authorization: network.NewTokenAuthorization(to...
go
func (gs GroupsService) RemoveMember(groupID, memberID, token string) error { _, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "DELETE", Path: fmt.Sprintf("/Groups/%s/members/%s", groupID, memberID), Authorization: network.NewTokenAuthorization(to...
[ "func", "(", "gs", "GroupsService", ")", "RemoveMember", "(", "groupID", ",", "memberID", ",", "token", "string", ")", "error", "{", "_", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Reque...
// RemoveMember will make a request to UAA to remove a member from a group resource. // A token with the "scim.write" scope is required.
[ "RemoveMember", "will", "make", "a", "request", "to", "UAA", "to", "remove", "a", "member", "from", "a", "group", "resource", ".", "A", "token", "with", "the", "scim", ".", "write", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L160-L172
148,433
pivotal-cf-experimental/warrant
groups_service.go
Get
func (gs GroupsService) Get(id, token string) (Group, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/Groups/%s", id), Authorization: network.NewTokenAuthorization(token), AcceptableStatusCodes: []int{http...
go
func (gs GroupsService) Get(id, token string) (Group, error) { resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: "GET", Path: fmt.Sprintf("/Groups/%s", id), Authorization: network.NewTokenAuthorization(token), AcceptableStatusCodes: []int{http...
[ "func", "(", "gs", "GroupsService", ")", "Get", "(", "id", ",", "token", "string", ")", "(", "Group", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "gs", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Reque...
// Get will make a request to UAA to fetch the group resource with the matching id. // A token with the "scim.read" scope is required.
[ "Get", "will", "make", "a", "request", "to", "UAA", "to", "fetch", "the", "group", "resource", "with", "the", "matching", "id", ".", "A", "token", "with", "the", "scim", ".", "read", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L176-L194
148,434
pivotal-cf-experimental/warrant
groups_service.go
List
func (gs GroupsService) List(query Query, token string) ([]Group, error) { requestPath := url.URL{ Path: "/Groups", RawQuery: url.Values{ "filter": []string{query.Filter}, "sortBy": []string{query.SortBy}, }.Encode(), } resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: ...
go
func (gs GroupsService) List(query Query, token string) ([]Group, error) { requestPath := url.URL{ Path: "/Groups", RawQuery: url.Values{ "filter": []string{query.Filter}, "sortBy": []string{query.SortBy}, }.Encode(), } resp, err := newNetworkClient(gs.config).MakeRequest(network.Request{ Method: ...
[ "func", "(", "gs", "GroupsService", ")", "List", "(", "query", "Query", ",", "token", "string", ")", "(", "[", "]", "Group", ",", "error", ")", "{", "requestPath", ":=", "url", ".", "URL", "{", "Path", ":", "\"", "\"", ",", "RawQuery", ":", "url", ...
// List wil make a request to UAA to list the groups that match the given Query. // A token with the "scim.read" scope is required.
[ "List", "wil", "make", "a", "request", "to", "UAA", "to", "list", "the", "groups", "that", "match", "the", "given", "Query", ".", "A", "token", "with", "the", "scim", ".", "read", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/groups_service.go#L198-L229
148,435
pivotal-cf-experimental/warrant
internal/network/client.go
MakeRequest
func (c Client) MakeRequest(req Request) (Response, error) { if req.AcceptableStatusCodes == nil { panic("acceptable status codes for this request were not set") } request, err := c.buildRequest(req) if err != nil { return Response{}, err } var resp *http.Response transport := buildTransport(c.config.SkipV...
go
func (c Client) MakeRequest(req Request) (Response, error) { if req.AcceptableStatusCodes == nil { panic("acceptable status codes for this request were not set") } request, err := c.buildRequest(req) if err != nil { return Response{}, err } var resp *http.Response transport := buildTransport(c.config.SkipV...
[ "func", "(", "c", "Client", ")", "MakeRequest", "(", "req", "Request", ")", "(", "Response", ",", "error", ")", "{", "if", "req", ".", "AcceptableStatusCodes", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "request", ",", "err",...
// MakeRequest initiates a request to the remote host, returning a response and // possible error.
[ "MakeRequest", "initiates", "a", "request", "to", "the", "remote", "host", "returning", "a", "response", "and", "possible", "error", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/internal/network/client.go#L90-L123
148,436
pivotal-cf-experimental/warrant
users_service.go
Create
func (us UsersService) Create(username, email, token string) (User, error) { resp, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: "POST", Path: "/Users", Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(documents.CreateUserRequest{ ...
go
func (us UsersService) Create(username, email, token string) (User, error) { resp, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: "POST", Path: "/Users", Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(documents.CreateUserRequest{ ...
[ "func", "(", "us", "UsersService", ")", "Create", "(", "username", ",", "email", ",", "token", "string", ")", "(", "User", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "us", ".", "config", ")", ".", "MakeRequest", "(", "...
// Create will make a request to UAA to create a new user resource with the given username and email. // A token with the "scim.write" scope is required.
[ "Create", "will", "make", "a", "request", "to", "UAA", "to", "create", "a", "new", "user", "resource", "with", "the", "given", "username", "and", "email", ".", "A", "token", "with", "the", "scim", ".", "write", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/users_service.go#L43-L67
148,437
pivotal-cf-experimental/warrant
users_service.go
Update
func (us UsersService) Update(user User, token string) (User, error) { resp, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/Users/%s", user.ID), Authorization: network.NewTokenAuthorization(token), IfMatch: strconv.Itoa(user.Version), ...
go
func (us UsersService) Update(user User, token string) (User, error) { resp, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/Users/%s", user.ID), Authorization: network.NewTokenAuthorization(token), IfMatch: strconv.Itoa(user.Version), ...
[ "func", "(", "us", "UsersService", ")", "Update", "(", "user", "User", ",", "token", "string", ")", "(", "User", ",", "error", ")", "{", "resp", ",", "err", ":=", "newNetworkClient", "(", "us", ".", "config", ")", ".", "MakeRequest", "(", "network", ...
// Update will make a request to UAA to update the matching user resource. // A token with the "scim.write" or "uaa.admin" scope is required.
[ "Update", "will", "make", "a", "request", "to", "UAA", "to", "update", "the", "matching", "user", "resource", ".", "A", "token", "with", "the", "scim", ".", "write", "or", "uaa", ".", "admin", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/users_service.go#L109-L129
148,438
pivotal-cf-experimental/warrant
users_service.go
SetPassword
func (us UsersService) SetPassword(id, password, token string) error { _, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/Users/%s/password", id), Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(documents.S...
go
func (us UsersService) SetPassword(id, password, token string) error { _, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: "PUT", Path: fmt.Sprintf("/Users/%s/password", id), Authorization: network.NewTokenAuthorization(token), Body: network.NewJSONRequestBody(documents.S...
[ "func", "(", "us", "UsersService", ")", "SetPassword", "(", "id", ",", "password", ",", "token", "string", ")", "error", "{", "_", ",", "err", ":=", "newNetworkClient", "(", "us", ".", "config", ")", ".", "MakeRequest", "(", "network", ".", "Request", ...
// SetPassword will make a request to UAA to set the password for the user with the matching id to the // given password value. A token with the "password.write" scope is required.
[ "SetPassword", "will", "make", "a", "request", "to", "UAA", "to", "set", "the", "password", "for", "the", "user", "with", "the", "matching", "id", "to", "the", "given", "password", "value", ".", "A", "token", "with", "the", "password", ".", "write", "sco...
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/users_service.go#L133-L148
148,439
pivotal-cf-experimental/warrant
users_service.go
GetToken
func (us UsersService) GetToken(username, password string, client Client) (string, error) { req := network.Request{ Method: "POST", Path: "/oauth/token", Authorization: network.NewBasicAuthorization(client.ID, ""), Body: network.NewFormRequestBody(url.Values{ "username": []string{userna...
go
func (us UsersService) GetToken(username, password string, client Client) (string, error) { req := network.Request{ Method: "POST", Path: "/oauth/token", Authorization: network.NewBasicAuthorization(client.ID, ""), Body: network.NewFormRequestBody(url.Values{ "username": []string{userna...
[ "func", "(", "us", "UsersService", ")", "GetToken", "(", "username", ",", "password", "string", ",", "client", "Client", ")", "(", "string", ",", "error", ")", "{", "req", ":=", "network", ".", "Request", "{", "Method", ":", "\"", "\"", ",", "Path", ...
// GetToken will make a request to UAA to retrieve the token for the user matching the given username. // The user's password is required.
[ "GetToken", "will", "make", "a", "request", "to", "UAA", "to", "retrieve", "the", "token", "for", "the", "user", "matching", "the", "given", "username", ".", "The", "user", "s", "password", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/users_service.go#L173-L201
148,440
pivotal-cf-experimental/warrant
users_service.go
List
func (us UsersService) List(query Query, token string) ([]User, error) { requestPath := url.URL{ Path: "/Users", RawQuery: url.Values{ "filter": []string{query.Filter}, "sortBy": []string{query.SortBy}, }.Encode(), } resp, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: ...
go
func (us UsersService) List(query Query, token string) ([]User, error) { requestPath := url.URL{ Path: "/Users", RawQuery: url.Values{ "filter": []string{query.Filter}, "sortBy": []string{query.SortBy}, }.Encode(), } resp, err := newNetworkClient(us.config).MakeRequest(network.Request{ Method: ...
[ "func", "(", "us", "UsersService", ")", "List", "(", "query", "Query", ",", "token", "string", ")", "(", "[", "]", "User", ",", "error", ")", "{", "requestPath", ":=", "url", ".", "URL", "{", "Path", ":", "\"", "\"", ",", "RawQuery", ":", "url", ...
// List will make a request to UAA to retrieve all user resources matching the given query. // A token with the "scim.read" or "uaa.admin" scope is required.
[ "List", "will", "make", "a", "request", "to", "UAA", "to", "retrieve", "all", "user", "resources", "matching", "the", "given", "query", ".", "A", "token", "with", "the", "scim", ".", "read", "or", "uaa", ".", "admin", "scope", "is", "required", "." ]
f140d9566646eb4188a369301415a5f92266445e
https://github.com/pivotal-cf-experimental/warrant/blob/f140d9566646eb4188a369301415a5f92266445e/users_service.go#L205-L236
148,441
drewlanenga/govector
convert.go
AsVector
func AsVector(any interface{}) (Vector, error) { switch x := any.(type) { case []uint8: return uint8ToVector(x), nil case []uint16: return uint16ToVector(x), nil case []uint32: return uint32ToVector(x), nil case []uint64: return uint64ToVector(x), nil case []int: return intToVector(x), nil case []int8:...
go
func AsVector(any interface{}) (Vector, error) { switch x := any.(type) { case []uint8: return uint8ToVector(x), nil case []uint16: return uint16ToVector(x), nil case []uint32: return uint32ToVector(x), nil case []uint64: return uint64ToVector(x), nil case []int: return intToVector(x), nil case []int8:...
[ "func", "AsVector", "(", "any", "interface", "{", "}", ")", "(", "Vector", ",", "error", ")", "{", "switch", "x", ":=", "any", ".", "(", "type", ")", "{", "case", "[", "]", "uint8", ":", "return", "uint8ToVector", "(", "x", ")", ",", "nil", "\n",...
// AsVector converts slices of numeric types into a Vector.
[ "AsVector", "converts", "slices", "of", "numeric", "types", "into", "a", "Vector", "." ]
f69e9f02317ee9608f7b224ce1fc63a8602d0785
https://github.com/drewlanenga/govector/blob/f69e9f02317ee9608f7b224ce1fc63a8602d0785/convert.go#L8-L35
148,442
Clever/go-utils
sort/bystring/bystring.go
Swap
func (b byString) Swap(i, j int) { t := reflect.ValueOf(b.Data.Index(i).Interface()) b.Data.Index(i).Set(b.Data.Index(j)) b.Data.Index(j).Set(t) b.Indices[i], b.Indices[j] = b.Indices[j], b.Indices[i] }
go
func (b byString) Swap(i, j int) { t := reflect.ValueOf(b.Data.Index(i).Interface()) b.Data.Index(i).Set(b.Data.Index(j)) b.Data.Index(j).Set(t) b.Indices[i], b.Indices[j] = b.Indices[j], b.Indices[i] }
[ "func", "(", "b", "byString", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "t", ":=", "reflect", ".", "ValueOf", "(", "b", ".", "Data", ".", "Index", "(", "i", ")", ".", "Interface", "(", ")", ")", "\n", "b", ".", "Data", ".", "Index", ...
// Swap interchanges the i-th and j-th entries, also keeping track of their original indices.
[ "Swap", "interchanges", "the", "i", "-", "th", "and", "j", "-", "th", "entries", "also", "keeping", "track", "of", "their", "original", "indices", "." ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/sort/bystring/bystring.go#L33-L38
148,443
Clever/go-utils
stringset/stringset.go
New
func New(strings ...string) StringSet { set := make(map[string]struct{}, len(strings)) for _, str := range strings { set[str] = struct{}{} } return set }
go
func New(strings ...string) StringSet { set := make(map[string]struct{}, len(strings)) for _, str := range strings { set[str] = struct{}{} } return set }
[ "func", "New", "(", "strings", "...", "string", ")", "StringSet", "{", "set", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "len", "(", "strings", ")", ")", "\n", "for", "_", ",", "str", ":=", "range", "strings", "{", "se...
// New creates a new stringset with the specified strings in it
[ "New", "creates", "a", "new", "stringset", "with", "the", "specified", "strings", "in", "it" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L9-L15
148,444
Clever/go-utils
stringset/stringset.go
ToList
func (inputSet StringSet) ToList() []string { returnList := make([]string, 0, len(inputSet)) for key, _ := range inputSet { returnList = append(returnList, key) } return returnList }
go
func (inputSet StringSet) ToList() []string { returnList := make([]string, 0, len(inputSet)) for key, _ := range inputSet { returnList = append(returnList, key) } return returnList }
[ "func", "(", "inputSet", "StringSet", ")", "ToList", "(", ")", "[", "]", "string", "{", "returnList", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "inputSet", ")", ")", "\n", "for", "key", ",", "_", ":=", "range", "inputSet", ...
// ToList converts a StringSet to a list of strings
[ "ToList", "converts", "a", "StringSet", "to", "a", "list", "of", "strings" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L32-L38
148,445
Clever/go-utils
stringset/stringset.go
Clone
func (s StringSet) Clone() StringSet { returnSet := make(map[string]struct{}, len(s)) for key, value := range s { returnSet[key] = value } return returnSet }
go
func (s StringSet) Clone() StringSet { returnSet := make(map[string]struct{}, len(s)) for key, value := range s { returnSet[key] = value } return returnSet }
[ "func", "(", "s", "StringSet", ")", "Clone", "(", ")", "StringSet", "{", "returnSet", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "len", "(", "s", ")", ")", "\n", "for", "key", ",", "value", ":=", "range", "s", "{", "...
// Clone copies a string set to a new string set
[ "Clone", "copies", "a", "string", "set", "to", "a", "new", "string", "set" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L41-L47
148,446
Clever/go-utils
stringset/stringset.go
Intersect
func (s1 StringSet) Intersect(s2 StringSet) StringSet { return setOperation(s1, s2, true) }
go
func (s1 StringSet) Intersect(s2 StringSet) StringSet { return setOperation(s1, s2, true) }
[ "func", "(", "s1", "StringSet", ")", "Intersect", "(", "s2", "StringSet", ")", "StringSet", "{", "return", "setOperation", "(", "s1", ",", "s2", ",", "true", ")", "\n", "}" ]
// Intersect returns a new StringSet with the intersection of all the elements in both sets
[ "Intersect", "returns", "a", "new", "StringSet", "with", "the", "intersection", "of", "all", "the", "elements", "in", "both", "sets" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L50-L52
148,447
Clever/go-utils
stringset/stringset.go
Minus
func (s1 StringSet) Minus(s2 StringSet) StringSet { return setOperation(s1, s2, false) }
go
func (s1 StringSet) Minus(s2 StringSet) StringSet { return setOperation(s1, s2, false) }
[ "func", "(", "s1", "StringSet", ")", "Minus", "(", "s2", "StringSet", ")", "StringSet", "{", "return", "setOperation", "(", "s1", ",", "s2", ",", "false", ")", "\n", "}" ]
// Minus returns a new StringSet with the
[ "Minus", "returns", "a", "new", "StringSet", "with", "the" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L55-L57
148,448
Clever/go-utils
stringset/stringset.go
setOperation
func setOperation(s1, s2 StringSet, wantElemsInSet2 bool) map[string]struct{} { resultSet := make(map[string]struct{}) for key, _ := range s1 { if _, ok := s2[key]; ok == wantElemsInSet2 { resultSet[key] = struct{}{} } } return resultSet }
go
func setOperation(s1, s2 StringSet, wantElemsInSet2 bool) map[string]struct{} { resultSet := make(map[string]struct{}) for key, _ := range s1 { if _, ok := s2[key]; ok == wantElemsInSet2 { resultSet[key] = struct{}{} } } return resultSet }
[ "func", "setOperation", "(", "s1", ",", "s2", "StringSet", ",", "wantElemsInSet2", "bool", ")", "map", "[", "string", "]", "struct", "{", "}", "{", "resultSet", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "for", "key"...
// setOperation is a helper method to either intersect or subtract sets
[ "setOperation", "is", "a", "helper", "method", "to", "either", "intersect", "or", "subtract", "sets" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L60-L68
148,449
Clever/go-utils
stringset/stringset.go
AddSet
func (s StringSet) AddSet(newValues StringSet) { for newValue, _ := range newValues { s[newValue] = struct{}{} } }
go
func (s StringSet) AddSet(newValues StringSet) { for newValue, _ := range newValues { s[newValue] = struct{}{} } }
[ "func", "(", "s", "StringSet", ")", "AddSet", "(", "newValues", "StringSet", ")", "{", "for", "newValue", ",", "_", ":=", "range", "newValues", "{", "s", "[", "newValue", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}" ]
// AddSet adds all the elements in a string set to the operand set.
[ "AddSet", "adds", "all", "the", "elements", "in", "a", "string", "set", "to", "the", "operand", "set", "." ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L71-L75
148,450
Clever/go-utils
stringset/stringset.go
AddAll
func (s StringSet) AddAll(newValues []string) { for _, newValue := range newValues { s[newValue] = struct{}{} } }
go
func (s StringSet) AddAll(newValues []string) { for _, newValue := range newValues { s[newValue] = struct{}{} } }
[ "func", "(", "s", "StringSet", ")", "AddAll", "(", "newValues", "[", "]", "string", ")", "{", "for", "_", ",", "newValue", ":=", "range", "newValues", "{", "s", "[", "newValue", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}" ]
// AddAll adds all the elements in a string slice to the operand set.
[ "AddAll", "adds", "all", "the", "elements", "in", "a", "string", "slice", "to", "the", "operand", "set", "." ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L78-L82
148,451
Clever/go-utils
stringset/stringset.go
Equals
func (s1 StringSet) Equals(s2 StringSet) bool { if len(s1) != len(s2) { return false } for key, _ := range s1 { if _, ok := s2[key]; !ok { return false } } return true }
go
func (s1 StringSet) Equals(s2 StringSet) bool { if len(s1) != len(s2) { return false } for key, _ := range s1 { if _, ok := s2[key]; !ok { return false } } return true }
[ "func", "(", "s1", "StringSet", ")", "Equals", "(", "s2", "StringSet", ")", "bool", "{", "if", "len", "(", "s1", ")", "!=", "len", "(", "s2", ")", "{", "return", "false", "\n", "}", "\n", "for", "key", ",", "_", ":=", "range", "s1", "{", "if", ...
// Equals returns true if two string sets have exactly the same elements
[ "Equals", "returns", "true", "if", "two", "string", "sets", "have", "exactly", "the", "same", "elements" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L85-L95
148,452
Clever/go-utils
stringset/stringset.go
Contains
func (s StringSet) Contains(str string) bool { _, ok := s[str] return ok }
go
func (s StringSet) Contains(str string) bool { _, ok := s[str] return ok }
[ "func", "(", "s", "StringSet", ")", "Contains", "(", "str", "string", ")", "bool", "{", "_", ",", "ok", ":=", "s", "[", "str", "]", "\n", "return", "ok", "\n", "}" ]
// Contains returns true if a stringset contains the specified string
[ "Contains", "returns", "true", "if", "a", "stringset", "contains", "the", "specified", "string" ]
2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0
https://github.com/Clever/go-utils/blob/2dac0ec6f2ac65ef7ca2ca5f563c1c33adc155c0/stringset/stringset.go#L108-L111
148,453
kisom/goutils
fileutil/fileutil.go
Access
func Access(path string, mode int) error { return unix.Access(path, uint32(mode)) }
go
func Access(path string, mode int) error { return unix.Access(path, uint32(mode)) }
[ "func", "Access", "(", "path", "string", ",", "mode", "int", ")", "error", "{", "return", "unix", ".", "Access", "(", "path", ",", "uint32", "(", "mode", ")", ")", "\n", "}" ]
// Access returns a boolean indicating whether the mode being checked // for is valid.
[ "Access", "returns", "a", "boolean", "indicating", "whether", "the", "mode", "being", "checked", "for", "is", "valid", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/fileutil/fileutil.go#L45-L47
148,454
kisom/goutils
logging/log.go
Debug
func (lw *LogWriter) Debug(actor, event string, attrs map[string]string) { if lw.lvl > LevelDebug { return } lw.output(lw.wo, LevelDebug, actor, event, attrs) }
go
func (lw *LogWriter) Debug(actor, event string, attrs map[string]string) { if lw.lvl > LevelDebug { return } lw.output(lw.wo, LevelDebug, actor, event, attrs) }
[ "func", "(", "lw", "*", "LogWriter", ")", "Debug", "(", "actor", ",", "event", "string", ",", "attrs", "map", "[", "string", "]", "string", ")", "{", "if", "lw", ".", "lvl", ">", "LevelDebug", "{", "return", "\n", "}", "\n", "lw", ".", "output", ...
// Debug emits a debug-level message. These are only used during // development or if a deployed system repeatedly sees abnormal // errors. // // Actor specifies the component emitting the message; event indicates // the event that caused the log message to be emitted. attrs is a map // of key-value string pairs that c...
[ "Debug", "emits", "a", "debug", "-", "level", "message", ".", "These", "are", "only", "used", "during", "development", "or", "if", "a", "deployed", "system", "repeatedly", "sees", "abnormal", "errors", ".", "Actor", "specifies", "the", "component", "emitting",...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/log.go#L140-L145
148,455
kisom/goutils
logging/log.go
Info
func (lw *LogWriter) Info(actor, event string, attrs map[string]string) { if lw.lvl > LevelInfo { return } lw.output(lw.wo, LevelInfo, actor, event, attrs) }
go
func (lw *LogWriter) Info(actor, event string, attrs map[string]string) { if lw.lvl > LevelInfo { return } lw.output(lw.wo, LevelInfo, actor, event, attrs) }
[ "func", "(", "lw", "*", "LogWriter", ")", "Info", "(", "actor", ",", "event", "string", ",", "attrs", "map", "[", "string", "]", "string", ")", "{", "if", "lw", ".", "lvl", ">", "LevelInfo", "{", "return", "\n", "}", "\n", "lw", ".", "output", "(...
// Info emits an informational message. This is a normal log message // that is used to deliver information, such as recording // requests. Ops teams are never paged for informational // messages. This is the default log level. // // Actor specifies the component emitting the message; event indicates // the event that ...
[ "Info", "emits", "an", "informational", "message", ".", "This", "is", "a", "normal", "log", "message", "that", "is", "used", "to", "deliver", "information", "such", "as", "recording", "requests", ".", "Ops", "teams", "are", "never", "paged", "for", "informat...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/log.go#L156-L161
148,456
kisom/goutils
logging/log.go
Critical
func (lw *LogWriter) Critical(actor, event string, attrs map[string]string) { if lw.lvl > LevelCritical { return } lw.output(lw.we, LevelCritical, actor, event, attrs) }
go
func (lw *LogWriter) Critical(actor, event string, attrs map[string]string) { if lw.lvl > LevelCritical { return } lw.output(lw.we, LevelCritical, actor, event, attrs) }
[ "func", "(", "lw", "*", "LogWriter", ")", "Critical", "(", "actor", ",", "event", "string", ",", "attrs", "map", "[", "string", "]", "string", ")", "{", "if", "lw", ".", "lvl", ">", "LevelCritical", "{", "return", "\n", "}", "\n", "lw", ".", "outpu...
// Critical emits a message indicating a critical condition. The // error, if uncorrected, is likely to cause a fatal condition // shortly. An example is running out of disk space. This is // something that the ops team should get paged for. // // Actor specifies the component emitting the message; event indicates // ...
[ "Critical", "emits", "a", "message", "indicating", "a", "critical", "condition", ".", "The", "error", "if", "uncorrected", "is", "likely", "to", "cause", "a", "fatal", "condition", "shortly", ".", "An", "example", "is", "running", "out", "of", "disk", "space...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/log.go#L208-L213
148,457
kisom/goutils
logging/log.go
Fatal
func (lw *LogWriter) Fatal(actor, event string, attrs map[string]string) { if lw.lvl > LevelFatal { return } lw.output(lw.we, LevelFatal, actor, event, attrs) os.Exit(1) }
go
func (lw *LogWriter) Fatal(actor, event string, attrs map[string]string) { if lw.lvl > LevelFatal { return } lw.output(lw.we, LevelFatal, actor, event, attrs) os.Exit(1) }
[ "func", "(", "lw", "*", "LogWriter", ")", "Fatal", "(", "actor", ",", "event", "string", ",", "attrs", "map", "[", "string", "]", "string", ")", "{", "if", "lw", ".", "lvl", ">", "LevelFatal", "{", "return", "\n", "}", "\n", "lw", ".", "output", ...
// Fatal emits a message indicating that the system is in an unsuable // state, and cannot continue to run. The program will exit with exit // code 1. // // Actor specifies the component emitting the message; event indicates // the event that caused the log message to be emitted. attrs is a map // of key-value string p...
[ "Fatal", "emits", "a", "message", "indicating", "that", "the", "system", "is", "in", "an", "unsuable", "state", "and", "cannot", "continue", "to", "run", ".", "The", "program", "will", "exit", "with", "exit", "code", "1", ".", "Actor", "specifies", "the", ...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/log.go#L223-L229
148,458
kisom/goutils
logging/log.go
FatalCode
func (lw *LogWriter) FatalCode(exitcode int, actor, event string, attrs map[string]string) { if lw.lvl > LevelFatal { return } lw.output(lw.we, LevelFatal, actor, event, attrs) os.Exit(exitcode) }
go
func (lw *LogWriter) FatalCode(exitcode int, actor, event string, attrs map[string]string) { if lw.lvl > LevelFatal { return } lw.output(lw.we, LevelFatal, actor, event, attrs) os.Exit(exitcode) }
[ "func", "(", "lw", "*", "LogWriter", ")", "FatalCode", "(", "exitcode", "int", ",", "actor", ",", "event", "string", ",", "attrs", "map", "[", "string", "]", "string", ")", "{", "if", "lw", ".", "lvl", ">", "LevelFatal", "{", "return", "\n", "}", "...
// FatalCode emits a message indicating that the system is in an unsuable // state, and cannot continue to run. The program will exit with the // exit code speicfied in the exitcode argument. // // Actor specifies the component emitting the message; event indicates // the event that caused the log message to be emitted...
[ "FatalCode", "emits", "a", "message", "indicating", "that", "the", "system", "is", "in", "an", "unsuable", "state", "and", "cannot", "continue", "to", "run", ".", "The", "program", "will", "exit", "with", "the", "exit", "code", "speicfied", "in", "the", "e...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/log.go#L239-L245
148,459
kisom/goutils
logging/log.go
FatalNoDie
func (lw *LogWriter) FatalNoDie(actor, event string, attrs map[string]string) { if lw.lvl > LevelFatal { return } lw.output(lw.we, LevelFatal, actor, event, attrs) }
go
func (lw *LogWriter) FatalNoDie(actor, event string, attrs map[string]string) { if lw.lvl > LevelFatal { return } lw.output(lw.we, LevelFatal, actor, event, attrs) }
[ "func", "(", "lw", "*", "LogWriter", ")", "FatalNoDie", "(", "actor", ",", "event", "string", ",", "attrs", "map", "[", "string", "]", "string", ")", "{", "if", "lw", ".", "lvl", ">", "LevelFatal", "{", "return", "\n", "}", "\n", "lw", ".", "output...
// FatalNoDie emits a message indicating that the system is in an unsuable // state, and cannot continue to run. The program will not exit; it is // assumed that the caller has some final clean up to perform. // // Actor specifies the component emitting the message; event indicates // the event that caused the log mess...
[ "FatalNoDie", "emits", "a", "message", "indicating", "that", "the", "system", "is", "in", "an", "unsuable", "state", "and", "cannot", "continue", "to", "run", ".", "The", "program", "will", "not", "exit", ";", "it", "is", "assumed", "that", "the", "caller"...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/log.go#L255-L260
148,460
kisom/goutils
cmd/certdump/util.go
TranslateCFSSLError
func TranslateCFSSLError(err error) error { if err == nil { return nil } // printing errors as json is terrible if cfsslError, ok := err.(*cferr.Error); ok { err = errors.New(cfsslError.Message) } return err }
go
func TranslateCFSSLError(err error) error { if err == nil { return nil } // printing errors as json is terrible if cfsslError, ok := err.(*cferr.Error); ok { err = errors.New(cfsslError.Message) } return err }
[ "func", "TranslateCFSSLError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// printing errors as json is terrible", "if", "cfsslError", ",", "ok", ":=", "err", ".", "(", "*", "cferr", ".", "Er...
// TranslateCFSSLError turns a CFSSL error into a more readable string.
[ "TranslateCFSSLError", "turns", "a", "CFSSL", "error", "into", "a", "more", "readable", "string", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/cmd/certdump/util.go#L93-L103
148,461
kisom/goutils
cmd/certdump/util.go
wrap
func wrap(s string, indent int) string { if indent > 3 { indent = 3 } wrapped := text.Wrap(s, maxLine) lines := strings.SplitN(wrapped, "\n", 2) if len(lines) == 1 { return lines[0] } if (maxLine - indentLen(indent)) <= 0 { panic("too much indentation") } rest := strings.Join(lines[1:], " ") wrapped ...
go
func wrap(s string, indent int) string { if indent > 3 { indent = 3 } wrapped := text.Wrap(s, maxLine) lines := strings.SplitN(wrapped, "\n", 2) if len(lines) == 1 { return lines[0] } if (maxLine - indentLen(indent)) <= 0 { panic("too much indentation") } rest := strings.Join(lines[1:], " ") wrapped ...
[ "func", "wrap", "(", "s", "string", ",", "indent", "int", ")", "string", "{", "if", "indent", ">", "3", "{", "indent", "=", "3", "\n", "}", "\n\n", "wrapped", ":=", "text", ".", "Wrap", "(", "s", ",", "maxLine", ")", "\n", "lines", ":=", "strings...
// this isn't real efficient, but that's not a problem here
[ "this", "isn", "t", "real", "efficient", "but", "that", "s", "not", "a", "problem", "here" ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/cmd/certdump/util.go#L135-L153
148,462
kisom/goutils
die/die.go
With
func With(fstr string, args ...interface{}) { out := fmt.Sprintf("[!] %s\n", fstr) fmt.Fprintf(os.Stderr, out, args...) os.Exit(1) }
go
func With(fstr string, args ...interface{}) { out := fmt.Sprintf("[!] %s\n", fstr) fmt.Fprintf(os.Stderr, out, args...) os.Exit(1) }
[ "func", "With", "(", "fstr", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "out", ":=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "fstr", ")", "\n", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "out", ",", "a...
// With prints the message to stderr, appending a newline, and exits.
[ "With", "prints", "the", "message", "to", "stderr", "appending", "a", "newline", "and", "exits", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/die/die.go#L18-L22
148,463
kisom/goutils
die/die.go
When
func When(cond bool, fstr string, args ...interface{}) { if cond { With(fstr, args...) } }
go
func When(cond bool, fstr string, args ...interface{}) { if cond { With(fstr, args...) } }
[ "func", "When", "(", "cond", "bool", ",", "fstr", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "cond", "{", "With", "(", "fstr", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// When prints the error to stderr and exits if cond is true.
[ "When", "prints", "the", "error", "to", "stderr", "and", "exits", "if", "cond", "is", "true", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/die/die.go#L25-L29
148,464
kisom/goutils
dbg/dbg.go
Write
func (dbg *DebugPrinter) Write(p []byte) (int, error) { if dbg.Enabled { return dbg.out.Write(p) } return 0, nil }
go
func (dbg *DebugPrinter) Write(p []byte) (int, error) { if dbg.Enabled { return dbg.out.Write(p) } return 0, nil }
[ "func", "(", "dbg", "*", "DebugPrinter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "dbg", ".", "Enabled", "{", "return", "dbg", ".", "out", ".", "Write", "(", "p", ")", "\n", "}", "\n", "return", ...
// Write satisfies the Writer interface.
[ "Write", "satisfies", "the", "Writer", "interface", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/dbg/dbg.go#L24-L29
148,465
kisom/goutils
dbg/dbg.go
ToFile
func ToFile(path string) (*DebugPrinter, error) { file, err := os.Create(path) if err != nil { return nil, err } return &DebugPrinter{ out: file, }, nil }
go
func ToFile(path string) (*DebugPrinter, error) { file, err := os.Create(path) if err != nil { return nil, err } return &DebugPrinter{ out: file, }, nil }
[ "func", "ToFile", "(", "path", "string", ")", "(", "*", "DebugPrinter", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Create", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", ...
// ToFile sets up a new DebugPrinter to a file, truncating it if it exists.
[ "ToFile", "sets", "up", "a", "new", "DebugPrinter", "to", "a", "file", "truncating", "it", "if", "it", "exists", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/dbg/dbg.go#L39-L48
148,466
kisom/goutils
dbg/dbg.go
Print
func (dbg DebugPrinter) Print(v ...interface{}) { if dbg.Enabled { fmt.Fprint(dbg.out, v...) } }
go
func (dbg DebugPrinter) Print(v ...interface{}) { if dbg.Enabled { fmt.Fprint(dbg.out, v...) } }
[ "func", "(", "dbg", "DebugPrinter", ")", "Print", "(", "v", "...", "interface", "{", "}", ")", "{", "if", "dbg", ".", "Enabled", "{", "fmt", ".", "Fprint", "(", "dbg", ".", "out", ",", "v", "...", ")", "\n", "}", "\n", "}" ]
// Print calls fmt.Print if Enabled is true.
[ "Print", "calls", "fmt", ".", "Print", "if", "Enabled", "is", "true", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/dbg/dbg.go#L58-L62
148,467
kisom/goutils
dbg/dbg.go
Println
func (dbg DebugPrinter) Println(v ...interface{}) { if dbg.Enabled { fmt.Fprintln(dbg.out, v...) } }
go
func (dbg DebugPrinter) Println(v ...interface{}) { if dbg.Enabled { fmt.Fprintln(dbg.out, v...) } }
[ "func", "(", "dbg", "DebugPrinter", ")", "Println", "(", "v", "...", "interface", "{", "}", ")", "{", "if", "dbg", ".", "Enabled", "{", "fmt", ".", "Fprintln", "(", "dbg", ".", "out", ",", "v", "...", ")", "\n", "}", "\n", "}" ]
// Println calls fmt.Println if Enabled is true.
[ "Println", "calls", "fmt", ".", "Println", "if", "Enabled", "is", "true", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/dbg/dbg.go#L65-L69
148,468
kisom/goutils
dbg/dbg.go
Printf
func (dbg DebugPrinter) Printf(format string, v ...interface{}) { if dbg.Enabled { fmt.Fprintf(dbg.out, format, v...) } }
go
func (dbg DebugPrinter) Printf(format string, v ...interface{}) { if dbg.Enabled { fmt.Fprintf(dbg.out, format, v...) } }
[ "func", "(", "dbg", "DebugPrinter", ")", "Printf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "dbg", ".", "Enabled", "{", "fmt", ".", "Fprintf", "(", "dbg", ".", "out", ",", "format", ",", "v", "...", ")", "\...
// Printf calls fmt.Printf if Enabled is true.
[ "Printf", "calls", "fmt", ".", "Printf", "if", "Enabled", "is", "true", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/dbg/dbg.go#L72-L76
148,469
obeattie/ohmyglob
utils.go
separatorsScanner
func separatorsScanner(separators []rune) func(data []byte, atEOF bool) (int, []byte, error) { return func(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } // Transform the separators into a map (for efficient lookup) seps := make(map[rune]...
go
func separatorsScanner(separators []rune) func(data []byte, atEOF bool) (int, []byte, error) { return func(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } // Transform the separators into a map (for efficient lookup) seps := make(map[rune]...
[ "func", "separatorsScanner", "(", "separators", "[", "]", "rune", ")", "func", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "int", ",", "[", "]", "byte", ",", "error", ")", "{", "return", "func", "(", "data", "[", "]", "byte", "...
// separatorsScanner returns a split function for a scanner that returns tokens delimited any of the specified runes. // Note that the delimiters themselves are counted as tokens, so callers who want to discard the separators must do this // themselves.
[ "separatorsScanner", "returns", "a", "split", "function", "for", "a", "scanner", "that", "returns", "tokens", "delimited", "any", "of", "the", "specified", "runes", ".", "Note", "that", "the", "delimiters", "themselves", "are", "counted", "as", "tokens", "so", ...
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/utils.go#L26-L61
148,470
obeattie/ohmyglob
utils.go
EscapeGlobComponent
func EscapeGlobComponent(component string, options *Options) string { if options == nil { options = DefaultOptions } runesToEscape := make([]rune, 0, len(expanders)+1) runesToEscape = append(runesToEscape, expanders...) runesToEscape = append(runesToEscape, options.Separator) runesToEscapeMap := make(map[stri...
go
func EscapeGlobComponent(component string, options *Options) string { if options == nil { options = DefaultOptions } runesToEscape := make([]rune, 0, len(expanders)+1) runesToEscape = append(runesToEscape, expanders...) runesToEscape = append(runesToEscape, options.Separator) runesToEscapeMap := make(map[stri...
[ "func", "EscapeGlobComponent", "(", "component", "string", ",", "options", "*", "Options", ")", "string", "{", "if", "options", "==", "nil", "{", "options", "=", "DefaultOptions", "\n", "}", "\n\n", "runesToEscape", ":=", "make", "(", "[", "]", "rune", ","...
// EscapeGlobComponent returns an escaped version of the passed string, ensuring a literal match when used in a pattern.
[ "EscapeGlobComponent", "returns", "an", "escaped", "version", "of", "the", "passed", "string", "ensuring", "a", "literal", "match", "when", "used", "in", "a", "pattern", "." ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/utils.go#L64-L90
148,471
obeattie/ohmyglob
utils.go
EscapeGlobString
func EscapeGlobString(gs string, options *Options) string { if options == nil { options = DefaultOptions } runesToEscapeMap := make(map[string]bool, len(expanders)) for _, r := range expanders { runesToEscapeMap[string(r)] = true } scanner := bufio.NewScanner(strings.NewReader(gs)) scanner.Split(separators...
go
func EscapeGlobString(gs string, options *Options) string { if options == nil { options = DefaultOptions } runesToEscapeMap := make(map[string]bool, len(expanders)) for _, r := range expanders { runesToEscapeMap[string(r)] = true } scanner := bufio.NewScanner(strings.NewReader(gs)) scanner.Split(separators...
[ "func", "EscapeGlobString", "(", "gs", "string", ",", "options", "*", "Options", ")", "string", "{", "if", "options", "==", "nil", "{", "options", "=", "DefaultOptions", "\n", "}", "\n\n", "runesToEscapeMap", ":=", "make", "(", "map", "[", "string", "]", ...
// EscapeGlobString returns an escaped version of the passed string, ensuring a literal match of its components. // As distinct to EscapeGlobComponent, it will not escape the separator
[ "EscapeGlobString", "returns", "an", "escaped", "version", "of", "the", "passed", "string", "ensuring", "a", "literal", "match", "of", "its", "components", ".", "As", "distinct", "to", "EscapeGlobComponent", "it", "will", "not", "escape", "the", "separator" ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/utils.go#L94-L116
148,472
obeattie/ohmyglob
tokeniser.go
parse
func (g *globTokeniser) parse(lastTokenType tc) (string, tc, error) { var err error tokenBuf := new(bytes.Buffer) tokenType := tcUnknown escaped := lastTokenType == tcEscaper for { var r rune r, _, err = g.input.ReadRune() if err != nil { break } runeType := tcUnknown switch r { case Escaper: ...
go
func (g *globTokeniser) parse(lastTokenType tc) (string, tc, error) { var err error tokenBuf := new(bytes.Buffer) tokenType := tcUnknown escaped := lastTokenType == tcEscaper for { var r rune r, _, err = g.input.ReadRune() if err != nil { break } runeType := tcUnknown switch r { case Escaper: ...
[ "func", "(", "g", "*", "globTokeniser", ")", "parse", "(", "lastTokenType", "tc", ")", "(", "string", ",", "tc", ",", "error", ")", "{", "var", "err", "error", "\n\n", "tokenBuf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "tokenType", ":="...
// Advances by a single token
[ "Advances", "by", "a", "single", "token" ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/tokeniser.go#L48-L120
148,473
obeattie/ohmyglob
tokeniser.go
Scan
func (g *globTokeniser) Scan() bool { if g.hasPeek { g.token, g.tokenType, g.err = g.peekToken, g.peekTokenType, g.peekErr } else { g.token, g.tokenType, g.err = g.parse(g.tokenType) } g.peekErr = nil g.peekToken = "" g.peekTokenType = tcUnknown g.hasPeek = false return g.err == nil }
go
func (g *globTokeniser) Scan() bool { if g.hasPeek { g.token, g.tokenType, g.err = g.peekToken, g.peekTokenType, g.peekErr } else { g.token, g.tokenType, g.err = g.parse(g.tokenType) } g.peekErr = nil g.peekToken = "" g.peekTokenType = tcUnknown g.hasPeek = false return g.err == nil }
[ "func", "(", "g", "*", "globTokeniser", ")", "Scan", "(", ")", "bool", "{", "if", "g", ".", "hasPeek", "{", "g", ".", "token", ",", "g", ".", "tokenType", ",", "g", ".", "err", "=", "g", ".", "peekToken", ",", "g", ".", "peekTokenType", ",", "g...
// Scan advances the tokeniser to the next token, which will then be available through the Token method. It returns // false when the tokenisation stops, either by reaching the end of the input or an error. After Scan returns false, // the Err method will return any error that occurred during scanning, except that if i...
[ "Scan", "advances", "the", "tokeniser", "to", "the", "next", "token", "which", "will", "then", "be", "available", "through", "the", "Token", "method", ".", "It", "returns", "false", "when", "the", "tokenisation", "stops", "either", "by", "reaching", "the", "...
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/tokeniser.go#L126-L138
148,474
obeattie/ohmyglob
tokeniser.go
Err
func (g *globTokeniser) Err() error { if g.err == io.EOF { return nil } return g.err }
go
func (g *globTokeniser) Err() error { if g.err == io.EOF { return nil } return g.err }
[ "func", "(", "g", "*", "globTokeniser", ")", "Err", "(", ")", "error", "{", "if", "g", ".", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "\n\n", "return", "g", ".", "err", "\n", "}" ]
// Err returns the first non-EOF error that was encountered by the tokeniser
[ "Err", "returns", "the", "first", "non", "-", "EOF", "error", "that", "was", "encountered", "by", "the", "tokeniser" ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/tokeniser.go#L152-L158
148,475
obeattie/ohmyglob
tokeniser.go
PeekToken
func (g *globTokeniser) PeekToken() (token string, tokenType tc) { return g.peekToken, g.peekTokenType }
go
func (g *globTokeniser) PeekToken() (token string, tokenType tc) { return g.peekToken, g.peekTokenType }
[ "func", "(", "g", "*", "globTokeniser", ")", "PeekToken", "(", ")", "(", "token", "string", ",", "tokenType", "tc", ")", "{", "return", "g", ".", "peekToken", ",", "g", ".", "peekTokenType", "\n", "}" ]
// PeekToken returns the peeked token
[ "PeekToken", "returns", "the", "peeked", "token" ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/tokeniser.go#L165-L167
148,476
kisom/goutils
assert/assert.go
ErrorEq
func ErrorEq(expected, actual error) { if NoDebug || (expected == actual) { return } if expected == nil { die(fmt.Sprintf("assert.ErrorEq: %s", actual.Error())) } var should string if actual == nil { should = "no error was returned" } else { should = fmt.Sprintf("have '%s'", actual) } die(fmt.Sprint...
go
func ErrorEq(expected, actual error) { if NoDebug || (expected == actual) { return } if expected == nil { die(fmt.Sprintf("assert.ErrorEq: %s", actual.Error())) } var should string if actual == nil { should = "no error was returned" } else { should = fmt.Sprintf("have '%s'", actual) } die(fmt.Sprint...
[ "func", "ErrorEq", "(", "expected", ",", "actual", "error", ")", "{", "if", "NoDebug", "||", "(", "expected", "==", "actual", ")", "{", "return", "\n", "}", "\n\n", "if", "expected", "==", "nil", "{", "die", "(", "fmt", ".", "Sprintf", "(", "\"", "...
// ErrorEq asserts that the actual error is the expected error.
[ "ErrorEq", "asserts", "that", "the", "actual", "error", "is", "the", "expected", "error", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/assert/assert.go#L102-L119
148,477
kisom/goutils
assert/assert.go
BoolT
func BoolT(t *testing.T, cond bool, s ...string) { if !cond { what := strings.Join(s, ", ") if len(what) > 0 { what = ": " + what } t.Fatalf("assert.Bool failed%s", what) } }
go
func BoolT(t *testing.T, cond bool, s ...string) { if !cond { what := strings.Join(s, ", ") if len(what) > 0 { what = ": " + what } t.Fatalf("assert.Bool failed%s", what) } }
[ "func", "BoolT", "(", "t", "*", "testing", ".", "T", ",", "cond", "bool", ",", "s", "...", "string", ")", "{", "if", "!", "cond", "{", "what", ":=", "strings", ".", "Join", "(", "s", ",", "\"", "\"", ")", "\n", "if", "len", "(", "what", ")", ...
// BoolT checks a boolean condition, calling Fatal on t if it is // false.
[ "BoolT", "checks", "a", "boolean", "condition", "calling", "Fatal", "on", "t", "if", "it", "is", "false", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/assert/assert.go#L123-L131
148,478
kisom/goutils
assert/assert.go
ErrorEqT
func ErrorEqT(t *testing.T, expected, actual error) { if NoDebug || (expected == actual) { return } if expected == nil { die(fmt.Sprintf("assert.Error2: %s", actual.Error())) } var should string if actual == nil { should = "no error was returned" } else { should = fmt.Sprintf("have '%s'", actual) } ...
go
func ErrorEqT(t *testing.T, expected, actual error) { if NoDebug || (expected == actual) { return } if expected == nil { die(fmt.Sprintf("assert.Error2: %s", actual.Error())) } var should string if actual == nil { should = "no error was returned" } else { should = fmt.Sprintf("have '%s'", actual) } ...
[ "func", "ErrorEqT", "(", "t", "*", "testing", ".", "T", ",", "expected", ",", "actual", "error", ")", "{", "if", "NoDebug", "||", "(", "expected", "==", "actual", ")", "{", "return", "\n", "}", "\n\n", "if", "expected", "==", "nil", "{", "die", "("...
// ErrorEqT compares a pair of errors, calling Fatal on it if they // don't match.
[ "ErrorEqT", "compares", "a", "pair", "of", "errors", "calling", "Fatal", "on", "it", "if", "they", "don", "t", "match", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/assert/assert.go#L157-L174
148,479
kisom/goutils
mwc/mwc.go
Write
func (t *mwc) Write(p []byte) (n int, err error) { for _, w := range t.wcs { n, err = w.Write(p) if err != nil { return } if n != len(p) { err = io.ErrShortWrite return } } return len(p), nil }
go
func (t *mwc) Write(p []byte) (n int, err error) { for _, w := range t.wcs { n, err = w.Write(p) if err != nil { return } if n != len(p) { err = io.ErrShortWrite return } } return len(p), nil }
[ "func", "(", "t", "*", "mwc", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "for", "_", ",", "w", ":=", "range", "t", ".", "wcs", "{", "n", ",", "err", "=", "w", ".", "Write", "(", "p", "...
// Write implements the Writer interface.
[ "Write", "implements", "the", "Writer", "interface", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/mwc/mwc.go#L11-L23
148,480
kisom/goutils
mwc/mwc.go
Close
func (t *mwc) Close() error { for _, wc := range t.wcs { err := wc.Close() if err != nil { return err } } return nil }
go
func (t *mwc) Close() error { for _, wc := range t.wcs { err := wc.Close() if err != nil { return err } } return nil }
[ "func", "(", "t", "*", "mwc", ")", "Close", "(", ")", "error", "{", "for", "_", ",", "wc", ":=", "range", "t", ".", "wcs", "{", "err", ":=", "wc", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n"...
// Close implements the Closer interface.
[ "Close", "implements", "the", "Closer", "interface", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/mwc/mwc.go#L26-L34
148,481
kisom/goutils
logging/file.go
Close
func (fl *File) Close() error { if fl.fo != nil { if err := fl.fo.Close(); err != nil { return err } fl.fo = nil } if fl.fe != nil { return fl.fe.Close() } return nil }
go
func (fl *File) Close() error { if fl.fo != nil { if err := fl.fo.Close(); err != nil { return err } fl.fo = nil } if fl.fe != nil { return fl.fe.Close() } return nil }
[ "func", "(", "fl", "*", "File", ")", "Close", "(", ")", "error", "{", "if", "fl", ".", "fo", "!=", "nil", "{", "if", "err", ":=", "fl", ".", "fo", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "fl",...
// Close calls close on the underlying log files.
[ "Close", "calls", "close", "on", "the", "underlying", "log", "files", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/file.go#L12-L25
148,482
kisom/goutils
logging/file.go
NewFile
func NewFile(path string, overwrite bool) (*File, error) { fl := new(File) var err error if overwrite { fl.fo, err = os.Create(path) } else { fl.fo, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0644) } if err != nil { return nil, err } fl.LogWriter = NewLogWriter(fl.fo, fl.fo) return fl, nil }
go
func NewFile(path string, overwrite bool) (*File, error) { fl := new(File) var err error if overwrite { fl.fo, err = os.Create(path) } else { fl.fo, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0644) } if err != nil { return nil, err } fl.LogWriter = NewLogWriter(fl.fo, fl.fo) return fl, nil }
[ "func", "NewFile", "(", "path", "string", ",", "overwrite", "bool", ")", "(", "*", "File", ",", "error", ")", "{", "fl", ":=", "new", "(", "File", ")", "\n\n", "var", "err", "error", "\n\n", "if", "overwrite", "{", "fl", ".", "fo", ",", "err", "=...
// NewFile creates a new Logger that writes all logs to the file // specified by path. If overwrite is specified, the log file will be // truncated before writing. Otherwise, the log file will be appended // to.
[ "NewFile", "creates", "a", "new", "Logger", "that", "writes", "all", "logs", "to", "the", "file", "specified", "by", "path", ".", "If", "overwrite", "is", "specified", "the", "log", "file", "will", "be", "truncated", "before", "writing", ".", "Otherwise", ...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/file.go#L31-L48
148,483
kisom/goutils
logging/file.go
NewSplitFile
func NewSplitFile(outpath, errpath string, overwrite bool) (*File, error) { fl := new(File) var err error if overwrite { fl.fo, err = os.Create(outpath) } else { fl.fo, err = os.OpenFile(outpath, os.O_WRONLY|os.O_APPEND, 0644) } if err != nil { return nil, err } if overwrite { fl.fe, err = os.Create...
go
func NewSplitFile(outpath, errpath string, overwrite bool) (*File, error) { fl := new(File) var err error if overwrite { fl.fo, err = os.Create(outpath) } else { fl.fo, err = os.OpenFile(outpath, os.O_WRONLY|os.O_APPEND, 0644) } if err != nil { return nil, err } if overwrite { fl.fe, err = os.Create...
[ "func", "NewSplitFile", "(", "outpath", ",", "errpath", "string", ",", "overwrite", "bool", ")", "(", "*", "File", ",", "error", ")", "{", "fl", ":=", "new", "(", "File", ")", "\n\n", "var", "err", "error", "\n\n", "if", "overwrite", "{", "fl", ".", ...
// NewSplitFile creates a new Logger that writes debug and information // messages to the output file, and warning and higher messages to the // error file. If overwrite is specified, the log files will be // truncated before writing.
[ "NewSplitFile", "creates", "a", "new", "Logger", "that", "writes", "debug", "and", "information", "messages", "to", "the", "output", "file", "and", "warning", "and", "higher", "messages", "to", "the", "error", "file", ".", "If", "overwrite", "is", "specified",...
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/logging/file.go#L54-L82
148,484
kisom/goutils
ahash/ahash.go
Sum32
func (h *Hash) Sum32() (uint32, bool) { h32, ok := h.Hash.(hash.Hash32) if !ok { return 0, false } return h32.Sum32(), true }
go
func (h *Hash) Sum32() (uint32, bool) { h32, ok := h.Hash.(hash.Hash32) if !ok { return 0, false } return h32.Sum32(), true }
[ "func", "(", "h", "*", "Hash", ")", "Sum32", "(", ")", "(", "uint32", ",", "bool", ")", "{", "h32", ",", "ok", ":=", "h", ".", "Hash", ".", "(", "hash", ".", "Hash32", ")", "\n", "if", "!", "ok", "{", "return", "0", ",", "false", "\n", "}",...
// Sum32 returns true if the underlying hash is a 32-bit hash; if is, the // uint32 parameter will contain the hash.
[ "Sum32", "returns", "true", "if", "the", "underlying", "hash", "is", "a", "32", "-", "bit", "hash", ";", "if", "is", "the", "uint32", "parameter", "will", "contain", "the", "hash", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/ahash/ahash.go#L74-L81
148,485
kisom/goutils
ahash/ahash.go
IsHash32
func (h *Hash) IsHash32() bool { _, ok := h.Hash.(hash.Hash32) return ok }
go
func (h *Hash) IsHash32() bool { _, ok := h.Hash.(hash.Hash32) return ok }
[ "func", "(", "h", "*", "Hash", ")", "IsHash32", "(", ")", "bool", "{", "_", ",", "ok", ":=", "h", ".", "Hash", ".", "(", "hash", ".", "Hash32", ")", "\n", "return", "ok", "\n", "}" ]
// IsHash32 returns true if the underlying hash is a 32-bit hash function.
[ "IsHash32", "returns", "true", "if", "the", "underlying", "hash", "is", "a", "32", "-", "bit", "hash", "function", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/ahash/ahash.go#L84-L87
148,486
kisom/goutils
ahash/ahash.go
Sum64
func (h *Hash) Sum64() (uint64, bool) { h64, ok := h.Hash.(hash.Hash64) if !ok { return 0, false } return h64.Sum64(), true }
go
func (h *Hash) Sum64() (uint64, bool) { h64, ok := h.Hash.(hash.Hash64) if !ok { return 0, false } return h64.Sum64(), true }
[ "func", "(", "h", "*", "Hash", ")", "Sum64", "(", ")", "(", "uint64", ",", "bool", ")", "{", "h64", ",", "ok", ":=", "h", ".", "Hash", ".", "(", "hash", ".", "Hash64", ")", "\n", "if", "!", "ok", "{", "return", "0", ",", "false", "\n", "}",...
// Sum64 returns true if the underlying hash is a 64-bit hash; if is, the // uint64 parameter will contain the hash.
[ "Sum64", "returns", "true", "if", "the", "underlying", "hash", "is", "a", "64", "-", "bit", "hash", ";", "if", "is", "the", "uint64", "parameter", "will", "contain", "the", "hash", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/ahash/ahash.go#L91-L98
148,487
kisom/goutils
ahash/ahash.go
IsHash64
func (h *Hash) IsHash64() bool { _, ok := h.Hash.(hash.Hash64) return ok }
go
func (h *Hash) IsHash64() bool { _, ok := h.Hash.(hash.Hash64) return ok }
[ "func", "(", "h", "*", "Hash", ")", "IsHash64", "(", ")", "bool", "{", "_", ",", "ok", ":=", "h", ".", "Hash", ".", "(", "hash", ".", "Hash64", ")", "\n", "return", "ok", "\n", "}" ]
// IsHash64 returns true if the underlying hash is a 64-bit hash function.
[ "IsHash64", "returns", "true", "if", "the", "underlying", "hash", "is", "a", "64", "-", "bit", "hash", "function", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/ahash/ahash.go#L101-L104
148,488
kisom/goutils
ahash/ahash.go
New
func New(algo string) (*Hash, error) { h := &Hash{algo: algo} hf, ok := secureHashes[algo] if ok { h.Hash = hf() h.secure = true return h, nil } hf, ok = insecureHashes[algo] if ok { h.Hash = hf() h.secure = false return h, nil } return nil, errors.New("chash: unsupport hash algorithm " + algo) }
go
func New(algo string) (*Hash, error) { h := &Hash{algo: algo} hf, ok := secureHashes[algo] if ok { h.Hash = hf() h.secure = true return h, nil } hf, ok = insecureHashes[algo] if ok { h.Hash = hf() h.secure = false return h, nil } return nil, errors.New("chash: unsupport hash algorithm " + algo) }
[ "func", "New", "(", "algo", "string", ")", "(", "*", "Hash", ",", "error", ")", "{", "h", ":=", "&", "Hash", "{", "algo", ":", "algo", "}", "\n\n", "hf", ",", "ok", ":=", "secureHashes", "[", "algo", "]", "\n", "if", "ok", "{", "h", ".", "Has...
// New returns a new Hash for the specified algorithm.
[ "New", "returns", "a", "new", "Hash", "for", "the", "specified", "algorithm", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/ahash/ahash.go#L164-L182
148,489
kisom/goutils
tee/tee.go
NewOut
func NewOut(logFile string) (*Tee, error) { if logFile == "" { return &Tee{}, nil } f, err := os.Create(logFile) if err != nil { return nil, err } return &Tee{f: f}, nil }
go
func NewOut(logFile string) (*Tee, error) { if logFile == "" { return &Tee{}, nil } f, err := os.Create(logFile) if err != nil { return nil, err } return &Tee{f: f}, nil }
[ "func", "NewOut", "(", "logFile", "string", ")", "(", "*", "Tee", ",", "error", ")", "{", "if", "logFile", "==", "\"", "\"", "{", "return", "&", "Tee", "{", "}", ",", "nil", "\n", "}", "\n\n", "f", ",", "err", ":=", "os", ".", "Create", "(", ...
// NewOut writes to standard output only. The file is created, not // appended to.
[ "NewOut", "writes", "to", "standard", "output", "only", ".", "The", "file", "is", "created", "not", "appended", "to", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/tee/tee.go#L33-L43
148,490
kisom/goutils
tee/tee.go
Printf
func (t *Tee) Printf(format string, args ...interface{}) (int, error) { s := fmt.Sprintf(format, args...) n, err := os.Stdout.WriteString(s) if err != nil { return n, err } if t.f == nil { return n, err } return t.f.WriteString(s) }
go
func (t *Tee) Printf(format string, args ...interface{}) (int, error) { s := fmt.Sprintf(format, args...) n, err := os.Stdout.WriteString(s) if err != nil { return n, err } if t.f == nil { return n, err } return t.f.WriteString(s) }
[ "func", "(", "t", "*", "Tee", ")", "Printf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", "\n", "n", ",", ...
// Printf formats according to a format specifier and writes to the // tee instance.
[ "Printf", "formats", "according", "to", "a", "format", "specifier", "and", "writes", "to", "the", "tee", "instance", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/tee/tee.go#L47-L59
148,491
kisom/goutils
tee/tee.go
VPrintf
func (t *Tee) VPrintf(format string, args ...interface{}) (int, error) { if t.Verbose { return t.Printf(format, args...) } return 0, nil }
go
func (t *Tee) VPrintf(format string, args ...interface{}) (int, error) { if t.Verbose { return t.Printf(format, args...) } return 0, nil }
[ "func", "(", "t", "*", "Tee", ")", "VPrintf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "if", "t", ".", "Verbose", "{", "return", "t", ".", "Printf", "(", "format", ",", "args", ...
// VPrintf is a variant of Printf that only prints if the Tee's // Verbose flag is set.
[ "VPrintf", "is", "a", "variant", "of", "Printf", "that", "only", "prints", "if", "the", "Tee", "s", "Verbose", "flag", "is", "set", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/tee/tee.go#L63-L68
148,492
kisom/goutils
tee/tee.go
Open
func Open(logFile string) error { f, err := os.Create(logFile) if err != nil { return err } globalTee.f = f return nil }
go
func Open(logFile string) error { f, err := os.Create(logFile) if err != nil { return err } globalTee.f = f return nil }
[ "func", "Open", "(", "logFile", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Create", "(", "logFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "globalTee", ".", "f", "=", "f", "\n", "return", ...
// Open will attempt to open the logFile for the global tee instance.
[ "Open", "will", "attempt", "to", "open", "the", "logFile", "for", "the", "global", "tee", "instance", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/tee/tee.go#L73-L80
148,493
kisom/goutils
tee/tee.go
Printf
func Printf(format string, args ...interface{}) (int, error) { return globalTee.Printf(format, args...) }
go
func Printf(format string, args ...interface{}) (int, error) { return globalTee.Printf(format, args...) }
[ "func", "Printf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "return", "globalTee", ".", "Printf", "(", "format", ",", "args", "...", ")", "\n", "}" ]
// Printf formats according to a format specifier and writes to the // global tee.
[ "Printf", "formats", "according", "to", "a", "format", "specifier", "and", "writes", "to", "the", "global", "tee", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/tee/tee.go#L84-L86
148,494
kisom/goutils
tee/tee.go
VPrintf
func VPrintf(format string, args ...interface{}) (int, error) { return globalTee.VPrintf(format, args...) }
go
func VPrintf(format string, args ...interface{}) (int, error) { return globalTee.VPrintf(format, args...) }
[ "func", "VPrintf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "return", "globalTee", ".", "VPrintf", "(", "format", ",", "args", "...", ")", "\n", "}" ]
// VPrintf calls VPrintf on the global tee instance.
[ "VPrintf", "calls", "VPrintf", "on", "the", "global", "tee", "instance", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/tee/tee.go#L89-L91
148,495
kisom/goutils
sbuf/sbuf.go
NewBufferFrom
func NewBufferFrom(p []byte) *Buffer { buf := NewBuffer(len(p)) buf.Write(p) zero(p, len(p)) return buf }
go
func NewBufferFrom(p []byte) *Buffer { buf := NewBuffer(len(p)) buf.Write(p) zero(p, len(p)) return buf }
[ "func", "NewBufferFrom", "(", "p", "[", "]", "byte", ")", "*", "Buffer", "{", "buf", ":=", "NewBuffer", "(", "len", "(", "p", ")", ")", "\n", "buf", ".", "Write", "(", "p", ")", "\n", "zero", "(", "p", ",", "len", "(", "p", ")", ")", "\n", ...
// NewBufferFrom creates a new buffer from the byte slice passed in. The // original data will be wiped.
[ "NewBufferFrom", "creates", "a", "new", "buffer", "from", "the", "byte", "slice", "passed", "in", ".", "The", "original", "data", "will", "be", "wiped", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/sbuf/sbuf.go#L38-L43
148,496
kisom/goutils
sbuf/sbuf.go
ReadByte
func (buf *Buffer) ReadByte() (byte, error) { if len(buf.buf) == 0 { return 0, io.EOF } c := buf.buf[0] buf.buf[0] = 0 buf.buf = buf.buf[1:] return c, nil }
go
func (buf *Buffer) ReadByte() (byte, error) { if len(buf.buf) == 0 { return 0, io.EOF } c := buf.buf[0] buf.buf[0] = 0 buf.buf = buf.buf[1:] return c, nil }
[ "func", "(", "buf", "*", "Buffer", ")", "ReadByte", "(", ")", "(", "byte", ",", "error", ")", "{", "if", "len", "(", "buf", ".", "buf", ")", "==", "0", "{", "return", "0", ",", "io", ".", "EOF", "\n", "}", "\n\n", "c", ":=", "buf", ".", "bu...
// ReadByte reads the next byte from the buffer. If the buffer has no // data to return, err is io.EOF; otherwise it is nil.
[ "ReadByte", "reads", "the", "next", "byte", "from", "the", "buffer", ".", "If", "the", "buffer", "has", "no", "data", "to", "return", "err", "is", "io", ".", "EOF", ";", "otherwise", "it", "is", "nil", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/sbuf/sbuf.go#L70-L79
148,497
kisom/goutils
sbuf/sbuf.go
Write
func (buf *Buffer) Write(p []byte) (int, error) { r := len(buf.buf) + len(p) if cap(buf.buf) < r { l := r for { if l > r { break } l *= 2 } buf.grow(l - cap(buf.buf)) } buf.buf = append(buf.buf, p...) return len(p), nil }
go
func (buf *Buffer) Write(p []byte) (int, error) { r := len(buf.buf) + len(p) if cap(buf.buf) < r { l := r for { if l > r { break } l *= 2 } buf.grow(l - cap(buf.buf)) } buf.buf = append(buf.buf, p...) return len(p), nil }
[ "func", "(", "buf", "*", "Buffer", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "r", ":=", "len", "(", "buf", ".", "buf", ")", "+", "len", "(", "p", ")", "\n", "if", "cap", "(", "buf", ".", "buf", ")"...
// Write appends the contents of p to the buffer, growing the buffer // as needed. The return value n is the length of p; err is always nil.
[ "Write", "appends", "the", "contents", "of", "p", "to", "the", "buffer", "growing", "the", "buffer", "as", "needed", ".", "The", "return", "value", "n", "is", "the", "length", "of", "p", ";", "err", "is", "always", "nil", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/sbuf/sbuf.go#L90-L104
148,498
kisom/goutils
sbuf/sbuf.go
WriteByte
func (buf *Buffer) WriteByte(c byte) error { r := len(buf.buf) + 1 if cap(buf.buf) < r { l := r * 2 buf.grow(l - cap(buf.buf)) } buf.buf = append(buf.buf, c) return nil }
go
func (buf *Buffer) WriteByte(c byte) error { r := len(buf.buf) + 1 if cap(buf.buf) < r { l := r * 2 buf.grow(l - cap(buf.buf)) } buf.buf = append(buf.buf, c) return nil }
[ "func", "(", "buf", "*", "Buffer", ")", "WriteByte", "(", "c", "byte", ")", "error", "{", "r", ":=", "len", "(", "buf", ".", "buf", ")", "+", "1", "\n", "if", "cap", "(", "buf", ".", "buf", ")", "<", "r", "{", "l", ":=", "r", "*", "2", "\...
// WriteByte adds the byte c to the buffer, growing the buffer as needed.
[ "WriteByte", "adds", "the", "byte", "c", "to", "the", "buffer", "growing", "the", "buffer", "as", "needed", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/sbuf/sbuf.go#L107-L115
148,499
kisom/goutils
sbuf/sbuf.go
Close
func (buf *Buffer) Close() { zero(buf.buf, len(buf.buf)) buf.buf = nil }
go
func (buf *Buffer) Close() { zero(buf.buf, len(buf.buf)) buf.buf = nil }
[ "func", "(", "buf", "*", "Buffer", ")", "Close", "(", ")", "{", "zero", "(", "buf", ".", "buf", ",", "len", "(", "buf", ".", "buf", ")", ")", "\n", "buf", ".", "buf", "=", "nil", "\n", "}" ]
// Close destroys and zeroises the buffer. The buffer will be re-opened // on the next write.
[ "Close", "destroys", "and", "zeroises", "the", "buffer", ".", "The", "buffer", "will", "be", "re", "-", "opened", "on", "the", "next", "write", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/sbuf/sbuf.go#L119-L122