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
partition
stringclasses
1 value
mailgun/mailgun-go
mailgun.go
generateCredentialsUrl
func generateCredentialsUrl(m Mailgun, id string) string { tail := "" if id != "" { tail = fmt.Sprintf("/%s", id) } return generateDomainApiUrl(m, fmt.Sprintf("credentials%s", tail)) // return fmt.Sprintf("%s/domains/%s/credentials%s", apiBase, m.Domain(), tail) }
go
func generateCredentialsUrl(m Mailgun, id string) string { tail := "" if id != "" { tail = fmt.Sprintf("/%s", id) } return generateDomainApiUrl(m, fmt.Sprintf("credentials%s", tail)) // return fmt.Sprintf("%s/domains/%s/credentials%s", apiBase, m.Domain(), tail) }
[ "func", "generateCredentialsUrl", "(", "m", "Mailgun", ",", "id", "string", ")", "string", "{", "tail", ":=", "\"", "\"", "\n", "if", "id", "!=", "\"", "\"", "{", "tail", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n...
// generateCredentialsUrl renders a URL as generateDomainApiUrl, // but focuses on the SMTP credentials family of API functions.
[ "generateCredentialsUrl", "renders", "a", "URL", "as", "generateDomainApiUrl", "but", "focuses", "on", "the", "SMTP", "credentials", "family", "of", "API", "functions", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L339-L346
train
mailgun/mailgun-go
mailgun.go
generateStoredMessageUrl
func generateStoredMessageUrl(m Mailgun, endpoint, id string) string { return generateDomainApiUrl(m, fmt.Sprintf("%s/%s", endpoint, id)) // return fmt.Sprintf("%s/domains/%s/%s/%s", apiBase, m.Domain(), endpoint, id) }
go
func generateStoredMessageUrl(m Mailgun, endpoint, id string) string { return generateDomainApiUrl(m, fmt.Sprintf("%s/%s", endpoint, id)) // return fmt.Sprintf("%s/domains/%s/%s/%s", apiBase, m.Domain(), endpoint, id) }
[ "func", "generateStoredMessageUrl", "(", "m", "Mailgun", ",", "endpoint", ",", "id", "string", ")", "string", "{", "return", "generateDomainApiUrl", "(", "m", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "endpoint", ",", "id", ")", ")", "\n", "// re...
// generateStoredMessageUrl generates the URL needed to acquire a copy of a stored message.
[ "generateStoredMessageUrl", "generates", "the", "URL", "needed", "to", "acquire", "a", "copy", "of", "a", "stored", "message", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L349-L352
train
mailgun/mailgun-go
mailgun.go
generatePublicApiUrl
func generatePublicApiUrl(m Mailgun, endpoint string) string { return fmt.Sprintf("%s/%s", m.APIBase(), endpoint) }
go
func generatePublicApiUrl(m Mailgun, endpoint string) string { return fmt.Sprintf("%s/%s", m.APIBase(), endpoint) }
[ "func", "generatePublicApiUrl", "(", "m", "Mailgun", ",", "endpoint", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "APIBase", "(", ")", ",", "endpoint", ")", "\n", "}" ]
// generatePublicApiUrl works as generateApiUrl, except that generatePublicApiUrl has no need for the domain.
[ "generatePublicApiUrl", "works", "as", "generateApiUrl", "except", "that", "generatePublicApiUrl", "has", "no", "need", "for", "the", "domain", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L355-L357
train
mailgun/mailgun-go
mailgun.go
generateParameterizedUrl
func generateParameterizedUrl(m Mailgun, endpoint string, payload payload) (string, error) { paramBuffer, err := payload.getPayloadBuffer() if err != nil { return "", err } params := string(paramBuffer.Bytes()) return fmt.Sprintf("%s?%s", generateApiUrl(m, eventsEndpoint), params), nil }
go
func generateParameterizedUrl(m Mailgun, endpoint string, payload payload) (string, error) { paramBuffer, err := payload.getPayloadBuffer() if err != nil { return "", err } params := string(paramBuffer.Bytes()) return fmt.Sprintf("%s?%s", generateApiUrl(m, eventsEndpoint), params), nil }
[ "func", "generateParameterizedUrl", "(", "m", "Mailgun", ",", "endpoint", "string", ",", "payload", "payload", ")", "(", "string", ",", "error", ")", "{", "paramBuffer", ",", "err", ":=", "payload", ".", "getPayloadBuffer", "(", ")", "\n", "if", "err", "!=...
// generateParameterizedUrl works as generateApiUrl, but supports query parameters.
[ "generateParameterizedUrl", "works", "as", "generateApiUrl", "but", "supports", "query", "parameters", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L360-L367
train
mailgun/mailgun-go
mailgun.go
parseMailgunTime
func parseMailgunTime(ts string) (t time.Time, err error) { t, err = time.Parse("Mon, 2 Jan 2006 15:04:05 MST", ts) return }
go
func parseMailgunTime(ts string) (t time.Time, err error) { t, err = time.Parse("Mon, 2 Jan 2006 15:04:05 MST", ts) return }
[ "func", "parseMailgunTime", "(", "ts", "string", ")", "(", "t", "time", ".", "Time", ",", "err", "error", ")", "{", "t", ",", "err", "=", "time", ".", "Parse", "(", "\"", "\"", ",", "ts", ")", "\n", "return", "\n", "}" ]
// parseMailgunTime translates a timestamp as returned by Mailgun into a Go standard timestamp.
[ "parseMailgunTime", "translates", "a", "timestamp", "as", "returned", "by", "Mailgun", "into", "a", "Go", "standard", "timestamp", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L370-L373
train
mailgun/mailgun-go
parse.go
new_
func new_(e interface{}) func() Event { typ := reflect.TypeOf(e) return func() Event { return reflect.New(typ).Interface().(Event) } }
go
func new_(e interface{}) func() Event { typ := reflect.TypeOf(e) return func() Event { return reflect.New(typ).Interface().(Event) } }
[ "func", "new_", "(", "e", "interface", "{", "}", ")", "func", "(", ")", "Event", "{", "typ", ":=", "reflect", ".", "TypeOf", "(", "e", ")", "\n", "return", "func", "(", ")", "Event", "{", "return", "reflect", ".", "New", "(", "typ", ")", ".", "...
// new_ is a universal event "constructor".
[ "new_", "is", "a", "universal", "event", "constructor", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/parse.go#L41-L46
train
mailgun/mailgun-go
parse.go
ParseEvents
func ParseEvents(raw []events.RawJSON) ([]Event, error) { var result []Event for _, value := range raw { event, err := ParseEvent(value) if err != nil { return nil, fmt.Errorf("while parsing event: %s", err) } result = append(result, event) } return result, nil }
go
func ParseEvents(raw []events.RawJSON) ([]Event, error) { var result []Event for _, value := range raw { event, err := ParseEvent(value) if err != nil { return nil, fmt.Errorf("while parsing event: %s", err) } result = append(result, event) } return result, nil }
[ "func", "ParseEvents", "(", "raw", "[", "]", "events", ".", "RawJSON", ")", "(", "[", "]", "Event", ",", "error", ")", "{", "var", "result", "[", "]", "Event", "\n", "for", "_", ",", "value", ":=", "range", "raw", "{", "event", ",", "err", ":=", ...
// Given a slice of events.RawJSON events return a slice of Event for each parsed event
[ "Given", "a", "slice", "of", "events", ".", "RawJSON", "events", "return", "a", "slice", "of", "Event", "for", "each", "parsed", "event" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/parse.go#L66-L76
train
mailgun/mailgun-go
parse.go
ParseEvent
func ParseEvent(raw []byte) (Event, error) { // Try to recognize the event first. var e events.EventName if err := easyjson.Unmarshal(raw, &e); err != nil { return nil, fmt.Errorf("failed to recognize event: %v", err) } // Get the event "constructor" from the map. newEvent, ok := EventNames[e.Name] if !ok { ...
go
func ParseEvent(raw []byte) (Event, error) { // Try to recognize the event first. var e events.EventName if err := easyjson.Unmarshal(raw, &e); err != nil { return nil, fmt.Errorf("failed to recognize event: %v", err) } // Get the event "constructor" from the map. newEvent, ok := EventNames[e.Name] if !ok { ...
[ "func", "ParseEvent", "(", "raw", "[", "]", "byte", ")", "(", "Event", ",", "error", ")", "{", "// Try to recognize the event first.", "var", "e", "events", ".", "EventName", "\n", "if", "err", ":=", "easyjson", ".", "Unmarshal", "(", "raw", ",", "&", "e...
// Parse converts raw bytes data into an event struct. Can accept events.RawJSON as input
[ "Parse", "converts", "raw", "bytes", "data", "into", "an", "event", "struct", ".", "Can", "accept", "events", ".", "RawJSON", "as", "input" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/parse.go#L79-L99
train
mailgun/mailgun-go
unsubscribes.go
ListUnsubscribes
func (mg *MailgunImpl) ListUnsubscribes(opts *ListOptions) *UnsubscribesIterator { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } ur...
go
func (mg *MailgunImpl) ListUnsubscribes(opts *ListOptions) *UnsubscribesIterator { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } ur...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListUnsubscribes", "(", "opts", "*", "ListOptions", ")", "*", "UnsubscribesIterator", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "unsubscribesEndpoint", ")", ")", "\n", "r", ".", "set...
// Fetches the list of unsubscribes
[ "Fetches", "the", "list", "of", "unsubscribes" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/unsubscribes.go#L21-L36
train
mailgun/mailgun-go
unsubscribes.go
GetUnsubscribe
func (mg *MailgunImpl) GetUnsubscribe(ctx context.Context, address string) (Unsubscribe, error) { r := newHTTPRequest(generateApiUrlWithTarget(mg, unsubscribesEndpoint, address)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) envelope := Unsubscribe{} err := getResponseFromJSON(ctx, r, &envel...
go
func (mg *MailgunImpl) GetUnsubscribe(ctx context.Context, address string) (Unsubscribe, error) { r := newHTTPRequest(generateApiUrlWithTarget(mg, unsubscribesEndpoint, address)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) envelope := Unsubscribe{} err := getResponseFromJSON(ctx, r, &envel...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetUnsubscribe", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "Unsubscribe", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrlWithTarget", "(", "mg", ",", "u...
// Retreives a single unsubscribe record. Can be used to check if a given address is present in the list of unsubscribed users.
[ "Retreives", "a", "single", "unsubscribe", "record", ".", "Can", "be", "used", "to", "check", "if", "a", "given", "address", "is", "present", "in", "the", "list", "of", "unsubscribed", "users", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/unsubscribes.go#L136-L145
train
mailgun/mailgun-go
unsubscribes.go
CreateUnsubscribe
func (mg *MailgunImpl) CreateUnsubscribe(ctx context.Context, address, tag string) error { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("address", address) p.addValue("tag", tag) _, err := ...
go
func (mg *MailgunImpl) CreateUnsubscribe(ctx context.Context, address, tag string) error { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("address", address) p.addValue("tag", tag) _, err := ...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateUnsubscribe", "(", "ctx", "context", ".", "Context", ",", "address", ",", "tag", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "unsubscribesEndpoint", ")", ...
// Unsubscribe adds an e-mail address to the domain's unsubscription table.
[ "Unsubscribe", "adds", "an", "e", "-", "mail", "address", "to", "the", "domain", "s", "unsubscription", "table", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/unsubscribes.go#L148-L157
train
mailgun/mailgun-go
tags.go
DeleteTag
func (mg *MailgunImpl) DeleteTag(ctx context.Context, tag string) error { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteTag(ctx context.Context, tag string) error { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteTag", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "tagsEndpoint", ")", "+", "\"", "\"", "+", "tag...
// DeleteTag removes all counters for a particular tag, including the tag itself.
[ "DeleteTag", "removes", "all", "counters", "for", "a", "particular", "tag", "including", "the", "tag", "itself", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L30-L36
train
mailgun/mailgun-go
tags.go
GetTag
func (mg *MailgunImpl) GetTag(ctx context.Context, tag string) (Tag, error) { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var tagItem Tag return tagItem, getResponseFromJSON(ctx, r, &tagItem) }
go
func (mg *MailgunImpl) GetTag(ctx context.Context, tag string) (Tag, error) { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var tagItem Tag return tagItem, getResponseFromJSON(ctx, r, &tagItem) }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetTag", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "(", "Tag", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "tagsEndpoint", ")", "+", ...
// GetTag retrieves metadata about the tag from the api
[ "GetTag", "retrieves", "metadata", "about", "the", "tag", "from", "the", "api" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L39-L45
train
mailgun/mailgun-go
tags.go
Next
func (ti *TagIterator) Next(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } if !canFetchPage(ti.Paging.Next) { return false } ti.err = ti.fetch(ctx, ti.Paging.Next) if ti.err != nil { return false } *items = ti.Items if len(ti.Items) == 0 { return false } return true }
go
func (ti *TagIterator) Next(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } if !canFetchPage(ti.Paging.Next) { return false } ti.err = ti.fetch(ctx, ti.Paging.Next) if ti.err != nil { return false } *items = ti.Items if len(ti.Items) == 0 { return false } return true }
[ "func", "(", "ti", "*", "TagIterator", ")", "Next", "(", "ctx", "context", ".", "Context", ",", "items", "*", "[", "]", "Tag", ")", "bool", "{", "if", "ti", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "canFetchP...
// Next returns the next page in the list of tags
[ "Next", "returns", "the", "next", "page", "in", "the", "list", "of", "tags" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L84-L102
train
mailgun/mailgun-go
tags.go
First
func (ti *TagIterator) First(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } ti.err = ti.fetch(ctx, ti.Paging.First) if ti.err != nil { return false } *items = ti.Items return true }
go
func (ti *TagIterator) First(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } ti.err = ti.fetch(ctx, ti.Paging.First) if ti.err != nil { return false } *items = ti.Items return true }
[ "func", "(", "ti", "*", "TagIterator", ")", "First", "(", "ctx", "context", ".", "Context", ",", "items", "*", "[", "]", "Tag", ")", "bool", "{", "if", "ti", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "ti", ".", "err", "=...
// First returns the first page in the list of tags
[ "First", "returns", "the", "first", "page", "in", "the", "list", "of", "tags" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L130-L140
train
mailgun/mailgun-go
mailing_lists.go
ListMailingLists
func (mg *MailgunImpl) ListMailingLists(opts *ListOptions) *ListsIterator { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/pages") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } ...
go
func (mg *MailgunImpl) ListMailingLists(opts *ListOptions) *ListsIterator { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/pages") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } ...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListMailingLists", "(", "opts", "*", "ListOptions", ")", "*", "ListsIterator", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "listsEndpoint", ")", "+", "\"", "\"", ")", "\n", "r"...
// ListMailingLists returns the specified set of mailing lists administered by your account.
[ "ListMailingLists", "returns", "the", "specified", "set", "of", "mailing", "lists", "administered", "by", "your", "account", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L53-L68
train
mailgun/mailgun-go
mailing_lists.go
DeleteMailingList
func (mg *MailgunImpl) DeleteMailingList(ctx context.Context, addr string) error { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteMailingList(ctx context.Context, addr string) error { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteMailingList", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "listsEndpoint", ")", "+", "\"", "\"...
// DeleteMailingList removes all current members of the list, then removes the list itself. // Attempts to send e-mail to the list will fail subsequent to this call.
[ "DeleteMailingList", "removes", "all", "current", "members", "of", "the", "list", "then", "removes", "the", "list", "itself", ".", "Attempts", "to", "send", "e", "-", "mail", "to", "the", "list", "will", "fail", "subsequent", "to", "this", "call", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L194-L200
train
mailgun/mailgun-go
mailing_lists.go
GetMailingList
func (mg *MailgunImpl) GetMailingList(ctx context.Context, addr string) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) response, err := makeGetRequest(ctx, r) if err != nil { return MailingList{}...
go
func (mg *MailgunImpl) GetMailingList(ctx context.Context, addr string) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) response, err := makeGetRequest(ctx, r) if err != nil { return MailingList{}...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetMailingList", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ")", "(", "MailingList", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "listsEnd...
// GetMailingList allows your application to recover the complete List structure // representing a mailing list, so long as you have its e-mail address.
[ "GetMailingList", "allows", "your", "application", "to", "recover", "the", "complete", "List", "structure", "representing", "a", "mailing", "list", "so", "long", "as", "you", "have", "its", "e", "-", "mail", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L204-L216
train
mailgun/mailgun-go
mailing_lists.go
UpdateMailingList
func (mg *MailgunImpl) UpdateMailingList(ctx context.Context, addr string, prototype MailingList) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if prototype.Address != ...
go
func (mg *MailgunImpl) UpdateMailingList(ctx context.Context, addr string, prototype MailingList) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if prototype.Address != ...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateMailingList", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ",", "prototype", "MailingList", ")", "(", "MailingList", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublic...
// UpdateMailingList allows you to change various attributes of a list. // Address, Name, Description, and AccessLevel are all optional; // only those fields which are set in the prototype will change. // // Be careful! If changing the address of a mailing list, // e-mail sent to the old address will not succeed. // M...
[ "UpdateMailingList", "allows", "you", "to", "change", "various", "attributes", "of", "a", "list", ".", "Address", "Name", "Description", "and", "AccessLevel", "are", "all", "optional", ";", "only", "those", "fields", "which", "are", "set", "in", "the", "protot...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L225-L249
train
mailgun/mailgun-go
stats.go
GetStats
func (mg *MailgunImpl) GetStats(ctx context.Context, events []string, opts *GetStatOptions) ([]Stats, error) { r := newHTTPRequest(generateApiUrl(mg, statsTotalEndpoint)) if opts != nil { if !opts.Start.IsZero() { r.addParameter("start", opts.Start.Format(iso8601date)) } if !opts.End.IsZero() { r.addPara...
go
func (mg *MailgunImpl) GetStats(ctx context.Context, events []string, opts *GetStatOptions) ([]Stats, error) { r := newHTTPRequest(generateApiUrl(mg, statsTotalEndpoint)) if opts != nil { if !opts.Start.IsZero() { r.addParameter("start", opts.Start.Format(iso8601date)) } if !opts.End.IsZero() { r.addPara...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetStats", "(", "ctx", "context", ".", "Context", ",", "events", "[", "]", "string", ",", "opts", "*", "GetStatOptions", ")", "(", "[", "]", "Stats", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(...
// GetStats returns total stats for a given domain for the specified time period
[ "GetStats", "returns", "total", "stats", "for", "a", "given", "domain", "for", "the", "specified", "time", "period" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/stats.go#L89-L121
train
mailgun/mailgun-go
events.go
ListEvents
func (mg *MailgunImpl) ListEvents(opts *ListEventOptions) *EventIterator { req := newHTTPRequest(generateApiUrl(mg, eventsEndpoint)) if opts != nil { if opts.Limit > 0 { req.addParameter("limit", fmt.Sprintf("%d", opts.Limit)) } if opts.Compact { req.addParameter("pretty", "no") } if opts.ForceAscendi...
go
func (mg *MailgunImpl) ListEvents(opts *ListEventOptions) *EventIterator { req := newHTTPRequest(generateApiUrl(mg, eventsEndpoint)) if opts != nil { if opts.Limit > 0 { req.addParameter("limit", fmt.Sprintf("%d", opts.Limit)) } if opts.Compact { req.addParameter("pretty", "no") } if opts.ForceAscendi...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListEvents", "(", "opts", "*", "ListEventOptions", ")", "*", "EventIterator", "{", "req", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "eventsEndpoint", ")", ")", "\n", "if", "opts", "!=", "nil...
// Create an new iterator to fetch a page of events from the events api
[ "Create", "an", "new", "iterator", "to", "fetch", "a", "page", "of", "events", "from", "the", "events", "api" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/events.go#L39-L71
train
mailgun/mailgun-go
recipients.go
UnmarshalText
func (r *Recipient) UnmarshalText(text []byte) error { s := string(text) if s[len(s)-1:] != ">" { *r = Recipient{Email: s} return nil } i := strings.Index(s, "<") // at least 1 char followed by a space if i < 2 { return fmt.Errorf("malformed recipient string '%s'", s) } *r = Recipient{ Name: strings.T...
go
func (r *Recipient) UnmarshalText(text []byte) error { s := string(text) if s[len(s)-1:] != ">" { *r = Recipient{Email: s} return nil } i := strings.Index(s, "<") // at least 1 char followed by a space if i < 2 { return fmt.Errorf("malformed recipient string '%s'", s) } *r = Recipient{ Name: strings.T...
[ "func", "(", "r", "*", "Recipient", ")", "UnmarshalText", "(", "text", "[", "]", "byte", ")", "error", "{", "s", ":=", "string", "(", "text", ")", "\n", "if", "s", "[", "len", "(", "s", ")", "-", "1", ":", "]", "!=", "\"", "\"", "{", "*", "...
// UnmarshalText satisfies TextUnmarshaler
[ "UnmarshalText", "satisfies", "TextUnmarshaler" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/recipients.go#L24-L42
train
mailgun/mailgun-go
bounces.go
GetBounce
func (mg *MailgunImpl) GetBounce(ctx context.Context, address string) (Bounce, error) { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var response Bounce err := getResponseFromJSON(ctx, r, &response) return response, e...
go
func (mg *MailgunImpl) GetBounce(ctx context.Context, address string) (Bounce, error) { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var response Bounce err := getResponseFromJSON(ctx, r, &response) return response, e...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetBounce", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "Bounce", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "bouncesEndpoint", "...
// GetBounce retrieves a single bounce record, if any exist, for the given recipient address.
[ "GetBounce", "retrieves", "a", "single", "bounce", "record", "if", "any", "exist", "for", "the", "given", "recipient", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/bounces.go#L152-L160
train
mailgun/mailgun-go
bounces.go
DeleteBounce
func (mg *MailgunImpl) DeleteBounce(ctx context.Context, address string) error { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteBounce(ctx context.Context, address string) error { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteBounce", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "bouncesEndpoint", ")", "+", "\"", "\"", "...
// DeleteBounce removes all bounces associted with the provided e-mail address.
[ "DeleteBounce", "removes", "all", "bounces", "associted", "with", "the", "provided", "e", "-", "mail", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/bounces.go#L196-L202
train
mailgun/mailgun-go
template.go
CreateTemplate
func (mg *MailgunImpl) CreateTemplate(ctx context.Context, template *Template) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() if template.Name != "" { payload.addValue("name", template.Name...
go
func (mg *MailgunImpl) CreateTemplate(ctx context.Context, template *Template) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() if template.Name != "" { payload.addValue("name", template.Name...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateTemplate", "(", "ctx", "context", ".", "Context", ",", "template", "*", "Template", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ")", ")", "\n...
// Create a new template which can be used to attach template versions to
[ "Create", "a", "new", "template", "which", "can", "be", "used", "to", "attach", "template", "versions", "to" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L36-L66
train
mailgun/mailgun-go
template.go
GetTemplate
func (mg *MailgunImpl) GetTemplate(ctx context.Context, name string) (Template, error) { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addParameter("active", "yes") var resp templateResp err := getResponseFromJSON(ctx...
go
func (mg *MailgunImpl) GetTemplate(ctx context.Context, name string) (Template, error) { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addParameter("active", "yes") var resp templateResp err := getResponseFromJSON(ctx...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetTemplate", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "Template", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ...
// GetTemplate gets a template given the template name
[ "GetTemplate", "gets", "a", "template", "given", "the", "template", "name" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L69-L81
train
mailgun/mailgun-go
template.go
UpdateTemplate
func (mg *MailgunImpl) UpdateTemplate(ctx context.Context, template *Template) error { if template.Name == "" { return errors.New("UpdateTemplate() Template.Name cannot be empty") } r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + template.Name) r.setClient(mg.Client()) r.setBasicAuth(basicAuth...
go
func (mg *MailgunImpl) UpdateTemplate(ctx context.Context, template *Template) error { if template.Name == "" { return errors.New("UpdateTemplate() Template.Name cannot be empty") } r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + template.Name) r.setClient(mg.Client()) r.setBasicAuth(basicAuth...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateTemplate", "(", "ctx", "context", ".", "Context", ",", "template", "*", "Template", ")", "error", "{", "if", "template", ".", "Name", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", ...
// Update the name and description of a template
[ "Update", "the", "name", "and", "description", "of", "a", "template" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L84-L108
train
mailgun/mailgun-go
template.go
DeleteTemplate
func (mg *MailgunImpl) DeleteTemplate(ctx context.Context, name string) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteTemplate(ctx context.Context, name string) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteTemplate", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ")", "+", "\"", "\"", ...
// Delete a template given a template name
[ "Delete", "a", "template", "given", "a", "template", "name" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L111-L117
train
mailgun/mailgun-go
template.go
ListTemplates
func (mg *MailgunImpl) ListTemplates(opts *ListTemplateOptions) *TemplatesIterator { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } if op...
go
func (mg *MailgunImpl) ListTemplates(opts *ListTemplateOptions) *TemplatesIterator { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } if op...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListTemplates", "(", "opts", "*", "ListTemplateOptions", ")", "*", "TemplatesIterator", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ")", ")", "\n", "r", ".", "setC...
// List all available templates
[ "List", "all", "available", "templates" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L131-L149
train
mailgun/mailgun-go
exports.go
CreateExport
func (mg *MailgunImpl) CreateExport(ctx context.Context, url string) error { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("url", url) _, err := makePostRequest(ctx, r, payload)...
go
func (mg *MailgunImpl) CreateExport(ctx context.Context, url string) error { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("url", url) _, err := makePostRequest(ctx, r, payload)...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateExport", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exportsEndpoint", ")", ")", "\n", "r", ...
// Create an export based on the URL given
[ "Create", "an", "export", "based", "on", "the", "URL", "given" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L21-L30
train
mailgun/mailgun-go
exports.go
ListExports
func (mg *MailgunImpl) ListExports(ctx context.Context, url string) ([]Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) if url != "" { r.addParameter("url", url) } r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp ExportList if err := getResponseFromJS...
go
func (mg *MailgunImpl) ListExports(ctx context.Context, url string) ([]Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) if url != "" { r.addParameter("url", url) } r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp ExportList if err := getResponseFromJS...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListExports", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "(", "[", "]", "Export", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exp...
// List all exports created within the past 24 hours
[ "List", "all", "exports", "created", "within", "the", "past", "24", "hours" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L33-L51
train
mailgun/mailgun-go
exports.go
GetExport
func (mg *MailgunImpl) GetExport(ctx context.Context, id string) (Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp Export err := getResponseFromJSON(ctx, r, &resp) return resp, err }
go
func (mg *MailgunImpl) GetExport(ctx context.Context, id string) (Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp Export err := getResponseFromJSON(ctx, r, &resp) return resp, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetExport", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "Export", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exportsEndpoint", ...
// GetExport gets an export by id
[ "GetExport", "gets", "an", "export", "by", "id" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L54-L61
train
mailgun/mailgun-go
exports.go
GetExportLink
func (mg *MailgunImpl) GetExportLink(ctx context.Context, id string) (string, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id + "/download_url") c := mg.Client() // Ensure the client doesn't attempt to retry c.CheckRedirect = func(req *http.Request, via []*http.Request) error { ...
go
func (mg *MailgunImpl) GetExportLink(ctx context.Context, id string) (string, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id + "/download_url") c := mg.Client() // Ensure the client doesn't attempt to retry c.CheckRedirect = func(req *http.Request, via []*http.Request) error { ...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetExportLink", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "string", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exportsEndpoint"...
// Download an export by ID. This will respond with a '302 Moved' // with the Location header of temporary S3 URL if it is available.
[ "Download", "an", "export", "by", "ID", ".", "This", "will", "respond", "with", "a", "302", "Moved", "with", "the", "Location", "header", "of", "temporary", "S3", "URL", "if", "it", "is", "available", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L65-L99
train
mailgun/mailgun-go
messages.go
AddReaderAttachment
func (m *Message) AddReaderAttachment(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerAttachments = append(m.readerAttachments, ra) }
go
func (m *Message) AddReaderAttachment(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerAttachments = append(m.readerAttachments, ra) }
[ "func", "(", "m", "*", "Message", ")", "AddReaderAttachment", "(", "filename", "string", ",", "readCloser", "io", ".", "ReadCloser", ")", "{", "ra", ":=", "ReaderAttachment", "{", "Filename", ":", "filename", ",", "ReadCloser", ":", "readCloser", "}", "\n", ...
// AddReaderAttachment arranges to send a file along with the e-mail message. // File contents are read from a io.ReadCloser. // The filename parameter is the resulting filename of the attachment. // The readCloser parameter is the io.ReadCloser which reads the actual bytes to be used // as the contents of the attached...
[ "AddReaderAttachment", "arranges", "to", "send", "a", "file", "along", "with", "the", "e", "-", "mail", "message", ".", "File", "contents", "are", "read", "from", "a", "io", ".", "ReadCloser", ".", "The", "filename", "parameter", "is", "the", "resulting", ...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L208-L211
train
mailgun/mailgun-go
messages.go
AddAttachment
func (m *Message) AddAttachment(attachment string) { m.attachments = append(m.attachments, attachment) }
go
func (m *Message) AddAttachment(attachment string) { m.attachments = append(m.attachments, attachment) }
[ "func", "(", "m", "*", "Message", ")", "AddAttachment", "(", "attachment", "string", ")", "{", "m", ".", "attachments", "=", "append", "(", "m", ".", "attachments", ",", "attachment", ")", "\n", "}" ]
// AddAttachment arranges to send a file from the filesystem along with the e-mail message. // The attachment parameter is a filename, which must refer to a file which actually resides // in the local filesystem.
[ "AddAttachment", "arranges", "to", "send", "a", "file", "from", "the", "filesystem", "along", "with", "the", "e", "-", "mail", "message", ".", "The", "attachment", "parameter", "is", "a", "filename", "which", "must", "refer", "to", "a", "file", "which", "a...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L226-L228
train
mailgun/mailgun-go
messages.go
AddReaderInline
func (m *Message) AddReaderInline(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerInlines = append(m.readerInlines, ra) }
go
func (m *Message) AddReaderInline(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerInlines = append(m.readerInlines, ra) }
[ "func", "(", "m", "*", "Message", ")", "AddReaderInline", "(", "filename", "string", ",", "readCloser", "io", ".", "ReadCloser", ")", "{", "ra", ":=", "ReaderAttachment", "{", "Filename", ":", "filename", ",", "ReadCloser", ":", "readCloser", "}", "\n", "m...
// AddReaderInline arranges to send a file along with the e-mail message. // File contents are read from a io.ReadCloser. // The filename parameter is the resulting filename of the attachment. // The readCloser parameter is the io.ReadCloser which reads the actual bytes to be used // as the contents of the attached fil...
[ "AddReaderInline", "arranges", "to", "send", "a", "file", "along", "with", "the", "e", "-", "mail", "message", ".", "File", "contents", "are", "read", "from", "a", "io", ".", "ReadCloser", ".", "The", "filename", "parameter", "is", "the", "resulting", "fil...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L235-L238
train
mailgun/mailgun-go
messages.go
AddInline
func (m *Message) AddInline(inline string) { m.inlines = append(m.inlines, inline) }
go
func (m *Message) AddInline(inline string) { m.inlines = append(m.inlines, inline) }
[ "func", "(", "m", "*", "Message", ")", "AddInline", "(", "inline", "string", ")", "{", "m", ".", "inlines", "=", "append", "(", "m", ".", "inlines", ",", "inline", ")", "\n", "}" ]
// AddInline arranges to send a file along with the e-mail message, but does so // in a way that its data remains "inline" with the rest of the message. This // can be used to send image or font data along with an HTML-encoded message body. // The attachment parameter is a filename, which must refer to a file which ac...
[ "AddInline", "arranges", "to", "send", "a", "file", "along", "with", "the", "e", "-", "mail", "message", "but", "does", "so", "in", "a", "way", "that", "its", "data", "remains", "inline", "with", "the", "rest", "of", "the", "message", ".", "This", "can...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L245-L247
train
mailgun/mailgun-go
messages.go
AddTag
func (m *Message) AddTag(tag ...string) error { if len(m.tags) >= MaxNumberOfTags { return fmt.Errorf("cannot add any new tags. Message tag limit (%b) reached", MaxNumberOfTags) } m.tags = append(m.tags, tag...) return nil }
go
func (m *Message) AddTag(tag ...string) error { if len(m.tags) >= MaxNumberOfTags { return fmt.Errorf("cannot add any new tags. Message tag limit (%b) reached", MaxNumberOfTags) } m.tags = append(m.tags, tag...) return nil }
[ "func", "(", "m", "*", "Message", ")", "AddTag", "(", "tag", "...", "string", ")", "error", "{", "if", "len", "(", "m", ".", "tags", ")", ">=", "MaxNumberOfTags", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "MaxNumberOfTags", ")", "\...
// AddTag attaches tags to the message. Tags are useful for metrics gathering and event tracking purposes. // Refer to the Mailgun documentation for further details.
[ "AddTag", "attaches", "tags", "to", "the", "message", ".", "Tags", "are", "useful", "for", "metrics", "gathering", "and", "event", "tracking", "purposes", ".", "Refer", "to", "the", "Mailgun", "documentation", "for", "further", "details", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L339-L346
train
mailgun/mailgun-go
messages.go
AddCampaign
func (m *Message) AddCampaign(campaign string) { m.campaigns = append(m.campaigns, campaign) }
go
func (m *Message) AddCampaign(campaign string) { m.campaigns = append(m.campaigns, campaign) }
[ "func", "(", "m", "*", "Message", ")", "AddCampaign", "(", "campaign", "string", ")", "{", "m", ".", "campaigns", "=", "append", "(", "m", ".", "campaigns", ",", "campaign", ")", "\n", "}" ]
// This feature is deprecated for new software.
[ "This", "feature", "is", "deprecated", "for", "new", "software", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L361-L363
train
mailgun/mailgun-go
messages.go
AddHeader
func (m *Message) AddHeader(header, value string) { if m.headers == nil { m.headers = make(map[string]string) } m.headers[header] = value }
go
func (m *Message) AddHeader(header, value string) { if m.headers == nil { m.headers = make(map[string]string) } m.headers[header] = value }
[ "func", "(", "m", "*", "Message", ")", "AddHeader", "(", "header", ",", "value", "string", ")", "{", "if", "m", ".", "headers", "==", "nil", "{", "m", ".", "headers", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", ...
// AddHeader allows you to send custom MIME headers with the message.
[ "AddHeader", "allows", "you", "to", "send", "custom", "MIME", "headers", "with", "the", "message", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L426-L431
train
mailgun/mailgun-go
messages.go
AddVariable
func (m *Message) AddVariable(variable string, value interface{}) error { if m.variables == nil { m.variables = make(map[string]string) } j, err := json.Marshal(value) if err != nil { return err } encoded := string(j) v, err := strconv.Unquote(encoded) if err != nil { v = encoded } m.variables[variab...
go
func (m *Message) AddVariable(variable string, value interface{}) error { if m.variables == nil { m.variables = make(map[string]string) } j, err := json.Marshal(value) if err != nil { return err } encoded := string(j) v, err := strconv.Unquote(encoded) if err != nil { v = encoded } m.variables[variab...
[ "func", "(", "m", "*", "Message", ")", "AddVariable", "(", "variable", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "if", "m", ".", "variables", "==", "nil", "{", "m", ".", "variables", "=", "make", "(", "map", "[", "string", "...
// AddVariable lets you associate a set of variables with messages you send, // which Mailgun can use to, in essence, complete form-mail. // Refer to the Mailgun documentation for more information.
[ "AddVariable", "lets", "you", "associate", "a", "set", "of", "variables", "with", "messages", "you", "send", "which", "Mailgun", "can", "use", "to", "in", "essence", "complete", "form", "-", "mail", ".", "Refer", "to", "the", "Mailgun", "documentation", "for...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L436-L454
train
mailgun/mailgun-go
messages.go
isValid
func isValid(m *Message) bool { if m == nil { return false } if !m.specific.isValid() { return false } if m.RecipientCount() == 0 { return false } if !validateStringList(m.tags, false) { return false } if !validateStringList(m.campaigns, false) || len(m.campaigns) > 3 { return false } return t...
go
func isValid(m *Message) bool { if m == nil { return false } if !m.specific.isValid() { return false } if m.RecipientCount() == 0 { return false } if !validateStringList(m.tags, false) { return false } if !validateStringList(m.campaigns, false) || len(m.campaigns) > 3 { return false } return t...
[ "func", "isValid", "(", "m", "*", "Message", ")", "bool", "{", "if", "m", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "m", ".", "specific", ".", "isValid", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "m", "...
// isValid returns true if, and only if, // a Message instance is sufficiently initialized to send via the Mailgun interface.
[ "isValid", "returns", "true", "if", "and", "only", "if", "a", "Message", "instance", "is", "sufficiently", "initialized", "to", "send", "via", "the", "Mailgun", "interface", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L636-L658
train
mailgun/mailgun-go
messages.go
validateStringList
func validateStringList(list []string, requireOne bool) bool { hasOne := false if list == nil { return !requireOne } else { for _, a := range list { if a == "" { return false } else { hasOne = hasOne || true } } } return hasOne }
go
func validateStringList(list []string, requireOne bool) bool { hasOne := false if list == nil { return !requireOne } else { for _, a := range list { if a == "" { return false } else { hasOne = hasOne || true } } } return hasOne }
[ "func", "validateStringList", "(", "list", "[", "]", "string", ",", "requireOne", "bool", ")", "bool", "{", "hasOne", ":=", "false", "\n\n", "if", "list", "==", "nil", "{", "return", "!", "requireOne", "\n", "}", "else", "{", "for", "_", ",", "a", ":...
// validateStringList returns true if, and only if, // a slice of strings exists AND all of its elements exist, // OR if the slice doesn't exist AND it's not required to exist. // The requireOne parameter indicates whether the list is required to exist.
[ "validateStringList", "returns", "true", "if", "and", "only", "if", "a", "slice", "of", "strings", "exists", "AND", "all", "of", "its", "elements", "exist", "OR", "if", "the", "slice", "doesn", "t", "exist", "AND", "it", "s", "not", "required", "to", "ex...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L693-L709
train
mailgun/mailgun-go
messages.go
ReSend
func (mg *MailgunImpl) ReSend(ctx context.Context, url string, recipients ...string) (string, string, error) { r := newHTTPRequest(url) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newFormDataPayload() if len(recipients) == 0 { return "", "", errors.New("must provide at least ...
go
func (mg *MailgunImpl) ReSend(ctx context.Context, url string, recipients ...string) (string, string, error) { r := newHTTPRequest(url) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newFormDataPayload() if len(recipients) == 0 { return "", "", errors.New("must provide at least ...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ReSend", "(", "ctx", "context", ".", "Context", ",", "url", "string", ",", "recipients", "...", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "url", ...
// Given a storage id resend the stored message to the specified recipients
[ "Given", "a", "storage", "id", "resend", "the", "stored", "message", "to", "the", "specified", "recipients" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L724-L746
train
mailgun/mailgun-go
messages.go
GetStoredMessageRaw
func (mg *MailgunImpl) GetStoredMessageRaw(ctx context.Context, url string) (StoredMessageRaw, error) { r := newHTTPRequest(url) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addHeader("Accept", "message/rfc2822") var response StoredMessageRaw err := getResponseFromJSON(ctx, r, &response)...
go
func (mg *MailgunImpl) GetStoredMessageRaw(ctx context.Context, url string) (StoredMessageRaw, error) { r := newHTTPRequest(url) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addHeader("Accept", "message/rfc2822") var response StoredMessageRaw err := getResponseFromJSON(ctx, r, &response)...
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetStoredMessageRaw", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "(", "StoredMessageRaw", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "url", ")", "\n", "r", ".", "setClient...
// GetStoredMessageRaw retrieves the raw MIME body of a received e-mail message. // Compared to GetStoredMessage, it gives access to the unparsed MIME body, and // thus delegates to the caller the required parsing.
[ "GetStoredMessageRaw", "retrieves", "the", "raw", "MIME", "body", "of", "a", "received", "e", "-", "mail", "message", ".", "Compared", "to", "GetStoredMessage", "it", "gives", "access", "to", "the", "unparsed", "MIME", "body", "and", "thus", "delegates", "to",...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L751-L760
train
mailgun/mailgun-go
messages.go
GetStoredAttachment
func (mg *MailgunImpl) GetStoredAttachment(ctx context.Context, url string) ([]byte, error) { r := newHTTPRequest(url) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addHeader("Accept", "message/rfc2822") response, err := makeGetRequest(ctx, r) return response.Data, err }
go
func (mg *MailgunImpl) GetStoredAttachment(ctx context.Context, url string) ([]byte, error) { r := newHTTPRequest(url) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addHeader("Accept", "message/rfc2822") response, err := makeGetRequest(ctx, r) return response.Data, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetStoredAttachment", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "url", ")", "\n", "r", ".", "setClie...
// GetStoredAttachment retrieves the raw MIME body of a received e-mail message attachment.
[ "GetStoredAttachment", "retrieves", "the", "raw", "MIME", "body", "of", "a", "received", "e", "-", "mail", "message", "attachment", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L773-L782
train
xtaci/smux
stream.go
newStream
func newStream(id uint32, frameSize int, sess *Session) *Stream { s := new(Stream) s.id = id s.chReadEvent = make(chan struct{}, 1) s.frameSize = frameSize s.sess = sess s.die = make(chan struct{}) return s }
go
func newStream(id uint32, frameSize int, sess *Session) *Stream { s := new(Stream) s.id = id s.chReadEvent = make(chan struct{}, 1) s.frameSize = frameSize s.sess = sess s.die = make(chan struct{}) return s }
[ "func", "newStream", "(", "id", "uint32", ",", "frameSize", "int", ",", "sess", "*", "Session", ")", "*", "Stream", "{", "s", ":=", "new", "(", "Stream", ")", "\n", "s", ".", "id", "=", "id", "\n", "s", ".", "chReadEvent", "=", "make", "(", "chan...
// newStream initiates a Stream struct
[ "newStream", "initiates", "a", "Stream", "struct" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/stream.go#L29-L37
train
xtaci/smux
stream.go
Write
func (s *Stream) Write(b []byte) (n int, err error) { var deadline <-chan time.Time if d, ok := s.writeDeadline.Load().(time.Time); ok && !d.IsZero() { timer := time.NewTimer(time.Until(d)) defer timer.Stop() deadline = timer.C } select { case <-s.die: return 0, errors.New(errBrokenPipe) default: } //...
go
func (s *Stream) Write(b []byte) (n int, err error) { var deadline <-chan time.Time if d, ok := s.writeDeadline.Load().(time.Time); ok && !d.IsZero() { timer := time.NewTimer(time.Until(d)) defer timer.Stop() deadline = timer.C } select { case <-s.die: return 0, errors.New(errBrokenPipe) default: } //...
[ "func", "(", "s", "*", "Stream", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "var", "deadline", "<-", "chan", "time", ".", "Time", "\n", "if", "d", ",", "ok", ":=", "s", ".", "writeDeadline", ...
// Write implements net.Conn
[ "Write", "implements", "net", ".", "Conn" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/stream.go#L93-L126
train
xtaci/smux
stream.go
Close
func (s *Stream) Close() error { s.dieLock.Lock() select { case <-s.die: s.dieLock.Unlock() return errors.New(errBrokenPipe) default: close(s.die) s.dieLock.Unlock() s.sess.streamClosed(s.id) _, err := s.sess.writeFrame(newFrame(cmdFIN, s.id)) return err } }
go
func (s *Stream) Close() error { s.dieLock.Lock() select { case <-s.die: s.dieLock.Unlock() return errors.New(errBrokenPipe) default: close(s.die) s.dieLock.Unlock() s.sess.streamClosed(s.id) _, err := s.sess.writeFrame(newFrame(cmdFIN, s.id)) return err } }
[ "func", "(", "s", "*", "Stream", ")", "Close", "(", ")", "error", "{", "s", ".", "dieLock", ".", "Lock", "(", ")", "\n\n", "select", "{", "case", "<-", "s", ".", "die", ":", "s", ".", "dieLock", ".", "Unlock", "(", ")", "\n", "return", "errors"...
// Close implements net.Conn
[ "Close", "implements", "net", ".", "Conn" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/stream.go#L129-L143
train
xtaci/smux
stream.go
sessionClose
func (s *Stream) sessionClose() { s.dieLock.Lock() defer s.dieLock.Unlock() select { case <-s.die: default: close(s.die) } }
go
func (s *Stream) sessionClose() { s.dieLock.Lock() defer s.dieLock.Unlock() select { case <-s.die: default: close(s.die) } }
[ "func", "(", "s", "*", "Stream", ")", "sessionClose", "(", ")", "{", "s", ".", "dieLock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "dieLock", ".", "Unlock", "(", ")", "\n\n", "select", "{", "case", "<-", "s", ".", "die", ":", "default", ...
// session closes the stream
[ "session", "closes", "the", "stream" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/stream.go#L181-L190
train
xtaci/smux
stream.go
RemoteAddr
func (s *Stream) RemoteAddr() net.Addr { if ts, ok := s.sess.conn.(interface { RemoteAddr() net.Addr }); ok { return ts.RemoteAddr() } return nil }
go
func (s *Stream) RemoteAddr() net.Addr { if ts, ok := s.sess.conn.(interface { RemoteAddr() net.Addr }); ok { return ts.RemoteAddr() } return nil }
[ "func", "(", "s", "*", "Stream", ")", "RemoteAddr", "(", ")", "net", ".", "Addr", "{", "if", "ts", ",", "ok", ":=", "s", ".", "sess", ".", "conn", ".", "(", "interface", "{", "RemoteAddr", "(", ")", "net", ".", "Addr", "\n", "}", ")", ";", "o...
// RemoteAddr satisfies net.Conn interface
[ "RemoteAddr", "satisfies", "net", ".", "Conn", "interface" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/stream.go#L203-L210
train
xtaci/smux
stream.go
pushBytes
func (s *Stream) pushBytes(buf []byte) (written int, err error) { s.bufferLock.Lock() s.buffers = append(s.buffers, buf) s.bufferLock.Unlock() return }
go
func (s *Stream) pushBytes(buf []byte) (written int, err error) { s.bufferLock.Lock() s.buffers = append(s.buffers, buf) s.bufferLock.Unlock() return }
[ "func", "(", "s", "*", "Stream", ")", "pushBytes", "(", "buf", "[", "]", "byte", ")", "(", "written", "int", ",", "err", "error", ")", "{", "s", ".", "bufferLock", ".", "Lock", "(", ")", "\n", "s", ".", "buffers", "=", "append", "(", "s", ".", ...
// pushBytes append buf to buffers
[ "pushBytes", "append", "buf", "to", "buffers" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/stream.go#L213-L218
train
xtaci/smux
session.go
Close
func (s *Session) Close() (err error) { s.dieLock.Lock() select { case <-s.die: s.dieLock.Unlock() return errors.New(errBrokenPipe) default: close(s.die) s.dieLock.Unlock() err = s.conn.Close() s.streamLock.Lock() for k := range s.streams { s.streams[k].sessionClose() } s.streamLock.Unlock() ...
go
func (s *Session) Close() (err error) { s.dieLock.Lock() select { case <-s.die: s.dieLock.Unlock() return errors.New(errBrokenPipe) default: close(s.die) s.dieLock.Unlock() err = s.conn.Close() s.streamLock.Lock() for k := range s.streams { s.streams[k].sessionClose() } s.streamLock.Unlock() ...
[ "func", "(", "s", "*", "Session", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "s", ".", "dieLock", ".", "Lock", "(", ")", "\n\n", "select", "{", "case", "<-", "s", ".", "die", ":", "s", ".", "dieLock", ".", "Unlock", "(", ")", "\n"...
// Close is used to close the session and all streams.
[ "Close", "is", "used", "to", "close", "the", "session", "and", "all", "streams", "." ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/session.go#L145-L163
train
xtaci/smux
session.go
streamClosed
func (s *Session) streamClosed(sid uint32) { s.streamLock.Lock() if n := s.streams[sid].recycleTokens(); n > 0 { // return remaining tokens to the bucket if atomic.AddInt32(&s.bucket, int32(n)) > 0 { s.notifyBucket() } } delete(s.streams, sid) s.streamLock.Unlock() }
go
func (s *Session) streamClosed(sid uint32) { s.streamLock.Lock() if n := s.streams[sid].recycleTokens(); n > 0 { // return remaining tokens to the bucket if atomic.AddInt32(&s.bucket, int32(n)) > 0 { s.notifyBucket() } } delete(s.streams, sid) s.streamLock.Unlock() }
[ "func", "(", "s", "*", "Session", ")", "streamClosed", "(", "sid", "uint32", ")", "{", "s", ".", "streamLock", ".", "Lock", "(", ")", "\n", "if", "n", ":=", "s", ".", "streams", "[", "sid", "]", ".", "recycleTokens", "(", ")", ";", "n", ">", "0...
// notify the session that a stream has closed
[ "notify", "the", "session", "that", "a", "stream", "has", "closed" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/session.go#L201-L210
train
xtaci/smux
session.go
returnTokens
func (s *Session) returnTokens(n int) { if atomic.AddInt32(&s.bucket, int32(n)) > 0 { s.notifyBucket() } }
go
func (s *Session) returnTokens(n int) { if atomic.AddInt32(&s.bucket, int32(n)) > 0 { s.notifyBucket() } }
[ "func", "(", "s", "*", "Session", ")", "returnTokens", "(", "n", "int", ")", "{", "if", "atomic", ".", "AddInt32", "(", "&", "s", ".", "bucket", ",", "int32", "(", "n", ")", ")", ">", "0", "{", "s", ".", "notifyBucket", "(", ")", "\n", "}", "...
// returnTokens is called by stream to return token after read
[ "returnTokens", "is", "called", "by", "stream", "to", "return", "token", "after", "read" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/session.go#L213-L217
train
xtaci/smux
session.go
recvLoop
func (s *Session) recvLoop() { var hdr rawHeader for { for atomic.LoadInt32(&s.bucket) <= 0 && !s.IsClosed() { select { case <-s.bucketNotify: case <-s.die: return } } // read header first if _, err := io.ReadFull(s.conn, hdr[:]); err == nil { atomic.StoreInt32(&s.dataReady, 1) if hdr....
go
func (s *Session) recvLoop() { var hdr rawHeader for { for atomic.LoadInt32(&s.bucket) <= 0 && !s.IsClosed() { select { case <-s.bucketNotify: case <-s.die: return } } // read header first if _, err := io.ReadFull(s.conn, hdr[:]); err == nil { atomic.StoreInt32(&s.dataReady, 1) if hdr....
[ "func", "(", "s", "*", "Session", ")", "recvLoop", "(", ")", "{", "var", "hdr", "rawHeader", "\n\n", "for", "{", "for", "atomic", ".", "LoadInt32", "(", "&", "s", ".", "bucket", ")", "<=", "0", "&&", "!", "s", ".", "IsClosed", "(", ")", "{", "s...
// recvLoop keeps on reading from underlying connection if tokens are available
[ "recvLoop", "keeps", "on", "reading", "from", "underlying", "connection", "if", "tokens", "are", "available" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/session.go#L220-L285
train
xtaci/smux
session.go
writeFrame
func (s *Session) writeFrame(f Frame) (n int, err error) { return s.writeFrameInternal(f, nil) }
go
func (s *Session) writeFrame(f Frame) (n int, err error) { return s.writeFrameInternal(f, nil) }
[ "func", "(", "s", "*", "Session", ")", "writeFrame", "(", "f", "Frame", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "s", ".", "writeFrameInternal", "(", "f", ",", "nil", ")", "\n", "}" ]
// writeFrame writes the frame to the underlying connection // and returns the number of bytes written if successful
[ "writeFrame", "writes", "the", "frame", "to", "the", "underlying", "connection", "and", "returns", "the", "number", "of", "bytes", "written", "if", "successful" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/session.go#L359-L361
train
xtaci/smux
session.go
writeFrameInternal
func (s *Session) writeFrameInternal(f Frame, deadline <-chan time.Time) (int, error) { req := writeRequest{ frame: f, result: make(chan writeResult, 1), } select { case <-s.die: return 0, errors.New(errBrokenPipe) case s.writes <- req: case <-deadline: return 0, errTimeout } select { case result := ...
go
func (s *Session) writeFrameInternal(f Frame, deadline <-chan time.Time) (int, error) { req := writeRequest{ frame: f, result: make(chan writeResult, 1), } select { case <-s.die: return 0, errors.New(errBrokenPipe) case s.writes <- req: case <-deadline: return 0, errTimeout } select { case result := ...
[ "func", "(", "s", "*", "Session", ")", "writeFrameInternal", "(", "f", "Frame", ",", "deadline", "<-", "chan", "time", ".", "Time", ")", "(", "int", ",", "error", ")", "{", "req", ":=", "writeRequest", "{", "frame", ":", "f", ",", "result", ":", "m...
// internal writeFrame version to support deadline used in keepalive
[ "internal", "writeFrame", "version", "to", "support", "deadline", "used", "in", "keepalive" ]
401b0da0596a2d1eb2d94aae5fa16973d6f50962
https://github.com/xtaci/smux/blob/401b0da0596a2d1eb2d94aae5fa16973d6f50962/session.go#L364-L385
train
dop251/goja
date_parser.go
skip
func skip(value, prefix string) (string, error) { for len(prefix) > 0 { if prefix[0] == ' ' { if len(value) > 0 && value[0] != ' ' { return value, errBad } prefix = cutspace(prefix) value = cutspace(value) continue } if len(value) == 0 || value[0] != prefix[0] { return value, errBad } p...
go
func skip(value, prefix string) (string, error) { for len(prefix) > 0 { if prefix[0] == ' ' { if len(value) > 0 && value[0] != ' ' { return value, errBad } prefix = cutspace(prefix) value = cutspace(value) continue } if len(value) == 0 || value[0] != prefix[0] { return value, errBad } p...
[ "func", "skip", "(", "value", ",", "prefix", "string", ")", "(", "string", ",", "error", ")", "{", "for", "len", "(", "prefix", ")", ">", "0", "{", "if", "prefix", "[", "0", "]", "==", "' '", "{", "if", "len", "(", "value", ")", ">", "0", "&&...
// skip removes the given prefix from value, // treating runs of space characters as equivalent.
[ "skip", "removes", "the", "given", "prefix", "from", "value", "treating", "runs", "of", "space", "characters", "as", "equivalent", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/date_parser.go#L649-L666
train
dop251/goja
date_parser.go
atoi
func atoi(s string) (x int, err error) { q, rem, err := signedLeadingInt(s) x = int(q) if err != nil || rem != "" { return 0, atoiError } return x, nil }
go
func atoi(s string) (x int, err error) { q, rem, err := signedLeadingInt(s) x = int(q) if err != nil || rem != "" { return 0, atoiError } return x, nil }
[ "func", "atoi", "(", "s", "string", ")", "(", "x", "int", ",", "err", "error", ")", "{", "q", ",", "rem", ",", "err", ":=", "signedLeadingInt", "(", "s", ")", "\n", "x", "=", "int", "(", "q", ")", "\n", "if", "err", "!=", "nil", "||", "rem", ...
// Duplicates functionality in strconv, but avoids dependency.
[ "Duplicates", "functionality", "in", "strconv", "but", "avoids", "dependency", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/date_parser.go#L672-L679
train
dop251/goja
date_parser.go
match
func match(s1, s2 string) bool { for i := 0; i < len(s1); i++ { c1 := s1[i] c2 := s2[i] if c1 != c2 { // Switch to lower-case; 'a'-'A' is known to be a single bit. c1 |= 'a' - 'A' c2 |= 'a' - 'A' if c1 != c2 || c1 < 'a' || c1 > 'z' { return false } } } return true }
go
func match(s1, s2 string) bool { for i := 0; i < len(s1); i++ { c1 := s1[i] c2 := s2[i] if c1 != c2 { // Switch to lower-case; 'a'-'A' is known to be a single bit. c1 |= 'a' - 'A' c2 |= 'a' - 'A' if c1 != c2 || c1 < 'a' || c1 > 'z' { return false } } } return true }
[ "func", "match", "(", "s1", ",", "s2", "string", ")", "bool", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "s1", ")", ";", "i", "++", "{", "c1", ":=", "s1", "[", "i", "]", "\n", "c2", ":=", "s2", "[", "i", "]", "\n", "if", "c1...
// match reports whether s1 and s2 match ignoring case. // It is assumed s1 and s2 are the same length.
[ "match", "reports", "whether", "s1", "and", "s2", "match", "ignoring", "case", ".", "It", "is", "assumed", "s1", "and", "s2", "are", "the", "same", "length", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/date_parser.go#L683-L697
train
dop251/goja
date_parser.go
parseTimeZone
func parseTimeZone(value string) (length int, ok bool) { if len(value) < 3 { return 0, false } // Special case 1: ChST and MeST are the only zones with a lower-case letter. if len(value) >= 4 && (value[:4] == "ChST" || value[:4] == "MeST") { return 4, true } // Special case 2: GMT may have an hour offset; tre...
go
func parseTimeZone(value string) (length int, ok bool) { if len(value) < 3 { return 0, false } // Special case 1: ChST and MeST are the only zones with a lower-case letter. if len(value) >= 4 && (value[:4] == "ChST" || value[:4] == "MeST") { return 4, true } // Special case 2: GMT may have an hour offset; tre...
[ "func", "parseTimeZone", "(", "value", "string", ")", "(", "length", "int", ",", "ok", "bool", ")", "{", "if", "len", "(", "value", ")", "<", "3", "{", "return", "0", ",", "false", "\n", "}", "\n", "// Special case 1: ChST and MeST are the only zones with a ...
// parseTimeZone parses a time zone string and returns its length. Time zones // are human-generated and unpredictable. We can't do precise error checking. // On the other hand, for a correct parse there must be a time zone at the // beginning of the string, so it's almost always true that there's one // there. We look...
[ "parseTimeZone", "parses", "a", "time", "zone", "string", "and", "returns", "its", "length", ".", "Time", "zones", "are", "human", "-", "generated", "and", "unpredictable", ".", "We", "can", "t", "do", "precise", "error", "checking", ".", "On", "the", "oth...
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/date_parser.go#L748-L792
train
dop251/goja
date_parser.go
parseGMT
func parseGMT(value string) int { value = value[3:] if len(value) == 0 { return 3 } return 3 + parseSignedOffset(value) }
go
func parseGMT(value string) int { value = value[3:] if len(value) == 0 { return 3 } return 3 + parseSignedOffset(value) }
[ "func", "parseGMT", "(", "value", "string", ")", "int", "{", "value", "=", "value", "[", "3", ":", "]", "\n", "if", "len", "(", "value", ")", "==", "0", "{", "return", "3", "\n", "}", "\n\n", "return", "3", "+", "parseSignedOffset", "(", "value", ...
// parseGMT parses a GMT time zone. The input string is known to start "GMT". // The function checks whether that is followed by a sign and a number in the // range -14 through 12 excluding zero.
[ "parseGMT", "parses", "a", "GMT", "time", "zone", ".", "The", "input", "string", "is", "known", "to", "start", "GMT", ".", "The", "function", "checks", "whether", "that", "is", "followed", "by", "a", "sign", "and", "a", "number", "in", "the", "range", ...
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/date_parser.go#L797-L804
train
dop251/goja
date_parser.go
startsWithLowerCase
func startsWithLowerCase(str string) bool { if len(str) == 0 { return false } c := str[0] return 'a' <= c && c <= 'z' }
go
func startsWithLowerCase(str string) bool { if len(str) == 0 { return false } c := str[0] return 'a' <= c && c <= 'z' }
[ "func", "startsWithLowerCase", "(", "str", "string", ")", "bool", "{", "if", "len", "(", "str", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "c", ":=", "str", "[", "0", "]", "\n", "return", "'a'", "<=", "c", "&&", "c", "<=", "'z'", ...
// startsWithLowerCase reports whether the string has a lower-case letter at the beginning. // Its purpose is to prevent matching strings like "Month" when looking for "Mon".
[ "startsWithLowerCase", "reports", "whether", "the", "string", "has", "a", "lower", "-", "case", "letter", "at", "the", "beginning", ".", "Its", "purpose", "is", "to", "prevent", "matching", "strings", "like", "Month", "when", "looking", "for", "Mon", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/date_parser.go#L854-L860
train
dop251/goja
object_goreflect.go
SetFieldNameMapper
func (r *Runtime) SetFieldNameMapper(mapper FieldNameMapper) { r.fieldNameMapper = mapper r.typeInfoCache = nil }
go
func (r *Runtime) SetFieldNameMapper(mapper FieldNameMapper) { r.fieldNameMapper = mapper r.typeInfoCache = nil }
[ "func", "(", "r", "*", "Runtime", ")", "SetFieldNameMapper", "(", "mapper", "FieldNameMapper", ")", "{", "r", ".", "fieldNameMapper", "=", "mapper", "\n", "r", ".", "typeInfoCache", "=", "nil", "\n", "}" ]
// Sets a custom field name mapper for Go types. It can be called at any time, however // the mapping for any given value is fixed at the point of creation. // Setting this to nil restores the default behaviour which is all exported fields and methods are mapped to their // original unchanged names.
[ "Sets", "a", "custom", "field", "name", "mapper", "for", "Go", "types", ".", "It", "can", "be", "called", "at", "any", "time", "however", "the", "mapping", "for", "any", "given", "value", "is", "fixed", "at", "the", "point", "of", "creation", ".", "Set...
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/object_goreflect.go#L515-L518
train
dop251/goja
builtin_global.go
parseInt
func parseInt(s string, base int) (Value, error) { var n int64 var err error var cutoff, maxVal int64 var sign bool i := 0 if len(s) < 1 { err = strconv.ErrSyntax goto Error } switch s[0] { case '-': sign = true s = s[1:] case '+': s = s[1:] } if len(s) < 1 { err = strconv.ErrSyntax goto Er...
go
func parseInt(s string, base int) (Value, error) { var n int64 var err error var cutoff, maxVal int64 var sign bool i := 0 if len(s) < 1 { err = strconv.ErrSyntax goto Error } switch s[0] { case '-': sign = true s = s[1:] case '+': s = s[1:] } if len(s) < 1 { err = strconv.ErrSyntax goto Er...
[ "func", "parseInt", "(", "s", "string", ",", "base", "int", ")", "(", "Value", ",", "error", ")", "{", "var", "n", "int64", "\n", "var", "err", "error", "\n", "var", "cutoff", ",", "maxVal", "int64", "\n", "var", "sign", "bool", "\n", "i", ":=", ...
// ECMAScript compatible version of strconv.ParseInt
[ "ECMAScript", "compatible", "version", "of", "strconv", ".", "ParseInt" ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/builtin_global.go#L275-L378
train
dop251/goja
string_ascii.go
strToInt
func strToInt(ss string) (int64, error) { if ss == "" { return 0, nil } if ss == "-0" { return 0, strconv.ErrSyntax } if len(ss) > 2 { switch ss[:2] { case "0x", "0X": i, _ := strconv.ParseInt(ss[2:], 16, 64) return i, nil case "0b", "0B": i, _ := strconv.ParseInt(ss[2:], 2, 64) return i, nil...
go
func strToInt(ss string) (int64, error) { if ss == "" { return 0, nil } if ss == "-0" { return 0, strconv.ErrSyntax } if len(ss) > 2 { switch ss[:2] { case "0x", "0X": i, _ := strconv.ParseInt(ss[2:], 16, 64) return i, nil case "0b", "0B": i, _ := strconv.ParseInt(ss[2:], 2, 64) return i, nil...
[ "func", "strToInt", "(", "ss", "string", ")", "(", "int64", ",", "error", ")", "{", "if", "ss", "==", "\"", "\"", "{", "return", "0", ",", "nil", "\n", "}", "\n", "if", "ss", "==", "\"", "\"", "{", "return", "0", ",", "strconv", ".", "ErrSyntax...
// ss must be trimmed
[ "ss", "must", "be", "trimmed" ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/string_ascii.go#L37-L58
train
dop251/goja
runtime.go
MustCompile
func MustCompile(name, src string, strict bool) *Program { prg, err := Compile(name, src, strict) if err != nil { panic(err) } return prg }
go
func MustCompile(name, src string, strict bool) *Program { prg, err := Compile(name, src, strict) if err != nil { panic(err) } return prg }
[ "func", "MustCompile", "(", "name", ",", "src", "string", ",", "strict", "bool", ")", "*", "Program", "{", "prg", ",", "err", ":=", "Compile", "(", "name", ",", "src", ",", "strict", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ...
// MustCompile is like Compile but panics if the code cannot be compiled. // It simplifies safe initialization of global variables holding compiled JavaScript code.
[ "MustCompile", "is", "like", "Compile", "but", "panics", "if", "the", "code", "cannot", "be", "compiled", ".", "It", "simplifies", "safe", "initialization", "of", "global", "variables", "holding", "compiled", "JavaScript", "code", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/runtime.go#L781-L788
train
dop251/goja
runtime.go
RunString
func (r *Runtime) RunString(str string) (Value, error) { return r.RunScript("", str) }
go
func (r *Runtime) RunString(str string) (Value, error) { return r.RunScript("", str) }
[ "func", "(", "r", "*", "Runtime", ")", "RunString", "(", "str", "string", ")", "(", "Value", ",", "error", ")", "{", "return", "r", ".", "RunScript", "(", "\"", "\"", ",", "str", ")", "\n", "}" ]
// RunString executes the given string in the global context.
[ "RunString", "executes", "the", "given", "string", "in", "the", "global", "context", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/runtime.go#L858-L860
train
dop251/goja
runtime.go
RunScript
func (r *Runtime) RunScript(name, src string) (Value, error) { p, err := Compile(name, src, false) if err != nil { return nil, err } return r.RunProgram(p) }
go
func (r *Runtime) RunScript(name, src string) (Value, error) { p, err := Compile(name, src, false) if err != nil { return nil, err } return r.RunProgram(p) }
[ "func", "(", "r", "*", "Runtime", ")", "RunScript", "(", "name", ",", "src", "string", ")", "(", "Value", ",", "error", ")", "{", "p", ",", "err", ":=", "Compile", "(", "name", ",", "src", ",", "false", ")", "\n\n", "if", "err", "!=", "nil", "{...
// RunScript executes the given string in the global context.
[ "RunScript", "executes", "the", "given", "string", "in", "the", "global", "context", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/runtime.go#L863-L871
train
dop251/goja
runtime.go
ExportTo
func (r *Runtime) ExportTo(v Value, target interface{}) error { tval := reflect.ValueOf(target) if tval.Kind() != reflect.Ptr || tval.IsNil() { return errors.New("target must be a non-nil pointer") } vv, err := r.toReflectValue(v, tval.Elem().Type()) if err != nil { return err } tval.Elem().Set(vv) return n...
go
func (r *Runtime) ExportTo(v Value, target interface{}) error { tval := reflect.ValueOf(target) if tval.Kind() != reflect.Ptr || tval.IsNil() { return errors.New("target must be a non-nil pointer") } vv, err := r.toReflectValue(v, tval.Elem().Type()) if err != nil { return err } tval.Elem().Set(vv) return n...
[ "func", "(", "r", "*", "Runtime", ")", "ExportTo", "(", "v", "Value", ",", "target", "interface", "{", "}", ")", "error", "{", "tval", ":=", "reflect", ".", "ValueOf", "(", "target", ")", "\n", "if", "tval", ".", "Kind", "(", ")", "!=", "reflect", ...
// ExportTo converts a JavaScript value into the specified Go value. The second parameter must be a non-nil pointer. // Returns error if conversion is not possible.
[ "ExportTo", "converts", "a", "JavaScript", "value", "into", "the", "specified", "Go", "value", ".", "The", "second", "parameter", "must", "be", "a", "non", "-", "nil", "pointer", ".", "Returns", "error", "if", "conversion", "is", "not", "possible", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/runtime.go#L1360-L1371
train
dop251/goja
runtime.go
Get
func (r *Runtime) Get(name string) Value { return r.globalObject.self.getStr(name) }
go
func (r *Runtime) Get(name string) Value { return r.globalObject.self.getStr(name) }
[ "func", "(", "r", "*", "Runtime", ")", "Get", "(", "name", "string", ")", "Value", "{", "return", "r", ".", "globalObject", ".", "self", ".", "getStr", "(", "name", ")", "\n", "}" ]
// Get the specified property of the global object.
[ "Get", "the", "specified", "property", "of", "the", "global", "object", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/runtime.go#L1385-L1387
train
dop251/goja
runtime.go
AssertFunction
func AssertFunction(v Value) (Callable, bool) { if obj, ok := v.(*Object); ok { if f, ok := obj.self.assertCallable(); ok { return func(this Value, args ...Value) (ret Value, err error) { defer func() { if x := recover(); x != nil { if ex, ok := x.(*InterruptedError); ok { err = ex } e...
go
func AssertFunction(v Value) (Callable, bool) { if obj, ok := v.(*Object); ok { if f, ok := obj.self.assertCallable(); ok { return func(this Value, args ...Value) (ret Value, err error) { defer func() { if x := recover(); x != nil { if ex, ok := x.(*InterruptedError); ok { err = ex } e...
[ "func", "AssertFunction", "(", "v", "Value", ")", "(", "Callable", ",", "bool", ")", "{", "if", "obj", ",", "ok", ":=", "v", ".", "(", "*", "Object", ")", ";", "ok", "{", "if", "f", ",", "ok", ":=", "obj", ".", "self", ".", "assertCallable", "(...
// AssertFunction checks if the Value is a function and returns a Callable.
[ "AssertFunction", "checks", "if", "the", "Value", "is", "a", "function", "and", "returns", "a", "Callable", "." ]
8d6ee3d1661108ff8433016620abb64dfa6d9937
https://github.com/dop251/goja/blob/8d6ee3d1661108ff8433016620abb64dfa6d9937/runtime.go#L1398-L1426
train
pelletier/go-toml
marshal.go
isPrimitive
func isPrimitive(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: return isPrimitive(mtype.Elem()) case reflect.Bool: return true case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return true case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflec...
go
func isPrimitive(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: return isPrimitive(mtype.Elem()) case reflect.Bool: return true case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return true case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflec...
[ "func", "isPrimitive", "(", "mtype", "reflect", ".", "Type", ")", "bool", "{", "switch", "mtype", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Ptr", ":", "return", "isPrimitive", "(", "mtype", ".", "Elem", "(", ")", ")", "\n", "case", "reflec...
// Check if the given marshal type maps to a Tree primitive
[ "Check", "if", "the", "given", "marshal", "type", "maps", "to", "a", "Tree", "primitive" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L73-L92
train
pelletier/go-toml
marshal.go
isTreeSlice
func isTreeSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Slice: return !isOtherSlice(mtype) default: return false } }
go
func isTreeSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Slice: return !isOtherSlice(mtype) default: return false } }
[ "func", "isTreeSlice", "(", "mtype", "reflect", ".", "Type", ")", "bool", "{", "switch", "mtype", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Slice", ":", "return", "!", "isOtherSlice", "(", "mtype", ")", "\n", "default", ":", "return", "false...
// Check if the given marshal type maps to a Tree slice
[ "Check", "if", "the", "given", "marshal", "type", "maps", "to", "a", "Tree", "slice" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L95-L102
train
pelletier/go-toml
marshal.go
isOtherSlice
func isOtherSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: return isOtherSlice(mtype.Elem()) case reflect.Slice: return isPrimitive(mtype.Elem()) || isOtherSlice(mtype.Elem()) default: return false } }
go
func isOtherSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: return isOtherSlice(mtype.Elem()) case reflect.Slice: return isPrimitive(mtype.Elem()) || isOtherSlice(mtype.Elem()) default: return false } }
[ "func", "isOtherSlice", "(", "mtype", "reflect", ".", "Type", ")", "bool", "{", "switch", "mtype", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Ptr", ":", "return", "isOtherSlice", "(", "mtype", ".", "Elem", "(", ")", ")", "\n", "case", "refl...
// Check if the given marshal type maps to a non-Tree slice
[ "Check", "if", "the", "given", "marshal", "type", "maps", "to", "a", "non", "-", "Tree", "slice" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L105-L114
train
pelletier/go-toml
marshal.go
isTree
func isTree(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Map: return true case reflect.Struct: return !isPrimitive(mtype) default: return false } }
go
func isTree(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Map: return true case reflect.Struct: return !isPrimitive(mtype) default: return false } }
[ "func", "isTree", "(", "mtype", "reflect", ".", "Type", ")", "bool", "{", "switch", "mtype", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Map", ":", "return", "true", "\n", "case", "reflect", ".", "Struct", ":", "return", "!", "isPrimitive", ...
// Check if the given marshal type maps to a Tree
[ "Check", "if", "the", "given", "marshal", "type", "maps", "to", "a", "Tree" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L117-L126
train
pelletier/go-toml
marshal.go
Encode
func (e *Encoder) Encode(v interface{}) error { b, err := e.marshal(v) if err != nil { return err } if _, err := e.w.Write(b); err != nil { return err } return nil }
go
func (e *Encoder) Encode(v interface{}) error { b, err := e.marshal(v) if err != nil { return err } if _, err := e.w.Write(b); err != nil { return err } return nil }
[ "func", "(", "e", "*", "Encoder", ")", "Encode", "(", "v", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "e", ".", "marshal", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "_", ...
// Encode writes the TOML encoding of v to the stream. // // See the documentation for Marshal for details.
[ "Encode", "writes", "the", "TOML", "encoding", "of", "v", "to", "the", "stream", ".", "See", "the", "documentation", "for", "Marshal", "for", "details", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L206-L215
train
pelletier/go-toml
marshal.go
QuoteMapKeys
func (e *Encoder) QuoteMapKeys(v bool) *Encoder { e.quoteMapKeys = v return e }
go
func (e *Encoder) QuoteMapKeys(v bool) *Encoder { e.quoteMapKeys = v return e }
[ "func", "(", "e", "*", "Encoder", ")", "QuoteMapKeys", "(", "v", "bool", ")", "*", "Encoder", "{", "e", ".", "quoteMapKeys", "=", "v", "\n", "return", "e", "\n", "}" ]
// QuoteMapKeys sets up the encoder to encode // maps with string type keys with quoted TOML keys. // // This relieves the character limitations on map keys.
[ "QuoteMapKeys", "sets", "up", "the", "encoder", "to", "encode", "maps", "with", "string", "type", "keys", "with", "quoted", "TOML", "keys", ".", "This", "relieves", "the", "character", "limitations", "on", "map", "keys", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L221-L224
train
pelletier/go-toml
marshal.go
Order
func (e *Encoder) Order(ord marshalOrder) *Encoder { e.order = ord return e }
go
func (e *Encoder) Order(ord marshalOrder) *Encoder { e.order = ord return e }
[ "func", "(", "e", "*", "Encoder", ")", "Order", "(", "ord", "marshalOrder", ")", "*", "Encoder", "{", "e", ".", "order", "=", "ord", "\n", "return", "e", "\n", "}" ]
// Order allows to change in which order fields will be written to the output stream.
[ "Order", "allows", "to", "change", "in", "which", "order", "fields", "will", "be", "written", "to", "the", "output", "stream", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L246-L249
train
pelletier/go-toml
marshal.go
SetTagComment
func (e *Encoder) SetTagComment(v string) *Encoder { e.comment = v return e }
go
func (e *Encoder) SetTagComment(v string) *Encoder { e.comment = v return e }
[ "func", "(", "e", "*", "Encoder", ")", "SetTagComment", "(", "v", "string", ")", "*", "Encoder", "{", "e", ".", "comment", "=", "v", "\n", "return", "e", "\n", "}" ]
// SetTagComment allows changing default tag "comment"
[ "SetTagComment", "allows", "changing", "default", "tag", "comment" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L258-L261
train
pelletier/go-toml
marshal.go
SetTagCommented
func (e *Encoder) SetTagCommented(v string) *Encoder { e.commented = v return e }
go
func (e *Encoder) SetTagCommented(v string) *Encoder { e.commented = v return e }
[ "func", "(", "e", "*", "Encoder", ")", "SetTagCommented", "(", "v", "string", ")", "*", "Encoder", "{", "e", ".", "commented", "=", "v", "\n", "return", "e", "\n", "}" ]
// SetTagCommented allows changing default tag "commented"
[ "SetTagCommented", "allows", "changing", "default", "tag", "commented" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L264-L267
train
pelletier/go-toml
marshal.go
SetTagMultiline
func (e *Encoder) SetTagMultiline(v string) *Encoder { e.multiline = v return e }
go
func (e *Encoder) SetTagMultiline(v string) *Encoder { e.multiline = v return e }
[ "func", "(", "e", "*", "Encoder", ")", "SetTagMultiline", "(", "v", "string", ")", "*", "Encoder", "{", "e", ".", "multiline", "=", "v", "\n", "return", "e", "\n", "}" ]
// SetTagMultiline allows changing default tag "multiline"
[ "SetTagMultiline", "allows", "changing", "default", "tag", "multiline" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L270-L273
train
pelletier/go-toml
marshal.go
nextTree
func (e *Encoder) nextTree() *Tree { return newTreeWithPosition(Position{Line: e.line, Col: 1}) }
go
func (e *Encoder) nextTree() *Tree { return newTreeWithPosition(Position{Line: e.line, Col: 1}) }
[ "func", "(", "e", "*", "Encoder", ")", "nextTree", "(", ")", "*", "Tree", "{", "return", "newTreeWithPosition", "(", "Position", "{", "Line", ":", "e", ".", "line", ",", "Col", ":", "1", "}", ")", "\n", "}" ]
// Create next tree with a position based on Encoder.line
[ "Create", "next", "tree", "with", "a", "position", "based", "on", "Encoder", ".", "line" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L304-L306
train
pelletier/go-toml
marshal.go
valueToTree
func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { if mtype.Kind() == reflect.Ptr { return e.valueToTree(mtype.Elem(), mval.Elem()) } tval := e.nextTree() switch mtype.Kind() { case reflect.Struct: for i := 0; i < mtype.NumField(); i++ { mtypef, mvalf := mtype.Field(i), m...
go
func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { if mtype.Kind() == reflect.Ptr { return e.valueToTree(mtype.Elem(), mval.Elem()) } tval := e.nextTree() switch mtype.Kind() { case reflect.Struct: for i := 0; i < mtype.NumField(); i++ { mtypef, mvalf := mtype.Field(i), m...
[ "func", "(", "e", "*", "Encoder", ")", "valueToTree", "(", "mtype", "reflect", ".", "Type", ",", "mval", "reflect", ".", "Value", ")", "(", "*", "Tree", ",", "error", ")", "{", "if", "mtype", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{...
// Convert given marshal struct or map value to toml tree
[ "Convert", "given", "marshal", "struct", "or", "map", "value", "to", "toml", "tree" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L309-L370
train
pelletier/go-toml
marshal.go
valueToTreeSlice
func (e *Encoder) valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { tval := make([]*Tree, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := e.valueToTree(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } tval[i] = val } return tval, nil }
go
func (e *Encoder) valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { tval := make([]*Tree, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := e.valueToTree(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } tval[i] = val } return tval, nil }
[ "func", "(", "e", "*", "Encoder", ")", "valueToTreeSlice", "(", "mtype", "reflect", ".", "Type", ",", "mval", "reflect", ".", "Value", ")", "(", "[", "]", "*", "Tree", ",", "error", ")", "{", "tval", ":=", "make", "(", "[", "]", "*", "Tree", ",",...
// Convert given marshal slice to slice of Toml trees
[ "Convert", "given", "marshal", "slice", "to", "slice", "of", "Toml", "trees" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L373-L383
train
pelletier/go-toml
marshal.go
valueToOtherSlice
func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) { tval := make([]interface{}, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := e.valueToToml(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } tval[i] = val } return tval, ni...
go
func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) { tval := make([]interface{}, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := e.valueToToml(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } tval[i] = val } return tval, ni...
[ "func", "(", "e", "*", "Encoder", ")", "valueToOtherSlice", "(", "mtype", "reflect", ".", "Type", ",", "mval", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "tval", ":=", "make", "(", "[", "]", "interface", "{", ...
// Convert given marshal slice to slice of toml values
[ "Convert", "given", "marshal", "slice", "to", "slice", "of", "toml", "values" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L386-L396
train
pelletier/go-toml
marshal.go
valueToToml
func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { e.line++ if mtype.Kind() == reflect.Ptr { return e.valueToToml(mtype.Elem(), mval.Elem()) } switch { case isCustomMarshaler(mtype): return callCustomMarshaler(mval) case isTree(mtype): return e.valueToTree(mtype, mv...
go
func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { e.line++ if mtype.Kind() == reflect.Ptr { return e.valueToToml(mtype.Elem(), mval.Elem()) } switch { case isCustomMarshaler(mtype): return callCustomMarshaler(mval) case isTree(mtype): return e.valueToTree(mtype, mv...
[ "func", "(", "e", "*", "Encoder", ")", "valueToToml", "(", "mtype", "reflect", ".", "Type", ",", "mval", "reflect", ".", "Value", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "e", ".", "line", "++", "\n", "if", "mtype", ".", "Kind", "...
// Convert given marshal value to toml value
[ "Convert", "given", "marshal", "value", "to", "toml", "value" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L399-L434
train
pelletier/go-toml
marshal.go
Unmarshal
func (t *Tree) Unmarshal(v interface{}) error { d := Decoder{tval: t, tagName: tagFieldName} return d.unmarshal(v) }
go
func (t *Tree) Unmarshal(v interface{}) error { d := Decoder{tval: t, tagName: tagFieldName} return d.unmarshal(v) }
[ "func", "(", "t", "*", "Tree", ")", "Unmarshal", "(", "v", "interface", "{", "}", ")", "error", "{", "d", ":=", "Decoder", "{", "tval", ":", "t", ",", "tagName", ":", "tagFieldName", "}", "\n", "return", "d", ".", "unmarshal", "(", "v", ")", "\n"...
// Unmarshal attempts to unmarshal the Tree into a Go struct pointed by v. // Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for // sub-structs, and only definite types can be unmarshaled.
[ "Unmarshal", "attempts", "to", "unmarshal", "the", "Tree", "into", "a", "Go", "struct", "pointed", "by", "v", ".", "Neither", "Unmarshaler", "interfaces", "nor", "UnmarshalTOML", "functions", "are", "supported", "for", "sub", "-", "structs", "and", "only", "de...
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L439-L442
train
pelletier/go-toml
marshal.go
Decode
func (d *Decoder) Decode(v interface{}) error { var err error d.tval, err = LoadReader(d.r) if err != nil { return err } return d.unmarshal(v) }
go
func (d *Decoder) Decode(v interface{}) error { var err error d.tval, err = LoadReader(d.r) if err != nil { return err } return d.unmarshal(v) }
[ "func", "(", "d", "*", "Decoder", ")", "Decode", "(", "v", "interface", "{", "}", ")", "error", "{", "var", "err", "error", "\n", "d", ".", "tval", ",", "err", "=", "LoadReader", "(", "d", ".", "r", ")", "\n", "if", "err", "!=", "nil", "{", "...
// Decode reads a TOML-encoded value from it's input // and unmarshals it in the value pointed at by v. // // See the documentation for Marshal for details.
[ "Decode", "reads", "a", "TOML", "-", "encoded", "value", "from", "it", "s", "input", "and", "unmarshals", "it", "in", "the", "value", "pointed", "at", "by", "v", ".", "See", "the", "documentation", "for", "Marshal", "for", "details", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L500-L507
train
pelletier/go-toml
marshal.go
valueFromOtherSlice
func (d *Decoder) valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { val, err := d.valueFromToml(mtype.Elem(), tval[i]) if err != nil { return mval, err } mval.Index(i).Set(val) } ret...
go
func (d *Decoder) valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { val, err := d.valueFromToml(mtype.Elem(), tval[i]) if err != nil { return mval, err } mval.Index(i).Set(val) } ret...
[ "func", "(", "d", "*", "Decoder", ")", "valueFromOtherSlice", "(", "mtype", "reflect", ".", "Type", ",", "tval", "[", "]", "interface", "{", "}", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "mval", ":=", "reflect", ".", "MakeSlice", "(...
// Convert toml value to marshal primitive slice, using marshal type
[ "Convert", "toml", "value", "to", "marshal", "primitive", "slice", "using", "marshal", "type" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/marshal.go#L638-L648
train
pelletier/go-toml
lexer.go
read
func (l *tomlLexer) read() rune { r := l.peek() if r == '\n' { l.endbufferLine++ l.endbufferCol = 1 } else { l.endbufferCol++ } l.inputIdx++ return r }
go
func (l *tomlLexer) read() rune { r := l.peek() if r == '\n' { l.endbufferLine++ l.endbufferCol = 1 } else { l.endbufferCol++ } l.inputIdx++ return r }
[ "func", "(", "l", "*", "tomlLexer", ")", "read", "(", ")", "rune", "{", "r", ":=", "l", ".", "peek", "(", ")", "\n", "if", "r", "==", "'\\n'", "{", "l", ".", "endbufferLine", "++", "\n", "l", ".", "endbufferCol", "=", "1", "\n", "}", "else", ...
// Basic read operations on input
[ "Basic", "read", "operations", "on", "input" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/lexer.go#L38-L48
train
pelletier/go-toml
lexer.go
lexKey
func (l *tomlLexer) lexKey() tomlLexStateFn { growingString := "" for r := l.peek(); isKeyChar(r) || r == '\n' || r == '\r'; r = l.peek() { if r == '"' { l.next() str, err := l.lexStringAsString(`"`, false, true) if err != nil { return l.errorf(err.Error()) } growingString += "\"" + str + "\"" ...
go
func (l *tomlLexer) lexKey() tomlLexStateFn { growingString := "" for r := l.peek(); isKeyChar(r) || r == '\n' || r == '\r'; r = l.peek() { if r == '"' { l.next() str, err := l.lexStringAsString(`"`, false, true) if err != nil { return l.errorf(err.Error()) } growingString += "\"" + str + "\"" ...
[ "func", "(", "l", "*", "tomlLexer", ")", "lexKey", "(", ")", "tomlLexStateFn", "{", "growingString", ":=", "\"", "\"", "\n\n", "for", "r", ":=", "l", ".", "peek", "(", ")", ";", "isKeyChar", "(", "r", ")", "||", "r", "==", "'\\n'", "||", "r", "==...
// Parse the key and emits its value without escape sequences. // bare keys, basic string keys and literal string keys are supported.
[ "Parse", "the", "key", "and", "emits", "its", "value", "without", "escape", "sequences", ".", "bare", "keys", "basic", "string", "keys", "and", "literal", "string", "keys", "are", "supported", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/lexer.go#L302-L338
train
pelletier/go-toml
lexer.go
lexStringAsString
func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, acceptNewLines bool) (string, error) { growingString := "" if discardLeadingNewLine { if l.follow("\r\n") { l.skip() l.skip() } else if l.peek() == '\n' { l.skip() } } for { if l.follow(terminator) { return growing...
go
func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, acceptNewLines bool) (string, error) { growingString := "" if discardLeadingNewLine { if l.follow("\r\n") { l.skip() l.skip() } else if l.peek() == '\n' { l.skip() } } for { if l.follow(terminator) { return growing...
[ "func", "(", "l", "*", "tomlLexer", ")", "lexStringAsString", "(", "terminator", "string", ",", "discardLeadingNewLine", ",", "acceptNewLines", "bool", ")", "(", "string", ",", "error", ")", "{", "growingString", ":=", "\"", "\"", "\n\n", "if", "discardLeading...
// Lex a string and return the results as a string. // Terminator is the substring indicating the end of the token. // The resulting string does not include the terminator.
[ "Lex", "a", "string", "and", "return", "the", "results", "as", "a", "string", ".", "Terminator", "is", "the", "substring", "indicating", "the", "end", "of", "the", "token", ".", "The", "resulting", "string", "does", "not", "include", "the", "terminator", "...
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/lexer.go#L414-L520
train
pelletier/go-toml
lexer.go
lexInsideTableArrayKey
func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn { for r := l.peek(); r != eof; r = l.peek() { switch r { case ']': if l.currentTokenStop > l.currentTokenStart { l.emit(tokenKeyGroupArray) } l.next() if l.peek() != ']' { break } l.next() l.emit(tokenDoubleRightBracket) re...
go
func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn { for r := l.peek(); r != eof; r = l.peek() { switch r { case ']': if l.currentTokenStop > l.currentTokenStart { l.emit(tokenKeyGroupArray) } l.next() if l.peek() != ']' { break } l.next() l.emit(tokenDoubleRightBracket) re...
[ "func", "(", "l", "*", "tomlLexer", ")", "lexInsideTableArrayKey", "(", ")", "tomlLexStateFn", "{", "for", "r", ":=", "l", ".", "peek", "(", ")", ";", "r", "!=", "eof", ";", "r", "=", "l", ".", "peek", "(", ")", "{", "switch", "r", "{", "case", ...
// Parse the key till "]]", but only bare keys are supported
[ "Parse", "the", "key", "till", "]]", "but", "only", "bare", "keys", "are", "supported" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/lexer.go#L564-L585
train
pelletier/go-toml
lexer.go
lexInsideTableKey
func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn { for r := l.peek(); r != eof; r = l.peek() { switch r { case ']': if l.currentTokenStop > l.currentTokenStart { l.emit(tokenKeyGroup) } l.next() l.emit(tokenRightBracket) return l.lexVoid case '[': return l.errorf("table key cannot con...
go
func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn { for r := l.peek(); r != eof; r = l.peek() { switch r { case ']': if l.currentTokenStop > l.currentTokenStart { l.emit(tokenKeyGroup) } l.next() l.emit(tokenRightBracket) return l.lexVoid case '[': return l.errorf("table key cannot con...
[ "func", "(", "l", "*", "tomlLexer", ")", "lexInsideTableKey", "(", ")", "tomlLexStateFn", "{", "for", "r", ":=", "l", ".", "peek", "(", ")", ";", "r", "!=", "eof", ";", "r", "=", "l", ".", "peek", "(", ")", "{", "switch", "r", "{", "case", "']'...
// Parse the key till "]" but only bare keys are supported
[ "Parse", "the", "key", "till", "]", "but", "only", "bare", "keys", "are", "supported" ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/lexer.go#L588-L605
train
pelletier/go-toml
toml.go
TreeFromMap
func TreeFromMap(m map[string]interface{}) (*Tree, error) { result, err := toTree(m) if err != nil { return nil, err } return result.(*Tree), nil }
go
func TreeFromMap(m map[string]interface{}) (*Tree, error) { result, err := toTree(m) if err != nil { return nil, err } return result.(*Tree), nil }
[ "func", "TreeFromMap", "(", "m", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "Tree", ",", "error", ")", "{", "result", ",", "err", ":=", "toTree", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "e...
// TreeFromMap initializes a new Tree object using the given map.
[ "TreeFromMap", "initializes", "a", "new", "Tree", "object", "using", "the", "given", "map", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/toml.go#L41-L47
train
pelletier/go-toml
toml.go
Has
func (t *Tree) Has(key string) bool { if key == "" { return false } return t.HasPath(strings.Split(key, ".")) }
go
func (t *Tree) Has(key string) bool { if key == "" { return false } return t.HasPath(strings.Split(key, ".")) }
[ "func", "(", "t", "*", "Tree", ")", "Has", "(", "key", "string", ")", "bool", "{", "if", "key", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "return", "t", ".", "HasPath", "(", "strings", ".", "Split", "(", "key", ",", "\"", "\"",...
// Has returns a boolean indicating if the given key exists.
[ "Has", "returns", "a", "boolean", "indicating", "if", "the", "given", "key", "exists", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/toml.go#L55-L60
train
pelletier/go-toml
toml.go
HasPath
func (t *Tree) HasPath(keys []string) bool { return t.GetPath(keys) != nil }
go
func (t *Tree) HasPath(keys []string) bool { return t.GetPath(keys) != nil }
[ "func", "(", "t", "*", "Tree", ")", "HasPath", "(", "keys", "[", "]", "string", ")", "bool", "{", "return", "t", ".", "GetPath", "(", "keys", ")", "!=", "nil", "\n", "}" ]
// HasPath returns true if the given path of keys exists, false otherwise.
[ "HasPath", "returns", "true", "if", "the", "given", "path", "of", "keys", "exists", "false", "otherwise", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/toml.go#L63-L65
train
pelletier/go-toml
toml.go
GetPath
func (t *Tree) GetPath(keys []string) interface{} { if len(keys) == 0 { return t } subtree := t for _, intermediateKey := range keys[:len(keys)-1] { value, exists := subtree.values[intermediateKey] if !exists { return nil } switch node := value.(type) { case *Tree: subtree = node case []*Tree: ...
go
func (t *Tree) GetPath(keys []string) interface{} { if len(keys) == 0 { return t } subtree := t for _, intermediateKey := range keys[:len(keys)-1] { value, exists := subtree.values[intermediateKey] if !exists { return nil } switch node := value.(type) { case *Tree: subtree = node case []*Tree: ...
[ "func", "(", "t", "*", "Tree", ")", "GetPath", "(", "keys", "[", "]", "string", ")", "interface", "{", "}", "{", "if", "len", "(", "keys", ")", "==", "0", "{", "return", "t", "\n", "}", "\n", "subtree", ":=", "t", "\n", "for", "_", ",", "inte...
// GetPath returns the element in the tree indicated by 'keys'. // If keys is of length zero, the current tree is returned.
[ "GetPath", "returns", "the", "element", "in", "the", "tree", "indicated", "by", "keys", ".", "If", "keys", "is", "of", "length", "zero", "the", "current", "tree", "is", "returned", "." ]
728039f679cbcd4f6a54e080d2219a4c4928c546
https://github.com/pelletier/go-toml/blob/728039f679cbcd4f6a54e080d2219a4c4928c546/toml.go#L92-L122
train