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
10,400
sethvargo/go-fastly
fastly/waf.go
ListWAFs
func (c *Client) ListWAFs(i *ListWAFsInput) ([]*WAF, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/wafs", i.Service, i.Version) resp, err := c.Get(path, nil) if err != nil { return nil, err } ...
go
func (c *Client) ListWAFs(i *ListWAFsInput) ([]*WAF, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/wafs", i.Service, i.Version) resp, err := c.Get(path, nil) if err != nil { return nil, err } ...
[ "func", "(", "c", "*", "Client", ")", "ListWAFs", "(", "i", "*", "ListWAFsInput", ")", "(", "[", "]", "*", "WAF", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n", "}", "\n\...
// ListWAFs returns the list of wafs for the configuration version.
[ "ListWAFs", "returns", "the", "list", "of", "wafs", "for", "the", "configuration", "version", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L48-L77
10,401
sethvargo/go-fastly
fastly/waf.go
CreateWAF
func (c *Client) CreateWAF(i *CreateWAFInput) (*WAF, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/wafs", i.Service, i.Version) resp, err := c.PostJSONAPI(path, i, nil) if err != nil { return n...
go
func (c *Client) CreateWAF(i *CreateWAFInput) (*WAF, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/wafs", i.Service, i.Version) resp, err := c.PostJSONAPI(path, i, nil) if err != nil { return n...
[ "func", "(", "c", "*", "Client", ")", "CreateWAF", "(", "i", "*", "CreateWAFInput", ")", "(", "*", "WAF", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n", "}", "\n\n", "if", ...
// CreateWAF creates a new Fastly WAF.
[ "CreateWAF", "creates", "a", "new", "Fastly", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L92-L112
10,402
sethvargo/go-fastly
fastly/waf.go
UpdateWAF
func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/version/%d/wafs/%s", i.Service, i.Version, i.ID) resp, er...
go
func (c *Client) UpdateWAF(i *UpdateWAFInput) (*WAF, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/version/%d/wafs/%s", i.Service, i.Version, i.ID) resp, er...
[ "func", "(", "c", "*", "Client", ")", "UpdateWAF", "(", "i", "*", "UpdateWAFInput", ")", "(", "*", "WAF", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n", "}", "\n\n", "if", ...
// UpdateWAF updates a specific WAF.
[ "UpdateWAF", "updates", "a", "specific", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L164-L188
10,403
sethvargo/go-fastly
fastly/waf.go
GetOWASP
func (c *Client) GetOWASP(i *GetOWASPInput) (*OWASP, error) { if i.Service == "" { return nil, ErrMissingService } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%s/owasp", i.Service, i.ID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var owasp ...
go
func (c *Client) GetOWASP(i *GetOWASPInput) (*OWASP, error) { if i.Service == "" { return nil, ErrMissingService } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%s/owasp", i.Service, i.ID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var owasp ...
[ "func", "(", "c", "*", "Client", ")", "GetOWASP", "(", "i", "*", "GetOWASPInput", ")", "(", "*", "OWASP", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n", "}", "\n\n", "if", ...
// GetOWASP gets OWASP settings for a service firewall object.
[ "GetOWASP", "gets", "OWASP", "settings", "for", "a", "service", "firewall", "object", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L263-L284
10,404
sethvargo/go-fastly
fastly/waf.go
GetRules
func (c *Client) GetRules() ([]*Rule, error) { path := fmt.Sprintf("/wafs/rules") resp, err := c.Get(path, nil) if err != nil { return nil, err } data, err := jsonapi.UnmarshalManyPayload(resp.Body, rulesType) if err != nil { return nil, err } rules := make([]*Rule, len(data)) for i := range data { typ...
go
func (c *Client) GetRules() ([]*Rule, error) { path := fmt.Sprintf("/wafs/rules") resp, err := c.Get(path, nil) if err != nil { return nil, err } data, err := jsonapi.UnmarshalManyPayload(resp.Body, rulesType) if err != nil { return nil, err } rules := make([]*Rule, len(data)) for i := range data { typ...
[ "func", "(", "c", "*", "Client", ")", "GetRules", "(", ")", "(", "[", "]", "*", "Rule", ",", "error", ")", "{", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Get", "(", "path", ",", "n...
// GetRules returns the list of wafs for the configuration version.
[ "GetRules", "returns", "the", "list", "of", "wafs", "for", "the", "configuration", "version", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L399-L421
10,405
sethvargo/go-fastly
fastly/waf.go
GetRule
func (c *Client) GetRule(i *GetRuleInput) (*Rule, error) { if i.RuleID == "" { return nil, ErrMissingRuleID } path := fmt.Sprintf("/wafs/rules/%s", i.RuleID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var rule Rule if err := jsonapi.UnmarshalPayload(resp.Body, &rule); err != nil { r...
go
func (c *Client) GetRule(i *GetRuleInput) (*Rule, error) { if i.RuleID == "" { return nil, ErrMissingRuleID } path := fmt.Sprintf("/wafs/rules/%s", i.RuleID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var rule Rule if err := jsonapi.UnmarshalPayload(resp.Body, &rule); err != nil { r...
[ "func", "(", "c", "*", "Client", ")", "GetRule", "(", "i", "*", "GetRuleInput", ")", "(", "*", "Rule", ",", "error", ")", "{", "if", "i", ".", "RuleID", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingRuleID", "\n", "}", "\n\n", "path", "...
// GetRule gets a Rule using the Rule ID.
[ "GetRule", "gets", "a", "Rule", "using", "the", "Rule", "ID", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L430-L446
10,406
sethvargo/go-fastly
fastly/waf.go
GetRuleVCL
func (c *Client) GetRuleVCL(i *GetRuleInput) (*RuleVCL, error) { if i.RuleID == "" { return nil, ErrMissingRuleID } path := fmt.Sprintf("/wafs/rules/%s/vcl", i.RuleID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var vcl RuleVCL if err := jsonapi.UnmarshalPayload(resp.Body, &vcl); err !...
go
func (c *Client) GetRuleVCL(i *GetRuleInput) (*RuleVCL, error) { if i.RuleID == "" { return nil, ErrMissingRuleID } path := fmt.Sprintf("/wafs/rules/%s/vcl", i.RuleID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var vcl RuleVCL if err := jsonapi.UnmarshalPayload(resp.Body, &vcl); err !...
[ "func", "(", "c", "*", "Client", ")", "GetRuleVCL", "(", "i", "*", "GetRuleInput", ")", "(", "*", "RuleVCL", ",", "error", ")", "{", "if", "i", ".", "RuleID", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingRuleID", "\n", "}", "\n\n", "path...
// GetRuleVCL gets the VCL for a Rule.
[ "GetRuleVCL", "gets", "the", "VCL", "for", "a", "Rule", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L455-L471
10,407
sethvargo/go-fastly
fastly/waf.go
GetWAFRuleVCL
func (c *Client) GetWAFRuleVCL(i *GetWAFRuleVCLInput) (*RuleVCL, error) { if i.ID == "" { return nil, ErrMissingWAFID } if i.RuleID == "" { return nil, ErrMissingRuleID } path := fmt.Sprintf("/wafs/%s/rules/%s/vcl", i.ID, i.RuleID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var vc...
go
func (c *Client) GetWAFRuleVCL(i *GetWAFRuleVCLInput) (*RuleVCL, error) { if i.ID == "" { return nil, ErrMissingWAFID } if i.RuleID == "" { return nil, ErrMissingRuleID } path := fmt.Sprintf("/wafs/%s/rules/%s/vcl", i.ID, i.RuleID) resp, err := c.Get(path, nil) if err != nil { return nil, err } var vc...
[ "func", "(", "c", "*", "Client", ")", "GetWAFRuleVCL", "(", "i", "*", "GetWAFRuleVCLInput", ")", "(", "*", "RuleVCL", ",", "error", ")", "{", "if", "i", ".", "ID", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingWAFID", "\n", "}", "\n\n", "...
// GetWAFRuleVCL gets the VCL for a role associated with a firewall WAF.
[ "GetWAFRuleVCL", "gets", "the", "VCL", "for", "a", "role", "associated", "with", "a", "firewall", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L482-L502
10,408
sethvargo/go-fastly
fastly/waf.go
GetWAFRuleRuleSets
func (c *Client) GetWAFRuleRuleSets(i *GetWAFRuleRuleSetsInput) (*Ruleset, error) { if i.Service == "" { return nil, ErrMissingService } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%s/ruleset", i.Service, i.ID) resp, err := c.Get(path, nil) if err != nil { return n...
go
func (c *Client) GetWAFRuleRuleSets(i *GetWAFRuleRuleSetsInput) (*Ruleset, error) { if i.Service == "" { return nil, ErrMissingService } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%s/ruleset", i.Service, i.ID) resp, err := c.Get(path, nil) if err != nil { return n...
[ "func", "(", "c", "*", "Client", ")", "GetWAFRuleRuleSets", "(", "i", "*", "GetWAFRuleRuleSetsInput", ")", "(", "*", "Ruleset", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n", "...
// GetWAFRuleRuleSets gets the VCL for rulesets associated with a firewall WAF.
[ "GetWAFRuleRuleSets", "gets", "the", "VCL", "for", "rulesets", "associated", "with", "a", "firewall", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L520-L540
10,409
sethvargo/go-fastly
fastly/waf.go
UpdateWAFRuleSets
func (c *Client) UpdateWAFRuleSets(i *UpdateWAFRuleRuleSetsInput) (*Ruleset, error) { if i.Service == "" { return nil, ErrMissingService } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%s/ruleset", i.Service, i.ID) resp, err := c.PatchJSONAPI(path, i, nil) if err != ni...
go
func (c *Client) UpdateWAFRuleSets(i *UpdateWAFRuleRuleSetsInput) (*Ruleset, error) { if i.Service == "" { return nil, ErrMissingService } if i.ID == "" { return nil, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%s/ruleset", i.Service, i.ID) resp, err := c.PatchJSONAPI(path, i, nil) if err != ni...
[ "func", "(", "c", "*", "Client", ")", "UpdateWAFRuleSets", "(", "i", "*", "UpdateWAFRuleRuleSetsInput", ")", "(", "*", "Ruleset", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n", ...
// UpdateWAFRuleSets updates the rulesets for a role associated with a firewall WAF.
[ "UpdateWAFRuleSets", "updates", "the", "rulesets", "for", "a", "role", "associated", "with", "a", "firewall", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L551-L571
10,410
sethvargo/go-fastly
fastly/waf.go
formatFilters
func (i *GetWAFRuleStatusesInput) formatFilters() map[string]string { input := i.Filters result := map[string]string{} pairings := map[string]interface{}{ "filter[status]": input.Status, "filter[rule][accuracy]": input.Accuracy, "filter[rule][maturity]": input.Maturity, "filter[rule][message]":...
go
func (i *GetWAFRuleStatusesInput) formatFilters() map[string]string { input := i.Filters result := map[string]string{} pairings := map[string]interface{}{ "filter[status]": input.Status, "filter[rule][accuracy]": input.Accuracy, "filter[rule][maturity]": input.Maturity, "filter[rule][message]":...
[ "func", "(", "i", "*", "GetWAFRuleStatusesInput", ")", "formatFilters", "(", ")", "map", "[", "string", "]", "string", "{", "input", ":=", "i", ".", "Filters", "\n", "result", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "pairings", ":=",...
// formatFilters converts user input into query parameters for filtering // Fastly results for rules in a WAF.
[ "formatFilters", "converts", "user", "input", "into", "query", "parameters", "for", "filtering", "Fastly", "results", "for", "rules", "in", "a", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L614-L657
10,411
sethvargo/go-fastly
fastly/waf.go
GetWAFRuleStatuses
func (c *Client) GetWAFRuleStatuses(i *GetWAFRuleStatusesInput) (GetWAFRuleStatusesResponse, error) { statusResponse := GetWAFRuleStatusesResponse{Rules: []*WAFRuleStatus{}} if i.Service == "" { return statusResponse, ErrMissingService } if i.WAF == "" { return statusResponse, ErrMissingWAFID } path := fmt.S...
go
func (c *Client) GetWAFRuleStatuses(i *GetWAFRuleStatusesInput) (GetWAFRuleStatusesResponse, error) { statusResponse := GetWAFRuleStatusesResponse{Rules: []*WAFRuleStatus{}} if i.Service == "" { return statusResponse, ErrMissingService } if i.WAF == "" { return statusResponse, ErrMissingWAFID } path := fmt.S...
[ "func", "(", "c", "*", "Client", ")", "GetWAFRuleStatuses", "(", "i", "*", "GetWAFRuleStatusesInput", ")", "(", "GetWAFRuleStatusesResponse", ",", "error", ")", "{", "statusResponse", ":=", "GetWAFRuleStatusesResponse", "{", "Rules", ":", "[", "]", "*", "WAFRule...
// GetWAFRuleStatuses fetches the status of a subset of rules associated with a WAF.
[ "GetWAFRuleStatuses", "fetches", "the", "status", "of", "a", "subset", "of", "rules", "associated", "with", "a", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L660-L681
10,412
sethvargo/go-fastly
fastly/waf.go
interpretWAFRuleStatusesPage
func (c *Client) interpretWAFRuleStatusesPage(answer *GetWAFRuleStatusesResponse, received *http.Response) error { // before we pull the status info out of the response body, fetch // pagination info from it: pages, body, err := getPages(received.Body) if err != nil { return err } data, err := jsonapi.Unmarshal...
go
func (c *Client) interpretWAFRuleStatusesPage(answer *GetWAFRuleStatusesResponse, received *http.Response) error { // before we pull the status info out of the response body, fetch // pagination info from it: pages, body, err := getPages(received.Body) if err != nil { return err } data, err := jsonapi.Unmarshal...
[ "func", "(", "c", "*", "Client", ")", "interpretWAFRuleStatusesPage", "(", "answer", "*", "GetWAFRuleStatusesResponse", ",", "received", "*", "http", ".", "Response", ")", "error", "{", "// before we pull the status info out of the response body, fetch", "// pagination info...
// interpretWAFRuleStatusesPage accepts a Fastly response for a set of WAF rule statuses // and unmarshals the results. If there are more pages of results, it fetches the next // page, adds that response to the array of results, and repeats until all results have // been fetched.
[ "interpretWAFRuleStatusesPage", "accepts", "a", "Fastly", "response", "for", "a", "set", "of", "WAF", "rule", "statuses", "and", "unmarshals", "the", "results", ".", "If", "there", "are", "more", "pages", "of", "results", "it", "fetches", "the", "next", "page"...
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L687-L715
10,413
sethvargo/go-fastly
fastly/waf.go
getPages
func getPages(body io.Reader) (paginationInfo, io.Reader, error) { var buf bytes.Buffer tee := io.TeeReader(body, &buf) bodyBytes, err := ioutil.ReadAll(tee) if err != nil { return paginationInfo{}, nil, err } var pages linksResponse json.Unmarshal(bodyBytes, &pages) return pages.Links, bytes.NewReader(buf....
go
func getPages(body io.Reader) (paginationInfo, io.Reader, error) { var buf bytes.Buffer tee := io.TeeReader(body, &buf) bodyBytes, err := ioutil.ReadAll(tee) if err != nil { return paginationInfo{}, nil, err } var pages linksResponse json.Unmarshal(bodyBytes, &pages) return pages.Links, bytes.NewReader(buf....
[ "func", "getPages", "(", "body", "io", ".", "Reader", ")", "(", "paginationInfo", ",", "io", ".", "Reader", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "tee", ":=", "io", ".", "TeeReader", "(", "body", ",", "&", "buf", ")", ...
// getPages parses a response to get the pagination data without destroying // the reader we receive as "resp.Body"; this essentially copies resp.Body // and returns it so we can use it again.
[ "getPages", "parses", "a", "response", "to", "get", "the", "pagination", "data", "without", "destroying", "the", "reader", "we", "receive", "as", "resp", ".", "Body", ";", "this", "essentially", "copies", "resp", ".", "Body", "and", "returns", "it", "so", ...
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L740-L752
10,414
sethvargo/go-fastly
fastly/waf.go
GetWAFRuleStatus
func (c *Client) GetWAFRuleStatus(i *GetWAFRuleStatusInput) (WAFRuleStatus, error) { if i.ID == 0 { return WAFRuleStatus{}, ErrMissingRuleID } if i.Service == "" { return WAFRuleStatus{}, ErrMissingService } if i.WAF == "" { return WAFRuleStatus{}, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%...
go
func (c *Client) GetWAFRuleStatus(i *GetWAFRuleStatusInput) (WAFRuleStatus, error) { if i.ID == 0 { return WAFRuleStatus{}, ErrMissingRuleID } if i.Service == "" { return WAFRuleStatus{}, ErrMissingService } if i.WAF == "" { return WAFRuleStatus{}, ErrMissingWAFID } path := fmt.Sprintf("/service/%s/wafs/%...
[ "func", "(", "c", "*", "Client", ")", "GetWAFRuleStatus", "(", "i", "*", "GetWAFRuleStatusInput", ")", "(", "WAFRuleStatus", ",", "error", ")", "{", "if", "i", ".", "ID", "==", "0", "{", "return", "WAFRuleStatus", "{", "}", ",", "ErrMissingRuleID", "\n",...
// GetWAFRuleStatus fetches the status of a single rule associated with a WAF.
[ "GetWAFRuleStatus", "fetches", "the", "status", "of", "a", "single", "rule", "associated", "with", "a", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L762-L782
10,415
sethvargo/go-fastly
fastly/waf.go
validate
func (i UpdateWAFRuleStatusInput) validate() error { if i.ID == "" { return ErrMissingID } if i.RuleID == 0 { return ErrMissingRuleID } if i.Service == "" { return ErrMissingService } if i.WAF == "" { return ErrMissingWAFID } if i.Status == "" { return ErrMissingStatus } return nil }
go
func (i UpdateWAFRuleStatusInput) validate() error { if i.ID == "" { return ErrMissingID } if i.RuleID == 0 { return ErrMissingRuleID } if i.Service == "" { return ErrMissingService } if i.WAF == "" { return ErrMissingWAFID } if i.Status == "" { return ErrMissingStatus } return nil }
[ "func", "(", "i", "UpdateWAFRuleStatusInput", ")", "validate", "(", ")", "error", "{", "if", "i", ".", "ID", "==", "\"", "\"", "{", "return", "ErrMissingID", "\n", "}", "\n", "if", "i", ".", "RuleID", "==", "0", "{", "return", "ErrMissingRuleID", "\n",...
// validate makes sure the UpdateWAFRuleStatusInput instance has all // fields we need to request a change.
[ "validate", "makes", "sure", "the", "UpdateWAFRuleStatusInput", "instance", "has", "all", "fields", "we", "need", "to", "request", "a", "change", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L795-L812
10,416
sethvargo/go-fastly
fastly/waf.go
UpdateWAFRuleStatus
func (c *Client) UpdateWAFRuleStatus(i *UpdateWAFRuleStatusInput) (WAFRuleStatus, error) { if err := i.validate(); err != nil { return WAFRuleStatus{}, err } path := fmt.Sprintf("/service/%s/wafs/%s/rules/%d/rule_status", i.Service, i.WAF, i.RuleID) var buf bytes.Buffer err := jsonapi.MarshalPayload(&buf, i) ...
go
func (c *Client) UpdateWAFRuleStatus(i *UpdateWAFRuleStatusInput) (WAFRuleStatus, error) { if err := i.validate(); err != nil { return WAFRuleStatus{}, err } path := fmt.Sprintf("/service/%s/wafs/%s/rules/%d/rule_status", i.Service, i.WAF, i.RuleID) var buf bytes.Buffer err := jsonapi.MarshalPayload(&buf, i) ...
[ "func", "(", "c", "*", "Client", ")", "UpdateWAFRuleStatus", "(", "i", "*", "UpdateWAFRuleStatusInput", ")", "(", "WAFRuleStatus", ",", "error", ")", "{", "if", "err", ":=", "i", ".", "validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "WAFRu...
// UpdateWAFRuleStatus changes the status of a single rule associated with a WAF.
[ "UpdateWAFRuleStatus", "changes", "the", "status", "of", "a", "single", "rule", "associated", "with", "a", "WAF", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L815-L844
10,417
sethvargo/go-fastly
fastly/waf.go
UpdateWAFConfigSet
func (c *Client) UpdateWAFConfigSet(i *UpdateWAFConfigSetInput) (UpdateWAFConfigSetResponse, error) { if err := i.validate(); err != nil { return UpdateWAFConfigSetResponse{}, err } var wafs []interface{} for _, w := range i.WAFList { wafs = append(wafs, &w) } path := fmt.Sprintf("/wafs/configuration_sets/%s...
go
func (c *Client) UpdateWAFConfigSet(i *UpdateWAFConfigSetInput) (UpdateWAFConfigSetResponse, error) { if err := i.validate(); err != nil { return UpdateWAFConfigSetResponse{}, err } var wafs []interface{} for _, w := range i.WAFList { wafs = append(wafs, &w) } path := fmt.Sprintf("/wafs/configuration_sets/%s...
[ "func", "(", "c", "*", "Client", ")", "UpdateWAFConfigSet", "(", "i", "*", "UpdateWAFConfigSetInput", ")", "(", "UpdateWAFConfigSetResponse", ",", "error", ")", "{", "if", "err", ":=", "i", ".", "validate", "(", ")", ";", "err", "!=", "nil", "{", "return...
// UpdateWAFConfigSet updates a list of WAFs with the given configset
[ "UpdateWAFConfigSet", "updates", "a", "list", "of", "WAFs", "with", "the", "given", "configset" ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L946-L969
10,418
sethvargo/go-fastly
fastly/waf.go
interpretWAFCongfigSetResponse
func (c *Client) interpretWAFCongfigSetResponse(answer *UpdateWAFConfigSetResponse, received *http.Response) error { pages, body, err := getPages(received.Body) if err != nil { return err } data, err := jsonapi.UnmarshalManyPayload(body, reflect.TypeOf([]ConfigSetWAFs{})) if err != nil { return err } for i ...
go
func (c *Client) interpretWAFCongfigSetResponse(answer *UpdateWAFConfigSetResponse, received *http.Response) error { pages, body, err := getPages(received.Body) if err != nil { return err } data, err := jsonapi.UnmarshalManyPayload(body, reflect.TypeOf([]ConfigSetWAFs{})) if err != nil { return err } for i ...
[ "func", "(", "c", "*", "Client", ")", "interpretWAFCongfigSetResponse", "(", "answer", "*", "UpdateWAFConfigSetResponse", ",", "received", "*", "http", ".", "Response", ")", "error", "{", "pages", ",", "body", ",", "err", ":=", "getPages", "(", "received", "...
// interpretWAFCongfigSetResponse accepts a Fastly response containing a set of WAF ID's that // where given to associate with the config set and unmarshals the results. // If there are more pages of results, it fetches the next // page, adds that response to the array of results, and repeats until all results have // ...
[ "interpretWAFCongfigSetResponse", "accepts", "a", "Fastly", "response", "containing", "a", "set", "of", "WAF", "ID", "s", "that", "where", "given", "to", "associate", "with", "the", "config", "set", "and", "unmarshals", "the", "results", ".", "If", "there", "a...
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/waf.go#L990-L1017
10,419
sethvargo/go-fastly
fastly/response_object.go
ListResponseObjects
func (c *Client) ListResponseObjects(i *ListResponseObjectsInput) ([]*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/response_object", i.Service, i.Version) resp, err := c.Get(path,...
go
func (c *Client) ListResponseObjects(i *ListResponseObjectsInput) ([]*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/response_object", i.Service, i.Version) resp, err := c.Get(path,...
[ "func", "(", "c", "*", "Client", ")", "ListResponseObjects", "(", "i", "*", "ListResponseObjectsInput", ")", "(", "[", "]", "*", "ResponseObject", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissi...
// ListResponseObjects returns the list of response objects for the // configuration version.
[ "ListResponseObjects", "returns", "the", "list", "of", "response", "objects", "for", "the", "configuration", "version", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/response_object.go#L44-L65
10,420
sethvargo/go-fastly
fastly/response_object.go
CreateResponseObject
func (c *Client) CreateResponseObject(i *CreateResponseObjectInput) (*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/response_object", i.Service, i.Version) resp, err := c.PostForm(...
go
func (c *Client) CreateResponseObject(i *CreateResponseObjectInput) (*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } path := fmt.Sprintf("/service/%s/version/%d/response_object", i.Service, i.Version) resp, err := c.PostForm(...
[ "func", "(", "c", "*", "Client", ")", "CreateResponseObject", "(", "i", "*", "CreateResponseObjectInput", ")", "(", "*", "ResponseObject", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", ...
// CreateResponseObject creates a new Fastly response object.
[ "CreateResponseObject", "creates", "a", "new", "Fastly", "response", "object", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/response_object.go#L85-L105
10,421
sethvargo/go-fastly
fastly/response_object.go
GetResponseObject
func (c *Client) GetResponseObject(i *GetResponseObjectInput) (*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } if i.Name == "" { return nil, ErrMissingName } path := fmt.Sprintf("/service/%s/version/%d/response_object/%s"...
go
func (c *Client) GetResponseObject(i *GetResponseObjectInput) (*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } if i.Name == "" { return nil, ErrMissingName } path := fmt.Sprintf("/service/%s/version/%d/response_object/%s"...
[ "func", "(", "c", "*", "Client", ")", "GetResponseObject", "(", "i", "*", "GetResponseObjectInput", ")", "(", "*", "ResponseObject", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", "\n"...
// GetResponseObject gets the response object configuration with the given // parameters.
[ "GetResponseObject", "gets", "the", "response", "object", "configuration", "with", "the", "given", "parameters", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/response_object.go#L120-L144
10,422
sethvargo/go-fastly
fastly/response_object.go
UpdateResponseObject
func (c *Client) UpdateResponseObject(i *UpdateResponseObjectInput) (*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } if i.Name == "" { return nil, ErrMissingName } path := fmt.Sprintf("/service/%s/version/%d/response_obje...
go
func (c *Client) UpdateResponseObject(i *UpdateResponseObjectInput) (*ResponseObject, error) { if i.Service == "" { return nil, ErrMissingService } if i.Version == 0 { return nil, ErrMissingVersion } if i.Name == "" { return nil, ErrMissingName } path := fmt.Sprintf("/service/%s/version/%d/response_obje...
[ "func", "(", "c", "*", "Client", ")", "UpdateResponseObject", "(", "i", "*", "UpdateResponseObjectInput", ")", "(", "*", "ResponseObject", ",", "error", ")", "{", "if", "i", ".", "Service", "==", "\"", "\"", "{", "return", "nil", ",", "ErrMissingService", ...
// UpdateResponseObject updates a specific response object.
[ "UpdateResponseObject", "updates", "a", "specific", "response", "object", "." ]
f249287bd4fda366a7f324f45a2308e934198464
https://github.com/sethvargo/go-fastly/blob/f249287bd4fda366a7f324f45a2308e934198464/fastly/response_object.go#L167-L191
10,423
dchest/passwordreset
passwordreset.go
VerifyToken
func VerifyToken(token string, pwdvalFn func(string) ([]byte, error), secret []byte) (login string, err error) { blen := base64.URLEncoding.DecodedLen(len(token)) // Avoid allocation if the token is too short if blen <= 4+32 { err = ErrMalformedToken return } b := make([]byte, blen) blen, err = base64.URLEnco...
go
func VerifyToken(token string, pwdvalFn func(string) ([]byte, error), secret []byte) (login string, err error) { blen := base64.URLEncoding.DecodedLen(len(token)) // Avoid allocation if the token is too short if blen <= 4+32 { err = ErrMalformedToken return } b := make([]byte, blen) blen, err = base64.URLEnco...
[ "func", "VerifyToken", "(", "token", "string", ",", "pwdvalFn", "func", "(", "string", ")", "(", "[", "]", "byte", ",", "error", ")", ",", "secret", "[", "]", "byte", ")", "(", "login", "string", ",", "err", "error", ")", "{", "blen", ":=", "base64...
// VerifyToken verifies the given token with the password value returned by the // given function and the given secret key, and returns login extracted from // the valid token. If the token is not valid, the function returns an error. // // Function pwdvalFn must return the current password value for the login it // re...
[ "VerifyToken", "verifies", "the", "given", "token", "with", "the", "password", "value", "returned", "by", "the", "given", "function", "and", "the", "given", "secret", "key", "and", "returns", "login", "extracted", "from", "the", "valid", "token", ".", "If", ...
642cf836ac8dfd4ddec7a28cbef7b00da0807812
https://github.com/dchest/passwordreset/blob/642cf836ac8dfd4ddec7a28cbef7b00da0807812/passwordreset.go#L134-L174
10,424
mitchellh/go-mruby
class.go
DefineClassMethod
func (c *Class) DefineClassMethod(name string, cb Func, as ArgSpec) { insertMethod(c.mrb.state, c.class.c, name, cb) cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) C.mrb_define_class_method( c.mrb.state, c.class, cs, C._go_mrb_func_t(), C.mrb_aspec(as)) }
go
func (c *Class) DefineClassMethod(name string, cb Func, as ArgSpec) { insertMethod(c.mrb.state, c.class.c, name, cb) cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) C.mrb_define_class_method( c.mrb.state, c.class, cs, C._go_mrb_func_t(), C.mrb_aspec(as)) }
[ "func", "(", "c", "*", "Class", ")", "DefineClassMethod", "(", "name", "string", ",", "cb", "Func", ",", "as", "ArgSpec", ")", "{", "insertMethod", "(", "c", ".", "mrb", ".", "state", ",", "c", ".", "class", ".", "c", ",", "name", ",", "cb", ")",...
// DefineClassMethod defines a class-level method on the given class.
[ "DefineClassMethod", "defines", "a", "class", "-", "level", "method", "on", "the", "given", "class", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/class.go#L17-L29
10,425
mitchellh/go-mruby
class.go
DefineConst
func (c *Class) DefineConst(name string, value Value) { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) C.mrb_define_const( c.mrb.state, c.class, cs, value.MrbValue(c.mrb).value) }
go
func (c *Class) DefineConst(name string, value Value) { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) C.mrb_define_const( c.mrb.state, c.class, cs, value.MrbValue(c.mrb).value) }
[ "func", "(", "c", "*", "Class", ")", "DefineConst", "(", "name", "string", ",", "value", "Value", ")", "{", "cs", ":=", "C", ".", "CString", "(", "name", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cs", ")", ")", ...
// DefineConst defines a constant within this class.
[ "DefineConst", "defines", "a", "constant", "within", "this", "class", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/class.go#L32-L38
10,426
mitchellh/go-mruby
class.go
New
func (c *Class) New(args ...Value) (*MrbValue, error) { var argv []C.mrb_value var argvPtr *C.mrb_value if len(args) > 0 { // Make the raw byte slice to hold our arguments we'll pass to C argv = make([]C.mrb_value, len(args)) for i, arg := range args { argv[i] = arg.MrbValue(c.mrb).value } argvPtr = &a...
go
func (c *Class) New(args ...Value) (*MrbValue, error) { var argv []C.mrb_value var argvPtr *C.mrb_value if len(args) > 0 { // Make the raw byte slice to hold our arguments we'll pass to C argv = make([]C.mrb_value, len(args)) for i, arg := range args { argv[i] = arg.MrbValue(c.mrb).value } argvPtr = &a...
[ "func", "(", "c", "*", "Class", ")", "New", "(", "args", "...", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "var", "argv", "[", "]", "C", ".", "mrb_value", "\n", "var", "argvPtr", "*", "C", ".", "mrb_value", "\n", "if", "len", "...
// New instantiates the class with the given args.
[ "New", "instantiates", "the", "class", "with", "the", "given", "args", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/class.go#L62-L81
10,427
mitchellh/go-mruby
mruby.go
GetGlobalVariable
func (m *Mrb) GetGlobalVariable(name string) *MrbValue { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) return newValue(m.state, C._go_mrb_gv_get(m.state, C.mrb_intern_cstr(m.state, cs))) }
go
func (m *Mrb) GetGlobalVariable(name string) *MrbValue { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) return newValue(m.state, C._go_mrb_gv_get(m.state, C.mrb_intern_cstr(m.state, cs))) }
[ "func", "(", "m", "*", "Mrb", ")", "GetGlobalVariable", "(", "name", "string", ")", "*", "MrbValue", "{", "cs", ":=", "C", ".", "CString", "(", "name", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cs", ")", ")", "\n"...
// GetGlobalVariable returns the value of the global variable by the given name.
[ "GetGlobalVariable", "returns", "the", "value", "of", "the", "global", "variable", "by", "the", "given", "name", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L17-L21
10,428
mitchellh/go-mruby
mruby.go
SetGlobalVariable
func (m *Mrb) SetGlobalVariable(name string, value Value) { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) v := value.MrbValue(m) C._go_mrb_gv_set(m.state, C.mrb_intern_cstr(m.state, cs), v.value) }
go
func (m *Mrb) SetGlobalVariable(name string, value Value) { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) v := value.MrbValue(m) C._go_mrb_gv_set(m.state, C.mrb_intern_cstr(m.state, cs), v.value) }
[ "func", "(", "m", "*", "Mrb", ")", "SetGlobalVariable", "(", "name", "string", ",", "value", "Value", ")", "{", "cs", ":=", "C", ".", "CString", "(", "name", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cs", ")", ")"...
// SetGlobalVariable sets the value of the global variable by the given name.
[ "SetGlobalVariable", "sets", "the", "value", "of", "the", "global", "variable", "by", "the", "given", "name", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L24-L30
10,429
mitchellh/go-mruby
mruby.go
ArenaRestore
func (m *Mrb) ArenaRestore(idx ArenaIndex) { C.mrb_gc_arena_restore(m.state, C.int(idx)) }
go
func (m *Mrb) ArenaRestore(idx ArenaIndex) { C.mrb_gc_arena_restore(m.state, C.int(idx)) }
[ "func", "(", "m", "*", "Mrb", ")", "ArenaRestore", "(", "idx", "ArenaIndex", ")", "{", "C", ".", "mrb_gc_arena_restore", "(", "m", ".", "state", ",", "C", ".", "int", "(", "idx", ")", ")", "\n", "}" ]
// ArenaRestore restores the arena index so the objects between the save and this point // can be garbage collected in the future. // // See ArenaSave for more documentation.
[ "ArenaRestore", "restores", "the", "arena", "index", "so", "the", "objects", "between", "the", "save", "and", "this", "point", "can", "be", "garbage", "collected", "in", "the", "future", ".", "See", "ArenaSave", "for", "more", "documentation", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L54-L56
10,430
mitchellh/go-mruby
mruby.go
Close
func (m *Mrb) Close() { // Delete all the methods from the state stateMethodTable.Mutex.Lock() delete(stateMethodTable.Map, m.state) stateMethodTable.Mutex.Unlock() // Close the state C.mrb_close(m.state) }
go
func (m *Mrb) Close() { // Delete all the methods from the state stateMethodTable.Mutex.Lock() delete(stateMethodTable.Map, m.state) stateMethodTable.Mutex.Unlock() // Close the state C.mrb_close(m.state) }
[ "func", "(", "m", "*", "Mrb", ")", "Close", "(", ")", "{", "// Delete all the methods from the state", "stateMethodTable", ".", "Mutex", ".", "Lock", "(", ")", "\n", "delete", "(", "stateMethodTable", ".", "Map", ",", "m", ".", "state", ")", "\n", "stateMe...
// Close a Mrb, this must be called to properly free resources, and // should only be called once.
[ "Close", "a", "Mrb", "this", "must", "be", "called", "to", "properly", "free", "resources", "and", "should", "only", "be", "called", "once", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L130-L138
10,431
mitchellh/go-mruby
mruby.go
LoadString
func (m *Mrb) LoadString(code string) (*MrbValue, error) { cs := C.CString(code) defer C.free(unsafe.Pointer(cs)) value := C._go_mrb_load_string(m.state, cs) if exc := checkException(m.state); exc != nil { return nil, exc } return newValue(m.state, value), nil }
go
func (m *Mrb) LoadString(code string) (*MrbValue, error) { cs := C.CString(code) defer C.free(unsafe.Pointer(cs)) value := C._go_mrb_load_string(m.state, cs) if exc := checkException(m.state); exc != nil { return nil, exc } return newValue(m.state, value), nil }
[ "func", "(", "m", "*", "Mrb", ")", "LoadString", "(", "code", "string", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "cs", ":=", "C", ".", "CString", "(", "code", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "...
// LoadString loads the given code, executes it, and returns its final // value that it might return.
[ "LoadString", "loads", "the", "given", "code", "executes", "it", "and", "returns", "its", "final", "value", "that", "it", "might", "return", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L194-L204
10,432
mitchellh/go-mruby
mruby.go
Run
func (m *Mrb) Run(v Value, self Value) (*MrbValue, error) { if self == nil { self = m.TopSelf() } mrbV := v.MrbValue(m) mrbSelf := self.MrbValue(m) proc := C._go_mrb_proc_ptr(mrbV.value) value := C.mrb_run(m.state, proc, mrbSelf.value) if exc := checkException(m.state); exc != nil { return nil, exc } r...
go
func (m *Mrb) Run(v Value, self Value) (*MrbValue, error) { if self == nil { self = m.TopSelf() } mrbV := v.MrbValue(m) mrbSelf := self.MrbValue(m) proc := C._go_mrb_proc_ptr(mrbV.value) value := C.mrb_run(m.state, proc, mrbSelf.value) if exc := checkException(m.state); exc != nil { return nil, exc } r...
[ "func", "(", "m", "*", "Mrb", ")", "Run", "(", "v", "Value", ",", "self", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "if", "self", "==", "nil", "{", "self", "=", "m", ".", "TopSelf", "(", ")", "\n", "}", "\n\n", "mrbV", ":=",...
// Run executes the given value, which should be a proc type. // // If you're looking to execute code directly a string, look at LoadString. // // If self is nil, it is set to the top-level self.
[ "Run", "executes", "the", "given", "value", "which", "should", "be", "a", "proc", "type", ".", "If", "you", "re", "looking", "to", "execute", "code", "directly", "a", "string", "look", "at", "LoadString", ".", "If", "self", "is", "nil", "it", "is", "se...
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L211-L227
10,433
mitchellh/go-mruby
mruby.go
Yield
func (m *Mrb) Yield(block Value, args ...Value) (*MrbValue, error) { mrbBlock := block.MrbValue(m) var argv []C.mrb_value var argvPtr *C.mrb_value if len(args) > 0 { // Make the raw byte slice to hold our arguments we'll pass to C argv = make([]C.mrb_value, len(args)) for i, arg := range args { argv[i] =...
go
func (m *Mrb) Yield(block Value, args ...Value) (*MrbValue, error) { mrbBlock := block.MrbValue(m) var argv []C.mrb_value var argvPtr *C.mrb_value if len(args) > 0 { // Make the raw byte slice to hold our arguments we'll pass to C argv = make([]C.mrb_value, len(args)) for i, arg := range args { argv[i] =...
[ "func", "(", "m", "*", "Mrb", ")", "Yield", "(", "block", "Value", ",", "args", "...", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "mrbBlock", ":=", "block", ".", "MrbValue", "(", "m", ")", "\n\n", "var", "argv", "[", "]", "C", ...
// Yield yields to a block with the given arguments. // // This should be called within the context of a Func.
[ "Yield", "yields", "to", "a", "block", "with", "the", "given", "arguments", ".", "This", "should", "be", "called", "within", "the", "context", "of", "a", "Func", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L258-L285
10,434
mitchellh/go-mruby
mruby.go
DefineModule
func (m *Mrb) DefineModule(name string) *Class { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) return newClass(m, C.mrb_define_module(m.state, cs)) }
go
func (m *Mrb) DefineModule(name string) *Class { cs := C.CString(name) defer C.free(unsafe.Pointer(cs)) return newClass(m, C.mrb_define_module(m.state, cs)) }
[ "func", "(", "m", "*", "Mrb", ")", "DefineModule", "(", "name", "string", ")", "*", "Class", "{", "cs", ":=", "C", ".", "CString", "(", "name", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cs", ")", ")", "\n", "ret...
// DefineModule defines a top-level module.
[ "DefineModule", "defines", "a", "top", "-", "level", "module", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L326-L330
10,435
mitchellh/go-mruby
mruby.go
TopSelf
func (m *Mrb) TopSelf() *MrbValue { return newValue(m.state, C.mrb_obj_value(unsafe.Pointer(m.state.top_self))) }
go
func (m *Mrb) TopSelf() *MrbValue { return newValue(m.state, C.mrb_obj_value(unsafe.Pointer(m.state.top_self))) }
[ "func", "(", "m", "*", "Mrb", ")", "TopSelf", "(", ")", "*", "MrbValue", "{", "return", "newValue", "(", "m", ".", "state", ",", "C", ".", "mrb_obj_value", "(", "unsafe", ".", "Pointer", "(", "m", ".", "state", ".", "top_self", ")", ")", ")", "\n...
// TopSelf returns the top-level `self` value.
[ "TopSelf", "returns", "the", "top", "-", "level", "self", "value", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L360-L362
10,436
mitchellh/go-mruby
mruby.go
FixnumValue
func (m *Mrb) FixnumValue(v int) *MrbValue { return newValue(m.state, C.mrb_fixnum_value(C.mrb_int(v))) }
go
func (m *Mrb) FixnumValue(v int) *MrbValue { return newValue(m.state, C.mrb_fixnum_value(C.mrb_int(v))) }
[ "func", "(", "m", "*", "Mrb", ")", "FixnumValue", "(", "v", "int", ")", "*", "MrbValue", "{", "return", "newValue", "(", "m", ".", "state", ",", "C", ".", "mrb_fixnum_value", "(", "C", ".", "mrb_int", "(", "v", ")", ")", ")", "\n", "}" ]
// FixnumValue returns a Value for a fixed number.
[ "FixnumValue", "returns", "a", "Value", "for", "a", "fixed", "number", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L380-L382
10,437
mitchellh/go-mruby
mruby.go
StringValue
func (m *Mrb) StringValue(s string) *MrbValue { cs := C.CString(s) defer C.free(unsafe.Pointer(cs)) return newValue(m.state, C.mrb_str_new_cstr(m.state, cs)) }
go
func (m *Mrb) StringValue(s string) *MrbValue { cs := C.CString(s) defer C.free(unsafe.Pointer(cs)) return newValue(m.state, C.mrb_str_new_cstr(m.state, cs)) }
[ "func", "(", "m", "*", "Mrb", ")", "StringValue", "(", "s", "string", ")", "*", "MrbValue", "{", "cs", ":=", "C", ".", "CString", "(", "s", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cs", ")", ")", "\n", "return"...
// StringValue returns a Value for a string.
[ "StringValue", "returns", "a", "Value", "for", "a", "string", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/mruby.go#L385-L389
10,438
mitchellh/go-mruby
hash.go
Delete
func (h *Hash) Delete(key Value) (*MrbValue, error) { keyVal := key.MrbValue(&Mrb{h.state}).value result := C.mrb_hash_delete_key(h.state, h.value, keyVal) val := newValue(h.state, result) if val.Type() == TypeNil { val = nil } return val, nil }
go
func (h *Hash) Delete(key Value) (*MrbValue, error) { keyVal := key.MrbValue(&Mrb{h.state}).value result := C.mrb_hash_delete_key(h.state, h.value, keyVal) val := newValue(h.state, result) if val.Type() == TypeNil { val = nil } return val, nil }
[ "func", "(", "h", "*", "Hash", ")", "Delete", "(", "key", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "keyVal", ":=", "key", ".", "MrbValue", "(", "&", "Mrb", "{", "h", ".", "state", "}", ")", ".", "value", "\n", "result", ":=",...
// Delete deletes a key from the hash, returning its existing value, // or nil if there wasn't a value.
[ "Delete", "deletes", "a", "key", "from", "the", "hash", "returning", "its", "existing", "value", "or", "nil", "if", "there", "wasn", "t", "a", "value", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/hash.go#L15-L25
10,439
mitchellh/go-mruby
hash.go
Get
func (h *Hash) Get(key Value) (*MrbValue, error) { keyVal := key.MrbValue(&Mrb{h.state}).value result := C.mrb_hash_get(h.state, h.value, keyVal) return newValue(h.state, result), nil }
go
func (h *Hash) Get(key Value) (*MrbValue, error) { keyVal := key.MrbValue(&Mrb{h.state}).value result := C.mrb_hash_get(h.state, h.value, keyVal) return newValue(h.state, result), nil }
[ "func", "(", "h", "*", "Hash", ")", "Get", "(", "key", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "keyVal", ":=", "key", ".", "MrbValue", "(", "&", "Mrb", "{", "h", ".", "state", "}", ")", ".", "value", "\n", "result", ":=", ...
// Get reads a value from the hash.
[ "Get", "reads", "a", "value", "from", "the", "hash", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/hash.go#L28-L32
10,440
mitchellh/go-mruby
hash.go
Set
func (h *Hash) Set(key, val Value) error { keyVal := key.MrbValue(&Mrb{h.state}).value valVal := val.MrbValue(&Mrb{h.state}).value C.mrb_hash_set(h.state, h.value, keyVal, valVal) return nil }
go
func (h *Hash) Set(key, val Value) error { keyVal := key.MrbValue(&Mrb{h.state}).value valVal := val.MrbValue(&Mrb{h.state}).value C.mrb_hash_set(h.state, h.value, keyVal, valVal) return nil }
[ "func", "(", "h", "*", "Hash", ")", "Set", "(", "key", ",", "val", "Value", ")", "error", "{", "keyVal", ":=", "key", ".", "MrbValue", "(", "&", "Mrb", "{", "h", ".", "state", "}", ")", ".", "value", "\n", "valVal", ":=", "val", ".", "MrbValue"...
// Set sets a value on the hash
[ "Set", "sets", "a", "value", "on", "the", "hash" ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/hash.go#L35-L40
10,441
mitchellh/go-mruby
parser.go
NewParser
func NewParser(m *Mrb) *Parser { p := C.mrb_parser_new(m.state) // Set capture_errors to true so we don't go just printing things // out to stdout. C._go_mrb_parser_set_capture_errors(p, 1) return &Parser{ mrb: m, parser: p, } }
go
func NewParser(m *Mrb) *Parser { p := C.mrb_parser_new(m.state) // Set capture_errors to true so we don't go just printing things // out to stdout. C._go_mrb_parser_set_capture_errors(p, 1) return &Parser{ mrb: m, parser: p, } }
[ "func", "NewParser", "(", "m", "*", "Mrb", ")", "*", "Parser", "{", "p", ":=", "C", ".", "mrb_parser_new", "(", "m", ".", "state", ")", "\n\n", "// Set capture_errors to true so we don't go just printing things", "// out to stdout.", "C", ".", "_go_mrb_parser_set_ca...
// NewParser initializes the resources for a parser. // // Make sure to Close the parser when you're done with it.
[ "NewParser", "initializes", "the", "resources", "for", "a", "parser", ".", "Make", "sure", "to", "Close", "the", "parser", "when", "you", "re", "done", "with", "it", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/parser.go#L23-L34
10,442
mitchellh/go-mruby
parser.go
GenerateCode
func (p *Parser) GenerateCode() *MrbValue { proc := C.mrb_generate_code(p.mrb.state, p.parser) return newValue(p.mrb.state, C.mrb_obj_value(unsafe.Pointer(proc))) }
go
func (p *Parser) GenerateCode() *MrbValue { proc := C.mrb_generate_code(p.mrb.state, p.parser) return newValue(p.mrb.state, C.mrb_obj_value(unsafe.Pointer(proc))) }
[ "func", "(", "p", "*", "Parser", ")", "GenerateCode", "(", ")", "*", "MrbValue", "{", "proc", ":=", "C", ".", "mrb_generate_code", "(", "p", ".", "mrb", ".", "state", ",", "p", ".", "parser", ")", "\n", "return", "newValue", "(", "p", ".", "mrb", ...
// GenerateCode takes all the internal parser state and generates // executable Ruby code, returning the callable proc.
[ "GenerateCode", "takes", "all", "the", "internal", "parser", "state", "and", "generates", "executable", "Ruby", "code", "returning", "the", "callable", "proc", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/parser.go#L46-L49
10,443
mitchellh/go-mruby
parser.go
Parse
func (p *Parser) Parse(code string, c *CompileContext) ([]*ParserMessage, error) { // We set p.code so that the string doesn't get garbage collected var s *C.char = C.CString(code) p.code = code p.parser.s = s p.parser.send = C._go_mrb_calc_send(s) var ctx *C.mrbc_context if c != nil { ctx = c.ctx } C.mrb_p...
go
func (p *Parser) Parse(code string, c *CompileContext) ([]*ParserMessage, error) { // We set p.code so that the string doesn't get garbage collected var s *C.char = C.CString(code) p.code = code p.parser.s = s p.parser.send = C._go_mrb_calc_send(s) var ctx *C.mrbc_context if c != nil { ctx = c.ctx } C.mrb_p...
[ "func", "(", "p", "*", "Parser", ")", "Parse", "(", "code", "string", ",", "c", "*", "CompileContext", ")", "(", "[", "]", "*", "ParserMessage", ",", "error", ")", "{", "// We set p.code so that the string doesn't get garbage collected", "var", "s", "*", "C", ...
// Parse parses the code in the given context, and returns any warnings // or errors from parsing. // // The CompileContext can be nil to not set a context.
[ "Parse", "parses", "the", "code", "in", "the", "given", "context", "and", "returns", "any", "warnings", "or", "errors", "from", "parsing", ".", "The", "CompileContext", "can", "be", "nil", "to", "not", "set", "a", "context", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/parser.go#L55-L100
10,444
mitchellh/go-mruby
args.go
ArgsArg
func ArgsArg(r, o int) ArgSpec { return ArgSpec(C._go_MRB_ARGS_ARG(C.int(r), C.int(o))) }
go
func ArgsArg(r, o int) ArgSpec { return ArgSpec(C._go_MRB_ARGS_ARG(C.int(r), C.int(o))) }
[ "func", "ArgsArg", "(", "r", ",", "o", "int", ")", "ArgSpec", "{", "return", "ArgSpec", "(", "C", ".", "_go_MRB_ARGS_ARG", "(", "C", ".", "int", "(", "r", ")", ",", "C", ".", "int", "(", "o", ")", ")", ")", "\n", "}" ]
// ArgsArg says the given number of arguments are required and // the second number is optional.
[ "ArgsArg", "says", "the", "given", "number", "of", "arguments", "are", "required", "and", "the", "second", "number", "is", "optional", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/args.go#L20-L22
10,445
mitchellh/go-mruby
args.go
ArgsReq
func ArgsReq(n int) ArgSpec { return ArgSpec(C._go_MRB_ARGS_REQ(C.int(n))) }
go
func ArgsReq(n int) ArgSpec { return ArgSpec(C._go_MRB_ARGS_REQ(C.int(n))) }
[ "func", "ArgsReq", "(", "n", "int", ")", "ArgSpec", "{", "return", "ArgSpec", "(", "C", ".", "_go_MRB_ARGS_REQ", "(", "C", ".", "int", "(", "n", ")", ")", ")", "\n", "}" ]
// ArgsReq says that the given number of arguments are required.
[ "ArgsReq", "says", "that", "the", "given", "number", "of", "arguments", "are", "required", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/args.go#L35-L37
10,446
mitchellh/go-mruby
args.go
ArgsOpt
func ArgsOpt(n int) ArgSpec { return ArgSpec(C._go_MRB_ARGS_OPT(C.int(n))) }
go
func ArgsOpt(n int) ArgSpec { return ArgSpec(C._go_MRB_ARGS_OPT(C.int(n))) }
[ "func", "ArgsOpt", "(", "n", "int", ")", "ArgSpec", "{", "return", "ArgSpec", "(", "C", ".", "_go_MRB_ARGS_OPT", "(", "C", ".", "int", "(", "n", ")", ")", ")", "\n", "}" ]
// ArgsOpt says that the given number of arguments are optional.
[ "ArgsOpt", "says", "that", "the", "given", "number", "of", "arguments", "are", "optional", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/args.go#L40-L42
10,447
mitchellh/go-mruby
array.go
Len
func (v *Array) Len() int { return int(C.mrb_ary_len(v.state, v.value)) }
go
func (v *Array) Len() int { return int(C.mrb_ary_len(v.state, v.value)) }
[ "func", "(", "v", "*", "Array", ")", "Len", "(", ")", "int", "{", "return", "int", "(", "C", ".", "mrb_ary_len", "(", "v", ".", "state", ",", "v", ".", "value", ")", ")", "\n", "}" ]
// Len returns the length of the array.
[ "Len", "returns", "the", "length", "of", "the", "array", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/array.go#L14-L16
10,448
mitchellh/go-mruby
decode.go
decodeStructHashGetter
func decodeStructHashGetter(mrb *Mrb, h *Hash) decodeStructGetter { return func(key string) (*MrbValue, error) { rbKey := mrb.StringValue(key) return h.Get(rbKey) } }
go
func decodeStructHashGetter(mrb *Mrb, h *Hash) decodeStructGetter { return func(key string) (*MrbValue, error) { rbKey := mrb.StringValue(key) return h.Get(rbKey) } }
[ "func", "decodeStructHashGetter", "(", "mrb", "*", "Mrb", ",", "h", "*", "Hash", ")", "decodeStructGetter", "{", "return", "func", "(", "key", "string", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "rbKey", ":=", "mrb", ".", "StringValue", "(", "...
// decodeStructHashGetter is a decodeStructGetter that reads values from // a hash.
[ "decodeStructHashGetter", "is", "a", "decodeStructGetter", "that", "reads", "values", "from", "a", "hash", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/decode.go#L498-L503
10,449
mitchellh/go-mruby
decode.go
decodeStructObjectMethods
func decodeStructObjectMethods(mrb *Mrb, v *MrbValue) decodeStructGetter { return func(key string) (*MrbValue, error) { return v.Call(key) } }
go
func decodeStructObjectMethods(mrb *Mrb, v *MrbValue) decodeStructGetter { return func(key string) (*MrbValue, error) { return v.Call(key) } }
[ "func", "decodeStructObjectMethods", "(", "mrb", "*", "Mrb", ",", "v", "*", "MrbValue", ")", "decodeStructGetter", "{", "return", "func", "(", "key", "string", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "return", "v", ".", "Call", "(", "key", "...
// decodeStructObjectMethods is a decodeStructGetter that reads values from // an object by calling methods.
[ "decodeStructObjectMethods", "is", "a", "decodeStructGetter", "that", "reads", "values", "from", "an", "object", "by", "calling", "methods", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/decode.go#L507-L511
10,450
mitchellh/go-mruby
context.go
SetFilename
func (c *CompileContext) SetFilename(f string) { c.filename = f c.ctx.filename = C.CString(c.filename) }
go
func (c *CompileContext) SetFilename(f string) { c.filename = f c.ctx.filename = C.CString(c.filename) }
[ "func", "(", "c", "*", "CompileContext", ")", "SetFilename", "(", "f", "string", ")", "{", "c", ".", "filename", "=", "f", "\n", "c", ".", "ctx", ".", "filename", "=", "C", ".", "CString", "(", "c", ".", "filename", ")", "\n", "}" ]
// SetFilename sets the filename associated with this compilation context. // // Code parsed under this context will be from this file.
[ "SetFilename", "sets", "the", "filename", "associated", "with", "this", "compilation", "context", ".", "Code", "parsed", "under", "this", "context", "will", "be", "from", "this", "file", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/context.go#L41-L44
10,451
mitchellh/go-mruby
value.go
SetInstanceVariable
func (v *MrbValue) SetInstanceVariable(variable string, value *MrbValue) { cs := C.CString(variable) defer C.free(unsafe.Pointer(cs)) C._go_mrb_iv_set(v.state, v.value, C.mrb_intern_cstr(v.state, cs), value.value) }
go
func (v *MrbValue) SetInstanceVariable(variable string, value *MrbValue) { cs := C.CString(variable) defer C.free(unsafe.Pointer(cs)) C._go_mrb_iv_set(v.state, v.value, C.mrb_intern_cstr(v.state, cs), value.value) }
[ "func", "(", "v", "*", "MrbValue", ")", "SetInstanceVariable", "(", "variable", "string", ",", "value", "*", "MrbValue", ")", "{", "cs", ":=", "C", ".", "CString", "(", "variable", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", ...
// SetInstanceVariable sets an instance variable on this value.
[ "SetInstanceVariable", "sets", "an", "instance", "variable", "on", "this", "value", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L45-L49
10,452
mitchellh/go-mruby
value.go
GetInstanceVariable
func (v *MrbValue) GetInstanceVariable(variable string) *MrbValue { cs := C.CString(variable) defer C.free(unsafe.Pointer(cs)) return newValue(v.state, C._go_mrb_iv_get(v.state, v.value, C.mrb_intern_cstr(v.state, cs))) }
go
func (v *MrbValue) GetInstanceVariable(variable string) *MrbValue { cs := C.CString(variable) defer C.free(unsafe.Pointer(cs)) return newValue(v.state, C._go_mrb_iv_get(v.state, v.value, C.mrb_intern_cstr(v.state, cs))) }
[ "func", "(", "v", "*", "MrbValue", ")", "GetInstanceVariable", "(", "variable", "string", ")", "*", "MrbValue", "{", "cs", ":=", "C", ".", "CString", "(", "variable", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cs", ")"...
// GetInstanceVariable gets an instance variable on this value.
[ "GetInstanceVariable", "gets", "an", "instance", "variable", "on", "this", "value", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L52-L56
10,453
mitchellh/go-mruby
value.go
Call
func (v *MrbValue) Call(method string, args ...Value) (*MrbValue, error) { return v.call(method, args, nil) }
go
func (v *MrbValue) Call(method string, args ...Value) (*MrbValue, error) { return v.call(method, args, nil) }
[ "func", "(", "v", "*", "MrbValue", ")", "Call", "(", "method", "string", ",", "args", "...", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "return", "v", ".", "call", "(", "method", ",", "args", ",", "nil", ")", "\n", "}" ]
// Call calls a method with the given name and arguments on this // value.
[ "Call", "calls", "a", "method", "with", "the", "given", "name", "and", "arguments", "on", "this", "value", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L60-L62
10,454
mitchellh/go-mruby
value.go
CallBlock
func (v *MrbValue) CallBlock(method string, args ...Value) (*MrbValue, error) { if len(args) == 0 { return nil, fmt.Errorf("args must be non-empty and have a proc at the end") } n := len(args) return v.call(method, args[:n-1], args[n-1]) }
go
func (v *MrbValue) CallBlock(method string, args ...Value) (*MrbValue, error) { if len(args) == 0 { return nil, fmt.Errorf("args must be non-empty and have a proc at the end") } n := len(args) return v.call(method, args[:n-1], args[n-1]) }
[ "func", "(", "v", "*", "MrbValue", ")", "CallBlock", "(", "method", "string", ",", "args", "...", "Value", ")", "(", "*", "MrbValue", ",", "error", ")", "{", "if", "len", "(", "args", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf...
// CallBlock is the same as call except that it expects the last // argument to be a Proc that will be passed into the function call. // It is an error if args is empty or if there is no block on the end.
[ "CallBlock", "is", "the", "same", "as", "call", "except", "that", "it", "expects", "the", "last", "argument", "to", "be", "a", "Proc", "that", "will", "be", "passed", "into", "the", "function", "call", ".", "It", "is", "an", "error", "if", "args", "is"...
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L67-L74
10,455
mitchellh/go-mruby
value.go
IsDead
func (v *MrbValue) IsDead() bool { return C.ushort(C._go_isdead(v.state, v.value)) != 0 }
go
func (v *MrbValue) IsDead() bool { return C.ushort(C._go_isdead(v.state, v.value)) != 0 }
[ "func", "(", "v", "*", "MrbValue", ")", "IsDead", "(", ")", "bool", "{", "return", "C", ".", "ushort", "(", "C", ".", "_go_isdead", "(", "v", ".", "state", ",", "v", ".", "value", ")", ")", "!=", "0", "\n", "}" ]
// IsDead tells you if an object has been collected by the GC or not.
[ "IsDead", "tells", "you", "if", "an", "object", "has", "been", "collected", "by", "the", "GC", "or", "not", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L119-L121
10,456
mitchellh/go-mruby
value.go
SetProcTargetClass
func (v *MrbValue) SetProcTargetClass(c *Class) { proc := C._go_mrb_proc_ptr(v.value) proc.target_class = c.class }
go
func (v *MrbValue) SetProcTargetClass(c *Class) { proc := C._go_mrb_proc_ptr(v.value) proc.target_class = c.class }
[ "func", "(", "v", "*", "MrbValue", ")", "SetProcTargetClass", "(", "c", "*", "Class", ")", "{", "proc", ":=", "C", ".", "_go_mrb_proc_ptr", "(", "v", ".", "value", ")", "\n", "proc", ".", "target_class", "=", "c", ".", "class", "\n", "}" ]
// SetProcTargetClass sets the target class where a proc will be executed // when this value is a proc.
[ "SetProcTargetClass", "sets", "the", "target", "class", "where", "a", "proc", "will", "be", "executed", "when", "this", "value", "is", "a", "proc", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L140-L143
10,457
mitchellh/go-mruby
value.go
Type
func (v *MrbValue) Type() ValueType { if C._go_mrb_nil_p(v.value) == 1 { return TypeNil } return ValueType(C._go_mrb_type(v.value)) }
go
func (v *MrbValue) Type() ValueType { if C._go_mrb_nil_p(v.value) == 1 { return TypeNil } return ValueType(C._go_mrb_type(v.value)) }
[ "func", "(", "v", "*", "MrbValue", ")", "Type", "(", ")", "ValueType", "{", "if", "C", ".", "_go_mrb_nil_p", "(", "v", ".", "value", ")", "==", "1", "{", "return", "TypeNil", "\n", "}", "\n\n", "return", "ValueType", "(", "C", ".", "_go_mrb_type", ...
// Type returns the ValueType of the MrbValue. See the constants table.
[ "Type", "returns", "the", "ValueType", "of", "the", "MrbValue", ".", "See", "the", "constants", "table", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L146-L152
10,458
mitchellh/go-mruby
value.go
String
func (v *MrbValue) String() string { value := C.mrb_obj_as_string(v.state, v.value) result := C.GoString(C.mrb_string_value_ptr(v.state, value)) return result }
go
func (v *MrbValue) String() string { value := C.mrb_obj_as_string(v.state, v.value) result := C.GoString(C.mrb_string_value_ptr(v.state, value)) return result }
[ "func", "(", "v", "*", "MrbValue", ")", "String", "(", ")", "string", "{", "value", ":=", "C", ".", "mrb_obj_as_string", "(", "v", ".", "state", ",", "v", ".", "value", ")", "\n", "result", ":=", "C", ".", "GoString", "(", "C", ".", "mrb_string_val...
// String returns the "to_s" result of this value.
[ "String", "returns", "the", "to_s", "result", "of", "this", "value", "." ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L207-L211
10,459
mitchellh/go-mruby
value.go
MrbValue
func (s String) MrbValue(m *Mrb) *MrbValue { return m.StringValue(string(s)) }
go
func (s String) MrbValue(m *Mrb) *MrbValue { return m.StringValue(string(s)) }
[ "func", "(", "s", "String", ")", "MrbValue", "(", "m", "*", "Mrb", ")", "*", "MrbValue", "{", "return", "m", ".", "StringValue", "(", "string", "(", "s", ")", ")", "\n", "}" ]
// MrbValue returns the native MRB value
[ "MrbValue", "returns", "the", "native", "MRB", "value" ]
cd6a04a6ea57d3ecdf60ec703c927fb4984569ff
https://github.com/mitchellh/go-mruby/blob/cd6a04a6ea57d3ecdf60ec703c927fb4984569ff/value.go#L242-L244
10,460
multiformats/go-multistream
client.go
SelectProtoOrFail
func SelectProtoOrFail(proto string, rwc io.ReadWriteCloser) error { err := handshake(rwc) if err != nil { return err } return trySelect(proto, rwc) }
go
func SelectProtoOrFail(proto string, rwc io.ReadWriteCloser) error { err := handshake(rwc) if err != nil { return err } return trySelect(proto, rwc) }
[ "func", "SelectProtoOrFail", "(", "proto", "string", ",", "rwc", "io", ".", "ReadWriteCloser", ")", "error", "{", "err", ":=", "handshake", "(", "rwc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "trySelect", ...
// SelectProtoOrFail performs the initial multistream handshake // to inform the muxer of the protocol that will be used to communicate // on this ReadWriteCloser. It returns an error if, for example, // the muxer does not know how to handle this protocol.
[ "SelectProtoOrFail", "performs", "the", "initial", "multistream", "handshake", "to", "inform", "the", "muxer", "of", "the", "protocol", "that", "will", "be", "used", "to", "communicate", "on", "this", "ReadWriteCloser", ".", "It", "returns", "an", "error", "if",...
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/client.go#L16-L23
10,461
multiformats/go-multistream
client.go
SelectOneOf
func SelectOneOf(protos []string, rwc io.ReadWriteCloser) (string, error) { err := handshake(rwc) if err != nil { return "", err } for _, p := range protos { err := trySelect(p, rwc) switch err { case nil: return p, nil case ErrNotSupported: default: return "", err } } return "", ErrNotSuppor...
go
func SelectOneOf(protos []string, rwc io.ReadWriteCloser) (string, error) { err := handshake(rwc) if err != nil { return "", err } for _, p := range protos { err := trySelect(p, rwc) switch err { case nil: return p, nil case ErrNotSupported: default: return "", err } } return "", ErrNotSuppor...
[ "func", "SelectOneOf", "(", "protos", "[", "]", "string", ",", "rwc", "io", ".", "ReadWriteCloser", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "handshake", "(", "rwc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",...
// SelectOneOf will perform handshakes with the protocols on the given slice // until it finds one which is supported by the muxer.
[ "SelectOneOf", "will", "perform", "handshakes", "with", "the", "protocols", "on", "the", "given", "slice", "until", "it", "finds", "one", "which", "is", "supported", "by", "the", "muxer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/client.go#L27-L44
10,462
multiformats/go-multistream
lazyClient.go
NewMSSelect
func NewMSSelect(c io.ReadWriteCloser, proto string) Multistream { return &lazyClientConn{ protos: []string{ProtocolID, proto}, con: c, } }
go
func NewMSSelect(c io.ReadWriteCloser, proto string) Multistream { return &lazyClientConn{ protos: []string{ProtocolID, proto}, con: c, } }
[ "func", "NewMSSelect", "(", "c", "io", ".", "ReadWriteCloser", ",", "proto", "string", ")", "Multistream", "{", "return", "&", "lazyClientConn", "{", "protos", ":", "[", "]", "string", "{", "ProtocolID", ",", "proto", "}", ",", "con", ":", "c", ",", "}...
// NewMSSelect returns a new Multistream which is able to perform // protocol selection with a MultistreamMuxer.
[ "NewMSSelect", "returns", "a", "new", "Multistream", "which", "is", "able", "to", "perform", "protocol", "selection", "with", "a", "MultistreamMuxer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/lazyClient.go#L19-L24
10,463
multiformats/go-multistream
lazyClient.go
NewMultistream
func NewMultistream(c io.ReadWriteCloser, proto string) Multistream { return &lazyClientConn{ protos: []string{proto}, con: c, } }
go
func NewMultistream(c io.ReadWriteCloser, proto string) Multistream { return &lazyClientConn{ protos: []string{proto}, con: c, } }
[ "func", "NewMultistream", "(", "c", "io", ".", "ReadWriteCloser", ",", "proto", "string", ")", "Multistream", "{", "return", "&", "lazyClientConn", "{", "protos", ":", "[", "]", "string", "{", "proto", "}", ",", "con", ":", "c", ",", "}", "\n", "}" ]
// NewMultistream returns a multistream for the given protocol. This will not // perform any protocol selection. If you are using a MultistreamMuxer, use // NewMSSelect.
[ "NewMultistream", "returns", "a", "multistream", "for", "the", "given", "protocol", ".", "This", "will", "not", "perform", "any", "protocol", "selection", ".", "If", "you", "are", "using", "a", "MultistreamMuxer", "use", "NewMSSelect", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/lazyClient.go#L29-L34
10,464
multiformats/go-multistream
lazyClient.go
Read
func (l *lazyClientConn) Read(b []byte) (int, error) { l.rhandshakeOnce.Do(func() { go l.whandshakeOnce.Do(l.doWriteHandshake) l.doReadHandshake() }) if l.rerr != nil { return 0, l.rerr } if len(b) == 0 { return 0, nil } return l.con.Read(b) }
go
func (l *lazyClientConn) Read(b []byte) (int, error) { l.rhandshakeOnce.Do(func() { go l.whandshakeOnce.Do(l.doWriteHandshake) l.doReadHandshake() }) if l.rerr != nil { return 0, l.rerr } if len(b) == 0 { return 0, nil } return l.con.Read(b) }
[ "func", "(", "l", "*", "lazyClientConn", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "l", ".", "rhandshakeOnce", ".", "Do", "(", "func", "(", ")", "{", "go", "l", ".", "whandshakeOnce", ".", "Do", "(", "l",...
// Read reads data from the io.ReadWriteCloser. // // If the protocol hasn't yet been negotiated, this method triggers the write // half of the handshake and then waits for the read half to complete. // // It returns an error if the read half of the handshake fails.
[ "Read", "reads", "data", "from", "the", "io", ".", "ReadWriteCloser", ".", "If", "the", "protocol", "hasn", "t", "yet", "been", "negotiated", "this", "method", "triggers", "the", "write", "half", "of", "the", "handshake", "and", "then", "waits", "for", "th...
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/lazyClient.go#L64-L77
10,465
multiformats/go-multistream
multistream.go
Ls
func Ls(rw io.ReadWriter) ([]string, error) { err := delimWriteBuffered(rw, []byte("ls")) if err != nil { return nil, err } n, err := binary.ReadUvarint(&byteReader{rw}) if err != nil { return nil, err } var out []string for i := uint64(0); i < n; i++ { val, err := lpReadBuf(rw) if err != nil { ret...
go
func Ls(rw io.ReadWriter) ([]string, error) { err := delimWriteBuffered(rw, []byte("ls")) if err != nil { return nil, err } n, err := binary.ReadUvarint(&byteReader{rw}) if err != nil { return nil, err } var out []string for i := uint64(0); i < n; i++ { val, err := lpReadBuf(rw) if err != nil { ret...
[ "func", "Ls", "(", "rw", "io", ".", "ReadWriter", ")", "(", "[", "]", "string", ",", "error", ")", "{", "err", ":=", "delimWriteBuffered", "(", "rw", ",", "[", "]", "byte", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// Ls is a Multistream muxer command which returns the list of handler names // available on a muxer.
[ "Ls", "is", "a", "Multistream", "muxer", "command", "which", "returns", "the", "list", "of", "handler", "names", "available", "on", "a", "muxer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L87-L108
10,466
multiformats/go-multistream
multistream.go
AddHandler
func (msm *MultistreamMuxer) AddHandler(protocol string, handler HandlerFunc) { msm.AddHandlerWithFunc(protocol, fulltextMatch(protocol), handler) }
go
func (msm *MultistreamMuxer) AddHandler(protocol string, handler HandlerFunc) { msm.AddHandlerWithFunc(protocol, fulltextMatch(protocol), handler) }
[ "func", "(", "msm", "*", "MultistreamMuxer", ")", "AddHandler", "(", "protocol", "string", ",", "handler", "HandlerFunc", ")", "{", "msm", ".", "AddHandlerWithFunc", "(", "protocol", ",", "fulltextMatch", "(", "protocol", ")", ",", "handler", ")", "\n", "}" ...
// AddHandler attaches a new protocol handler to the muxer.
[ "AddHandler", "attaches", "a", "new", "protocol", "handler", "to", "the", "muxer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L117-L119
10,467
multiformats/go-multistream
multistream.go
AddHandlerWithFunc
func (msm *MultistreamMuxer) AddHandlerWithFunc(protocol string, match func(string) bool, handler HandlerFunc) { msm.handlerlock.Lock() defer msm.handlerlock.Unlock() msm.removeHandler(protocol) msm.handlers = append(msm.handlers, Handler{ MatchFunc: match, Handle: handler, AddName: protocol, }) }
go
func (msm *MultistreamMuxer) AddHandlerWithFunc(protocol string, match func(string) bool, handler HandlerFunc) { msm.handlerlock.Lock() defer msm.handlerlock.Unlock() msm.removeHandler(protocol) msm.handlers = append(msm.handlers, Handler{ MatchFunc: match, Handle: handler, AddName: protocol, }) }
[ "func", "(", "msm", "*", "MultistreamMuxer", ")", "AddHandlerWithFunc", "(", "protocol", "string", ",", "match", "func", "(", "string", ")", "bool", ",", "handler", "HandlerFunc", ")", "{", "msm", ".", "handlerlock", ".", "Lock", "(", ")", "\n", "defer", ...
// AddHandlerWithFunc attaches a new protocol handler to the muxer with a match. // If the match function returns true for a given protocol tag, the protocol // will be selected even if the handler name and protocol tags are different.
[ "AddHandlerWithFunc", "attaches", "a", "new", "protocol", "handler", "to", "the", "muxer", "with", "a", "match", ".", "If", "the", "match", "function", "returns", "true", "for", "a", "given", "protocol", "tag", "the", "protocol", "will", "be", "selected", "e...
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L124-L134
10,468
multiformats/go-multistream
multistream.go
RemoveHandler
func (msm *MultistreamMuxer) RemoveHandler(protocol string) { msm.handlerlock.Lock() defer msm.handlerlock.Unlock() msm.removeHandler(protocol) }
go
func (msm *MultistreamMuxer) RemoveHandler(protocol string) { msm.handlerlock.Lock() defer msm.handlerlock.Unlock() msm.removeHandler(protocol) }
[ "func", "(", "msm", "*", "MultistreamMuxer", ")", "RemoveHandler", "(", "protocol", "string", ")", "{", "msm", ".", "handlerlock", ".", "Lock", "(", ")", "\n", "defer", "msm", ".", "handlerlock", ".", "Unlock", "(", ")", "\n\n", "msm", ".", "removeHandle...
// RemoveHandler removes the handler with the given name from the muxer.
[ "RemoveHandler", "removes", "the", "handler", "with", "the", "given", "name", "from", "the", "muxer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L137-L142
10,469
multiformats/go-multistream
multistream.go
Protocols
func (msm *MultistreamMuxer) Protocols() []string { msm.handlerlock.RLock() defer msm.handlerlock.RUnlock() var out []string for _, h := range msm.handlers { out = append(out, h.AddName) } return out }
go
func (msm *MultistreamMuxer) Protocols() []string { msm.handlerlock.RLock() defer msm.handlerlock.RUnlock() var out []string for _, h := range msm.handlers { out = append(out, h.AddName) } return out }
[ "func", "(", "msm", "*", "MultistreamMuxer", ")", "Protocols", "(", ")", "[", "]", "string", "{", "msm", ".", "handlerlock", ".", "RLock", "(", ")", "\n", "defer", "msm", ".", "handlerlock", ".", "RUnlock", "(", ")", "\n\n", "var", "out", "[", "]", ...
// Protocols returns the list of handler-names added to this this muxer.
[ "Protocols", "returns", "the", "list", "of", "handler", "-", "names", "added", "to", "this", "this", "muxer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L154-L164
10,470
multiformats/go-multistream
multistream.go
NegotiateLazy
func (msm *MultistreamMuxer) NegotiateLazy(rwc io.ReadWriteCloser) (Multistream, string, HandlerFunc, error) { pval := make(chan string, 1) writeErr := make(chan error, 1) defer close(pval) lzc := &lazyServerConn{ con: rwc, } started := make(chan struct{}) go lzc.waitForHandshake.Do(func() { close(started)...
go
func (msm *MultistreamMuxer) NegotiateLazy(rwc io.ReadWriteCloser) (Multistream, string, HandlerFunc, error) { pval := make(chan string, 1) writeErr := make(chan error, 1) defer close(pval) lzc := &lazyServerConn{ con: rwc, } started := make(chan struct{}) go lzc.waitForHandshake.Do(func() { close(started)...
[ "func", "(", "msm", "*", "MultistreamMuxer", ")", "NegotiateLazy", "(", "rwc", "io", ".", "ReadWriteCloser", ")", "(", "Multistream", ",", "string", ",", "HandlerFunc", ",", "error", ")", "{", "pval", ":=", "make", "(", "chan", "string", ",", "1", ")", ...
// NegotiateLazy performs protocol selection and returns // a multistream, the protocol used, the handler and an error. It is lazy // because the write-handshake is performed on a subroutine, allowing this // to return before that handshake is completed.
[ "NegotiateLazy", "performs", "protocol", "selection", "and", "returns", "a", "multistream", "the", "protocol", "used", "the", "handler", "and", "an", "error", ".", "It", "is", "lazy", "because", "the", "write", "-", "handshake", "is", "performed", "on", "a", ...
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L187-L269
10,471
multiformats/go-multistream
multistream.go
Ls
func (msm *MultistreamMuxer) Ls(w io.Writer) error { buf := new(bytes.Buffer) msm.handlerlock.RLock() err := writeUvarint(buf, uint64(len(msm.handlers))) if err != nil { return err } for _, h := range msm.handlers { err := delimWrite(buf, []byte(h.AddName)) if err != nil { msm.handlerlock.RUnlock() ...
go
func (msm *MultistreamMuxer) Ls(w io.Writer) error { buf := new(bytes.Buffer) msm.handlerlock.RLock() err := writeUvarint(buf, uint64(len(msm.handlers))) if err != nil { return err } for _, h := range msm.handlers { err := delimWrite(buf, []byte(h.AddName)) if err != nil { msm.handlerlock.RUnlock() ...
[ "func", "(", "msm", "*", "MultistreamMuxer", ")", "Ls", "(", "w", "io", ".", "Writer", ")", "error", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n\n", "msm", ".", "handlerlock", ".", "RLock", "(", ")", "\n", "err", ":=", "writeUvar...
// Ls implements the "ls" command which writes the list of // supported protocols to the given Writer.
[ "Ls", "implements", "the", "ls", "command", "which", "writes", "the", "list", "of", "supported", "protocols", "to", "the", "given", "Writer", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L328-L353
10,472
multiformats/go-multistream
multistream.go
ReadNextToken
func ReadNextToken(rw io.ReadWriter) (string, error) { tok, err := ReadNextTokenBytes(rw) if err != nil { return "", err } return string(tok), nil }
go
func ReadNextToken(rw io.ReadWriter) (string, error) { tok, err := ReadNextTokenBytes(rw) if err != nil { return "", err } return string(tok), nil }
[ "func", "ReadNextToken", "(", "rw", "io", ".", "ReadWriter", ")", "(", "string", ",", "error", ")", "{", "tok", ",", "err", ":=", "ReadNextTokenBytes", "(", "rw", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}"...
// ReadNextToken extracts a token from a ReadWriter. It is used during // protocol negotiation and returns a string.
[ "ReadNextToken", "extracts", "a", "token", "from", "a", "ReadWriter", ".", "It", "is", "used", "during", "protocol", "negotiation", "and", "returns", "a", "string", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L368-L375
10,473
multiformats/go-multistream
multistream.go
ReadNextTokenBytes
func ReadNextTokenBytes(rw io.ReadWriter) ([]byte, error) { data, err := lpReadBuf(rw) switch err { case nil: return data, nil case ErrTooLarge: err := delimWriteBuffered(rw, []byte("messages over 64k are not allowed")) if err != nil { return nil, err } return nil, ErrTooLarge default: return nil, e...
go
func ReadNextTokenBytes(rw io.ReadWriter) ([]byte, error) { data, err := lpReadBuf(rw) switch err { case nil: return data, nil case ErrTooLarge: err := delimWriteBuffered(rw, []byte("messages over 64k are not allowed")) if err != nil { return nil, err } return nil, ErrTooLarge default: return nil, e...
[ "func", "ReadNextTokenBytes", "(", "rw", "io", ".", "ReadWriter", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "data", ",", "err", ":=", "lpReadBuf", "(", "rw", ")", "\n", "switch", "err", "{", "case", "nil", ":", "return", "data", ",", "nil...
// ReadNextTokenBytes extracts a token from a ReadWriter. It is used // during protocol negotiation and returns a byte slice.
[ "ReadNextTokenBytes", "extracts", "a", "token", "from", "a", "ReadWriter", ".", "It", "is", "used", "during", "protocol", "negotiation", "and", "returns", "a", "byte", "slice", "." ]
7fe63401b47b8ee414fc16619e08a6abc1c5cf2b
https://github.com/multiformats/go-multistream/blob/7fe63401b47b8ee414fc16619e08a6abc1c5cf2b/multistream.go#L379-L393
10,474
kataras/go-template
loader.go
Directory
func (t *Loader) Directory(dir string, fileExtension string) *BinaryLoader { if dir == "" { dir = DefaultDirectory // the default templates dir } if fileExtension == "" { fileExtension = DefaultExtension } else if fileExtension[0] != '.' { // if missing the start dot fileExtension = "." + fileExtension } t...
go
func (t *Loader) Directory(dir string, fileExtension string) *BinaryLoader { if dir == "" { dir = DefaultDirectory // the default templates dir } if fileExtension == "" { fileExtension = DefaultExtension } else if fileExtension[0] != '.' { // if missing the start dot fileExtension = "." + fileExtension } t...
[ "func", "(", "t", "*", "Loader", ")", "Directory", "(", "dir", "string", ",", "fileExtension", "string", ")", "*", "BinaryLoader", "{", "if", "dir", "==", "\"", "\"", "{", "dir", "=", "DefaultDirectory", "// the default templates dir", "\n", "}", "\n", "if...
// Directory sets the directory to load from // returns the Binary location which is optional
[ "Directory", "sets", "the", "directory", "to", "load", "from", "returns", "the", "Binary", "location", "which", "is", "optional" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/loader.go#L40-L54
10,475
kataras/go-template
loader.go
Binary
func (t *BinaryLoader) Binary(assetFn func(name string) ([]byte, error), namesFn func() []string) { if assetFn == nil || namesFn == nil { return } t.AssetFn = assetFn t.NamesFn = namesFn // if extension is not static(setted by .Directory) if t.Extension == "" { if names := namesFn(); len(names) > 0 { t.Ex...
go
func (t *BinaryLoader) Binary(assetFn func(name string) ([]byte, error), namesFn func() []string) { if assetFn == nil || namesFn == nil { return } t.AssetFn = assetFn t.NamesFn = namesFn // if extension is not static(setted by .Directory) if t.Extension == "" { if names := namesFn(); len(names) > 0 { t.Ex...
[ "func", "(", "t", "*", "BinaryLoader", ")", "Binary", "(", "assetFn", "func", "(", "name", "string", ")", "(", "[", "]", "byte", ",", "error", ")", ",", "namesFn", "func", "(", ")", "[", "]", "string", ")", "{", "if", "assetFn", "==", "nil", "||"...
// Binary optionally, called after Loader.Directory, used when files are distributed inside the app executable // sets the AssetFn and NamesFn
[ "Binary", "optionally", "called", "after", "Loader", ".", "Directory", "used", "when", "files", "are", "distributed", "inside", "the", "app", "executable", "sets", "the", "AssetFn", "and", "NamesFn" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/loader.go#L58-L71
10,476
kataras/go-template
loader.go
IsBinary
func (t *Loader) IsBinary() bool { return t.AssetFn != nil && t.NamesFn != nil }
go
func (t *Loader) IsBinary() bool { return t.AssetFn != nil && t.NamesFn != nil }
[ "func", "(", "t", "*", "Loader", ")", "IsBinary", "(", ")", "bool", "{", "return", "t", ".", "AssetFn", "!=", "nil", "&&", "t", ".", "NamesFn", "!=", "nil", "\n", "}" ]
// IsBinary returns true if .Binary is called and AssetFn and NamesFn are setted
[ "IsBinary", "returns", "true", "if", ".", "Binary", "is", "called", "and", "AssetFn", "and", "NamesFn", "are", "setted" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/loader.go#L74-L76
10,477
kataras/go-template
loader.go
LoadEngine
func (t *Loader) LoadEngine(e Engine) error { if t.Dir == "" { return errMissingDirectoryOrAssets } if t.IsBinary() { // don't try to put abs path here // fixes: http://support.iris-go.com/d/22-template-binary-problem-in-v6 return e.LoadAssets(t.Dir, t.Extension, t.AssetFn, t.NamesFn) } // fixes when use...
go
func (t *Loader) LoadEngine(e Engine) error { if t.Dir == "" { return errMissingDirectoryOrAssets } if t.IsBinary() { // don't try to put abs path here // fixes: http://support.iris-go.com/d/22-template-binary-problem-in-v6 return e.LoadAssets(t.Dir, t.Extension, t.AssetFn, t.NamesFn) } // fixes when use...
[ "func", "(", "t", "*", "Loader", ")", "LoadEngine", "(", "e", "Engine", ")", "error", "{", "if", "t", ".", "Dir", "==", "\"", "\"", "{", "return", "errMissingDirectoryOrAssets", "\n", "}", "\n\n", "if", "t", ".", "IsBinary", "(", ")", "{", "// don't ...
// LoadEngine receives a template Engine and calls its LoadAssets or the LoadDirectory with the loader's locations
[ "LoadEngine", "receives", "a", "template", "Engine", "and", "calls", "its", "LoadAssets", "or", "the", "LoadDirectory", "with", "the", "loader", "s", "locations" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/loader.go#L81-L100
10,478
kataras/go-template
handlebars/handlebars.go
New
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Helpers == nil { c.Helpers = make(map[string]interface{}, 0) } e := &Engine{Config: c, templateCache: make(map[string]*raymond.Template, 0)} raymond.RegisterHelper("render", fu...
go
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Helpers == nil { c.Helpers = make(map[string]interface{}, 0) } e := &Engine{Config: c, templateCache: make(map[string]*raymond.Template, 0)} raymond.RegisterHelper("render", fu...
[ "func", "New", "(", "cfg", "...", "Config", ")", "*", "Engine", "{", "c", ":=", "DefaultConfig", "(", ")", "\n", "if", "len", "(", "cfg", ")", ">", "0", "{", "c", "=", "cfg", "[", "0", "]", "\n", "}", "\n\n", "// cuz mergo has a little bug on maps", ...
// New creates and returns the Handlebars template engine
[ "New", "creates", "and", "returns", "the", "Handlebars", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/handlebars/handlebars.go#L31-L53
10,479
kataras/go-template
handlebars/handlebars.go
LoadDirectory
func (e *Engine) LoadDirectory(dir string, extension string) error { // register the global helpers on the first load if len(e.templateCache) == 0 && e.Config.Helpers != nil { raymond.RegisterHelpers(e.Config.Helpers) } // the render works like {{ render "myfile.html" theContext.PartialContext}} // instead of...
go
func (e *Engine) LoadDirectory(dir string, extension string) error { // register the global helpers on the first load if len(e.templateCache) == 0 && e.Config.Helpers != nil { raymond.RegisterHelpers(e.Config.Helpers) } // the render works like {{ render "myfile.html" theContext.PartialContext}} // instead of...
[ "func", "(", "e", "*", "Engine", ")", "LoadDirectory", "(", "dir", "string", ",", "extension", "string", ")", "error", "{", "// register the global helpers on the first load", "if", "len", "(", "e", ".", "templateCache", ")", "==", "0", "&&", "e", ".", "Conf...
// LoadDirectory builds the handlebars templates
[ "LoadDirectory", "builds", "the", "handlebars", "templates" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/handlebars/handlebars.go#L61-L107
10,480
kataras/go-template
amber/amber.go
New
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Funcs == nil { c.Funcs = make(map[string]interface{}, 0) } return &Engine{Config: c} }
go
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Funcs == nil { c.Funcs = make(map[string]interface{}, 0) } return &Engine{Config: c} }
[ "func", "New", "(", "cfg", "...", "Config", ")", "*", "Engine", "{", "c", ":=", "DefaultConfig", "(", ")", "\n", "if", "len", "(", "cfg", ")", ">", "0", "{", "c", "=", "cfg", "[", "0", "]", "\n", "}", "\n\n", "// cuz mergo has a little bug on maps", ...
// New creates and returns a new amber engine
[ "New", "creates", "and", "returns", "a", "new", "amber", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/amber/amber.go#L22-L34
10,481
kataras/go-template
amber/amber.go
LoadDirectory
func (e *Engine) LoadDirectory(directory string, extension string) error { opt := amber.DirOptions{} opt.Recursive = true // prepare the global amber funcs funcs := template.FuncMap{} for k, v := range amber.FuncMap { // add the amber's default funcs funcs[k] = v } if e.Config.Funcs != nil { // add the conf...
go
func (e *Engine) LoadDirectory(directory string, extension string) error { opt := amber.DirOptions{} opt.Recursive = true // prepare the global amber funcs funcs := template.FuncMap{} for k, v := range amber.FuncMap { // add the amber's default funcs funcs[k] = v } if e.Config.Funcs != nil { // add the conf...
[ "func", "(", "e", "*", "Engine", ")", "LoadDirectory", "(", "directory", "string", ",", "extension", "string", ")", "error", "{", "opt", ":=", "amber", ".", "DirOptions", "{", "}", "\n", "opt", ".", "Recursive", "=", "true", "\n\n", "// prepare the global ...
// LoadDirectory builds the amber templates
[ "LoadDirectory", "builds", "the", "amber", "templates" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/amber/amber.go#L42-L75
10,482
kataras/go-template
amber/amber.go
LoadAssets
func (e *Engine) LoadAssets(virtualDirectory string, virtualExtension string, assetFn func(name string) ([]byte, error), namesFn func() []string) error { e.templateCache = make(map[string]*template.Template) // prepare the global amber funcs funcs := template.FuncMap{} for k, v := range amber.FuncMap { // add the ...
go
func (e *Engine) LoadAssets(virtualDirectory string, virtualExtension string, assetFn func(name string) ([]byte, error), namesFn func() []string) error { e.templateCache = make(map[string]*template.Template) // prepare the global amber funcs funcs := template.FuncMap{} for k, v := range amber.FuncMap { // add the ...
[ "func", "(", "e", "*", "Engine", ")", "LoadAssets", "(", "virtualDirectory", "string", ",", "virtualExtension", "string", ",", "assetFn", "func", "(", "name", "string", ")", "(", "[", "]", "byte", ",", "error", ")", ",", "namesFn", "func", "(", ")", "[...
// LoadAssets builds the templates from binary assets
[ "LoadAssets", "builds", "the", "templates", "from", "binary", "assets" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/amber/amber.go#L78-L136
10,483
kataras/go-template
mux.go
LoadAll
func (entries Entries) LoadAll() error { for i, n := 0, len(entries); i < n; i++ { if err := entries[i].LoadEngine(); err != nil { return err } } return nil }
go
func (entries Entries) LoadAll() error { for i, n := 0, len(entries); i < n; i++ { if err := entries[i].LoadEngine(); err != nil { return err } } return nil }
[ "func", "(", "entries", "Entries", ")", "LoadAll", "(", ")", "error", "{", "for", "i", ",", "n", ":=", "0", ",", "len", "(", "entries", ")", ";", "i", "<", "n", ";", "i", "++", "{", "if", "err", ":=", "entries", "[", "i", "]", ".", "LoadEngin...
// LoadAll loads all template engines entries, returns the first error
[ "LoadAll", "loads", "all", "template", "engines", "entries", "returns", "the", "first", "error" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L50-L57
10,484
kataras/go-template
mux.go
Find
func (entries Entries) Find(filename string) *Entry { extension := filepath.Ext(filename) // Read-Only no locks needed, at serve/runtime-time the library is not supposed to add new template engines for i, n := 0, len(entries); i < n; i++ { e := entries[i] if e.Loader.Extension == extension { return e } } ...
go
func (entries Entries) Find(filename string) *Entry { extension := filepath.Ext(filename) // Read-Only no locks needed, at serve/runtime-time the library is not supposed to add new template engines for i, n := 0, len(entries); i < n; i++ { e := entries[i] if e.Loader.Extension == extension { return e } } ...
[ "func", "(", "entries", "Entries", ")", "Find", "(", "filename", "string", ")", "*", "Entry", "{", "extension", ":=", "filepath", ".", "Ext", "(", "filename", ")", "\n", "// Read-Only no locks needed, at serve/runtime-time the library is not supposed to add new template e...
// Find receives a filename, gets its extension and returns the template engine responsible for that file extension
[ "Find", "receives", "a", "filename", "gets", "its", "extension", "and", "returns", "the", "template", "engine", "responsible", "for", "that", "file", "extension" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L60-L70
10,485
kataras/go-template
mux.go
UseFuncMap
func (m *Mux) UseFuncMap(funcMap map[string]interface{}) *Mux { if len(funcMap) == 0 { return m } for k, v := range m.SharedFuncs { m.SharedFuncs[k] = v } // if template engine is already added (but not loaded) // then it's valid to add these funcs there. for i, n := 0, len(m.Entries); i < n; i++ { // ad...
go
func (m *Mux) UseFuncMap(funcMap map[string]interface{}) *Mux { if len(funcMap) == 0 { return m } for k, v := range m.SharedFuncs { m.SharedFuncs[k] = v } // if template engine is already added (but not loaded) // then it's valid to add these funcs there. for i, n := 0, len(m.Entries); i < n; i++ { // ad...
[ "func", "(", "m", "*", "Mux", ")", "UseFuncMap", "(", "funcMap", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "Mux", "{", "if", "len", "(", "funcMap", ")", "==", "0", "{", "return", "m", "\n", "}", "\n\n", "for", "k", ",", "v", ...
// UseFuncMap adds shared template funcs to the Mux // these funcs are applied to all template engines // // Should be called not called after Load.
[ "UseFuncMap", "adds", "shared", "template", "funcs", "to", "the", "Mux", "these", "funcs", "are", "applied", "to", "all", "template", "engines", "Should", "be", "called", "not", "called", "after", "Load", "." ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L111-L128
10,486
kataras/go-template
mux.go
AddEngine
func (m *Mux) AddEngine(e Engine) *Loader { // add the shared funcs m.SetFuncMapToEngine(m.SharedFuncs, e) entry := &Entry{Engine: e, Loader: NewLoader()} m.Entries = append(m.Entries, entry) // returns the entry's Loader(pointer) return entry.Loader }
go
func (m *Mux) AddEngine(e Engine) *Loader { // add the shared funcs m.SetFuncMapToEngine(m.SharedFuncs, e) entry := &Entry{Engine: e, Loader: NewLoader()} m.Entries = append(m.Entries, entry) // returns the entry's Loader(pointer) return entry.Loader }
[ "func", "(", "m", "*", "Mux", ")", "AddEngine", "(", "e", "Engine", ")", "*", "Loader", "{", "// add the shared funcs", "m", ".", "SetFuncMapToEngine", "(", "m", ".", "SharedFuncs", ",", "e", ")", "\n\n", "entry", ":=", "&", "Entry", "{", "Engine", ":...
// AddEngine adds but not loads a template engine, returns the entry's Loader
[ "AddEngine", "adds", "but", "not", "loads", "a", "template", "engine", "returns", "the", "entry", "s", "Loader" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/mux.go#L165-L174
10,487
kataras/go-template
django/config.go
DefaultConfig
func DefaultConfig() Config { return Config{ Filters: make(map[string]FilterFunction), Globals: make(map[string]interface{}, 0), DebugTemplates: false, } }
go
func DefaultConfig() Config { return Config{ Filters: make(map[string]FilterFunction), Globals: make(map[string]interface{}, 0), DebugTemplates: false, } }
[ "func", "DefaultConfig", "(", ")", "Config", "{", "return", "Config", "{", "Filters", ":", "make", "(", "map", "[", "string", "]", "FilterFunction", ")", ",", "Globals", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "0", ")...
// DefaultConfig returns the default configuration for the django template engine
[ "DefaultConfig", "returns", "the", "default", "configuration", "for", "the", "django", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/django/config.go#L26-L32
10,488
kataras/go-template
pug/pug.go
New
func New(cfg ...Config) *html.Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // pass the Pug/Jade configs to the html's configuration s := html.New(html.Config(c)) s.Middleware = jade.Parse return s }
go
func New(cfg ...Config) *html.Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // pass the Pug/Jade configs to the html's configuration s := html.New(html.Config(c)) s.Middleware = jade.Parse return s }
[ "func", "New", "(", "cfg", "...", "Config", ")", "*", "html", ".", "Engine", "{", "c", ":=", "DefaultConfig", "(", ")", "\n", "if", "len", "(", "cfg", ")", ">", "0", "{", "c", "=", "cfg", "[", "0", "]", "\n", "}", "\n", "// pass the Pug/Jade conf...
// New creates and returns the Pug template engine
[ "New", "creates", "and", "returns", "the", "Pug", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/pug/pug.go#L10-L20
10,489
kataras/go-template
django/django.go
convertFilters
func (p *Engine) convertFilters() map[string]pongo2.FilterFunction { filters := make(map[string]pongo2.FilterFunction, len(p.Config.Filters)) for k, v := range p.Config.Filters { func(filterName string, filterFunc FilterFunction) { fn := pongo2.FilterFunction(func(in *pongo2.Value, param *pongo2.Value) (*pongo2....
go
func (p *Engine) convertFilters() map[string]pongo2.FilterFunction { filters := make(map[string]pongo2.FilterFunction, len(p.Config.Filters)) for k, v := range p.Config.Filters { func(filterName string, filterFunc FilterFunction) { fn := pongo2.FilterFunction(func(in *pongo2.Value, param *pongo2.Value) (*pongo2....
[ "func", "(", "p", "*", "Engine", ")", "convertFilters", "(", ")", "map", "[", "string", "]", "pongo2", ".", "FilterFunction", "{", "filters", ":=", "make", "(", "map", "[", "string", "]", "pongo2", ".", "FilterFunction", ",", "len", "(", "p", ".", "C...
// this exists because of moving the pongo2 to the vendors without conflictitions if users // wants to register pongo2 filters they can use this django.FilterFunc to do so.
[ "this", "exists", "because", "of", "moving", "the", "pongo2", "to", "the", "vendors", "without", "conflictitions", "if", "users", "wants", "to", "register", "pongo2", "filters", "they", "can", "use", "this", "django", ".", "FilterFunc", "to", "do", "so", "."...
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/django/django.go#L56-L68
10,490
kataras/go-template
django/django.go
ExecuteWriter
func (p *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) error { if tmpl := p.fromCache(name); tmpl != nil { return tmpl.ExecuteWriter(getPongoContext(binding), out) } return fmt.Errorf("[IRIS TEMPLATES] Template with name %s doesn't exists in the dir", na...
go
func (p *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) error { if tmpl := p.fromCache(name); tmpl != nil { return tmpl.ExecuteWriter(getPongoContext(binding), out) } return fmt.Errorf("[IRIS TEMPLATES] Template with name %s doesn't exists in the dir", na...
[ "func", "(", "p", "*", "Engine", ")", "ExecuteWriter", "(", "out", "io", ".", "Writer", ",", "name", "string", ",", "binding", "interface", "{", "}", ",", "options", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", ...
// ExecuteWriter executes a templates and write its results to the out writer // layout here is useless
[ "ExecuteWriter", "executes", "a", "templates", "and", "write", "its", "results", "to", "the", "out", "writer", "layout", "here", "is", "useless" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/django/django.go#L217-L223
10,491
kataras/go-template
html/config.go
DefaultConfig
func DefaultConfig() Config { return Config{ Left: "{{", Right: "}}", Layout: "", Funcs: make(map[string]interface{}, 0), LayoutFuncs: make(map[string]interface{}, 0), } }
go
func DefaultConfig() Config { return Config{ Left: "{{", Right: "}}", Layout: "", Funcs: make(map[string]interface{}, 0), LayoutFuncs: make(map[string]interface{}, 0), } }
[ "func", "DefaultConfig", "(", ")", "Config", "{", "return", "Config", "{", "Left", ":", "\"", "\"", ",", "Right", ":", "\"", "\"", ",", "Layout", ":", "\"", "\"", ",", "Funcs", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", "...
// DefaultConfig returns the default configs for the html template engine
[ "DefaultConfig", "returns", "the", "default", "configs", "for", "the", "html", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/html/config.go#L13-L21
10,492
kataras/go-template
engine.go
GetGzipOption
func GetGzipOption(defaultValue bool, options map[string]interface{}) bool { gzipOpt := options["gzip"] // we only need that, so don't create new map to keep the options. if b, isBool := gzipOpt.(bool); isBool { return b } return defaultValue }
go
func GetGzipOption(defaultValue bool, options map[string]interface{}) bool { gzipOpt := options["gzip"] // we only need that, so don't create new map to keep the options. if b, isBool := gzipOpt.(bool); isBool { return b } return defaultValue }
[ "func", "GetGzipOption", "(", "defaultValue", "bool", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ")", "bool", "{", "gzipOpt", ":=", "options", "[", "\"", "\"", "]", "// we only need that, so don't create new map to keep the options.", "\n", ...
// GetGzipOption receives a default value and the render options map and returns if gzip is enabled for this render action
[ "GetGzipOption", "receives", "a", "default", "value", "and", "the", "render", "options", "map", "and", "returns", "if", "gzip", "is", "enabled", "for", "this", "render", "action" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/engine.go#L45-L51
10,493
kataras/go-template
engine.go
GetCharsetOption
func GetCharsetOption(defaultValue string, options map[string]interface{}) string { charsetOpt := options["charset"] if s, isString := charsetOpt.(string); isString { return s } return defaultValue }
go
func GetCharsetOption(defaultValue string, options map[string]interface{}) string { charsetOpt := options["charset"] if s, isString := charsetOpt.(string); isString { return s } return defaultValue }
[ "func", "GetCharsetOption", "(", "defaultValue", "string", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ")", "string", "{", "charsetOpt", ":=", "options", "[", "\"", "\"", "]", "\n", "if", "s", ",", "isString", ":=", "charsetOpt", "....
// GetCharsetOption receives a default value and the render options map and returns the correct charset for this render action
[ "GetCharsetOption", "receives", "a", "default", "value", "and", "the", "render", "options", "map", "and", "returns", "the", "correct", "charset", "for", "this", "render", "action" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/engine.go#L54-L60
10,494
kataras/go-template
html/html.go
New
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Funcs == nil { c.Funcs = make(map[string]interface{}, 0) } if c.LayoutFuncs == nil { c.LayoutFuncs = make(map[string]interface{}, 0) } e := &Engine{Config: c} return e }
go
func New(cfg ...Config) *Engine { c := DefaultConfig() if len(cfg) > 0 { c = cfg[0] } // cuz mergo has a little bug on maps if c.Funcs == nil { c.Funcs = make(map[string]interface{}, 0) } if c.LayoutFuncs == nil { c.LayoutFuncs = make(map[string]interface{}, 0) } e := &Engine{Config: c} return e }
[ "func", "New", "(", "cfg", "...", "Config", ")", "*", "Engine", "{", "c", ":=", "DefaultConfig", "(", ")", "\n", "if", "len", "(", "cfg", ")", ">", "0", "{", "c", "=", "cfg", "[", "0", "]", "\n", "}", "\n", "// cuz mergo has a little bug on maps", ...
// New creates and returns the HTMLTemplate template engine
[ "New", "creates", "and", "returns", "the", "HTMLTemplate", "template", "engine" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/html/html.go#L48-L62
10,495
kataras/go-template
markdown/markdown.go
LoadDirectory
func (e *Engine) LoadDirectory(dir string, extension string) error { e.mu.Lock() defer e.mu.Unlock() var templateErr error // Walk the supplied directory and compile any files that match our extension list. filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if info == nil || info.IsDir() ...
go
func (e *Engine) LoadDirectory(dir string, extension string) error { e.mu.Lock() defer e.mu.Unlock() var templateErr error // Walk the supplied directory and compile any files that match our extension list. filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if info == nil || info.IsDir() ...
[ "func", "(", "e", "*", "Engine", ")", "LoadDirectory", "(", "dir", "string", ",", "extension", "string", ")", "error", "{", "e", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "Unlock", "(", ")", "\n", "var", "templateErr", ...
// LoadDirectory builds the markdown templates
[ "LoadDirectory", "builds", "the", "markdown", "templates" ]
a4a986b413e8d88ebd894b4a3e327314069f2439
https://github.com/kataras/go-template/blob/a4a986b413e8d88ebd894b4a3e327314069f2439/markdown/markdown.go#L38-L83
10,496
micro/util
go/lib/addr/addr.go
IPs
func IPs() []string { ifaces, err := net.Interfaces() if err != nil { return nil } var ipAddrs []string for _, i := range ifaces { addrs, err := i.Addrs() if err != nil { continue } for _, addr := range addrs { var ip net.IP switch v := addr.(type) { case *net.IPNet: ip = v.IP case ...
go
func IPs() []string { ifaces, err := net.Interfaces() if err != nil { return nil } var ipAddrs []string for _, i := range ifaces { addrs, err := i.Addrs() if err != nil { continue } for _, addr := range addrs { var ip net.IP switch v := addr.(type) { case *net.IPNet: ip = v.IP case ...
[ "func", "IPs", "(", ")", "[", "]", "string", "{", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "var", "ipAddrs", "[", "]", "string", "\n\n", "for", "_", ...
// IPs returns all known ips
[ "IPs", "returns", "all", "known", "ips" ]
b9d497e656ef2a7ae781bd909cfc938144a653ff
https://github.com/micro/util/blob/b9d497e656ef2a7ae781bd909cfc938144a653ff/go/lib/addr/addr.go#L83-L120
10,497
cloudfoundry/dropsonde
dropsonde_marshaller/dropsonde_marshaller.go
NewDropsondeMarshaller
func NewDropsondeMarshaller(logger *gosteno.Logger) *DropsondeMarshaller { messageCounts := make(map[events.Envelope_EventType]*uint64) for key := range events.Envelope_EventType_name { var count uint64 messageCounts[events.Envelope_EventType(key)] = &count } return &DropsondeMarshaller{ logger: logger...
go
func NewDropsondeMarshaller(logger *gosteno.Logger) *DropsondeMarshaller { messageCounts := make(map[events.Envelope_EventType]*uint64) for key := range events.Envelope_EventType_name { var count uint64 messageCounts[events.Envelope_EventType(key)] = &count } return &DropsondeMarshaller{ logger: logger...
[ "func", "NewDropsondeMarshaller", "(", "logger", "*", "gosteno", ".", "Logger", ")", "*", "DropsondeMarshaller", "{", "messageCounts", ":=", "make", "(", "map", "[", "events", ".", "Envelope_EventType", "]", "*", "uint64", ")", "\n", "for", "key", ":=", "ran...
// NewDropsondeMarshaller instantiates a DropsondeMarshaller and logs to the // provided logger.
[ "NewDropsondeMarshaller", "instantiates", "a", "DropsondeMarshaller", "and", "logs", "to", "the", "provided", "logger", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_marshaller/dropsonde_marshaller.go#L50-L60
10,498
cloudfoundry/dropsonde
dropsonde_marshaller/dropsonde_marshaller.go
Run
func (u *DropsondeMarshaller) Run(inputChan <-chan *events.Envelope, outputChan chan<- []byte) { for message := range inputChan { messageBytes, err := proto.Marshal(message) if err != nil { u.logger.Errorf("dropsondeMarshaller: marshal error %v", err) metrics.BatchIncrementCounter("dropsondeMarshaller.marsh...
go
func (u *DropsondeMarshaller) Run(inputChan <-chan *events.Envelope, outputChan chan<- []byte) { for message := range inputChan { messageBytes, err := proto.Marshal(message) if err != nil { u.logger.Errorf("dropsondeMarshaller: marshal error %v", err) metrics.BatchIncrementCounter("dropsondeMarshaller.marsh...
[ "func", "(", "u", "*", "DropsondeMarshaller", ")", "Run", "(", "inputChan", "<-", "chan", "*", "events", ".", "Envelope", ",", "outputChan", "chan", "<-", "[", "]", "byte", ")", "{", "for", "message", ":=", "range", "inputChan", "{", "messageBytes", ",",...
// Run reads Envelopes from inputChan, marshals them to Protocol Buffer format, // and emits the binary messages onto outputChan. It operates one message at a // time, and will block if outputChan is not read.
[ "Run", "reads", "Envelopes", "from", "inputChan", "marshals", "them", "to", "Protocol", "Buffer", "format", "and", "emits", "the", "binary", "messages", "onto", "outputChan", ".", "It", "operates", "one", "message", "at", "a", "time", "and", "will", "block", ...
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/dropsonde_marshaller/dropsonde_marshaller.go#L65-L78
10,499
cloudfoundry/dropsonde
signature/signature_verifier.go
SignMessage
func SignMessage(message, secret []byte) []byte { signature := generateSignature(message, secret) return append(signature, message...) }
go
func SignMessage(message, secret []byte) []byte { signature := generateSignature(message, secret) return append(signature, message...) }
[ "func", "SignMessage", "(", "message", ",", "secret", "[", "]", "byte", ")", "[", "]", "byte", "{", "signature", ":=", "generateSignature", "(", "message", ",", "secret", ")", "\n", "return", "append", "(", "signature", ",", "message", "...", ")", "\n", ...
// SignMessage returns a message signed with the provided secret, with the // signature prepended to the original message.
[ "SignMessage", "returns", "a", "message", "signed", "with", "the", "provided", "secret", "with", "the", "signature", "prepended", "to", "the", "original", "message", "." ]
a5c24343b09d7b811567b68cf18c7aa2a34a798a
https://github.com/cloudfoundry/dropsonde/blob/a5c24343b09d7b811567b68cf18c7aa2a34a798a/signature/signature_verifier.go#L63-L66