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
24,400
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/customoverrides.go
PostUnmarshalJSON
func (overrides *CustomOverrides) PostUnmarshalJSON() error { overrides.Init() for key, override := range overrides.CustomOverrides.Items { overrides.CustomOverrides.Items[key].parent = overrides if err := override.PostUnmarshalJSON(); err != nil { return err } } overrides.Complete <- true return nil ...
go
func (overrides *CustomOverrides) PostUnmarshalJSON() error { overrides.Init() for key, override := range overrides.CustomOverrides.Items { overrides.CustomOverrides.Items[key].parent = overrides if err := override.PostUnmarshalJSON(); err != nil { return err } } overrides.Complete <- true return nil ...
[ "func", "(", "overrides", "*", "CustomOverrides", ")", "PostUnmarshalJSON", "(", ")", "error", "{", "overrides", ".", "Init", "(", ")", "\n\n", "for", "key", ",", "override", ":=", "range", "overrides", ".", "CustomOverrides", ".", "Items", "{", "overrides",...
// PostUnmarshalJSON is called after UnmarshalJSON to setup the // structs internal state. The CustomOverrides.Complete channel is utilized // to communicate full completion.
[ "PostUnmarshalJSON", "is", "called", "after", "UnmarshalJSON", "to", "setup", "the", "structs", "internal", "state", ".", "The", "CustomOverrides", ".", "Complete", "channel", "is", "utilized", "to", "communicate", "full", "completion", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/customoverrides.go#L30-L44
24,401
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/products.go
FindProduct
func (products *Products) FindProduct(id string) (*Product, error) { var product *Product var productFound bool for _, product = range products.Products.Items { if product.ProductID == id { productFound = true break } } if !productFound { return nil, fmt.Errorf("Unable to find product: \"%s\"", id) }...
go
func (products *Products) FindProduct(id string) (*Product, error) { var product *Product var productFound bool for _, product = range products.Products.Items { if product.ProductID == id { productFound = true break } } if !productFound { return nil, fmt.Errorf("Unable to find product: \"%s\"", id) }...
[ "func", "(", "products", "*", "Products", ")", "FindProduct", "(", "id", "string", ")", "(", "*", "Product", ",", "error", ")", "{", "var", "product", "*", "Product", "\n", "var", "productFound", "bool", "\n", "for", "_", ",", "product", "=", "range", ...
// FindProduct finds a specific product by ID
[ "FindProduct", "finds", "a", "specific", "product", "by", "ID" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/products.go#L78-L93
24,402
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/products.go
NewProduct
func NewProduct(parent *Products) *Product { product := &Product{parent: parent} product.Init() return product }
go
func NewProduct(parent *Products) *Product { product := &Product{parent: parent} product.Init() return product }
[ "func", "NewProduct", "(", "parent", "*", "Products", ")", "*", "Product", "{", "product", ":=", "&", "Product", "{", "parent", ":", "parent", "}", "\n", "product", ".", "Init", "(", ")", "\n\n", "return", "product", "\n", "}" ]
// NewProduct creates a new Product
[ "NewProduct", "creates", "a", "new", "Product" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/products.go#L104-L109
24,403
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetContracts
func GetContracts() (*Contracts, error) { contracts := NewContracts() if err := contracts.GetContracts(); err != nil { return nil, err } return contracts, nil }
go
func GetContracts() (*Contracts, error) { contracts := NewContracts() if err := contracts.GetContracts(); err != nil { return nil, err } return contracts, nil }
[ "func", "GetContracts", "(", ")", "(", "*", "Contracts", ",", "error", ")", "{", "contracts", ":=", "NewContracts", "(", ")", "\n", "if", "err", ":=", "contracts", ".", "GetContracts", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "er...
// GetContracts retrieves all contracts
[ "GetContracts", "retrieves", "all", "contracts" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L22-L29
24,404
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetProducts
func GetProducts(contract *Contract) (*Products, error) { products := NewProducts() if err := products.GetProducts(contract); err != nil { return nil, err } return products, nil }
go
func GetProducts(contract *Contract) (*Products, error) { products := NewProducts() if err := products.GetProducts(contract); err != nil { return nil, err } return products, nil }
[ "func", "GetProducts", "(", "contract", "*", "Contract", ")", "(", "*", "Products", ",", "error", ")", "{", "products", ":=", "NewProducts", "(", ")", "\n", "if", "err", ":=", "products", ".", "GetProducts", "(", "contract", ")", ";", "err", "!=", "nil...
// GetProducts retrieves all products
[ "GetProducts", "retrieves", "all", "products" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L32-L39
24,405
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetEdgeHostnames
func GetEdgeHostnames(contract *Contract, group *Group, options string) (*EdgeHostnames, error) { edgeHostnames := NewEdgeHostnames() if err := edgeHostnames.GetEdgeHostnames(contract, group, options); err != nil { return nil, err } return edgeHostnames, nil }
go
func GetEdgeHostnames(contract *Contract, group *Group, options string) (*EdgeHostnames, error) { edgeHostnames := NewEdgeHostnames() if err := edgeHostnames.GetEdgeHostnames(contract, group, options); err != nil { return nil, err } return edgeHostnames, nil }
[ "func", "GetEdgeHostnames", "(", "contract", "*", "Contract", ",", "group", "*", "Group", ",", "options", "string", ")", "(", "*", "EdgeHostnames", ",", "error", ")", "{", "edgeHostnames", ":=", "NewEdgeHostnames", "(", ")", "\n", "if", "err", ":=", "edgeH...
// GetEdgeHostnames retrieves all edge hostnames
[ "GetEdgeHostnames", "retrieves", "all", "edge", "hostnames" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L42-L49
24,406
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetVersions
func GetVersions(property *Property) (*Versions, error) { versions := NewVersions() if err := versions.GetVersions(property); err != nil { return nil, err } return versions, nil }
go
func GetVersions(property *Property) (*Versions, error) { versions := NewVersions() if err := versions.GetVersions(property); err != nil { return nil, err } return versions, nil }
[ "func", "GetVersions", "(", "property", "*", "Property", ")", "(", "*", "Versions", ",", "error", ")", "{", "versions", ":=", "NewVersions", "(", ")", "\n", "if", "err", ":=", "versions", ".", "GetVersions", "(", "property", ")", ";", "err", "!=", "nil...
// GetVersions retrieves all versions for a given property
[ "GetVersions", "retrieves", "all", "versions", "for", "a", "given", "property" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L74-L81
24,407
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetAvailableCriteria
func GetAvailableCriteria(property *Property) (*AvailableCriteria, error) { availableCriteria := NewAvailableCriteria() if err := availableCriteria.GetAvailableCriteria(property); err != nil { return nil, err } return availableCriteria, nil }
go
func GetAvailableCriteria(property *Property) (*AvailableCriteria, error) { availableCriteria := NewAvailableCriteria() if err := availableCriteria.GetAvailableCriteria(property); err != nil { return nil, err } return availableCriteria, nil }
[ "func", "GetAvailableCriteria", "(", "property", "*", "Property", ")", "(", "*", "AvailableCriteria", ",", "error", ")", "{", "availableCriteria", ":=", "NewAvailableCriteria", "(", ")", "\n", "if", "err", ":=", "availableCriteria", ".", "GetAvailableCriteria", "(...
// GetAvailableCriteria retrieves all available criteria for a property
[ "GetAvailableCriteria", "retrieves", "all", "available", "criteria", "for", "a", "property" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L94-L101
24,408
akamai/AkamaiOPEN-edgegrid-golang
configdns-v1/zone.go
NewZone
func NewZone(hostname string) *Zone { zone := &Zone{Token: "new"} zone.Zone.Soa = NewSoaRecord() zone.Zone.Name = hostname return zone }
go
func NewZone(hostname string) *Zone { zone := &Zone{Token: "new"} zone.Zone.Soa = NewSoaRecord() zone.Zone.Name = hostname return zone }
[ "func", "NewZone", "(", "hostname", "string", ")", "*", "Zone", "{", "zone", ":=", "&", "Zone", "{", "Token", ":", "\"", "\"", "}", "\n", "zone", ".", "Zone", ".", "Soa", "=", "NewSoaRecord", "(", ")", "\n", "zone", ".", "Zone", ".", "Name", "=",...
// NewZone creates a new Zone
[ "NewZone", "creates", "a", "new", "Zone" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/configdns-v1/zone.go#L55-L60
24,409
akamai/AkamaiOPEN-edgegrid-golang
configdns-v1/zone.go
GetZone
func GetZone(hostname string) (*Zone, error) { zone := NewZone(hostname) req, err := client.NewRequest( Config, "GET", "/config-dns/v1/zones/"+hostname, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } if client.IsError(res) && res.Stat...
go
func GetZone(hostname string) (*Zone, error) { zone := NewZone(hostname) req, err := client.NewRequest( Config, "GET", "/config-dns/v1/zones/"+hostname, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } if client.IsError(res) && res.Stat...
[ "func", "GetZone", "(", "hostname", "string", ")", "(", "*", "Zone", ",", "error", ")", "{", "zone", ":=", "NewZone", "(", "hostname", ")", "\n", "req", ",", "err", ":=", "client", ".", "NewRequest", "(", "Config", ",", "\"", "\"", ",", "\"", "\"",...
// GetZone retrieves a DNS Zone for a given hostname
[ "GetZone", "retrieves", "a", "DNS", "Zone", "for", "a", "given", "hostname" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/configdns-v1/zone.go#L63-L92
24,410
akamai/AkamaiOPEN-edgegrid-golang
configdns-v1/zone.go
Save
func (zone *Zone) Save() error { // This lock will restrict the concurrency of API calls // to 1 save request at a time. This is needed for the Soa.Serial value which // is required to be incremented for every subsequent update to a zone // so we have to save just one request at a time to ensure this is always // ...
go
func (zone *Zone) Save() error { // This lock will restrict the concurrency of API calls // to 1 save request at a time. This is needed for the Soa.Serial value which // is required to be incremented for every subsequent update to a zone // so we have to save just one request at a time to ensure this is always // ...
[ "func", "(", "zone", "*", "Zone", ")", "Save", "(", ")", "error", "{", "// This lock will restrict the concurrency of API calls", "// to 1 save request at a time. This is needed for the Soa.Serial value which", "// is required to be incremented for every subsequent update to a zone", "//...
// Save updates the Zone
[ "Save", "updates", "the", "Zone" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/configdns-v1/zone.go#L95-L157
24,411
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/available.go
NewAvailableBehavior
func NewAvailableBehavior(parent *AvailableBehaviors) *AvailableBehavior { availableBehavior := &AvailableBehavior{parent: parent} availableBehavior.Init() return availableBehavior }
go
func NewAvailableBehavior(parent *AvailableBehaviors) *AvailableBehavior { availableBehavior := &AvailableBehavior{parent: parent} availableBehavior.Init() return availableBehavior }
[ "func", "NewAvailableBehavior", "(", "parent", "*", "AvailableBehaviors", ")", "*", "AvailableBehavior", "{", "availableBehavior", ":=", "&", "AvailableBehavior", "{", "parent", ":", "parent", "}", "\n", "availableBehavior", ".", "Init", "(", ")", "\n\n", "return"...
// NewAvailableBehavior creates a new AvailableBehavior
[ "NewAvailableBehavior", "creates", "a", "new", "AvailableBehavior" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/available.go#L153-L158
24,412
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/available.go
GetSchema
func (behavior *AvailableBehavior) GetSchema() (*gojsonschema.Schema, error) { req, err := client.NewRequest( Config, "GET", behavior.SchemaLink, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } schemaBytes, _ := ioutil.ReadAll(res.Body)...
go
func (behavior *AvailableBehavior) GetSchema() (*gojsonschema.Schema, error) { req, err := client.NewRequest( Config, "GET", behavior.SchemaLink, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } schemaBytes, _ := ioutil.ReadAll(res.Body)...
[ "func", "(", "behavior", "*", "AvailableBehavior", ")", "GetSchema", "(", ")", "(", "*", "gojsonschema", ".", "Schema", ",", "error", ")", "{", "req", ",", "err", ":=", "client", ".", "NewRequest", "(", "Config", ",", "\"", "\"", ",", "behavior", ".", ...
// GetSchema retrieves the JSON schema for an available behavior
[ "GetSchema", "retrieves", "the", "JSON", "schema", "for", "an", "available", "behavior" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/available.go#L161-L183
24,413
akamai/AkamaiOPEN-edgegrid-golang
jsonhooks-v1/jsonhooks.go
ImplementsPreJSONMarshaler
func ImplementsPreJSONMarshaler(v interface{}) bool { value := reflect.ValueOf(v) if !value.IsValid() { return false } _, ok := value.Interface().(PreJSONMarshaler) return ok }
go
func ImplementsPreJSONMarshaler(v interface{}) bool { value := reflect.ValueOf(v) if !value.IsValid() { return false } _, ok := value.Interface().(PreJSONMarshaler) return ok }
[ "func", "ImplementsPreJSONMarshaler", "(", "v", "interface", "{", "}", ")", "bool", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "!", "value", ".", "IsValid", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",",...
// ImplementsPreJSONMarshaler checks for support for the PreMarshalJSON pre-hook
[ "ImplementsPreJSONMarshaler", "checks", "for", "support", "for", "the", "PreMarshalJSON", "pre", "-", "hook" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/jsonhooks-v1/jsonhooks.go#L45-L53
24,414
akamai/AkamaiOPEN-edgegrid-golang
jsonhooks-v1/jsonhooks.go
ImplementsPostJSONUnmarshaler
func ImplementsPostJSONUnmarshaler(v interface{}) bool { value := reflect.ValueOf(v) if value.Kind() == reflect.Ptr && value.IsNil() { return false } _, ok := value.Interface().(PostJSONUnmarshaler) return ok }
go
func ImplementsPostJSONUnmarshaler(v interface{}) bool { value := reflect.ValueOf(v) if value.Kind() == reflect.Ptr && value.IsNil() { return false } _, ok := value.Interface().(PostJSONUnmarshaler) return ok }
[ "func", "ImplementsPostJSONUnmarshaler", "(", "v", "interface", "{", "}", ")", "bool", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "value", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "&&", "value", ".", "IsNil", ...
// ImplementsPostJSONUnmarshaler checks for support for the PostUnmarshalJSON post-hook
[ "ImplementsPostJSONUnmarshaler", "checks", "for", "support", "for", "the", "PostUnmarshalJSON", "post", "-", "hook" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/jsonhooks-v1/jsonhooks.go#L61-L69
24,415
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
NewRequest
func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*http.Request, error) { var ( baseURL *url.URL err error ) if strings.HasPrefix(config.Host, "https://") { baseURL, err = url.Parse(config.Host) } else { baseURL, err = url.Parse("https://" + config.Host) } if err != nil {...
go
func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*http.Request, error) { var ( baseURL *url.URL err error ) if strings.HasPrefix(config.Host, "https://") { baseURL, err = url.Parse(config.Host) } else { baseURL, err = url.Parse("https://" + config.Host) } if err != nil {...
[ "func", "NewRequest", "(", "config", "edgegrid", ".", "Config", ",", "method", ",", "path", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "var", "(", "baseURL", "*", "url", ".", "URL", "\...
// NewRequest creates an HTTP request that can be sent to Akamai APIs. A relative URL can be provided in path, which will be resolved to the // Host specified in Config. If body is specified, it will be sent as the request body.
[ "NewRequest", "creates", "an", "HTTP", "request", "that", "can", "be", "sent", "to", "Akamai", "APIs", ".", "A", "relative", "URL", "can", "be", "provided", "in", "path", "which", "will", "be", "resolved", "to", "the", "Host", "specified", "in", "Config", ...
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L31-L62
24,416
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
NewMultiPartFormDataRequest
func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, otherFormParams map[string]string) (*http.Request, error) { file, err := os.Open(filePath) if err != nil { return nil, err } defer file.Close() body := &bytes.Buffer{} writer := multipart.NewWriter(body) // TODO: make this fiel...
go
func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, otherFormParams map[string]string) (*http.Request, error) { file, err := os.Open(filePath) if err != nil { return nil, err } defer file.Close() body := &bytes.Buffer{} writer := multipart.NewWriter(body) // TODO: make this fiel...
[ "func", "NewMultiPartFormDataRequest", "(", "config", "edgegrid", ".", "Config", ",", "uriPath", ",", "filePath", "string", ",", "otherFormParams", "map", "[", "string", "]", "string", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "file", ...
// NewMultiPartFormDataRequest creates an HTTP request that uploads a file to the Akamai API
[ "NewMultiPartFormDataRequest", "creates", "an", "HTTP", "request", "that", "uploads", "a", "file", "to", "the", "Akamai", "API" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L93-L120
24,417
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
Do
func Do(config edgegrid.Config, req *http.Request) (*http.Response, error) { Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { req = edgegrid.AddRequestHeader(config, req) return nil } req = edgegrid.AddRequestHeader(config, req) res, err := Client.Do(req) if err != nil { return ni...
go
func Do(config edgegrid.Config, req *http.Request) (*http.Response, error) { Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { req = edgegrid.AddRequestHeader(config, req) return nil } req = edgegrid.AddRequestHeader(config, req) res, err := Client.Do(req) if err != nil { return ni...
[ "func", "Do", "(", "config", "edgegrid", ".", "Config", ",", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "Client", ".", "CheckRedirect", "=", "func", "(", "req", "*", "http", ".", "Request", "...
// Do performs a given HTTP Request, signed with the Akamai OPEN Edgegrid // Authorization header. An edgegrid.Response or an error is returned.
[ "Do", "performs", "a", "given", "HTTP", "Request", "signed", "with", "the", "Akamai", "OPEN", "Edgegrid", "Authorization", "header", ".", "An", "edgegrid", ".", "Response", "or", "an", "error", "is", "returned", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L124-L137
24,418
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
BodyJSON
func BodyJSON(r *http.Response, data interface{}) error { if data == nil { return errors.New("You must pass in an interface{}") } body, err := ioutil.ReadAll(r.Body) if err != nil { return err } err = jsonhooks.Unmarshal(body, data) return err }
go
func BodyJSON(r *http.Response, data interface{}) error { if data == nil { return errors.New("You must pass in an interface{}") } body, err := ioutil.ReadAll(r.Body) if err != nil { return err } err = jsonhooks.Unmarshal(body, data) return err }
[ "func", "BodyJSON", "(", "r", "*", "http", ".", "Response", ",", "data", "interface", "{", "}", ")", "error", "{", "if", "data", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "body", ",", "err", ":=", ...
// BodyJSON unmarshals the Response.Body into a given data structure
[ "BodyJSON", "unmarshals", "the", "Response", ".", "Body", "into", "a", "given", "data", "structure" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L140-L152
24,419
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
AddGroup
func (groups *Groups) AddGroup(newGroup *Group) { if newGroup.GroupID != "" { for key, group := range groups.Groups.Items { if group.GroupID == newGroup.GroupID { groups.Groups.Items[key] = newGroup return } } } newGroup.parent = groups groups.Groups.Items = append(groups.Groups.Items, newGroup)...
go
func (groups *Groups) AddGroup(newGroup *Group) { if newGroup.GroupID != "" { for key, group := range groups.Groups.Items { if group.GroupID == newGroup.GroupID { groups.Groups.Items[key] = newGroup return } } } newGroup.parent = groups groups.Groups.Items = append(groups.Groups.Items, newGroup)...
[ "func", "(", "groups", "*", "Groups", ")", "AddGroup", "(", "newGroup", "*", "Group", ")", "{", "if", "newGroup", ".", "GroupID", "!=", "\"", "\"", "{", "for", "key", ",", "group", ":=", "range", "groups", ".", "Groups", ".", "Items", "{", "if", "g...
// AddGroup adds a group to a Groups collection
[ "AddGroup", "adds", "a", "group", "to", "a", "Groups", "collection" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L74-L87
24,420
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
FindGroup
func (groups *Groups) FindGroup(id string) (*Group, error) { var group *Group var groupFound bool if id == "" { goto err } for _, group = range groups.Groups.Items { if group.GroupID == id { groupFound = true break } } err: if !groupFound { return nil, fmt.Errorf("Unable to find group: \"%s\"", ...
go
func (groups *Groups) FindGroup(id string) (*Group, error) { var group *Group var groupFound bool if id == "" { goto err } for _, group = range groups.Groups.Items { if group.GroupID == id { groupFound = true break } } err: if !groupFound { return nil, fmt.Errorf("Unable to find group: \"%s\"", ...
[ "func", "(", "groups", "*", "Groups", ")", "FindGroup", "(", "id", "string", ")", "(", "*", "Group", ",", "error", ")", "{", "var", "group", "*", "Group", "\n", "var", "groupFound", "bool", "\n\n", "if", "id", "==", "\"", "\"", "{", "goto", "err", ...
// FindGroup finds a specific group by ID
[ "FindGroup", "finds", "a", "specific", "group", "by", "ID" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L90-L111
24,421
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
NewGroup
func NewGroup(parent *Groups) *Group { group := &Group{ parent: parent, } group.Init() return group }
go
func NewGroup(parent *Groups) *Group { group := &Group{ parent: parent, } group.Init() return group }
[ "func", "NewGroup", "(", "parent", "*", "Groups", ")", "*", "Group", "{", "group", ":=", "&", "Group", "{", "parent", ":", "parent", ",", "}", "\n", "group", ".", "Init", "(", ")", "\n", "return", "group", "\n", "}" ]
// NewGroup creates a new Group
[ "NewGroup", "creates", "a", "new", "Group" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L124-L130
24,422
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
GetGroup
func (group *Group) GetGroup() { groups, err := GetGroups() if err != nil { return } for _, g := range groups.Groups.Items { if g.GroupID == group.GroupID { group.parent = groups group.ContractIDs = g.ContractIDs group.GroupName = g.GroupName group.ParentGroupID = g.ParentGroupID group.Complete ...
go
func (group *Group) GetGroup() { groups, err := GetGroups() if err != nil { return } for _, g := range groups.Groups.Items { if g.GroupID == group.GroupID { group.parent = groups group.ContractIDs = g.ContractIDs group.GroupName = g.GroupName group.ParentGroupID = g.ParentGroupID group.Complete ...
[ "func", "(", "group", "*", "Group", ")", "GetGroup", "(", ")", "{", "groups", ",", "err", ":=", "GetGroups", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "for", "_", ",", "g", ":=", "range", "groups", ".", "Groups",...
// GetGroup populates a Group
[ "GetGroup", "populates", "a", "Group" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L133-L151
24,423
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
GetProperties
func (group *Group) GetProperties(contract *Contract) (*Properties, error) { return GetProperties(contract, group) }
go
func (group *Group) GetProperties(contract *Contract) (*Properties, error) { return GetProperties(contract, group) }
[ "func", "(", "group", "*", "Group", ")", "GetProperties", "(", "contract", "*", "Contract", ")", "(", "*", "Properties", ",", "error", ")", "{", "return", "GetProperties", "(", "contract", ",", "group", ")", "\n", "}" ]
// GetProperties retrieves all properties associated with a given group and contract
[ "GetProperties", "retrieves", "all", "properties", "associated", "with", "a", "given", "group", "and", "contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L154-L156
24,424
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
GetCpCodes
func (group *Group) GetCpCodes(contract *Contract) (*CpCodes, error) { return GetCpCodes(contract, group) }
go
func (group *Group) GetCpCodes(contract *Contract) (*CpCodes, error) { return GetCpCodes(contract, group) }
[ "func", "(", "group", "*", "Group", ")", "GetCpCodes", "(", "contract", "*", "Contract", ")", "(", "*", "CpCodes", ",", "error", ")", "{", "return", "GetCpCodes", "(", "contract", ",", "group", ")", "\n", "}" ]
// GetCpCodes retrieves all CP codes associated with a given group and contract
[ "GetCpCodes", "retrieves", "all", "CP", "codes", "associated", "with", "a", "given", "group", "and", "contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L159-L161
24,425
giantswarm/mayu
client/client.go
New
func New(scheme, host string, port uint16) (*Client, error) { client := &Client{ Scheme: scheme, Host: host, Port: port, } return client, nil }
go
func New(scheme, host string, port uint16) (*Client, error) { client := &Client{ Scheme: scheme, Host: host, Port: port, } return client, nil }
[ "func", "New", "(", "scheme", ",", "host", "string", ",", "port", "uint16", ")", "(", "*", "Client", ",", "error", ")", "{", "client", ":=", "&", "Client", "{", "Scheme", ":", "scheme", ",", "Host", ":", "host", ",", "Port", ":", "port", ",", "}"...
// New creates a new configured client to interact with mayu over its network // API.
[ "New", "creates", "a", "new", "configured", "client", "to", "interact", "with", "mayu", "over", "its", "network", "API", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L33-L41
24,426
giantswarm/mayu
client/client.go
SetProviderId
func (c *Client) SetProviderId(serial, value string) error { data, err := json.Marshal(hostmgr.Host{ ProviderId: value, }) if err != nil { return microerror.Mask(err) } resp, err := httputil.Put(fmt.Sprintf("%s://%s:%d/admin/host/%s/set_provider_id", c.Scheme, c.Host, c.Port, serial), contentType, bytes.NewBu...
go
func (c *Client) SetProviderId(serial, value string) error { data, err := json.Marshal(hostmgr.Host{ ProviderId: value, }) if err != nil { return microerror.Mask(err) } resp, err := httputil.Put(fmt.Sprintf("%s://%s:%d/admin/host/%s/set_provider_id", c.Scheme, c.Host, c.Port, serial), contentType, bytes.NewBu...
[ "func", "(", "c", "*", "Client", ")", "SetProviderId", "(", "serial", ",", "value", "string", ")", "error", "{", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "hostmgr", ".", "Host", "{", "ProviderId", ":", "value", ",", "}", ")", "\n", "i...
// SetProviderId sets the provider ID given by value for a node given by serial.
[ "SetProviderId", "sets", "the", "provider", "ID", "given", "by", "value", "for", "a", "node", "given", "by", "serial", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L59-L78
24,427
giantswarm/mayu
client/client.go
List
func (c *Client) List() ([]hostmgr.Host, error) { list := []hostmgr.Host{} resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return list, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return nil, microerror.Mask(fmt.Errorf("inv...
go
func (c *Client) List() ([]hostmgr.Host, error) { list := []hostmgr.Host{} resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return list, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return nil, microerror.Mask(fmt.Errorf("inv...
[ "func", "(", "c", "*", "Client", ")", "List", "(", ")", "(", "[", "]", "hostmgr", ".", "Host", ",", "error", ")", "{", "list", ":=", "[", "]", "hostmgr", ".", "Host", "{", "}", "\n\n", "resp", ",", "err", ":=", "http", ".", "Get", "(", "fmt",...
// List fetches a list of node information within the current cluster.
[ "List", "fetches", "a", "list", "of", "node", "information", "within", "the", "current", "cluster", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L174-L197
24,428
giantswarm/mayu
client/client.go
Status
func (c *Client) Status(serial string) (hostmgr.Host, error) { var host hostmgr.Host resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return host, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return host, microerror.Mask(fmt.E...
go
func (c *Client) Status(serial string) (hostmgr.Host, error) { var host hostmgr.Host resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return host, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return host, microerror.Mask(fmt.E...
[ "func", "(", "c", "*", "Client", ")", "Status", "(", "serial", "string", ")", "(", "hostmgr", ".", "Host", ",", "error", ")", "{", "var", "host", "hostmgr", ".", "Host", "\n\n", "resp", ",", "err", ":=", "http", ".", "Get", "(", "fmt", ".", "Spri...
// Status fetches status information for a node given by serial.
[ "Status", "fetches", "status", "information", "for", "a", "node", "given", "by", "serial", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L200-L230
24,429
giantswarm/mayu
pxemgr/iputil.go
ipLessThanOrEqual
func ipLessThanOrEqual(ip net.IP, upperBound net.IP) bool { if ip[3] < upperBound[3] { return true } if ip[2] < upperBound[2] { return true } if ip[1] < upperBound[1] { return true } if ip[0] <= upperBound[0] { return true } return false }
go
func ipLessThanOrEqual(ip net.IP, upperBound net.IP) bool { if ip[3] < upperBound[3] { return true } if ip[2] < upperBound[2] { return true } if ip[1] < upperBound[1] { return true } if ip[0] <= upperBound[0] { return true } return false }
[ "func", "ipLessThanOrEqual", "(", "ip", "net", ".", "IP", ",", "upperBound", "net", ".", "IP", ")", "bool", "{", "if", "ip", "[", "3", "]", "<", "upperBound", "[", "3", "]", "{", "return", "true", "\n", "}", "\n", "if", "ip", "[", "2", "]", "<"...
// ip less or equal
[ "ip", "less", "or", "equal" ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/pxemgr/iputil.go#L18-L33
24,430
giantswarm/mayu
fs/fake.go
NewFakeFilesystemWithFiles
func NewFakeFilesystemWithFiles(fs []FakeFile) FakeFilesystem { fileMap := make(map[string]FakeFile) for _, f := range fs { fileMap[f.Name] = f } return FakeFilesystem{files: fileMap} }
go
func NewFakeFilesystemWithFiles(fs []FakeFile) FakeFilesystem { fileMap := make(map[string]FakeFile) for _, f := range fs { fileMap[f.Name] = f } return FakeFilesystem{files: fileMap} }
[ "func", "NewFakeFilesystemWithFiles", "(", "fs", "[", "]", "FakeFile", ")", "FakeFilesystem", "{", "fileMap", ":=", "make", "(", "map", "[", "string", "]", "FakeFile", ")", "\n", "for", "_", ",", "f", ":=", "range", "fs", "{", "fileMap", "[", "f", ".",...
// NewFakeFilesystemWithFiles creates a new FakeFilesystem // instance bundled with a list of FakeFile instances that // can be passed.
[ "NewFakeFilesystemWithFiles", "creates", "a", "new", "FakeFilesystem", "instance", "bundled", "with", "a", "list", "of", "FakeFile", "instances", "that", "can", "be", "passed", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L25-L32
24,431
giantswarm/mayu
fs/fake.go
NewFakeFile
func NewFakeFile(name, content string) FakeFile { return FakeFile{ Name: name, Mode: os.FileMode(0777), ModTime: time.Now(), Buffer: bytes.NewReader([]byte(content)), } }
go
func NewFakeFile(name, content string) FakeFile { return FakeFile{ Name: name, Mode: os.FileMode(0777), ModTime: time.Now(), Buffer: bytes.NewReader([]byte(content)), } }
[ "func", "NewFakeFile", "(", "name", ",", "content", "string", ")", "FakeFile", "{", "return", "FakeFile", "{", "Name", ":", "name", ",", "Mode", ":", "os", ".", "FileMode", "(", "0777", ")", ",", "ModTime", ":", "time", ".", "Now", "(", ")", ",", "...
// NewFakeFile creates a new FakeFile instances based on a file name // and it's contents from strings. The content of the new instance will // be stored in an internal bytes.Reader instance. The default file mode // will be 0777 and the last modification time the moment when the // function is called.
[ "NewFakeFile", "creates", "a", "new", "FakeFile", "instances", "based", "on", "a", "file", "name", "and", "it", "s", "contents", "from", "strings", ".", "The", "content", "of", "the", "new", "instance", "will", "be", "stored", "in", "an", "internal", "byte...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L75-L82
24,432
giantswarm/mayu
fs/fake.go
Read
func (f FakeFile) Read(p []byte) (n int, err error) { return f.Buffer.Read(p) }
go
func (f FakeFile) Read(p []byte) (n int, err error) { return f.Buffer.Read(p) }
[ "func", "(", "f", "FakeFile", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "f", ".", "Buffer", ".", "Read", "(", "p", ")", "\n", "}" ]
// Read wraps io.Reader's functionality around the internal // bytes.Reader instance.
[ "Read", "wraps", "io", ".", "Reader", "s", "functionality", "around", "the", "internal", "bytes", ".", "Reader", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L91-L93
24,433
giantswarm/mayu
fs/fake.go
ReadAt
func (f FakeFile) ReadAt(p []byte, off int64) (n int, err error) { return f.Buffer.ReadAt(p, off) }
go
func (f FakeFile) ReadAt(p []byte, off int64) (n int, err error) { return f.Buffer.ReadAt(p, off) }
[ "func", "(", "f", "FakeFile", ")", "ReadAt", "(", "p", "[", "]", "byte", ",", "off", "int64", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "f", ".", "Buffer", ".", "ReadAt", "(", "p", ",", "off", ")", "\n", "}" ]
// ReadAt wraps io.ReaderAt's functionality around the internalt // bytes.Reader instance.
[ "ReadAt", "wraps", "io", ".", "ReaderAt", "s", "functionality", "around", "the", "internalt", "bytes", ".", "Reader", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L97-L99
24,434
giantswarm/mayu
fs/fake.go
Seek
func (f FakeFile) Seek(offset int64, whence int) (int64, error) { return f.Buffer.Seek(offset, whence) }
go
func (f FakeFile) Seek(offset int64, whence int) (int64, error) { return f.Buffer.Seek(offset, whence) }
[ "func", "(", "f", "FakeFile", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "int64", ",", "error", ")", "{", "return", "f", ".", "Buffer", ".", "Seek", "(", "offset", ",", "whence", ")", "\n", "}" ]
// Seek wraps io.Seeker's functionality around the internalt // bytes.Reader instance.
[ "Seek", "wraps", "io", ".", "Seeker", "s", "functionality", "around", "the", "internalt", "bytes", ".", "Reader", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L103-L105
24,435
giantswarm/mayu
fs/fake.go
Stat
func (f FakeFile) Stat() (os.FileInfo, error) { return FakeFileInfo{File: f}, nil }
go
func (f FakeFile) Stat() (os.FileInfo, error) { return FakeFileInfo{File: f}, nil }
[ "func", "(", "f", "FakeFile", ")", "Stat", "(", ")", "(", "os", ".", "FileInfo", ",", "error", ")", "{", "return", "FakeFileInfo", "{", "File", ":", "f", "}", ",", "nil", "\n", "}" ]
// Stat returns the FakeFileInfo structure describing the FakeFile // instance.
[ "Stat", "returns", "the", "FakeFileInfo", "structure", "describing", "the", "FakeFile", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L109-L111
24,436
giantswarm/mayu
flag.go
ValidateHTTPCertificateUsage
func (g MayuFlags) ValidateHTTPCertificateUsage() (bool, error) { if g.noTLS { return true, nil } if !g.noTLS && g.tlsCertFile != "" && g.tlsKeyFile != "" { return true, nil } return false, ErrNotAllCertFilesProvided }
go
func (g MayuFlags) ValidateHTTPCertificateUsage() (bool, error) { if g.noTLS { return true, nil } if !g.noTLS && g.tlsCertFile != "" && g.tlsKeyFile != "" { return true, nil } return false, ErrNotAllCertFilesProvided }
[ "func", "(", "g", "MayuFlags", ")", "ValidateHTTPCertificateUsage", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "g", ".", "noTLS", "{", "return", "true", ",", "nil", "\n", "}", "\n\n", "if", "!", "g", ".", "noTLS", "&&", "g", ".", "tlsCert...
// ValidateHTTPCertificateUsage checks if the fields HTTPSCertFile and HTTPSKeyFile // of the configuration struct are set whenever the NoTLS is set to false. // This makes sure that users are configuring the needed certificate files when // using TLS encrypted connections.
[ "ValidateHTTPCertificateUsage", "checks", "if", "the", "fields", "HTTPSCertFile", "and", "HTTPSKeyFile", "of", "the", "configuration", "struct", "are", "set", "whenever", "the", "NoTLS", "is", "set", "to", "false", ".", "This", "makes", "sure", "that", "users", ...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/flag.go#L96-L106
24,437
giantswarm/mayu
flag.go
ValidateHTTPCertificateFileExistance
func (g MayuFlags) ValidateHTTPCertificateFileExistance() (bool, error) { if g.noTLS { return true, nil } if _, err := g.filesystem.Stat(g.tlsCertFile); err != nil { return false, ErrHTTPSCertFileNotRedable } if _, err := g.filesystem.Stat(g.tlsKeyFile); err != nil { return false, ErrHTTPSKeyFileNotReadabl...
go
func (g MayuFlags) ValidateHTTPCertificateFileExistance() (bool, error) { if g.noTLS { return true, nil } if _, err := g.filesystem.Stat(g.tlsCertFile); err != nil { return false, ErrHTTPSCertFileNotRedable } if _, err := g.filesystem.Stat(g.tlsKeyFile); err != nil { return false, ErrHTTPSKeyFileNotReadabl...
[ "func", "(", "g", "MayuFlags", ")", "ValidateHTTPCertificateFileExistance", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "g", ".", "noTLS", "{", "return", "true", ",", "nil", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "g", ".", "filesyst...
// ValidateHTTPCertificateFileExistance checks if the filenames configured // in the fields HTTPSCertFile and HTTPSKeyFile can be stat'ed to make sure // they actually exist.
[ "ValidateHTTPCertificateFileExistance", "checks", "if", "the", "filenames", "configured", "in", "the", "fields", "HTTPSCertFile", "and", "HTTPSKeyFile", "can", "be", "stat", "ed", "to", "make", "sure", "they", "actually", "exist", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/flag.go#L111-L125
24,438
giantswarm/mayu
hostmgr/host.go
Commit
func (h *Host) Commit(msg string) error { h.save() return h.maybeGitCommit(h.Serial + ": " + msg) }
go
func (h *Host) Commit(msg string) error { h.save() return h.maybeGitCommit(h.Serial + ": " + msg) }
[ "func", "(", "h", "*", "Host", ")", "Commit", "(", "msg", "string", ")", "error", "{", "h", ".", "save", "(", ")", "\n", "return", "h", ".", "maybeGitCommit", "(", "h", ".", "Serial", "+", "\"", "\"", "+", "msg", ")", "\n", "}" ]
// Commit stores the given msg in git version control.
[ "Commit", "stores", "the", "given", "msg", "in", "git", "version", "control", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/host.go#L51-L54
24,439
giantswarm/mayu
hostmgr/host.go
HostFromDir
func HostFromDir(hostdir string) (*Host, error) { confPath := path.Join(hostdir, hostConfFile) h := &Host{} err := loadJson(h, confPath) if err != nil { return nil, microerror.Mask(err) } h.hostDir, err = os.Open(hostdir) if err != nil { return nil, microerror.Mask(err) } fi, err := os.Stat(confPath) i...
go
func HostFromDir(hostdir string) (*Host, error) { confPath := path.Join(hostdir, hostConfFile) h := &Host{} err := loadJson(h, confPath) if err != nil { return nil, microerror.Mask(err) } h.hostDir, err = os.Open(hostdir) if err != nil { return nil, microerror.Mask(err) } fi, err := os.Stat(confPath) i...
[ "func", "HostFromDir", "(", "hostdir", "string", ")", "(", "*", "Host", ",", "error", ")", "{", "confPath", ":=", "path", ".", "Join", "(", "hostdir", ",", "hostConfFile", ")", "\n\n", "h", ":=", "&", "Host", "{", "}", "\n", "err", ":=", "loadJson", ...
// HostFromDir takes a path to a host directory within the cluster directory // and loads the found configuration. Then the corresponding Host is returned.
[ "HostFromDir", "takes", "a", "path", "to", "a", "host", "directory", "within", "the", "cluster", "directory", "and", "loads", "the", "found", "configuration", ".", "Then", "the", "corresponding", "Host", "is", "returned", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/host.go#L67-L88
24,440
giantswarm/mayu
pxemgr/ignition.go
hasUnrecognizedKeys
func hasUnrecognizedKeys(inCfg interface{}, refType reflect.Type) (warnings bool) { if refType.Kind() == reflect.Ptr { refType = refType.Elem() } switch inCfg.(type) { case map[interface{}]interface{}: ks := inCfg.(map[interface{}]interface{}) keys: for key := range ks { for i := 0; i < refType.NumField()...
go
func hasUnrecognizedKeys(inCfg interface{}, refType reflect.Type) (warnings bool) { if refType.Kind() == reflect.Ptr { refType = refType.Elem() } switch inCfg.(type) { case map[interface{}]interface{}: ks := inCfg.(map[interface{}]interface{}) keys: for key := range ks { for i := 0; i < refType.NumField()...
[ "func", "hasUnrecognizedKeys", "(", "inCfg", "interface", "{", "}", ",", "refType", "reflect", ".", "Type", ")", "(", "warnings", "bool", ")", "{", "if", "refType", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "refType", "=", "refType", "."...
// hasUnrecognizedKeys finds unrecognized keys and warns about them on stderr. // returns false when no unrecognized keys were found, true otherwise.
[ "hasUnrecognizedKeys", "finds", "unrecognized", "keys", "and", "warns", "about", "them", "on", "stderr", ".", "returns", "false", "when", "no", "unrecognized", "keys", "were", "found", "true", "otherwise", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/pxemgr/ignition.go#L142-L175
24,441
giantswarm/mayu
hostmgr/cluster.go
NewCluster
func NewCluster(baseDir string, gitStore bool, logger micrologger.Logger) (*Cluster, error) { if !fileExists(baseDir) { err := os.Mkdir(baseDir, 0755) if err != nil { return nil, microerror.Mask(err) } } if gitStore && !isGitRepo(baseDir) { err := gitInit(baseDir) if err != nil { return nil, microer...
go
func NewCluster(baseDir string, gitStore bool, logger micrologger.Logger) (*Cluster, error) { if !fileExists(baseDir) { err := os.Mkdir(baseDir, 0755) if err != nil { return nil, microerror.Mask(err) } } if gitStore && !isGitRepo(baseDir) { err := gitInit(baseDir) if err != nil { return nil, microer...
[ "func", "NewCluster", "(", "baseDir", "string", ",", "gitStore", "bool", ",", "logger", "micrologger", ".", "Logger", ")", "(", "*", "Cluster", ",", "error", ")", "{", "if", "!", "fileExists", "(", "baseDir", ")", "{", "err", ":=", "os", ".", "Mkdir", ...
// NewCluster creates a new cluster based on the cluster directory. gitStore // defines whether cluster changes should be tracked using version control or // not.
[ "NewCluster", "creates", "a", "new", "cluster", "based", "on", "the", "cluster", "directory", ".", "gitStore", "defines", "whether", "cluster", "changes", "should", "be", "tracked", "using", "version", "control", "or", "not", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L78-L108
24,442
giantswarm/mayu
hostmgr/cluster.go
CreateNewHost
func (c *Cluster) CreateNewHost(serial string) (*Host, error) { serial = strings.ToLower(serial) hostDir := path.Join(c.baseDir, strings.ToLower(serial)) newHost, err := createHost(serial, hostDir) if err != nil { return nil, microerror.Mask(err) } if predef, exists := c.predefinedVals[serial]; exists { c.lo...
go
func (c *Cluster) CreateNewHost(serial string) (*Host, error) { serial = strings.ToLower(serial) hostDir := path.Join(c.baseDir, strings.ToLower(serial)) newHost, err := createHost(serial, hostDir) if err != nil { return nil, microerror.Mask(err) } if predef, exists := c.predefinedVals[serial]; exists { c.lo...
[ "func", "(", "c", "*", "Cluster", ")", "CreateNewHost", "(", "serial", "string", ")", "(", "*", "Host", ",", "error", ")", "{", "serial", "=", "strings", ".", "ToLower", "(", "serial", ")", "\n", "hostDir", ":=", "path", ".", "Join", "(", "c", ".",...
// CreateNewHost creates a new host with the given serial.
[ "CreateNewHost", "creates", "a", "new", "host", "with", "the", "given", "serial", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L111-L153
24,443
giantswarm/mayu
hostmgr/cluster.go
Update
func (c *Cluster) Update() error { c.mu.Lock() defer c.mu.Unlock() if err := c.cacheHosts(); err != nil { return microerror.Mask(err) } err := c.reindex() if err != nil { return microerror.Mask(err) } return nil }
go
func (c *Cluster) Update() error { c.mu.Lock() defer c.mu.Unlock() if err := c.cacheHosts(); err != nil { return microerror.Mask(err) } err := c.reindex() if err != nil { return microerror.Mask(err) } return nil }
[ "func", "(", "c", "*", "Cluster", ")", "Update", "(", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "err", ":=", "c", ".", "cacheHosts", "(", ")", ";", "err", "...
// Update refreshs the internal host cache based on information within the // cluster directory.
[ "Update", "refreshs", "the", "internal", "host", "cache", "based", "on", "information", "within", "the", "cluster", "directory", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L168-L180
24,444
giantswarm/mayu
hostmgr/cluster.go
HostWithMacAddress
func (c *Cluster) HostWithMacAddress(macAddr string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the mac address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByMacAddr[str...
go
func (c *Cluster) HostWithMacAddress(macAddr string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the mac address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByMacAddr[str...
[ "func", "(", "c", "*", "Cluster", ")", "HostWithMacAddress", "(", "macAddr", "string", ")", "(", "*", "Host", ",", "bool", ")", "{", "if", "err", ":=", "c", ".", "Update", "(", ")", ";", "err", "!=", "nil", "{", "c", ".", "logger", ".", "Log", ...
// HostWithMacAddress returns the host object given by macAddr based on the // internal cache. In case the host could not be found, host is nil and false // is returned as second return value.
[ "HostWithMacAddress", "returns", "the", "host", "object", "given", "by", "macAddr", "based", "on", "the", "internal", "cache", ".", "In", "case", "the", "host", "could", "not", "be", "found", "host", "is", "nil", "and", "false", "is", "returned", "as", "se...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L185-L198
24,445
giantswarm/mayu
hostmgr/cluster.go
HostWithInternalAddr
func (c *Cluster) HostWithInternalAddr(ipAddr net.IP) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the ip address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByInternalAdd...
go
func (c *Cluster) HostWithInternalAddr(ipAddr net.IP) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the ip address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByInternalAdd...
[ "func", "(", "c", "*", "Cluster", ")", "HostWithInternalAddr", "(", "ipAddr", "net", ".", "IP", ")", "(", "*", "Host", ",", "bool", ")", "{", "if", "err", ":=", "c", ".", "Update", "(", ")", ";", "err", "!=", "nil", "{", "c", ".", "logger", "."...
// HostWithInternalAddr returns the host object given by ipAddr based on the // internal cache. In case the host could not be found, host is nil and false // is returned as second return value.
[ "HostWithInternalAddr", "returns", "the", "host", "object", "given", "by", "ipAddr", "based", "on", "the", "internal", "cache", ".", "In", "case", "the", "host", "could", "not", "be", "found", "host", "is", "nil", "and", "false", "is", "returned", "as", "s...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L203-L216
24,446
giantswarm/mayu
hostmgr/cluster.go
HostWithSerial
func (c *Cluster) HostWithSerial(serial string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the serial number using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostsCache[strings.T...
go
func (c *Cluster) HostWithSerial(serial string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the serial number using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostsCache[strings.T...
[ "func", "(", "c", "*", "Cluster", ")", "HostWithSerial", "(", "serial", "string", ")", "(", "*", "Host", ",", "bool", ")", "{", "if", "err", ":=", "c", ".", "Update", "(", ")", ";", "err", "!=", "nil", "{", "c", ".", "logger", ".", "Log", "(", ...
// HostWithSerial returns the host object given by serial based on the internal // cache. In case the host could not be found, host is nil and false is // returned as second return value.
[ "HostWithSerial", "returns", "the", "host", "object", "given", "by", "serial", "based", "on", "the", "internal", "cache", ".", "In", "case", "the", "host", "could", "not", "be", "found", "host", "is", "nil", "and", "false", "is", "returned", "as", "second"...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L221-L234
24,447
giantswarm/mayu
hostmgr/cluster.go
GetAllHosts
func (c *Cluster) GetAllHosts() []*Host { hosts := make([]*Host, 0, len(c.hostsCache)) if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the list of hosts based on the internal cache: %#v", "stack", err) return hosts } for _, cachedHost := range c.hostsCache { hosts...
go
func (c *Cluster) GetAllHosts() []*Host { hosts := make([]*Host, 0, len(c.hostsCache)) if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the list of hosts based on the internal cache: %#v", "stack", err) return hosts } for _, cachedHost := range c.hostsCache { hosts...
[ "func", "(", "c", "*", "Cluster", ")", "GetAllHosts", "(", ")", "[", "]", "*", "Host", "{", "hosts", ":=", "make", "(", "[", "]", "*", "Host", ",", "0", ",", "len", "(", "c", ".", "hostsCache", ")", ")", "\n\n", "if", "err", ":=", "c", ".", ...
// GetAllHosts returns a list of all hosts based on the internal cache.
[ "GetAllHosts", "returns", "a", "list", "of", "all", "hosts", "based", "on", "the", "internal", "cache", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L261-L273
24,448
fatih/color
color.go
New
func New(value ...Attribute) *Color { c := &Color{params: make([]Attribute, 0)} c.Add(value...) return c }
go
func New(value ...Attribute) *Color { c := &Color{params: make([]Attribute, 0)} c.Add(value...) return c }
[ "func", "New", "(", "value", "...", "Attribute", ")", "*", "Color", "{", "c", ":=", "&", "Color", "{", "params", ":", "make", "(", "[", "]", "Attribute", ",", "0", ")", "}", "\n", "c", ".", "Add", "(", "value", "...", ")", "\n", "return", "c", ...
// New returns a newly created color object.
[ "New", "returns", "a", "newly", "created", "color", "object", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L110-L114
24,449
fatih/color
color.go
Set
func (c *Color) Set() *Color { if c.isNoColorSet() { return c } fmt.Fprintf(Output, c.format()) return c }
go
func (c *Color) Set() *Color { if c.isNoColorSet() { return c } fmt.Fprintf(Output, c.format()) return c }
[ "func", "(", "c", "*", "Color", ")", "Set", "(", ")", "*", "Color", "{", "if", "c", ".", "isNoColorSet", "(", ")", "{", "return", "c", "\n", "}", "\n\n", "fmt", ".", "Fprintf", "(", "Output", ",", "c", ".", "format", "(", ")", ")", "\n", "ret...
// Set sets the SGR sequence.
[ "Set", "sets", "the", "SGR", "sequence", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L135-L142
24,450
fatih/color
color.go
Sprint
func (c *Color) Sprint(a ...interface{}) string { return c.wrap(fmt.Sprint(a...)) }
go
func (c *Color) Sprint(a ...interface{}) string { return c.wrap(fmt.Sprint(a...)) }
[ "func", "(", "c", "*", "Color", ")", "Sprint", "(", "a", "...", "interface", "{", "}", ")", "string", "{", "return", "c", ".", "wrap", "(", "fmt", ".", "Sprint", "(", "a", "...", ")", ")", "\n", "}" ]
// Sprint is just like Print, but returns a string instead of printing it.
[ "Sprint", "is", "just", "like", "Print", "but", "returns", "a", "string", "instead", "of", "printing", "it", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L255-L257
24,451
fatih/color
color.go
Sprintln
func (c *Color) Sprintln(a ...interface{}) string { return c.wrap(fmt.Sprintln(a...)) }
go
func (c *Color) Sprintln(a ...interface{}) string { return c.wrap(fmt.Sprintln(a...)) }
[ "func", "(", "c", "*", "Color", ")", "Sprintln", "(", "a", "...", "interface", "{", "}", ")", "string", "{", "return", "c", ".", "wrap", "(", "fmt", ".", "Sprintln", "(", "a", "...", ")", ")", "\n", "}" ]
// Sprintln is just like Println, but returns a string instead of printing it.
[ "Sprintln", "is", "just", "like", "Println", "but", "returns", "a", "string", "instead", "of", "printing", "it", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L260-L262
24,452
fatih/color
color.go
Sprintf
func (c *Color) Sprintf(format string, a ...interface{}) string { return c.wrap(fmt.Sprintf(format, a...)) }
go
func (c *Color) Sprintf(format string, a ...interface{}) string { return c.wrap(fmt.Sprintf(format, a...)) }
[ "func", "(", "c", "*", "Color", ")", "Sprintf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "string", "{", "return", "c", ".", "wrap", "(", "fmt", ".", "Sprintf", "(", "format", ",", "a", "...", ")", ")", "\n", "}" ]
// Sprintf is just like Printf, but returns a string instead of printing it.
[ "Sprintf", "is", "just", "like", "Printf", "but", "returns", "a", "string", "instead", "of", "printing", "it", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L265-L267
24,453
fatih/color
color.go
wrap
func (c *Color) wrap(s string) string { if c.isNoColorSet() { return s } return c.format() + s + c.unformat() }
go
func (c *Color) wrap(s string) string { if c.isNoColorSet() { return s } return c.format() + s + c.unformat() }
[ "func", "(", "c", "*", "Color", ")", "wrap", "(", "s", "string", ")", "string", "{", "if", "c", ".", "isNoColorSet", "(", ")", "{", "return", "s", "\n", "}", "\n\n", "return", "c", ".", "format", "(", ")", "+", "s", "+", "c", ".", "unformat", ...
// wrap wraps the s string with the colors attributes. The string is ready to // be printed.
[ "wrap", "wraps", "the", "s", "string", "with", "the", "colors", "attributes", ".", "The", "string", "is", "ready", "to", "be", "printed", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L360-L366
24,454
fatih/color
color.go
Equals
func (c *Color) Equals(c2 *Color) bool { if len(c.params) != len(c2.params) { return false } for _, attr := range c.params { if !c2.attrExists(attr) { return false } } return true }
go
func (c *Color) Equals(c2 *Color) bool { if len(c.params) != len(c2.params) { return false } for _, attr := range c.params { if !c2.attrExists(attr) { return false } } return true }
[ "func", "(", "c", "*", "Color", ")", "Equals", "(", "c2", "*", "Color", ")", "bool", "{", "if", "len", "(", "c", ".", "params", ")", "!=", "len", "(", "c2", ".", "params", ")", "{", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "attr...
// Equals returns a boolean value indicating whether two colors are equal.
[ "Equals", "returns", "a", "boolean", "value", "indicating", "whether", "two", "colors", "are", "equal", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L400-L412
24,455
BurntSushi/toml
decode.go
PrimitiveDecode
func PrimitiveDecode(primValue Primitive, v interface{}) error { md := MetaData{decoded: make(map[string]bool)} return md.unify(primValue.undecoded, rvalue(v)) }
go
func PrimitiveDecode(primValue Primitive, v interface{}) error { md := MetaData{decoded: make(map[string]bool)} return md.unify(primValue.undecoded, rvalue(v)) }
[ "func", "PrimitiveDecode", "(", "primValue", "Primitive", ",", "v", "interface", "{", "}", ")", "error", "{", "md", ":=", "MetaData", "{", "decoded", ":", "make", "(", "map", "[", "string", "]", "bool", ")", "}", "\n", "return", "md", ".", "unify", "...
// DEPRECATED! // // Use MetaData.PrimitiveDecode instead.
[ "DEPRECATED!", "Use", "MetaData", ".", "PrimitiveDecode", "instead", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode.go#L49-L52
24,456
BurntSushi/toml
decode.go
DecodeFile
func DecodeFile(fpath string, v interface{}) (MetaData, error) { bs, err := ioutil.ReadFile(fpath) if err != nil { return MetaData{}, err } return Decode(string(bs), v) }
go
func DecodeFile(fpath string, v interface{}) (MetaData, error) { bs, err := ioutil.ReadFile(fpath) if err != nil { return MetaData{}, err } return Decode(string(bs), v) }
[ "func", "DecodeFile", "(", "fpath", "string", ",", "v", "interface", "{", "}", ")", "(", "MetaData", ",", "error", ")", "{", "bs", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "fpath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "MetaD...
// DecodeFile is just like Decode, except it will automatically read the // contents of the file at `fpath` and decode it for you.
[ "DecodeFile", "is", "just", "like", "Decode", "except", "it", "will", "automatically", "read", "the", "contents", "of", "the", "file", "at", "fpath", "and", "decode", "it", "for", "you", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode.go#L128-L134
24,457
BurntSushi/toml
decode.go
DecodeReader
func DecodeReader(r io.Reader, v interface{}) (MetaData, error) { bs, err := ioutil.ReadAll(r) if err != nil { return MetaData{}, err } return Decode(string(bs), v) }
go
func DecodeReader(r io.Reader, v interface{}) (MetaData, error) { bs, err := ioutil.ReadAll(r) if err != nil { return MetaData{}, err } return Decode(string(bs), v) }
[ "func", "DecodeReader", "(", "r", "io", ".", "Reader", ",", "v", "interface", "{", "}", ")", "(", "MetaData", ",", "error", ")", "{", "bs", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// DecodeReader is just like Decode, except it will consume all bytes // from the reader and decode it for you.
[ "DecodeReader", "is", "just", "like", "Decode", "except", "it", "will", "consume", "all", "bytes", "from", "the", "reader", "and", "decode", "it", "for", "you", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode.go#L138-L144
24,458
BurntSushi/toml
decode.go
unify
func (md *MetaData) unify(data interface{}, rv reflect.Value) error { // Special case. Look for a `Primitive` value. if rv.Type() == reflect.TypeOf((*Primitive)(nil)).Elem() { // Save the undecoded data and the key context into the primitive // value. context := make(Key, len(md.context)) copy(context, md.co...
go
func (md *MetaData) unify(data interface{}, rv reflect.Value) error { // Special case. Look for a `Primitive` value. if rv.Type() == reflect.TypeOf((*Primitive)(nil)).Elem() { // Save the undecoded data and the key context into the primitive // value. context := make(Key, len(md.context)) copy(context, md.co...
[ "func", "(", "md", "*", "MetaData", ")", "unify", "(", "data", "interface", "{", "}", ",", "rv", "reflect", ".", "Value", ")", "error", "{", "// Special case. Look for a `Primitive` value.", "if", "rv", ".", "Type", "(", ")", "==", "reflect", ".", "TypeOf"...
// unify performs a sort of type unification based on the structure of `rv`, // which is the client representation. // // Any type mismatch produces an error. Finding a type that we don't know // how to handle produces an unsupported type error.
[ "unify", "performs", "a", "sort", "of", "type", "unification", "based", "on", "the", "structure", "of", "rv", "which", "is", "the", "client", "representation", ".", "Any", "type", "mismatch", "produces", "an", "error", ".", "Finding", "a", "type", "that", ...
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode.go#L151-L232
24,459
BurntSushi/toml
parse.go
numUnderscoresOK
func numUnderscoresOK(s string) bool { accept := false for _, r := range s { if r == '_' { if !accept { return false } accept = false continue } accept = true } return accept }
go
func numUnderscoresOK(s string) bool { accept := false for _, r := range s { if r == '_' { if !accept { return false } accept = false continue } accept = true } return accept }
[ "func", "numUnderscoresOK", "(", "s", "string", ")", "bool", "{", "accept", ":=", "false", "\n", "for", "_", ",", "r", ":=", "range", "s", "{", "if", "r", "==", "'_'", "{", "if", "!", "accept", "{", "return", "false", "\n", "}", "\n", "accept", "...
// numUnderscoresOK checks whether each underscore in s is surrounded by // characters that are not underscores.
[ "numUnderscoresOK", "checks", "whether", "each", "underscore", "in", "s", "is", "surrounded", "by", "characters", "that", "are", "not", "underscores", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L314-L327
24,460
BurntSushi/toml
parse.go
numPeriodsOK
func numPeriodsOK(s string) bool { period := false for _, r := range s { if period && !isDigit(r) { return false } period = r == '.' } return !period }
go
func numPeriodsOK(s string) bool { period := false for _, r := range s { if period && !isDigit(r) { return false } period = r == '.' } return !period }
[ "func", "numPeriodsOK", "(", "s", "string", ")", "bool", "{", "period", ":=", "false", "\n", "for", "_", ",", "r", ":=", "range", "s", "{", "if", "period", "&&", "!", "isDigit", "(", "r", ")", "{", "return", "false", "\n", "}", "\n", "period", "=...
// numPeriodsOK checks whether every period in s is followed by a digit.
[ "numPeriodsOK", "checks", "whether", "every", "period", "in", "s", "is", "followed", "by", "a", "digit", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L330-L339
24,461
BurntSushi/toml
parse.go
establishContext
func (p *parser) establishContext(key Key, array bool) { var ok bool // Always start at the top level and drill down for our context. hashContext := p.mapping keyContext := make(Key, 0) // We only need implicit hashes for key[0:-1] for _, k := range key[0 : len(key)-1] { _, ok = hashContext[k] keyContext = ...
go
func (p *parser) establishContext(key Key, array bool) { var ok bool // Always start at the top level and drill down for our context. hashContext := p.mapping keyContext := make(Key, 0) // We only need implicit hashes for key[0:-1] for _, k := range key[0 : len(key)-1] { _, ok = hashContext[k] keyContext = ...
[ "func", "(", "p", "*", "parser", ")", "establishContext", "(", "key", "Key", ",", "array", "bool", ")", "{", "var", "ok", "bool", "\n\n", "// Always start at the top level and drill down for our context.", "hashContext", ":=", "p", ".", "mapping", "\n", "keyContex...
// establishContext sets the current context of the parser, // where the context is either a hash or an array of hashes. Which one is // set depends on the value of the `array` parameter. // // Establishing the context also makes sure that the key isn't a duplicate, and // will create implicit hashes automatically.
[ "establishContext", "sets", "the", "current", "context", "of", "the", "parser", "where", "the", "context", "is", "either", "a", "hash", "or", "an", "array", "of", "hashes", ".", "Which", "one", "is", "set", "depends", "on", "the", "value", "of", "the", "...
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L347-L401
24,462
BurntSushi/toml
parse.go
setValue
func (p *parser) setValue(key string, value interface{}) { var tmpHash interface{} var ok bool hash := p.mapping keyContext := make(Key, 0) for _, k := range p.context { keyContext = append(keyContext, k) if tmpHash, ok = hash[k]; !ok { p.bug("Context for key '%s' has not been established.", keyContext) ...
go
func (p *parser) setValue(key string, value interface{}) { var tmpHash interface{} var ok bool hash := p.mapping keyContext := make(Key, 0) for _, k := range p.context { keyContext = append(keyContext, k) if tmpHash, ok = hash[k]; !ok { p.bug("Context for key '%s' has not been established.", keyContext) ...
[ "func", "(", "p", "*", "parser", ")", "setValue", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "var", "tmpHash", "interface", "{", "}", "\n", "var", "ok", "bool", "\n\n", "hash", ":=", "p", ".", "mapping", "\n", "keyContext", ...
// setValue sets the given key to the given value in the current context. // It will make sure that the key hasn't already been defined, account for // implicit key groups.
[ "setValue", "sets", "the", "given", "key", "to", "the", "given", "value", "in", "the", "current", "context", ".", "It", "will", "make", "sure", "that", "the", "key", "hasn", "t", "already", "been", "defined", "account", "for", "implicit", "key", "groups", ...
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L406-L453
24,463
BurntSushi/toml
parse.go
addImplicit
func (p *parser) addImplicit(key Key) { p.implicits[key.String()] = true }
go
func (p *parser) addImplicit(key Key) { p.implicits[key.String()] = true }
[ "func", "(", "p", "*", "parser", ")", "addImplicit", "(", "key", "Key", ")", "{", "p", ".", "implicits", "[", "key", ".", "String", "(", ")", "]", "=", "true", "\n", "}" ]
// addImplicit sets the given Key as having been created implicitly.
[ "addImplicit", "sets", "the", "given", "Key", "as", "having", "been", "created", "implicitly", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L472-L474
24,464
BurntSushi/toml
parse.go
removeImplicit
func (p *parser) removeImplicit(key Key) { p.implicits[key.String()] = false }
go
func (p *parser) removeImplicit(key Key) { p.implicits[key.String()] = false }
[ "func", "(", "p", "*", "parser", ")", "removeImplicit", "(", "key", "Key", ")", "{", "p", ".", "implicits", "[", "key", ".", "String", "(", ")", "]", "=", "false", "\n", "}" ]
// removeImplicit stops tagging the given key as having been implicitly // created.
[ "removeImplicit", "stops", "tagging", "the", "given", "key", "as", "having", "been", "implicitly", "created", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L478-L480
24,465
BurntSushi/toml
parse.go
isImplicit
func (p *parser) isImplicit(key Key) bool { return p.implicits[key.String()] }
go
func (p *parser) isImplicit(key Key) bool { return p.implicits[key.String()] }
[ "func", "(", "p", "*", "parser", ")", "isImplicit", "(", "key", "Key", ")", "bool", "{", "return", "p", ".", "implicits", "[", "key", ".", "String", "(", ")", "]", "\n", "}" ]
// isImplicit returns true if the key group pointed to by the key was created // implicitly.
[ "isImplicit", "returns", "true", "if", "the", "key", "group", "pointed", "to", "by", "the", "key", "was", "created", "implicitly", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L484-L486
24,466
BurntSushi/toml
parse.go
current
func (p *parser) current() string { if len(p.currentKey) == 0 { return p.context.String() } if len(p.context) == 0 { return p.currentKey } return fmt.Sprintf("%s.%s", p.context, p.currentKey) }
go
func (p *parser) current() string { if len(p.currentKey) == 0 { return p.context.String() } if len(p.context) == 0 { return p.currentKey } return fmt.Sprintf("%s.%s", p.context, p.currentKey) }
[ "func", "(", "p", "*", "parser", ")", "current", "(", ")", "string", "{", "if", "len", "(", "p", ".", "currentKey", ")", "==", "0", "{", "return", "p", ".", "context", ".", "String", "(", ")", "\n", "}", "\n", "if", "len", "(", "p", ".", "con...
// current returns the full key name of the current context.
[ "current", "returns", "the", "full", "key", "name", "of", "the", "current", "context", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/parse.go#L489-L497
24,467
BurntSushi/toml
type_check.go
typeOfArray
func (p *parser) typeOfArray(types []tomlType) tomlType { // Empty arrays are cool. if len(types) == 0 { return tomlArray } theType := types[0] for _, t := range types[1:] { if !typeEqual(theType, t) { p.panicf("Array contains values of type '%s' and '%s', but "+ "arrays must be homogeneous.", theType,...
go
func (p *parser) typeOfArray(types []tomlType) tomlType { // Empty arrays are cool. if len(types) == 0 { return tomlArray } theType := types[0] for _, t := range types[1:] { if !typeEqual(theType, t) { p.panicf("Array contains values of type '%s' and '%s', but "+ "arrays must be homogeneous.", theType,...
[ "func", "(", "p", "*", "parser", ")", "typeOfArray", "(", "types", "[", "]", "tomlType", ")", "tomlType", "{", "// Empty arrays are cool.", "if", "len", "(", "types", ")", "==", "0", "{", "return", "tomlArray", "\n", "}", "\n\n", "theType", ":=", "types"...
// typeOfArray returns a tomlType for an array given a list of types of its // values. // // In the current spec, if an array is homogeneous, then its type is always // "Array". If the array is not homogeneous, an error is generated.
[ "typeOfArray", "returns", "a", "tomlType", "for", "an", "array", "given", "a", "list", "of", "types", "of", "its", "values", ".", "In", "the", "current", "spec", "if", "an", "array", "is", "homogeneous", "then", "its", "type", "is", "always", "Array", "....
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/type_check.go#L77-L91
24,468
BurntSushi/toml
decode_meta.go
Type
func (md *MetaData) Type(key ...string) string { fullkey := strings.Join(key, ".") if typ, ok := md.types[fullkey]; ok { return typ.typeString() } return "" }
go
func (md *MetaData) Type(key ...string) string { fullkey := strings.Join(key, ".") if typ, ok := md.types[fullkey]; ok { return typ.typeString() } return "" }
[ "func", "(", "md", "*", "MetaData", ")", "Type", "(", "key", "...", "string", ")", "string", "{", "fullkey", ":=", "strings", ".", "Join", "(", "key", ",", "\"", "\"", ")", "\n", "if", "typ", ",", "ok", ":=", "md", ".", "types", "[", "fullkey", ...
// Type returns a string representation of the type of the key specified. // // Type will return the empty string if given an empty key or a key that // does not exist. Keys are case sensitive.
[ "Type", "returns", "a", "string", "representation", "of", "the", "type", "of", "the", "key", "specified", ".", "Type", "will", "return", "the", "empty", "string", "if", "given", "an", "empty", "key", "or", "a", "key", "that", "does", "not", "exist", ".",...
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode_meta.go#L46-L52
24,469
BurntSushi/toml
decode_meta.go
Undecoded
func (md *MetaData) Undecoded() []Key { undecoded := make([]Key, 0, len(md.keys)) for _, key := range md.keys { if !md.decoded[key.String()] { undecoded = append(undecoded, key) } } return undecoded }
go
func (md *MetaData) Undecoded() []Key { undecoded := make([]Key, 0, len(md.keys)) for _, key := range md.keys { if !md.decoded[key.String()] { undecoded = append(undecoded, key) } } return undecoded }
[ "func", "(", "md", "*", "MetaData", ")", "Undecoded", "(", ")", "[", "]", "Key", "{", "undecoded", ":=", "make", "(", "[", "]", "Key", ",", "0", ",", "len", "(", "md", ".", "keys", ")", ")", "\n", "for", "_", ",", "key", ":=", "range", "md", ...
// Undecoded returns all keys that have not been decoded in the order in which // they appear in the original TOML document. // // This includes keys that haven't been decoded because of a Primitive value. // Once the Primitive value is decoded, the keys will be considered decoded. // // Also note that decoding into an...
[ "Undecoded", "returns", "all", "keys", "that", "have", "not", "been", "decoded", "in", "the", "order", "in", "which", "they", "appear", "in", "the", "original", "TOML", "document", ".", "This", "includes", "keys", "that", "haven", "t", "been", "decoded", "...
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode_meta.go#L113-L121
24,470
BurntSushi/toml
lex.go
backup
func (lx *lexer) backup() { if lx.atEOF { lx.atEOF = false return } if lx.nprev < 1 { panic("backed up too far") } w := lx.prevWidths[0] lx.prevWidths[0] = lx.prevWidths[1] lx.prevWidths[1] = lx.prevWidths[2] lx.nprev-- lx.pos -= w if lx.pos < len(lx.input) && lx.input[lx.pos] == '\n' { lx.line-- } }
go
func (lx *lexer) backup() { if lx.atEOF { lx.atEOF = false return } if lx.nprev < 1 { panic("backed up too far") } w := lx.prevWidths[0] lx.prevWidths[0] = lx.prevWidths[1] lx.prevWidths[1] = lx.prevWidths[2] lx.nprev-- lx.pos -= w if lx.pos < len(lx.input) && lx.input[lx.pos] == '\n' { lx.line-- } }
[ "func", "(", "lx", "*", "lexer", ")", "backup", "(", ")", "{", "if", "lx", ".", "atEOF", "{", "lx", ".", "atEOF", "=", "false", "\n", "return", "\n", "}", "\n", "if", "lx", ".", "nprev", "<", "1", "{", "panic", "(", "\"", "\"", ")", "\n", "...
// backup steps back one rune. Can be called only twice between calls to next.
[ "backup", "steps", "back", "one", "rune", ".", "Can", "be", "called", "only", "twice", "between", "calls", "to", "next", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L167-L183
24,471
BurntSushi/toml
lex.go
accept
func (lx *lexer) accept(valid rune) bool { if lx.next() == valid { return true } lx.backup() return false }
go
func (lx *lexer) accept(valid rune) bool { if lx.next() == valid { return true } lx.backup() return false }
[ "func", "(", "lx", "*", "lexer", ")", "accept", "(", "valid", "rune", ")", "bool", "{", "if", "lx", ".", "next", "(", ")", "==", "valid", "{", "return", "true", "\n", "}", "\n", "lx", ".", "backup", "(", ")", "\n", "return", "false", "\n", "}" ...
// accept consumes the next rune if it's equal to `valid`.
[ "accept", "consumes", "the", "next", "rune", "if", "it", "s", "equal", "to", "valid", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L186-L192
24,472
BurntSushi/toml
lex.go
skip
func (lx *lexer) skip(pred func(rune) bool) { for { r := lx.next() if pred(r) { continue } lx.backup() lx.ignore() return } }
go
func (lx *lexer) skip(pred func(rune) bool) { for { r := lx.next() if pred(r) { continue } lx.backup() lx.ignore() return } }
[ "func", "(", "lx", "*", "lexer", ")", "skip", "(", "pred", "func", "(", "rune", ")", "bool", ")", "{", "for", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "if", "pred", "(", "r", ")", "{", "continue", "\n", "}", "\n", "lx", ".", "back...
// skip ignores all input that matches the given predicate.
[ "skip", "ignores", "all", "input", "that", "matches", "the", "given", "predicate", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L202-L212
24,473
BurntSushi/toml
lex.go
lexTop
func lexTop(lx *lexer) stateFn { r := lx.next() if isWhitespace(r) || isNL(r) { return lexSkip(lx, lexTop) } switch r { case commentStart: lx.push(lexTop) return lexCommentStart case tableStart: return lexTableStart case eof: if lx.pos > lx.start { return lx.errorf("unexpected EOF") } lx.emit(it...
go
func lexTop(lx *lexer) stateFn { r := lx.next() if isWhitespace(r) || isNL(r) { return lexSkip(lx, lexTop) } switch r { case commentStart: lx.push(lexTop) return lexCommentStart case tableStart: return lexTableStart case eof: if lx.pos > lx.start { return lx.errorf("unexpected EOF") } lx.emit(it...
[ "func", "lexTop", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "if", "isWhitespace", "(", "r", ")", "||", "isNL", "(", "r", ")", "{", "return", "lexSkip", "(", "lx", ",", "lexTop", ")", "\n", "}", ...
// lexTop consumes elements at the top level of TOML data.
[ "lexTop", "consumes", "elements", "at", "the", "top", "level", "of", "TOML", "data", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L227-L251
24,474
BurntSushi/toml
lex.go
lexBareTableName
func lexBareTableName(lx *lexer) stateFn { r := lx.next() if isBareKeyChar(r) { return lexBareTableName } lx.backup() lx.emit(itemText) return lexTableNameEnd }
go
func lexBareTableName(lx *lexer) stateFn { r := lx.next() if isBareKeyChar(r) { return lexBareTableName } lx.backup() lx.emit(itemText) return lexTableNameEnd }
[ "func", "lexBareTableName", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "if", "isBareKeyChar", "(", "r", ")", "{", "return", "lexBareTableName", "\n", "}", "\n", "lx", ".", "backup", "(", ")", "\n", "...
// lexBareTableName lexes the name of a table. It assumes that at least one // valid character for the table has already been read.
[ "lexBareTableName", "lexes", "the", "name", "of", "a", "table", ".", "It", "assumes", "that", "at", "least", "one", "valid", "character", "for", "the", "table", "has", "already", "been", "read", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L327-L335
24,475
BurntSushi/toml
lex.go
lexTableNameEnd
func lexTableNameEnd(lx *lexer) stateFn { lx.skip(isWhitespace) switch r := lx.next(); { case isWhitespace(r): return lexTableNameEnd case r == tableSep: lx.ignore() return lexTableNameStart case r == tableEnd: return lx.pop() default: return lx.errorf("expected '.' or ']' to end table name, "+ "but ...
go
func lexTableNameEnd(lx *lexer) stateFn { lx.skip(isWhitespace) switch r := lx.next(); { case isWhitespace(r): return lexTableNameEnd case r == tableSep: lx.ignore() return lexTableNameStart case r == tableEnd: return lx.pop() default: return lx.errorf("expected '.' or ']' to end table name, "+ "but ...
[ "func", "lexTableNameEnd", "(", "lx", "*", "lexer", ")", "stateFn", "{", "lx", ".", "skip", "(", "isWhitespace", ")", "\n", "switch", "r", ":=", "lx", ".", "next", "(", ")", ";", "{", "case", "isWhitespace", "(", "r", ")", ":", "return", "lexTableNam...
// lexTableNameEnd reads the end of a piece of a table name, optionally // consuming whitespace.
[ "lexTableNameEnd", "reads", "the", "end", "of", "a", "piece", "of", "a", "table", "name", "optionally", "consuming", "whitespace", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L339-L353
24,476
BurntSushi/toml
lex.go
lexKeyStart
func lexKeyStart(lx *lexer) stateFn { r := lx.peek() switch { case r == keySep: return lx.errorf("unexpected key separator %q", keySep) case isWhitespace(r) || isNL(r): lx.next() return lexSkip(lx, lexKeyStart) case r == stringStart || r == rawStringStart: lx.ignore() lx.emit(itemKeyStart) lx.push(lexK...
go
func lexKeyStart(lx *lexer) stateFn { r := lx.peek() switch { case r == keySep: return lx.errorf("unexpected key separator %q", keySep) case isWhitespace(r) || isNL(r): lx.next() return lexSkip(lx, lexKeyStart) case r == stringStart || r == rawStringStart: lx.ignore() lx.emit(itemKeyStart) lx.push(lexK...
[ "func", "lexKeyStart", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "peek", "(", ")", "\n", "switch", "{", "case", "r", "==", "keySep", ":", "return", "lx", ".", "errorf", "(", "\"", "\"", ",", "keySep", ")", "\n", "case", ...
// lexKeyStart consumes a key name up until the first non-whitespace character. // lexKeyStart will ignore whitespace.
[ "lexKeyStart", "consumes", "a", "key", "name", "up", "until", "the", "first", "non", "-", "whitespace", "character", ".", "lexKeyStart", "will", "ignore", "whitespace", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L357-L375
24,477
BurntSushi/toml
lex.go
lexArrayValue
func lexArrayValue(lx *lexer) stateFn { r := lx.next() switch { case isWhitespace(r) || isNL(r): return lexSkip(lx, lexArrayValue) case r == commentStart: lx.push(lexArrayValue) return lexCommentStart case r == comma: return lx.errorf("unexpected comma") case r == arrayEnd: // NOTE(caleb): The spec isn'...
go
func lexArrayValue(lx *lexer) stateFn { r := lx.next() switch { case isWhitespace(r) || isNL(r): return lexSkip(lx, lexArrayValue) case r == commentStart: lx.push(lexArrayValue) return lexCommentStart case r == comma: return lx.errorf("unexpected comma") case r == arrayEnd: // NOTE(caleb): The spec isn'...
[ "func", "lexArrayValue", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "switch", "{", "case", "isWhitespace", "(", "r", ")", "||", "isNL", "(", "r", ")", ":", "return", "lexSkip", "(", "lx", ",", "lex...
// lexArrayValue consumes one value in an array. It assumes that '[' or ',' // have already been consumed. All whitespace and newlines are ignored.
[ "lexArrayValue", "consumes", "one", "value", "in", "an", "array", ".", "It", "assumes", "that", "[", "or", "have", "already", "been", "consumed", ".", "All", "whitespace", "and", "newlines", "are", "ignored", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L471-L490
24,478
BurntSushi/toml
lex.go
lexInlineTableEnd
func lexInlineTableEnd(lx *lexer) stateFn { lx.ignore() lx.emit(itemInlineTableEnd) return lx.pop() }
go
func lexInlineTableEnd(lx *lexer) stateFn { lx.ignore() lx.emit(itemInlineTableEnd) return lx.pop() }
[ "func", "lexInlineTableEnd", "(", "lx", "*", "lexer", ")", "stateFn", "{", "lx", ".", "ignore", "(", ")", "\n", "lx", ".", "emit", "(", "itemInlineTableEnd", ")", "\n", "return", "lx", ".", "pop", "(", ")", "\n", "}" ]
// lexInlineTableEnd finishes the lexing of an inline table. // It assumes that a '}' has just been consumed.
[ "lexInlineTableEnd", "finishes", "the", "lexing", "of", "an", "inline", "table", ".", "It", "assumes", "that", "a", "}", "has", "just", "been", "consumed", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L570-L574
24,479
BurntSushi/toml
lex.go
lexMultilineString
func lexMultilineString(lx *lexer) stateFn { switch lx.next() { case eof: return lx.errorf("unexpected EOF") case '\\': return lexMultilineStringEscape case stringEnd: if lx.accept(stringEnd) { if lx.accept(stringEnd) { lx.backup() lx.backup() lx.backup() lx.emit(itemMultilineString) lx...
go
func lexMultilineString(lx *lexer) stateFn { switch lx.next() { case eof: return lx.errorf("unexpected EOF") case '\\': return lexMultilineStringEscape case stringEnd: if lx.accept(stringEnd) { if lx.accept(stringEnd) { lx.backup() lx.backup() lx.backup() lx.emit(itemMultilineString) lx...
[ "func", "lexMultilineString", "(", "lx", "*", "lexer", ")", "stateFn", "{", "switch", "lx", ".", "next", "(", ")", "{", "case", "eof", ":", "return", "lx", ".", "errorf", "(", "\"", "\"", ")", "\n", "case", "'\\\\'", ":", "return", "lexMultilineStringE...
// lexMultilineString consumes the inner contents of a string. It assumes that // the beginning '"""' has already been consumed and ignored.
[ "lexMultilineString", "consumes", "the", "inner", "contents", "of", "a", "string", ".", "It", "assumes", "that", "the", "beginning", "has", "already", "been", "consumed", "and", "ignored", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L600-L623
24,480
BurntSushi/toml
lex.go
lexRawString
func lexRawString(lx *lexer) stateFn { r := lx.next() switch { case r == eof: return lx.errorf("unexpected EOF") case isNL(r): return lx.errorf("strings cannot contain newlines") case r == rawStringEnd: lx.backup() lx.emit(itemRawString) lx.next() lx.ignore() return lx.pop() } return lexRawString }
go
func lexRawString(lx *lexer) stateFn { r := lx.next() switch { case r == eof: return lx.errorf("unexpected EOF") case isNL(r): return lx.errorf("strings cannot contain newlines") case r == rawStringEnd: lx.backup() lx.emit(itemRawString) lx.next() lx.ignore() return lx.pop() } return lexRawString }
[ "func", "lexRawString", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "switch", "{", "case", "r", "==", "eof", ":", "return", "lx", ".", "errorf", "(", "\"", "\"", ")", "\n", "case", "isNL", "(", "r...
// lexRawString consumes a raw string. Nothing can be escaped in such a string. // It assumes that the beginning "'" has already been consumed and ignored.
[ "lexRawString", "consumes", "a", "raw", "string", ".", "Nothing", "can", "be", "escaped", "in", "such", "a", "string", ".", "It", "assumes", "that", "the", "beginning", "has", "already", "been", "consumed", "and", "ignored", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L627-L642
24,481
BurntSushi/toml
lex.go
lexMultilineRawString
func lexMultilineRawString(lx *lexer) stateFn { switch lx.next() { case eof: return lx.errorf("unexpected EOF") case rawStringEnd: if lx.accept(rawStringEnd) { if lx.accept(rawStringEnd) { lx.backup() lx.backup() lx.backup() lx.emit(itemRawMultilineString) lx.next() lx.next() lx.ne...
go
func lexMultilineRawString(lx *lexer) stateFn { switch lx.next() { case eof: return lx.errorf("unexpected EOF") case rawStringEnd: if lx.accept(rawStringEnd) { if lx.accept(rawStringEnd) { lx.backup() lx.backup() lx.backup() lx.emit(itemRawMultilineString) lx.next() lx.next() lx.ne...
[ "func", "lexMultilineRawString", "(", "lx", "*", "lexer", ")", "stateFn", "{", "switch", "lx", ".", "next", "(", ")", "{", "case", "eof", ":", "return", "lx", ".", "errorf", "(", "\"", "\"", ")", "\n", "case", "rawStringEnd", ":", "if", "lx", ".", ...
// lexMultilineRawString consumes a raw string. Nothing can be escaped in such // a string. It assumes that the beginning "'''" has already been consumed and // ignored.
[ "lexMultilineRawString", "consumes", "a", "raw", "string", ".", "Nothing", "can", "be", "escaped", "in", "such", "a", "string", ".", "It", "assumes", "that", "the", "beginning", "has", "already", "been", "consumed", "and", "ignored", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L647-L668
24,482
BurntSushi/toml
lex.go
lexMultilineStringEscape
func lexMultilineStringEscape(lx *lexer) stateFn { // Handle the special case first: if isNL(lx.next()) { return lexMultilineString } lx.backup() lx.push(lexMultilineString) return lexStringEscape(lx) }
go
func lexMultilineStringEscape(lx *lexer) stateFn { // Handle the special case first: if isNL(lx.next()) { return lexMultilineString } lx.backup() lx.push(lexMultilineString) return lexStringEscape(lx) }
[ "func", "lexMultilineStringEscape", "(", "lx", "*", "lexer", ")", "stateFn", "{", "// Handle the special case first:", "if", "isNL", "(", "lx", ".", "next", "(", ")", ")", "{", "return", "lexMultilineString", "\n", "}", "\n", "lx", ".", "backup", "(", ")", ...
// lexMultilineStringEscape consumes an escaped character. It assumes that the // preceding '\\' has already been consumed.
[ "lexMultilineStringEscape", "consumes", "an", "escaped", "character", ".", "It", "assumes", "that", "the", "preceding", "\\\\", "has", "already", "been", "consumed", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L672-L680
24,483
BurntSushi/toml
lex.go
lexNumberOrDate
func lexNumberOrDate(lx *lexer) stateFn { r := lx.next() if isDigit(r) { return lexNumberOrDate } switch r { case '-': return lexDatetime case '_': return lexNumber case '.', 'e', 'E': return lexFloat } lx.backup() lx.emit(itemInteger) return lx.pop() }
go
func lexNumberOrDate(lx *lexer) stateFn { r := lx.next() if isDigit(r) { return lexNumberOrDate } switch r { case '-': return lexDatetime case '_': return lexNumber case '.', 'e', 'E': return lexFloat } lx.backup() lx.emit(itemInteger) return lx.pop() }
[ "func", "lexNumberOrDate", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "if", "isDigit", "(", "r", ")", "{", "return", "lexNumberOrDate", "\n", "}", "\n", "switch", "r", "{", "case", "'-'", ":", "retur...
// lexNumberOrDate consumes either an integer, float or datetime.
[ "lexNumberOrDate", "consumes", "either", "an", "integer", "float", "or", "datetime", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L751-L768
24,484
BurntSushi/toml
lex.go
lexDatetime
func lexDatetime(lx *lexer) stateFn { r := lx.next() if isDigit(r) { return lexDatetime } switch r { case '-', 'T', ':', '.', 'Z', '+': return lexDatetime } lx.backup() lx.emit(itemDatetime) return lx.pop() }
go
func lexDatetime(lx *lexer) stateFn { r := lx.next() if isDigit(r) { return lexDatetime } switch r { case '-', 'T', ':', '.', 'Z', '+': return lexDatetime } lx.backup() lx.emit(itemDatetime) return lx.pop() }
[ "func", "lexDatetime", "(", "lx", "*", "lexer", ")", "stateFn", "{", "r", ":=", "lx", ".", "next", "(", ")", "\n", "if", "isDigit", "(", "r", ")", "{", "return", "lexDatetime", "\n", "}", "\n", "switch", "r", "{", "case", "'-'", ",", "'T'", ",", ...
// lexDatetime consumes a Datetime, to a first approximation. // The parser validates that it matches one of the accepted formats.
[ "lexDatetime", "consumes", "a", "Datetime", "to", "a", "first", "approximation", ".", "The", "parser", "validates", "that", "it", "matches", "one", "of", "the", "accepted", "formats", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/lex.go#L772-L785
24,485
BurntSushi/toml
encode.go
NewEncoder
func NewEncoder(w io.Writer) *Encoder { return &Encoder{ w: bufio.NewWriter(w), Indent: " ", } }
go
func NewEncoder(w io.Writer) *Encoder { return &Encoder{ w: bufio.NewWriter(w), Indent: " ", } }
[ "func", "NewEncoder", "(", "w", "io", ".", "Writer", ")", "*", "Encoder", "{", "return", "&", "Encoder", "{", "w", ":", "bufio", ".", "NewWriter", "(", "w", ")", ",", "Indent", ":", "\"", "\"", ",", "}", "\n", "}" ]
// NewEncoder returns a TOML encoder that encodes Go values to the io.Writer // given. By default, a single indentation level is 2 spaces.
[ "NewEncoder", "returns", "a", "TOML", "encoder", "that", "encodes", "Go", "values", "to", "the", "io", ".", "Writer", "given", ".", "By", "default", "a", "single", "indentation", "level", "is", "2", "spaces", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/encode.go#L56-L61
24,486
bluele/gcache
lru.go
evict
func (c *LRUCache) evict(count int) { for i := 0; i < count; i++ { ent := c.evictList.Back() if ent == nil { return } else { c.removeElement(ent) } } }
go
func (c *LRUCache) evict(count int) { for i := 0; i < count; i++ { ent := c.evictList.Back() if ent == nil { return } else { c.removeElement(ent) } } }
[ "func", "(", "c", "*", "LRUCache", ")", "evict", "(", "count", "int", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "count", ";", "i", "++", "{", "ent", ":=", "c", ".", "evictList", ".", "Back", "(", ")", "\n", "if", "ent", "==", "nil", "...
// evict removes the oldest item from the cache.
[ "evict", "removes", "the", "oldest", "item", "from", "the", "cache", "." ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/lru.go#L174-L183
24,487
bluele/gcache
arc.go
Has
func (c *ARC) Has(key interface{}) bool { c.mu.RLock() defer c.mu.RUnlock() now := time.Now() return c.has(key, &now) }
go
func (c *ARC) Has(key interface{}) bool { c.mu.RLock() defer c.mu.RUnlock() now := time.Now() return c.has(key, &now) }
[ "func", "(", "c", "*", "ARC", ")", "Has", "(", "key", "interface", "{", "}", ")", "bool", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "now", ":=", "time", ".", "Now", "(", ")",...
// Has checks if key exists in cache
[ "Has", "checks", "if", "key", "exists", "in", "cache" ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/arc.go#L267-L272
24,488
bluele/gcache
arc.go
Keys
func (c *ARC) Keys() []interface{} { keys := []interface{}{} for _, k := range c.keys() { _, err := c.GetIFPresent(k) if err == nil { keys = append(keys, k) } } return keys }
go
func (c *ARC) Keys() []interface{} { keys := []interface{}{} for _, k := range c.keys() { _, err := c.GetIFPresent(k) if err == nil { keys = append(keys, k) } } return keys }
[ "func", "(", "c", "*", "ARC", ")", "Keys", "(", ")", "[", "]", "interface", "{", "}", "{", "keys", ":=", "[", "]", "interface", "{", "}", "{", "}", "\n", "for", "_", ",", "k", ":=", "range", "c", ".", "keys", "(", ")", "{", "_", ",", "err...
// Keys returns a slice of the keys in the cache.
[ "Keys", "returns", "a", "slice", "of", "the", "keys", "in", "the", "cache", "." ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/arc.go#L329-L338
24,489
bluele/gcache
arc.go
GetALL
func (c *ARC) GetALL() map[interface{}]interface{} { m := make(map[interface{}]interface{}) for _, k := range c.keys() { v, err := c.GetIFPresent(k) if err == nil { m[k] = v } } return m }
go
func (c *ARC) GetALL() map[interface{}]interface{} { m := make(map[interface{}]interface{}) for _, k := range c.keys() { v, err := c.GetIFPresent(k) if err == nil { m[k] = v } } return m }
[ "func", "(", "c", "*", "ARC", ")", "GetALL", "(", ")", "map", "[", "interface", "{", "}", "]", "interface", "{", "}", "{", "m", ":=", "make", "(", "map", "[", "interface", "{", "}", "]", "interface", "{", "}", ")", "\n", "for", "_", ",", "k",...
// GetALL returns all key-value pairs in the cache.
[ "GetALL", "returns", "all", "key", "-", "value", "pairs", "in", "the", "cache", "." ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/arc.go#L341-L350
24,490
bluele/gcache
lfu.go
Set
func (c *LFUCache) Set(key, value interface{}) error { c.mu.Lock() defer c.mu.Unlock() _, err := c.set(key, value) return err }
go
func (c *LFUCache) Set(key, value interface{}) error { c.mu.Lock() defer c.mu.Unlock() _, err := c.set(key, value) return err }
[ "func", "(", "c", "*", "LFUCache", ")", "Set", "(", "key", ",", "value", "interface", "{", "}", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "_", ",", "err", ":=", "...
// Set a new key-value pair
[ "Set", "a", "new", "key", "-", "value", "pair" ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/lfu.go#L34-L39
24,491
bluele/gcache
lfu.go
SetWithExpire
func (c *LFUCache) SetWithExpire(key, value interface{}, expiration time.Duration) error { c.mu.Lock() defer c.mu.Unlock() item, err := c.set(key, value) if err != nil { return err } t := c.clock.Now().Add(expiration) item.(*lfuItem).expiration = &t return nil }
go
func (c *LFUCache) SetWithExpire(key, value interface{}, expiration time.Duration) error { c.mu.Lock() defer c.mu.Unlock() item, err := c.set(key, value) if err != nil { return err } t := c.clock.Now().Add(expiration) item.(*lfuItem).expiration = &t return nil }
[ "func", "(", "c", "*", "LFUCache", ")", "SetWithExpire", "(", "key", ",", "value", "interface", "{", "}", ",", "expiration", "time", ".", "Duration", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "U...
// Set a new key-value pair with an expiration time
[ "Set", "a", "new", "key", "-", "value", "pair", "with", "an", "expiration", "time" ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/lfu.go#L42-L53
24,492
bluele/gcache
lfu.go
Get
func (c *LFUCache) Get(key interface{}) (interface{}, error) { v, err := c.get(key, false) if err == KeyNotFoundError { return c.getWithLoader(key, true) } return v, err }
go
func (c *LFUCache) Get(key interface{}) (interface{}, error) { v, err := c.get(key, false) if err == KeyNotFoundError { return c.getWithLoader(key, true) } return v, err }
[ "func", "(", "c", "*", "LFUCache", ")", "Get", "(", "key", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "v", ",", "err", ":=", "c", ".", "get", "(", "key", ",", "false", ")", "\n", "if", "err", "==", "KeyNot...
// Get a value from cache pool using key if it exists. // If it dose not exists key and has LoaderFunc, // generate a value using `LoaderFunc` method returns value.
[ "Get", "a", "value", "from", "cache", "pool", "using", "key", "if", "it", "exists", ".", "If", "it", "dose", "not", "exists", "key", "and", "has", "LoaderFunc", "generate", "a", "value", "using", "LoaderFunc", "method", "returns", "value", "." ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/lfu.go#L102-L108
24,493
bluele/gcache
lfu.go
evict
func (c *LFUCache) evict(count int) { entry := c.freqList.Front() for i := 0; i < count; { if entry == nil { return } else { for item, _ := range entry.Value.(*freqEntry).items { if i >= count { return } c.removeItem(item) i++ } entry = entry.Next() } } }
go
func (c *LFUCache) evict(count int) { entry := c.freqList.Front() for i := 0; i < count; { if entry == nil { return } else { for item, _ := range entry.Value.(*freqEntry).items { if i >= count { return } c.removeItem(item) i++ } entry = entry.Next() } } }
[ "func", "(", "c", "*", "LFUCache", ")", "evict", "(", "count", "int", ")", "{", "entry", ":=", "c", ".", "freqList", ".", "Front", "(", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "count", ";", "{", "if", "entry", "==", "nil", "{", "retu...
// evict removes the least frequence item from the cache.
[ "evict", "removes", "the", "least", "frequence", "item", "from", "the", "cache", "." ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/lfu.go#L198-L214
24,494
bluele/gcache
stats.go
HitRate
func (st *stats) HitRate() float64 { hc, mc := st.HitCount(), st.MissCount() total := hc + mc if total == 0 { return 0.0 } return float64(hc) / float64(total) }
go
func (st *stats) HitRate() float64 { hc, mc := st.HitCount(), st.MissCount() total := hc + mc if total == 0 { return 0.0 } return float64(hc) / float64(total) }
[ "func", "(", "st", "*", "stats", ")", "HitRate", "(", ")", "float64", "{", "hc", ",", "mc", ":=", "st", ".", "HitCount", "(", ")", ",", "st", ".", "MissCount", "(", ")", "\n", "total", ":=", "hc", "+", "mc", "\n", "if", "total", "==", "0", "{...
// HitRate returns rate for cache hitting
[ "HitRate", "returns", "rate", "for", "cache", "hitting" ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/stats.go#L46-L53
24,495
bluele/gcache
cache.go
load
func (c *baseCache) load(key interface{}, cb func(interface{}, *time.Duration, error) (interface{}, error), isWait bool) (interface{}, bool, error) { v, called, err := c.loadGroup.Do(key, func() (v interface{}, e error) { defer func() { if r := recover(); r != nil { e = fmt.Errorf("Loader panics: %v", r) }...
go
func (c *baseCache) load(key interface{}, cb func(interface{}, *time.Duration, error) (interface{}, error), isWait bool) (interface{}, bool, error) { v, called, err := c.loadGroup.Do(key, func() (v interface{}, e error) { defer func() { if r := recover(); r != nil { e = fmt.Errorf("Loader panics: %v", r) }...
[ "func", "(", "c", "*", "baseCache", ")", "load", "(", "key", "interface", "{", "}", ",", "cb", "func", "(", "interface", "{", "}", ",", "*", "time", ".", "Duration", ",", "error", ")", "(", "interface", "{", "}", ",", "error", ")", ",", "isWait",...
// load a new value using by specified key.
[ "load", "a", "new", "value", "using", "by", "specified", "key", "." ]
79ae3b2d8680cbc7ad3dba9db66b8a648575221c
https://github.com/bluele/gcache/blob/79ae3b2d8680cbc7ad3dba9db66b8a648575221c/cache.go#L192-L205
24,496
bitly/oauth2_proxy
options.go
secretBytes
func secretBytes(secret string) []byte { b, err := base64.URLEncoding.DecodeString(addPadding(secret)) if err == nil { return []byte(addPadding(string(b))) } return []byte(secret) }
go
func secretBytes(secret string) []byte { b, err := base64.URLEncoding.DecodeString(addPadding(secret)) if err == nil { return []byte(addPadding(string(b))) } return []byte(secret) }
[ "func", "secretBytes", "(", "secret", "string", ")", "[", "]", "byte", "{", "b", ",", "err", ":=", "base64", ".", "URLEncoding", ".", "DecodeString", "(", "addPadding", "(", "secret", ")", ")", "\n", "if", "err", "==", "nil", "{", "return", "[", "]",...
// secretBytes attempts to base64 decode the secret, if that fails it treats the secret as binary
[ "secretBytes", "attempts", "to", "base64", "decode", "the", "secret", "if", "that", "fails", "it", "treats", "the", "secret", "as", "binary" ]
fa2771998a98a5bfdfa3c3503757668ac4f1c8ec
https://github.com/bitly/oauth2_proxy/blob/fa2771998a98a5bfdfa3c3503757668ac4f1c8ec/options.go#L329-L335
24,497
bitly/oauth2_proxy
providers/internal_util.go
stripParam
func stripParam(param, endpoint string) string { u, err := url.Parse(endpoint) if err != nil { log.Printf("error attempting to strip %s: %s", param, err) return endpoint } if u.RawQuery != "" { values, err := url.ParseQuery(u.RawQuery) if err != nil { log.Printf("error attempting to strip %s: %s", param...
go
func stripParam(param, endpoint string) string { u, err := url.Parse(endpoint) if err != nil { log.Printf("error attempting to strip %s: %s", param, err) return endpoint } if u.RawQuery != "" { values, err := url.ParseQuery(u.RawQuery) if err != nil { log.Printf("error attempting to strip %s: %s", param...
[ "func", "stripParam", "(", "param", ",", "endpoint", "string", ")", "string", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "param", ",", "e...
// stripParam generalizes the obfuscation of a particular // query parameter - typically 'access_token' or 'client_secret' // The parameter's second half is replaced by '...' and returned // as part of the encoded query parameters. // If the target parameter isn't found, the endpoint is returned // unmodified.
[ "stripParam", "generalizes", "the", "obfuscation", "of", "a", "particular", "query", "parameter", "-", "typically", "access_token", "or", "client_secret", "The", "parameter", "s", "second", "half", "is", "replaced", "by", "...", "and", "returned", "as", "part", ...
fa2771998a98a5bfdfa3c3503757668ac4f1c8ec
https://github.com/bitly/oauth2_proxy/blob/fa2771998a98a5bfdfa3c3503757668ac4f1c8ec/providers/internal_util.go#L24-L46
24,498
bitly/oauth2_proxy
providers/internal_util.go
validateToken
func validateToken(p Provider, access_token string, header http.Header) bool { if access_token == "" || p.Data().ValidateURL == nil { return false } endpoint := p.Data().ValidateURL.String() if len(header) == 0 { params := url.Values{"access_token": {access_token}} endpoint = endpoint + "?" + params.Encode() ...
go
func validateToken(p Provider, access_token string, header http.Header) bool { if access_token == "" || p.Data().ValidateURL == nil { return false } endpoint := p.Data().ValidateURL.String() if len(header) == 0 { params := url.Values{"access_token": {access_token}} endpoint = endpoint + "?" + params.Encode() ...
[ "func", "validateToken", "(", "p", "Provider", ",", "access_token", "string", ",", "header", "http", ".", "Header", ")", "bool", "{", "if", "access_token", "==", "\"", "\"", "||", "p", ".", "Data", "(", ")", ".", "ValidateURL", "==", "nil", "{", "retur...
// validateToken returns true if token is valid
[ "validateToken", "returns", "true", "if", "token", "is", "valid" ]
fa2771998a98a5bfdfa3c3503757668ac4f1c8ec
https://github.com/bitly/oauth2_proxy/blob/fa2771998a98a5bfdfa3c3503757668ac4f1c8ec/providers/internal_util.go#L49-L74
24,499
bitly/oauth2_proxy
logging_handler.go
writeLogLine
func (h loggingHandler) writeLogLine(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int) { if username == "" { username = "-" } if upstream == "" { upstream = "-" } if url.User != nil && username == "-" { if name := url.User.Username(); name != "" { username = na...
go
func (h loggingHandler) writeLogLine(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int) { if username == "" { username = "-" } if upstream == "" { upstream = "-" } if url.User != nil && username == "-" { if name := url.User.Username(); name != "" { username = na...
[ "func", "(", "h", "loggingHandler", ")", "writeLogLine", "(", "username", ",", "upstream", "string", ",", "req", "*", "http", ".", "Request", ",", "url", "url", ".", "URL", ",", "ts", "time", ".", "Time", ",", "status", "int", ",", "size", "int", ")"...
// Log entry for req similar to Apache Common Log Format. // ts is the timestamp with which the entry should be logged. // status, size are used to provide the response HTTP status and size.
[ "Log", "entry", "for", "req", "similar", "to", "Apache", "Common", "Log", "Format", ".", "ts", "is", "the", "timestamp", "with", "which", "the", "entry", "should", "be", "logged", ".", "status", "size", "are", "used", "to", "provide", "the", "response", ...
fa2771998a98a5bfdfa3c3503757668ac4f1c8ec
https://github.com/bitly/oauth2_proxy/blob/fa2771998a98a5bfdfa3c3503757668ac4f1c8ec/logging_handler.go#L120-L160