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
DataDog/datadog-go
statsd/statsd.go
send
func (c *Client) send(name string, value interface{}, suffix []byte, tags []string, rate float64) error { if c == nil { return fmt.Errorf("Client is nil") } if rate < 1 && rand.Float64() > rate { return nil } data := c.format(name, value, suffix, tags, rate) return c.sendMsg(data) }
go
func (c *Client) send(name string, value interface{}, suffix []byte, tags []string, rate float64) error { if c == nil { return fmt.Errorf("Client is nil") } if rate < 1 && rand.Float64() > rate { return nil } data := c.format(name, value, suffix, tags, rate) return c.sendMsg(data) }
[ "func", "(", "c", "*", "Client", ")", "send", "(", "name", "string", ",", "value", "interface", "{", "}", ",", "suffix", "[", "]", "byte", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "if", "c", "==", "nil", "{", ...
// send handles sampling and sends the message over UDP. It also adds global namespace prefixes and tags.
[ "send", "handles", "sampling", "and", "sends", "the", "message", "over", "UDP", ".", "It", "also", "adds", "global", "namespace", "prefixes", "and", "tags", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L362-L371
train
DataDog/datadog-go
statsd/statsd.go
Gauge
func (c *Client) Gauge(name string, value float64, tags []string, rate float64) error { return c.send(name, value, gaugeSuffix, tags, rate) }
go
func (c *Client) Gauge(name string, value float64, tags []string, rate float64) error { return c.send(name, value, gaugeSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Gauge", "(", "name", "string", ",", "value", "float64", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "value", ",", "gaugeSuffix", ",...
// Gauge measures the value of a metric at a particular time.
[ "Gauge", "measures", "the", "value", "of", "a", "metric", "at", "a", "particular", "time", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L374-L376
train
DataDog/datadog-go
statsd/statsd.go
Count
func (c *Client) Count(name string, value int64, tags []string, rate float64) error { return c.send(name, value, countSuffix, tags, rate) }
go
func (c *Client) Count(name string, value int64, tags []string, rate float64) error { return c.send(name, value, countSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Count", "(", "name", "string", ",", "value", "int64", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "value", ",", "countSuffix", ",",...
// Count tracks how many times something happened per second.
[ "Count", "tracks", "how", "many", "times", "something", "happened", "per", "second", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L379-L381
train
DataDog/datadog-go
statsd/statsd.go
Histogram
func (c *Client) Histogram(name string, value float64, tags []string, rate float64) error { return c.send(name, value, histogramSuffix, tags, rate) }
go
func (c *Client) Histogram(name string, value float64, tags []string, rate float64) error { return c.send(name, value, histogramSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Histogram", "(", "name", "string", ",", "value", "float64", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "value", ",", "histogramSuffi...
// Histogram tracks the statistical distribution of a set of values on each host.
[ "Histogram", "tracks", "the", "statistical", "distribution", "of", "a", "set", "of", "values", "on", "each", "host", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L384-L386
train
DataDog/datadog-go
statsd/statsd.go
Distribution
func (c *Client) Distribution(name string, value float64, tags []string, rate float64) error { return c.send(name, value, distributionSuffix, tags, rate) }
go
func (c *Client) Distribution(name string, value float64, tags []string, rate float64) error { return c.send(name, value, distributionSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Distribution", "(", "name", "string", ",", "value", "float64", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "value", ",", "distributio...
// Distribution tracks the statistical distribution of a set of values across your infrastructure.
[ "Distribution", "tracks", "the", "statistical", "distribution", "of", "a", "set", "of", "values", "across", "your", "infrastructure", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L389-L391
train
DataDog/datadog-go
statsd/statsd.go
Decr
func (c *Client) Decr(name string, tags []string, rate float64) error { return c.send(name, nil, decrSuffix, tags, rate) }
go
func (c *Client) Decr(name string, tags []string, rate float64) error { return c.send(name, nil, decrSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Decr", "(", "name", "string", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "nil", ",", "decrSuffix", ",", "tags", ",", "rate", ")"...
// Decr is just Count of -1
[ "Decr", "is", "just", "Count", "of", "-", "1" ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L394-L396
train
DataDog/datadog-go
statsd/statsd.go
Incr
func (c *Client) Incr(name string, tags []string, rate float64) error { return c.send(name, nil, incrSuffix, tags, rate) }
go
func (c *Client) Incr(name string, tags []string, rate float64) error { return c.send(name, nil, incrSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Incr", "(", "name", "string", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "nil", ",", "incrSuffix", ",", "tags", ",", "rate", ")"...
// Incr is just Count of 1
[ "Incr", "is", "just", "Count", "of", "1" ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L399-L401
train
DataDog/datadog-go
statsd/statsd.go
Set
func (c *Client) Set(name string, value string, tags []string, rate float64) error { return c.send(name, value, setSuffix, tags, rate) }
go
func (c *Client) Set(name string, value string, tags []string, rate float64) error { return c.send(name, value, setSuffix, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Set", "(", "name", "string", ",", "value", "string", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "send", "(", "name", ",", "value", ",", "setSuffix", ",", ...
// Set counts the number of unique elements in a group.
[ "Set", "counts", "the", "number", "of", "unique", "elements", "in", "a", "group", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L404-L406
train
DataDog/datadog-go
statsd/statsd.go
Timing
func (c *Client) Timing(name string, value time.Duration, tags []string, rate float64) error { return c.TimeInMilliseconds(name, value.Seconds()*1000, tags, rate) }
go
func (c *Client) Timing(name string, value time.Duration, tags []string, rate float64) error { return c.TimeInMilliseconds(name, value.Seconds()*1000, tags, rate) }
[ "func", "(", "c", "*", "Client", ")", "Timing", "(", "name", "string", ",", "value", "time", ".", "Duration", ",", "tags", "[", "]", "string", ",", "rate", "float64", ")", "error", "{", "return", "c", ".", "TimeInMilliseconds", "(", "name", ",", "val...
// Timing sends timing information, it is an alias for TimeInMilliseconds
[ "Timing", "sends", "timing", "information", "it", "is", "an", "alias", "for", "TimeInMilliseconds" ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L409-L411
train
DataDog/datadog-go
statsd/statsd.go
Event
func (c *Client) Event(e *Event) error { if c == nil { return fmt.Errorf("Client is nil") } stat, err := e.Encode(c.Tags...) if err != nil { return err } return c.sendMsg([]byte(stat)) }
go
func (c *Client) Event(e *Event) error { if c == nil { return fmt.Errorf("Client is nil") } stat, err := e.Encode(c.Tags...) if err != nil { return err } return c.sendMsg([]byte(stat)) }
[ "func", "(", "c", "*", "Client", ")", "Event", "(", "e", "*", "Event", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "stat", ",", "err", ":=", "e", ".", "Encode", "(", ...
// Event sends the provided Event.
[ "Event", "sends", "the", "provided", "Event", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L420-L429
train
DataDog/datadog-go
statsd/statsd.go
SimpleEvent
func (c *Client) SimpleEvent(title, text string) error { e := NewEvent(title, text) return c.Event(e) }
go
func (c *Client) SimpleEvent(title, text string) error { e := NewEvent(title, text) return c.Event(e) }
[ "func", "(", "c", "*", "Client", ")", "SimpleEvent", "(", "title", ",", "text", "string", ")", "error", "{", "e", ":=", "NewEvent", "(", "title", ",", "text", ")", "\n", "return", "c", ".", "Event", "(", "e", ")", "\n", "}" ]
// SimpleEvent sends an event with the provided title and text.
[ "SimpleEvent", "sends", "an", "event", "with", "the", "provided", "title", "and", "text", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L432-L435
train
DataDog/datadog-go
statsd/statsd.go
ServiceCheck
func (c *Client) ServiceCheck(sc *ServiceCheck) error { if c == nil { return fmt.Errorf("Client is nil") } stat, err := sc.Encode(c.Tags...) if err != nil { return err } return c.sendMsg([]byte(stat)) }
go
func (c *Client) ServiceCheck(sc *ServiceCheck) error { if c == nil { return fmt.Errorf("Client is nil") } stat, err := sc.Encode(c.Tags...) if err != nil { return err } return c.sendMsg([]byte(stat)) }
[ "func", "(", "c", "*", "Client", ")", "ServiceCheck", "(", "sc", "*", "ServiceCheck", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "stat", ",", "err", ":=", "sc", ".", "E...
// ServiceCheck sends the provided ServiceCheck.
[ "ServiceCheck", "sends", "the", "provided", "ServiceCheck", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L438-L447
train
DataDog/datadog-go
statsd/statsd.go
SimpleServiceCheck
func (c *Client) SimpleServiceCheck(name string, status ServiceCheckStatus) error { sc := NewServiceCheck(name, status) return c.ServiceCheck(sc) }
go
func (c *Client) SimpleServiceCheck(name string, status ServiceCheckStatus) error { sc := NewServiceCheck(name, status) return c.ServiceCheck(sc) }
[ "func", "(", "c", "*", "Client", ")", "SimpleServiceCheck", "(", "name", "string", ",", "status", "ServiceCheckStatus", ")", "error", "{", "sc", ":=", "NewServiceCheck", "(", "name", ",", "status", ")", "\n", "return", "c", ".", "ServiceCheck", "(", "sc", ...
// SimpleServiceCheck sends an serviceCheck with the provided name and status.
[ "SimpleServiceCheck", "sends", "an", "serviceCheck", "with", "the", "provided", "name", "and", "status", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L450-L453
train
DataDog/datadog-go
statsd/statsd.go
Close
func (c *Client) Close() error { if c == nil { return fmt.Errorf("Client is nil") } select { case c.stop <- struct{}{}: default: } // if this client is buffered, flush before closing the writer if c.bufferLength > 0 { if err := c.Flush(); err != nil { return err } } return c.writer.Close() }
go
func (c *Client) Close() error { if c == nil { return fmt.Errorf("Client is nil") } select { case c.stop <- struct{}{}: default: } // if this client is buffered, flush before closing the writer if c.bufferLength > 0 { if err := c.Flush(); err != nil { return err } } return c.writer.Close() }
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "select", "{", "case", "c", ".", "stop", "<-", "struct", "{", "}", "{",...
// Close the client connection.
[ "Close", "the", "client", "connection", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L456-L473
train
DataDog/datadog-go
statsd/statsd.go
NewEvent
func NewEvent(title, text string) *Event { return &Event{ Title: title, Text: text, } }
go
func NewEvent(title, text string) *Event { return &Event{ Title: title, Text: text, } }
[ "func", "NewEvent", "(", "title", ",", "text", "string", ")", "*", "Event", "{", "return", "&", "Event", "{", "Title", ":", "title", ",", "Text", ":", "text", ",", "}", "\n", "}" ]
// NewEvent creates a new event with the given title and text. Error checking // against these values is done at send-time, or upon running e.Check.
[ "NewEvent", "creates", "a", "new", "event", "with", "the", "given", "title", "and", "text", ".", "Error", "checking", "against", "these", "values", "is", "done", "at", "send", "-", "time", "or", "upon", "running", "e", ".", "Check", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L529-L534
train
DataDog/datadog-go
statsd/statsd.go
Encode
func (e Event) Encode(tags ...string) (string, error) { err := e.Check() if err != nil { return "", err } text := e.escapedText() var buffer bytes.Buffer buffer.WriteString("_e{") buffer.WriteString(strconv.FormatInt(int64(len(e.Title)), 10)) buffer.WriteRune(',') buffer.WriteString(strconv.FormatInt(int64(...
go
func (e Event) Encode(tags ...string) (string, error) { err := e.Check() if err != nil { return "", err } text := e.escapedText() var buffer bytes.Buffer buffer.WriteString("_e{") buffer.WriteString(strconv.FormatInt(int64(len(e.Title)), 10)) buffer.WriteRune(',') buffer.WriteString(strconv.FormatInt(int64(...
[ "func", "(", "e", "Event", ")", "Encode", "(", "tags", "...", "string", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "e", ".", "Check", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\...
// Encode returns the dogstatsd wire protocol representation for an event. // Tags may be passed which will be added to the encoded output but not to // the Event's list of tags, eg. for default tags.
[ "Encode", "returns", "the", "dogstatsd", "wire", "protocol", "representation", "for", "an", "event", ".", "Tags", "may", "be", "passed", "which", "will", "be", "added", "to", "the", "encoded", "output", "but", "not", "to", "the", "Event", "s", "list", "of"...
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L550-L601
train
DataDog/datadog-go
statsd/statsd.go
NewServiceCheck
func NewServiceCheck(name string, status ServiceCheckStatus) *ServiceCheck { return &ServiceCheck{ Name: name, Status: status, } }
go
func NewServiceCheck(name string, status ServiceCheckStatus) *ServiceCheck { return &ServiceCheck{ Name: name, Status: status, } }
[ "func", "NewServiceCheck", "(", "name", "string", ",", "status", "ServiceCheckStatus", ")", "*", "ServiceCheck", "{", "return", "&", "ServiceCheck", "{", "Name", ":", "name", ",", "Status", ":", "status", ",", "}", "\n", "}" ]
// NewServiceCheck creates a new serviceCheck with the given name and status. Error checking // against these values is done at send-time, or upon running sc.Check.
[ "NewServiceCheck", "creates", "a", "new", "serviceCheck", "with", "the", "given", "name", "and", "status", ".", "Error", "checking", "against", "these", "values", "is", "done", "at", "send", "-", "time", "or", "upon", "running", "sc", ".", "Check", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L636-L641
train
DataDog/datadog-go
statsd/statsd.go
Encode
func (sc ServiceCheck) Encode(tags ...string) (string, error) { err := sc.Check() if err != nil { return "", err } message := sc.escapedMessage() var buffer bytes.Buffer buffer.WriteString("_sc|") buffer.WriteString(sc.Name) buffer.WriteRune('|') buffer.WriteString(strconv.FormatInt(int64(sc.Status), 10)) ...
go
func (sc ServiceCheck) Encode(tags ...string) (string, error) { err := sc.Check() if err != nil { return "", err } message := sc.escapedMessage() var buffer bytes.Buffer buffer.WriteString("_sc|") buffer.WriteString(sc.Name) buffer.WriteRune('|') buffer.WriteString(strconv.FormatInt(int64(sc.Status), 10)) ...
[ "func", "(", "sc", "ServiceCheck", ")", "Encode", "(", "tags", "...", "string", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "sc", ".", "Check", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", ...
// Encode returns the dogstatsd wire protocol representation for an serviceCheck. // Tags may be passed which will be added to the encoded output but not to // the Event's list of tags, eg. for default tags.
[ "Encode", "returns", "the", "dogstatsd", "wire", "protocol", "representation", "for", "an", "serviceCheck", ".", "Tags", "may", "be", "passed", "which", "will", "be", "added", "to", "the", "encoded", "output", "but", "not", "to", "the", "Event", "s", "list",...
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/statsd.go#L657-L688
train
DataDog/datadog-go
statsd/uds_async.go
newAsyncUdsWriter
func newAsyncUdsWriter(addr string) (*asyncUdsWriter, error) { udsAddr, err := net.ResolveUnixAddr("unixgram", addr) if err != nil { return nil, err } writer := &asyncUdsWriter{ addr: udsAddr, conn: nil, writeTimeout: defaultUDSTimeout, // 8192 * 8KB = 65.5MB datagramQueue: make(chan []...
go
func newAsyncUdsWriter(addr string) (*asyncUdsWriter, error) { udsAddr, err := net.ResolveUnixAddr("unixgram", addr) if err != nil { return nil, err } writer := &asyncUdsWriter{ addr: udsAddr, conn: nil, writeTimeout: defaultUDSTimeout, // 8192 * 8KB = 65.5MB datagramQueue: make(chan []...
[ "func", "newAsyncUdsWriter", "(", "addr", "string", ")", "(", "*", "asyncUdsWriter", ",", "error", ")", "{", "udsAddr", ",", "err", ":=", "net", ".", "ResolveUnixAddr", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// New returns a pointer to a new asyncUdsWriter given a socket file path as addr.
[ "New", "returns", "a", "pointer", "to", "a", "new", "asyncUdsWriter", "given", "a", "socket", "file", "path", "as", "addr", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/uds_async.go#L23-L40
train
DataDog/datadog-go
statsd/uds_async.go
SetWriteTimeout
func (w *asyncUdsWriter) SetWriteTimeout(d time.Duration) error { w.writeTimeout = d return nil }
go
func (w *asyncUdsWriter) SetWriteTimeout(d time.Duration) error { w.writeTimeout = d return nil }
[ "func", "(", "w", "*", "asyncUdsWriter", ")", "SetWriteTimeout", "(", "d", "time", ".", "Duration", ")", "error", "{", "w", ".", "writeTimeout", "=", "d", "\n", "return", "nil", "\n", "}" ]
// SetWriteTimeout allows the user to set a custom write timeout
[ "SetWriteTimeout", "allows", "the", "user", "to", "set", "a", "custom", "write", "timeout" ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/uds_async.go#L54-L57
train
DataDog/datadog-go
statsd/udp.go
Write
func (w *udpWriter) Write(data []byte) (int, error) { return w.conn.Write(data) }
go
func (w *udpWriter) Write(data []byte) (int, error) { return w.conn.Write(data) }
[ "func", "(", "w", "*", "udpWriter", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "w", ".", "conn", ".", "Write", "(", "data", ")", "\n", "}" ]
// Write data to the UDP connection with no error handling
[ "Write", "data", "to", "the", "UDP", "connection", "with", "no", "error", "handling" ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/udp.go#L49-L51
train
DataDog/datadog-go
statsd/options.go
WithNamespace
func WithNamespace(namespace string) Option { return func(o *Options) error { o.Namespace = namespace return nil } }
go
func WithNamespace(namespace string) Option { return func(o *Options) error { o.Namespace = namespace return nil } }
[ "func", "WithNamespace", "(", "namespace", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Namespace", "=", "namespace", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithNamespace sets the Namespace option.
[ "WithNamespace", "sets", "the", "Namespace", "option", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/options.go#L64-L69
train
DataDog/datadog-go
statsd/options.go
WithTags
func WithTags(tags []string) Option { return func(o *Options) error { o.Tags = tags return nil } }
go
func WithTags(tags []string) Option { return func(o *Options) error { o.Tags = tags return nil } }
[ "func", "WithTags", "(", "tags", "[", "]", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Tags", "=", "tags", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithTags sets the Tags option.
[ "WithTags", "sets", "the", "Tags", "option", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/options.go#L72-L77
train
DataDog/datadog-go
statsd/options.go
WithMaxMessagesPerPayload
func WithMaxMessagesPerPayload(maxMessagesPerPayload int) Option { return func(o *Options) error { o.MaxMessagesPerPayload = maxMessagesPerPayload return nil } }
go
func WithMaxMessagesPerPayload(maxMessagesPerPayload int) Option { return func(o *Options) error { o.MaxMessagesPerPayload = maxMessagesPerPayload return nil } }
[ "func", "WithMaxMessagesPerPayload", "(", "maxMessagesPerPayload", "int", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "MaxMessagesPerPayload", "=", "maxMessagesPerPayload", "\n", "return", "nil", "\n", "}", "\n", ...
// WithMaxMessagesPerPayload sets the MaxMessagesPerPayload option.
[ "WithMaxMessagesPerPayload", "sets", "the", "MaxMessagesPerPayload", "option", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/options.go#L88-L93
train
DataDog/datadog-go
statsd/options.go
WithWriteTimeoutUDS
func WithWriteTimeoutUDS(writeTimeoutUDS time.Duration) Option { return func(o *Options) error { o.WriteTimeoutUDS = writeTimeoutUDS return nil } }
go
func WithWriteTimeoutUDS(writeTimeoutUDS time.Duration) Option { return func(o *Options) error { o.WriteTimeoutUDS = writeTimeoutUDS return nil } }
[ "func", "WithWriteTimeoutUDS", "(", "writeTimeoutUDS", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "WriteTimeoutUDS", "=", "writeTimeoutUDS", "\n", "return", "nil", "\n", "}", "\n", ...
// WithWriteTimeoutUDS sets the WriteTimeoutUDS option.
[ "WithWriteTimeoutUDS", "sets", "the", "WriteTimeoutUDS", "option", "." ]
40bafcb5f6c1d49df36deaf4ab019e44961d5e36
https://github.com/DataDog/datadog-go/blob/40bafcb5f6c1d49df36deaf4ab019e44961d5e36/statsd/options.go#L104-L109
train
google/go-jsonnet
vm.go
MakeVM
func MakeVM() *VM { return &VM{ MaxStack: 500, ext: make(vmExtMap), tla: make(vmExtMap), nativeFuncs: make(map[string]*NativeFunction), ErrorFormatter: &termErrorFormatter{pretty: false, maxStackTraceSize: 20}, importer: &FileImporter{}, } }
go
func MakeVM() *VM { return &VM{ MaxStack: 500, ext: make(vmExtMap), tla: make(vmExtMap), nativeFuncs: make(map[string]*NativeFunction), ErrorFormatter: &termErrorFormatter{pretty: false, maxStackTraceSize: 20}, importer: &FileImporter{}, } }
[ "func", "MakeVM", "(", ")", "*", "VM", "{", "return", "&", "VM", "{", "MaxStack", ":", "500", ",", "ext", ":", "make", "(", "vmExtMap", ")", ",", "tla", ":", "make", "(", "vmExtMap", ")", ",", "nativeFuncs", ":", "make", "(", "map", "[", "string"...
// MakeVM creates a new VM with default parameters.
[ "MakeVM", "creates", "a", "new", "VM", "with", "default", "parameters", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L55-L64
train
google/go-jsonnet
vm.go
ExtVar
func (vm *VM) ExtVar(key string, val string) { vm.ext[key] = vmExt{value: val, isCode: false} }
go
func (vm *VM) ExtVar(key string, val string) { vm.ext[key] = vmExt{value: val, isCode: false} }
[ "func", "(", "vm", "*", "VM", ")", "ExtVar", "(", "key", "string", ",", "val", "string", ")", "{", "vm", ".", "ext", "[", "key", "]", "=", "vmExt", "{", "value", ":", "val", ",", "isCode", ":", "false", "}", "\n", "}" ]
// ExtVar binds a Jsonnet external var to the given value.
[ "ExtVar", "binds", "a", "Jsonnet", "external", "var", "to", "the", "given", "value", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L67-L69
train
google/go-jsonnet
vm.go
ExtCode
func (vm *VM) ExtCode(key string, val string) { vm.ext[key] = vmExt{value: val, isCode: true} }
go
func (vm *VM) ExtCode(key string, val string) { vm.ext[key] = vmExt{value: val, isCode: true} }
[ "func", "(", "vm", "*", "VM", ")", "ExtCode", "(", "key", "string", ",", "val", "string", ")", "{", "vm", ".", "ext", "[", "key", "]", "=", "vmExt", "{", "value", ":", "val", ",", "isCode", ":", "true", "}", "\n", "}" ]
// ExtCode binds a Jsonnet external code var to the given code.
[ "ExtCode", "binds", "a", "Jsonnet", "external", "code", "var", "to", "the", "given", "code", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L72-L74
train
google/go-jsonnet
vm.go
TLAVar
func (vm *VM) TLAVar(key string, val string) { vm.tla[key] = vmExt{value: val, isCode: false} }
go
func (vm *VM) TLAVar(key string, val string) { vm.tla[key] = vmExt{value: val, isCode: false} }
[ "func", "(", "vm", "*", "VM", ")", "TLAVar", "(", "key", "string", ",", "val", "string", ")", "{", "vm", ".", "tla", "[", "key", "]", "=", "vmExt", "{", "value", ":", "val", ",", "isCode", ":", "false", "}", "\n", "}" ]
// TLAVar binds a Jsonnet top level argument to the given value.
[ "TLAVar", "binds", "a", "Jsonnet", "top", "level", "argument", "to", "the", "given", "value", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L77-L79
train
google/go-jsonnet
vm.go
TLACode
func (vm *VM) TLACode(key string, val string) { vm.tla[key] = vmExt{value: val, isCode: true} }
go
func (vm *VM) TLACode(key string, val string) { vm.tla[key] = vmExt{value: val, isCode: true} }
[ "func", "(", "vm", "*", "VM", ")", "TLACode", "(", "key", "string", ",", "val", "string", ")", "{", "vm", ".", "tla", "[", "key", "]", "=", "vmExt", "{", "value", ":", "val", ",", "isCode", ":", "true", "}", "\n", "}" ]
// TLACode binds a Jsonnet top level argument to the given code.
[ "TLACode", "binds", "a", "Jsonnet", "top", "level", "argument", "to", "the", "given", "code", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L82-L84
train
google/go-jsonnet
vm.go
NativeFunction
func (vm *VM) NativeFunction(f *NativeFunction) { vm.nativeFuncs[f.Name] = f }
go
func (vm *VM) NativeFunction(f *NativeFunction) { vm.nativeFuncs[f.Name] = f }
[ "func", "(", "vm", "*", "VM", ")", "NativeFunction", "(", "f", "*", "NativeFunction", ")", "{", "vm", ".", "nativeFuncs", "[", "f", ".", "Name", "]", "=", "f", "\n", "}" ]
// NativeFunction registers a native function.
[ "NativeFunction", "registers", "a", "native", "function", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L151-L153
train
google/go-jsonnet
vm.go
EvaluateSnippet
func (vm *VM) EvaluateSnippet(filename string, snippet string) (json string, formattedErr error) { output, err := vm.evaluateSnippet(filename, snippet, evalKindRegular) if err != nil { return "", errors.New(vm.ErrorFormatter.Format(err)) } json = output.(string) return }
go
func (vm *VM) EvaluateSnippet(filename string, snippet string) (json string, formattedErr error) { output, err := vm.evaluateSnippet(filename, snippet, evalKindRegular) if err != nil { return "", errors.New(vm.ErrorFormatter.Format(err)) } json = output.(string) return }
[ "func", "(", "vm", "*", "VM", ")", "EvaluateSnippet", "(", "filename", "string", ",", "snippet", "string", ")", "(", "json", "string", ",", "formattedErr", "error", ")", "{", "output", ",", "err", ":=", "vm", ".", "evaluateSnippet", "(", "filename", ",",...
// EvaluateSnippet evaluates a string containing Jsonnet code, return a JSON // string. // // The filename parameter is only used for error messages.
[ "EvaluateSnippet", "evaluates", "a", "string", "containing", "Jsonnet", "code", "return", "a", "JSON", "string", ".", "The", "filename", "parameter", "is", "only", "used", "for", "error", "messages", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L159-L166
train
google/go-jsonnet
vm.go
EvaluateSnippetStream
func (vm *VM) EvaluateSnippetStream(filename string, snippet string) (docs []string, formattedErr error) { output, err := vm.evaluateSnippet(filename, snippet, evalKindStream) if err != nil { return nil, errors.New(vm.ErrorFormatter.Format(err)) } docs = output.([]string) return }
go
func (vm *VM) EvaluateSnippetStream(filename string, snippet string) (docs []string, formattedErr error) { output, err := vm.evaluateSnippet(filename, snippet, evalKindStream) if err != nil { return nil, errors.New(vm.ErrorFormatter.Format(err)) } docs = output.([]string) return }
[ "func", "(", "vm", "*", "VM", ")", "EvaluateSnippetStream", "(", "filename", "string", ",", "snippet", "string", ")", "(", "docs", "[", "]", "string", ",", "formattedErr", "error", ")", "{", "output", ",", "err", ":=", "vm", ".", "evaluateSnippet", "(", ...
// EvaluateSnippetStream evaluates a string containing Jsonnet code to an array. // The array is returned as an array of JSON strings. // // The filename parameter is only used for error messages.
[ "EvaluateSnippetStream", "evaluates", "a", "string", "containing", "Jsonnet", "code", "to", "an", "array", ".", "The", "array", "is", "returned", "as", "an", "array", "of", "JSON", "strings", ".", "The", "filename", "parameter", "is", "only", "used", "for", ...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L172-L179
train
google/go-jsonnet
vm.go
EvaluateSnippetMulti
func (vm *VM) EvaluateSnippetMulti(filename string, snippet string) (files map[string]string, formattedErr error) { output, err := vm.evaluateSnippet(filename, snippet, evalKindMulti) if err != nil { return nil, errors.New(vm.ErrorFormatter.Format(err)) } files = output.(map[string]string) return }
go
func (vm *VM) EvaluateSnippetMulti(filename string, snippet string) (files map[string]string, formattedErr error) { output, err := vm.evaluateSnippet(filename, snippet, evalKindMulti) if err != nil { return nil, errors.New(vm.ErrorFormatter.Format(err)) } files = output.(map[string]string) return }
[ "func", "(", "vm", "*", "VM", ")", "EvaluateSnippetMulti", "(", "filename", "string", ",", "snippet", "string", ")", "(", "files", "map", "[", "string", "]", "string", ",", "formattedErr", "error", ")", "{", "output", ",", "err", ":=", "vm", ".", "eval...
// EvaluateSnippetMulti evaluates a string containing Jsonnet code to key-value // pairs. The keys are field name strings and the values are JSON strings. // // The filename parameter is only used for error messages.
[ "EvaluateSnippetMulti", "evaluates", "a", "string", "containing", "Jsonnet", "code", "to", "key", "-", "value", "pairs", ".", "The", "keys", "are", "field", "name", "strings", "and", "the", "values", "are", "JSON", "strings", ".", "The", "filename", "parameter...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L185-L192
train
google/go-jsonnet
vm.go
SnippetToAST
func SnippetToAST(filename string, snippet string) (ast.Node, error) { return snippetToAST(filename, snippet) }
go
func SnippetToAST(filename string, snippet string) (ast.Node, error) { return snippetToAST(filename, snippet) }
[ "func", "SnippetToAST", "(", "filename", "string", ",", "snippet", "string", ")", "(", "ast", ".", "Node", ",", "error", ")", "{", "return", "snippetToAST", "(", "filename", ",", "snippet", ")", "\n", "}" ]
// SnippetToAST parses a snippet and returns the resulting AST.
[ "SnippetToAST", "parses", "a", "snippet", "and", "returns", "the", "resulting", "AST", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/vm.go#L219-L221
train
google/go-jsonnet
value.go
findField
func findField(curr value, minSuperDepth int, f string) (bool, simpleObjectField, bindingFrame, int) { switch curr := curr.(type) { case *valueExtendedObject: if curr.right.inheritanceSize() > minSuperDepth { found, field, frame, counter := findField(curr.right, minSuperDepth, f) if found { return true, f...
go
func findField(curr value, minSuperDepth int, f string) (bool, simpleObjectField, bindingFrame, int) { switch curr := curr.(type) { case *valueExtendedObject: if curr.right.inheritanceSize() > minSuperDepth { found, field, frame, counter := findField(curr.right, minSuperDepth, f) if found { return true, f...
[ "func", "findField", "(", "curr", "value", ",", "minSuperDepth", "int", ",", "f", "string", ")", "(", "bool", ",", "simpleObjectField", ",", "bindingFrame", ",", "int", ")", "{", "switch", "curr", ":=", "curr", ".", "(", "type", ")", "{", "case", "*", ...
// findField returns a field in object curr, with superDepth at least minSuperDepth // It also returns an associated bindingFrame and actual superDepth that the field // was found at.
[ "findField", "returns", "a", "field", "in", "object", "curr", "with", "superDepth", "at", "least", "minSuperDepth", "It", "also", "returns", "an", "associated", "bindingFrame", "and", "actual", "superDepth", "that", "the", "field", "was", "found", "at", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/value.go#L582-L604
train
google/go-jsonnet
dump/utils.go
deInterface
func deInterface(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() } return v }
go
func deInterface(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() } return v }
[ "func", "deInterface", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Interface", "&&", "!", "v", ".", "IsNil", "(", ")", "{", "v", "=", "v", ".", "Elem", "(", ")",...
// deInterface returns values inside of non-nil interfaces when possible. // This is useful for data types like structs, arrays, slices, and maps which // can contain varying types packed inside an interface.
[ "deInterface", "returns", "values", "inside", "of", "non", "-", "nil", "interfaces", "when", "possible", ".", "This", "is", "useful", "for", "data", "types", "like", "structs", "arrays", "slices", "and", "maps", "which", "can", "contain", "varying", "types", ...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/dump/utils.go#L69-L74
train
google/go-jsonnet
parser/static_error.go
MakeStaticError
func MakeStaticError(msg string, lr ast.LocationRange) StaticError { return StaticError{Msg: msg, Loc: lr} }
go
func MakeStaticError(msg string, lr ast.LocationRange) StaticError { return StaticError{Msg: msg, Loc: lr} }
[ "func", "MakeStaticError", "(", "msg", "string", ",", "lr", "ast", ".", "LocationRange", ")", "StaticError", "{", "return", "StaticError", "{", "Msg", ":", "msg", ",", "Loc", ":", "lr", "}", "\n", "}" ]
// MakeStaticError returns a StaticError with a message and a LocationRange.
[ "MakeStaticError", "returns", "a", "StaticError", "with", "a", "message", "and", "a", "LocationRange", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/static_error.go#L41-L43
train
google/go-jsonnet
parser/static_error.go
Error
func (err StaticError) Error() string { loc := "" if err.Loc.IsSet() { loc = err.Loc.String() } return fmt.Sprintf("%v %v", loc, err.Msg) }
go
func (err StaticError) Error() string { loc := "" if err.Loc.IsSet() { loc = err.Loc.String() } return fmt.Sprintf("%v %v", loc, err.Msg) }
[ "func", "(", "err", "StaticError", ")", "Error", "(", ")", "string", "{", "loc", ":=", "\"", "\"", "\n", "if", "err", ".", "Loc", ".", "IsSet", "(", ")", "{", "loc", "=", "err", ".", "Loc", ".", "String", "(", ")", "\n", "}", "\n", "return", ...
// Error returns the string representation of a StaticError.
[ "Error", "returns", "the", "string", "representation", "of", "a", "StaticError", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/static_error.go#L46-L52
train
google/go-jsonnet
linter/linter.go
Lint
func Lint(node ast.Node, e *ErrorWriter) { lintingInfo := LintingInfo{ variables: nil, } std := variable{ name: "std", declNode: nil, uses: nil, param: false, } findVariables(node, &lintingInfo, vScope{"std": &std}) for _, v := range lintingInfo.variables { if len(v.uses) == 0 && !v.param {...
go
func Lint(node ast.Node, e *ErrorWriter) { lintingInfo := LintingInfo{ variables: nil, } std := variable{ name: "std", declNode: nil, uses: nil, param: false, } findVariables(node, &lintingInfo, vScope{"std": &std}) for _, v := range lintingInfo.variables { if len(v.uses) == 0 && !v.param {...
[ "func", "Lint", "(", "node", "ast", ".", "Node", ",", "e", "*", "ErrorWriter", ")", "{", "lintingInfo", ":=", "LintingInfo", "{", "variables", ":", "nil", ",", "}", "\n", "std", ":=", "variable", "{", "name", ":", "\"", "\"", ",", "declNode", ":", ...
// Lint analyses a node and reports any issues it encounters to an error writer.
[ "Lint", "analyses", "a", "node", "and", "reports", "any", "issues", "it", "encounters", "to", "an", "error", "writer", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/linter/linter.go#L39-L55
train
google/go-jsonnet
imports.go
MakeImportCache
func MakeImportCache(importer Importer) *ImportCache { return &ImportCache{ importer: importer, foundAtVerification: make(map[string]Contents), codeCache: make(map[string]potentialValue), } }
go
func MakeImportCache(importer Importer) *ImportCache { return &ImportCache{ importer: importer, foundAtVerification: make(map[string]Contents), codeCache: make(map[string]potentialValue), } }
[ "func", "MakeImportCache", "(", "importer", "Importer", ")", "*", "ImportCache", "{", "return", "&", "ImportCache", "{", "importer", ":", "importer", ",", "foundAtVerification", ":", "make", "(", "map", "[", "string", "]", "Contents", ")", ",", "codeCache", ...
// MakeImportCache creates an ImportCache using an Importer.
[ "MakeImportCache", "creates", "an", "ImportCache", "using", "an", "Importer", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/imports.go#L77-L83
train
google/go-jsonnet
imports.go
ImportString
func (cache *ImportCache) ImportString(importedFrom, importedPath string, i *interpreter, trace TraceElement) (*valueString, error) { data, _, err := cache.importData(importedFrom, importedPath) if err != nil { return nil, i.Error(err.Error(), trace) } return makeValueString(data.String()), nil }
go
func (cache *ImportCache) ImportString(importedFrom, importedPath string, i *interpreter, trace TraceElement) (*valueString, error) { data, _, err := cache.importData(importedFrom, importedPath) if err != nil { return nil, i.Error(err.Error(), trace) } return makeValueString(data.String()), nil }
[ "func", "(", "cache", "*", "ImportCache", ")", "ImportString", "(", "importedFrom", ",", "importedPath", "string", ",", "i", "*", "interpreter", ",", "trace", "TraceElement", ")", "(", "*", "valueString", ",", "error", ")", "{", "data", ",", "_", ",", "e...
// ImportString imports a string, caches it and then returns it.
[ "ImportString", "imports", "a", "string", "caches", "it", "and", "then", "returns", "it", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/imports.go#L101-L107
train
google/go-jsonnet
imports.go
ImportCode
func (cache *ImportCache) ImportCode(importedFrom, importedPath string, i *interpreter, trace TraceElement) (value, error) { contents, foundAt, err := cache.importData(importedFrom, importedPath) if err != nil { return nil, i.Error(err.Error(), trace) } var pv potentialValue if cachedPV, isCached := cache.codeCa...
go
func (cache *ImportCache) ImportCode(importedFrom, importedPath string, i *interpreter, trace TraceElement) (value, error) { contents, foundAt, err := cache.importData(importedFrom, importedPath) if err != nil { return nil, i.Error(err.Error(), trace) } var pv potentialValue if cachedPV, isCached := cache.codeCa...
[ "func", "(", "cache", "*", "ImportCache", ")", "ImportCode", "(", "importedFrom", ",", "importedPath", "string", ",", "i", "*", "interpreter", ",", "trace", "TraceElement", ")", "(", "value", ",", "error", ")", "{", "contents", ",", "foundAt", ",", "err", ...
// ImportCode imports code from a path.
[ "ImportCode", "imports", "code", "from", "a", "path", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/imports.go#L128-L142
train
google/go-jsonnet
imports.go
Import
func (importer *FileImporter) Import(importedFrom, importedPath string) (contents Contents, foundAt string, err error) { dir, _ := path.Split(importedFrom) found, content, foundHere, err := importer.tryPath(dir, importedPath) if err != nil { return Contents{}, "", err } for i := len(importer.JPaths) - 1; !found...
go
func (importer *FileImporter) Import(importedFrom, importedPath string) (contents Contents, foundAt string, err error) { dir, _ := path.Split(importedFrom) found, content, foundHere, err := importer.tryPath(dir, importedPath) if err != nil { return Contents{}, "", err } for i := len(importer.JPaths) - 1; !found...
[ "func", "(", "importer", "*", "FileImporter", ")", "Import", "(", "importedFrom", ",", "importedPath", "string", ")", "(", "contents", "Contents", ",", "foundAt", "string", ",", "err", "error", ")", "{", "dir", ",", "_", ":=", "path", ".", "Split", "(", ...
// Import imports file from the filesystem.
[ "Import", "imports", "file", "from", "the", "filesystem", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/imports.go#L193-L211
train
google/go-jsonnet
imports.go
Import
func (importer *MemoryImporter) Import(importedFrom, importedPath string) (contents Contents, foundAt string, err error) { if content, ok := importer.Data[importedPath]; ok { return content, importedPath, nil } return Contents{}, "", fmt.Errorf("import not available %v", importedPath) }
go
func (importer *MemoryImporter) Import(importedFrom, importedPath string) (contents Contents, foundAt string, err error) { if content, ok := importer.Data[importedPath]; ok { return content, importedPath, nil } return Contents{}, "", fmt.Errorf("import not available %v", importedPath) }
[ "func", "(", "importer", "*", "MemoryImporter", ")", "Import", "(", "importedFrom", ",", "importedPath", "string", ")", "(", "contents", "Contents", ",", "foundAt", "string", ",", "err", "error", ")", "{", "if", "content", ",", "ok", ":=", "importer", ".",...
// Import fetches data from a map entry. // All paths are treated as absolute keys.
[ "Import", "fetches", "data", "from", "a", "map", "entry", ".", "All", "paths", "are", "treated", "as", "absolute", "keys", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/imports.go#L220-L225
train
google/go-jsonnet
cmd/jsonnet/cmd.go
writeOutputStream
func writeOutputStream(output []string, outputFile string) error { var f *os.File if outputFile == "" { f = os.Stdout } else { var err error f, err = os.Create(outputFile) if err != nil { return err } defer f.Close() } for _, doc := range output { _, err := f.WriteString("---\n") if err != nil...
go
func writeOutputStream(output []string, outputFile string) error { var f *os.File if outputFile == "" { f = os.Stdout } else { var err error f, err = os.Create(outputFile) if err != nil { return err } defer f.Close() } for _, doc := range output { _, err := f.WriteString("---\n") if err != nil...
[ "func", "writeOutputStream", "(", "output", "[", "]", "string", ",", "outputFile", "string", ")", "error", "{", "var", "f", "*", "os", ".", "File", "\n\n", "if", "outputFile", "==", "\"", "\"", "{", "f", "=", "os", ".", "Stdout", "\n", "}", "else", ...
// writeOutputStream writes the output as a YAML stream.
[ "writeOutputStream", "writes", "the", "output", "as", "a", "YAML", "stream", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/cmd/jsonnet/cmd.go#L442-L475
train
google/go-jsonnet
parser/lexer.go
checkWhitespace
func checkWhitespace(a, b string) int { i := 0 for ; i < len(a); i++ { if a[i] != ' ' && a[i] != '\t' { // a has run out of whitespace and b matched up to this point. Return // result. return i } if i >= len(b) { // We ran off the edge of b while a still has whitespace. Return 0 as // failure. ...
go
func checkWhitespace(a, b string) int { i := 0 for ; i < len(a); i++ { if a[i] != ' ' && a[i] != '\t' { // a has run out of whitespace and b matched up to this point. Return // result. return i } if i >= len(b) { // We ran off the edge of b while a still has whitespace. Return 0 as // failure. ...
[ "func", "checkWhitespace", "(", "a", ",", "b", "string", ")", "int", "{", "i", ":=", "0", "\n", "for", ";", "i", "<", "len", "(", "a", ")", ";", "i", "++", "{", "if", "a", "[", "i", "]", "!=", "' '", "&&", "a", "[", "i", "]", "!=", "'\\t'...
// Check that b has at least the same whitespace prefix as a and returns the // amount of this whitespace, otherwise returns 0. If a has no whitespace // prefix than return 0.
[ "Check", "that", "b", "has", "at", "least", "the", "same", "whitespace", "prefix", "as", "a", "and", "returns", "the", "amount", "of", "this", "whitespace", "otherwise", "returns", "0", ".", "If", "a", "has", "no", "whitespace", "prefix", "than", "return",...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L235-L255
train
google/go-jsonnet
parser/lexer.go
backup
func (l *lexer) backup() { if l.prev.byteNo == lexEOF { panic("backup called with no valid previous rune") } l.pos = l.prev l.prev = position{byteNo: lexEOF} }
go
func (l *lexer) backup() { if l.prev.byteNo == lexEOF { panic("backup called with no valid previous rune") } l.pos = l.prev l.prev = position{byteNo: lexEOF} }
[ "func", "(", "l", "*", "lexer", ")", "backup", "(", ")", "{", "if", "l", ".", "prev", ".", "byteNo", "==", "lexEOF", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "l", ".", "pos", "=", "l", ".", "prev", "\n", "l", ".", "prev", "=", ...
// backup steps back one rune. Can only be called once per call of next. // It also does not recover the previous value of freshLine.
[ "backup", "steps", "back", "one", "rune", ".", "Can", "only", "be", "called", "once", "per", "call", "of", "next", ".", "It", "also", "does", "not", "recover", "the", "previous", "value", "of", "freshLine", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L335-L341
train
google/go-jsonnet
parser/lexer.go
resetTokenStart
func (l *lexer) resetTokenStart() { l.tokenStart = l.pos.byteNo l.tokenStartLoc = l.location() }
go
func (l *lexer) resetTokenStart() { l.tokenStart = l.pos.byteNo l.tokenStartLoc = l.location() }
[ "func", "(", "l", "*", "lexer", ")", "resetTokenStart", "(", ")", "{", "l", ".", "tokenStart", "=", "l", ".", "pos", ".", "byteNo", "\n", "l", ".", "tokenStartLoc", "=", "l", ".", "location", "(", ")", "\n", "}" ]
// Reset the current working token start to the current cursor position. This // may throw away some characters. This does not throw away any accumulated // fodder.
[ "Reset", "the", "current", "working", "token", "start", "to", "the", "current", "cursor", "position", ".", "This", "may", "throw", "away", "some", "characters", ".", "This", "does", "not", "throw", "away", "any", "accumulated", "fodder", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L361-L364
train
google/go-jsonnet
parser/lexer.go
lexWhitespace
func (l *lexer) lexWhitespace() (int, int) { r := l.next() indent := 0 newLines := 0 for ; isWhitespace(r); r = l.next() { switch r { case '\r': // Ignore. break case '\n': indent = 0 newLines++ break case ' ': indent++ break // This only works for \t at the beginning of lines, but...
go
func (l *lexer) lexWhitespace() (int, int) { r := l.next() indent := 0 newLines := 0 for ; isWhitespace(r); r = l.next() { switch r { case '\r': // Ignore. break case '\n': indent = 0 newLines++ break case ' ': indent++ break // This only works for \t at the beginning of lines, but...
[ "func", "(", "l", "*", "lexer", ")", "lexWhitespace", "(", ")", "(", "int", ",", "int", ")", "{", "r", ":=", "l", ".", "next", "(", ")", "\n", "indent", ":=", "0", "\n", "newLines", ":=", "0", "\n", "for", ";", "isWhitespace", "(", "r", ")", ...
// lexWhitespace consumes all whitespace and returns the number of \n and number of // spaces after last \n. It also converts \t to spaces. // The parameter 'r' is the rune that begins the whitespace.
[ "lexWhitespace", "consumes", "all", "whitespace", "and", "returns", "the", "number", "of", "\\", "n", "and", "number", "of", "spaces", "after", "last", "\\", "n", ".", "It", "also", "converts", "\\", "t", "to", "spaces", ".", "The", "parameter", "r", "is...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L395-L425
train
google/go-jsonnet
parser/lexer.go
lexUntilNewline
func (l *lexer) lexUntilNewline() (string, int, int) { // Compute 'text'. var buf bytes.Buffer lastNonSpace := 0 for r := l.next(); r != lexEOF && r != '\n'; r = l.next() { buf.WriteRune(r) if !isHorizontalWhitespace(r) { lastNonSpace = buf.Len() } } l.backup() // Trim whitespace off the end. buf.Trunc...
go
func (l *lexer) lexUntilNewline() (string, int, int) { // Compute 'text'. var buf bytes.Buffer lastNonSpace := 0 for r := l.next(); r != lexEOF && r != '\n'; r = l.next() { buf.WriteRune(r) if !isHorizontalWhitespace(r) { lastNonSpace = buf.Len() } } l.backup() // Trim whitespace off the end. buf.Trunc...
[ "func", "(", "l", "*", "lexer", ")", "lexUntilNewline", "(", ")", "(", "string", ",", "int", ",", "int", ")", "{", "// Compute 'text'.", "var", "buf", "bytes", ".", "Buffer", "\n", "lastNonSpace", ":=", "0", "\n", "for", "r", ":=", "l", ".", "next", ...
// lexUntilNewLine consumes all text until the end of the line and returns the // number of newlines after that as well as the next indent.
[ "lexUntilNewLine", "consumes", "all", "text", "until", "the", "end", "of", "the", "line", "and", "returns", "the", "number", "of", "newlines", "after", "that", "as", "well", "as", "the", "next", "indent", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L429-L452
train
google/go-jsonnet
parser/lexer.go
lexNumber
func (l *lexer) lexNumber() error { // This function should be understood with reference to the linked image: // http://www.json.org/number.gif // Note, we deviate from the json.org documentation as follows: // There is no reason to lex negative numbers as atomic tokens, it is better to parse them // as a unary o...
go
func (l *lexer) lexNumber() error { // This function should be understood with reference to the linked image: // http://www.json.org/number.gif // Note, we deviate from the json.org documentation as follows: // There is no reason to lex negative numbers as atomic tokens, it is better to parse them // as a unary o...
[ "func", "(", "l", "*", "lexer", ")", "lexNumber", "(", ")", "error", "{", "// This function should be understood with reference to the linked image:", "// http://www.json.org/number.gif", "// Note, we deviate from the json.org documentation as follows:", "// There is no reason to lex neg...
// lexNumber will consume a number and emit a token. It is assumed // that the next rune to be served by the lexer will be a leading digit.
[ "lexNumber", "will", "consume", "a", "number", "and", "emit", "a", "token", ".", "It", "is", "assumed", "that", "the", "next", "rune", "to", "be", "served", "by", "the", "lexer", "will", "be", "a", "leading", "digit", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L456-L563
train
google/go-jsonnet
parser/lexer.go
lexIdentifier
func (l *lexer) lexIdentifier() { r := l.next() if !isIdentifierFirst(r) { panic("Unexpected character in lexIdentifier") } for ; r != lexEOF; r = l.next() { if !isIdentifier(r) { break } } l.backup() switch l.input[l.tokenStart:l.pos.byteNo] { case "assert": l.emitToken(tokenAssert) case "else": ...
go
func (l *lexer) lexIdentifier() { r := l.next() if !isIdentifierFirst(r) { panic("Unexpected character in lexIdentifier") } for ; r != lexEOF; r = l.next() { if !isIdentifier(r) { break } } l.backup() switch l.input[l.tokenStart:l.pos.byteNo] { case "assert": l.emitToken(tokenAssert) case "else": ...
[ "func", "(", "l", "*", "lexer", ")", "lexIdentifier", "(", ")", "{", "r", ":=", "l", ".", "next", "(", ")", "\n", "if", "!", "isIdentifierFirst", "(", "r", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "for", ";", "r", "!=", "lexE...
// lexIdentifier will consume a identifer and emit a token. It is assumed // that the next rune to be served by the lexer will be a leading digit. This // may emit a keyword or an identifier.
[ "lexIdentifier", "will", "consume", "a", "identifer", "and", "emit", "a", "token", ".", "It", "is", "assumed", "that", "the", "next", "rune", "to", "be", "served", "by", "the", "lexer", "will", "be", "a", "leading", "digit", ".", "This", "may", "emit", ...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/lexer.go#L568-L619
train
google/go-jsonnet
thunks.go
EvalCall
func (native *NativeFunction) EvalCall(arguments callArguments, i *interpreter, trace TraceElement) (value, error) { flatArgs := flattenArgs(arguments, native.Parameters()) nativeArgs := make([]interface{}, 0, len(flatArgs)) for _, arg := range flatArgs { v, err := i.evaluatePV(arg, trace) if err != nil { ret...
go
func (native *NativeFunction) EvalCall(arguments callArguments, i *interpreter, trace TraceElement) (value, error) { flatArgs := flattenArgs(arguments, native.Parameters()) nativeArgs := make([]interface{}, 0, len(flatArgs)) for _, arg := range flatArgs { v, err := i.evaluatePV(arg, trace) if err != nil { ret...
[ "func", "(", "native", "*", "NativeFunction", ")", "EvalCall", "(", "arguments", "callArguments", ",", "i", "*", "interpreter", ",", "trace", "TraceElement", ")", "(", "value", ",", "error", ")", "{", "flatArgs", ":=", "flattenArgs", "(", "arguments", ",", ...
// EvalCall evaluates a call to a NativeFunction and returns the result.
[ "EvalCall", "evaluates", "a", "call", "to", "a", "NativeFunction", "and", "returns", "the", "result", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/thunks.go#L242-L261
train
google/go-jsonnet
ast/util.go
AddIdentifiers
func (i IdentifierSet) AddIdentifiers(idents Identifiers) { for _, ident := range idents { i.Add(ident) } }
go
func (i IdentifierSet) AddIdentifiers(idents Identifiers) { for _, ident := range idents { i.Add(ident) } }
[ "func", "(", "i", "IdentifierSet", ")", "AddIdentifiers", "(", "idents", "Identifiers", ")", "{", "for", "_", ",", "ident", ":=", "range", "idents", "{", "i", ".", "Add", "(", "ident", ")", "\n", "}", "\n", "}" ]
// AddIdentifiers adds a slice of identifiers to an identifier set.
[ "AddIdentifiers", "adds", "a", "slice", "of", "identifiers", "to", "an", "identifier", "set", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/util.go#L22-L26
train
google/go-jsonnet
ast/util.go
ToOrderedSlice
func (i IdentifierSet) ToOrderedSlice() []Identifier { var s []Identifier for v := range i { s = append(s, v) } sort.Sort(identifierSorter(s)) return s }
go
func (i IdentifierSet) ToOrderedSlice() []Identifier { var s []Identifier for v := range i { s = append(s, v) } sort.Sort(identifierSorter(s)) return s }
[ "func", "(", "i", "IdentifierSet", ")", "ToOrderedSlice", "(", ")", "[", "]", "Identifier", "{", "var", "s", "[", "]", "Identifier", "\n", "for", "v", ":=", "range", "i", "{", "s", "=", "append", "(", "s", ",", "v", ")", "\n", "}", "\n", "sort", ...
// ToOrderedSlice returns the elements of the current set as an ordered slice.
[ "ToOrderedSlice", "returns", "the", "elements", "of", "the", "current", "set", "as", "an", "ordered", "slice", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/util.go#L29-L36
train
google/go-jsonnet
ast/identifier_set.go
NewIdentifierSet
func NewIdentifierSet(a ...Identifier) IdentifierSet { s := make(IdentifierSet) for _, i := range a { s.Add(i) } return s }
go
func NewIdentifierSet(a ...Identifier) IdentifierSet { s := make(IdentifierSet) for _, i := range a { s.Add(i) } return s }
[ "func", "NewIdentifierSet", "(", "a", "...", "Identifier", ")", "IdentifierSet", "{", "s", ":=", "make", "(", "IdentifierSet", ")", "\n", "for", "_", ",", "i", ":=", "range", "a", "{", "s", ".", "Add", "(", "i", ")", "\n", "}", "\n", "return", "s",...
// NewIdentifierSet creates and returns a reference to an empty set.
[ "NewIdentifierSet", "creates", "and", "returns", "a", "reference", "to", "an", "empty", "set", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/identifier_set.go#L15-L21
train
google/go-jsonnet
ast/identifier_set.go
Iter
func (set IdentifierSet) Iter() <-chan Identifier { ch := make(chan Identifier) go func() { for elem := range set { ch <- elem } close(ch) }() return ch }
go
func (set IdentifierSet) Iter() <-chan Identifier { ch := make(chan Identifier) go func() { for elem := range set { ch <- elem } close(ch) }() return ch }
[ "func", "(", "set", "IdentifierSet", ")", "Iter", "(", ")", "<-", "chan", "Identifier", "{", "ch", ":=", "make", "(", "chan", "Identifier", ")", "\n", "go", "func", "(", ")", "{", "for", "elem", ":=", "range", "set", "{", "ch", "<-", "elem", "\n", ...
// Iter returns a channel of type identifier that you can range over.
[ "Iter", "returns", "a", "channel", "of", "type", "identifier", "that", "you", "can", "range", "over", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/identifier_set.go#L137-L147
train
google/go-jsonnet
parser/context.go
Children
func Children(node ast.Node) []ast.Node { var result []ast.Node result = append(result, directChildren(node)...) result = append(result, thunkChildren(node)...) result = append(result, specialChildren(node)...) return result }
go
func Children(node ast.Node) []ast.Node { var result []ast.Node result = append(result, directChildren(node)...) result = append(result, thunkChildren(node)...) result = append(result, specialChildren(node)...) return result }
[ "func", "Children", "(", "node", "ast", ".", "Node", ")", "[", "]", "ast", ".", "Node", "{", "var", "result", "[", "]", "ast", ".", "Node", "\n", "result", "=", "append", "(", "result", ",", "directChildren", "(", "node", ")", "...", ")", "\n", "...
// Children returns all children of a node. It supports ASTs before and after desugaring.
[ "Children", "returns", "all", "children", "of", "a", "node", ".", "It", "supports", "ASTs", "before", "and", "after", "desugaring", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/context.go#L339-L345
train
google/go-jsonnet
ast/fodder.go
MakeFodderElement
func MakeFodderElement(kind FodderKind, blanks int, indent int, comment []string) FodderElement { if kind == FodderLineEnd && len(comment) > 1 { panic(fmt.Sprintf("FodderLineEnd but comment == %v.", comment)) } if kind == FodderInterstitial && blanks > 0 { panic(fmt.Sprintf("FodderInterstitial but blanks == %d",...
go
func MakeFodderElement(kind FodderKind, blanks int, indent int, comment []string) FodderElement { if kind == FodderLineEnd && len(comment) > 1 { panic(fmt.Sprintf("FodderLineEnd but comment == %v.", comment)) } if kind == FodderInterstitial && blanks > 0 { panic(fmt.Sprintf("FodderInterstitial but blanks == %d",...
[ "func", "MakeFodderElement", "(", "kind", "FodderKind", ",", "blanks", "int", ",", "indent", "int", ",", "comment", "[", "]", "string", ")", "FodderElement", "{", "if", "kind", "==", "FodderLineEnd", "&&", "len", "(", "comment", ")", ">", "1", "{", "pani...
// MakeFodderElement is a helper function that checks some preconditions.
[ "MakeFodderElement", "is", "a", "helper", "function", "that", "checks", "some", "preconditions", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L76-L93
train
google/go-jsonnet
ast/fodder.go
FodderHasCleanEndline
func FodderHasCleanEndline(fodder Fodder) bool { return len(fodder) > 0 && fodder[len(fodder)-1].Kind != FodderInterstitial }
go
func FodderHasCleanEndline(fodder Fodder) bool { return len(fodder) > 0 && fodder[len(fodder)-1].Kind != FodderInterstitial }
[ "func", "FodderHasCleanEndline", "(", "fodder", "Fodder", ")", "bool", "{", "return", "len", "(", "fodder", ")", ">", "0", "&&", "fodder", "[", "len", "(", "fodder", ")", "-", "1", "]", ".", "Kind", "!=", "FodderInterstitial", "\n", "}" ]
// FodderHasCleanEndline is true if the fodder doesn't end with an interstitial.
[ "FodderHasCleanEndline", "is", "true", "if", "the", "fodder", "doesn", "t", "end", "with", "an", "interstitial", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L100-L102
train
google/go-jsonnet
ast/fodder.go
FodderAppend
func FodderAppend(a *Fodder, elem FodderElement) { if FodderHasCleanEndline(*a) && elem.Kind == FodderLineEnd { if len(elem.Comment) > 0 { // The line end had a comment, so create a single line paragraph for it. *a = append(*a, MakeFodderElement(FodderParagraph, elem.Blanks, elem.Indent, elem.Comment)) } els...
go
func FodderAppend(a *Fodder, elem FodderElement) { if FodderHasCleanEndline(*a) && elem.Kind == FodderLineEnd { if len(elem.Comment) > 0 { // The line end had a comment, so create a single line paragraph for it. *a = append(*a, MakeFodderElement(FodderParagraph, elem.Blanks, elem.Indent, elem.Comment)) } els...
[ "func", "FodderAppend", "(", "a", "*", "Fodder", ",", "elem", "FodderElement", ")", "{", "if", "FodderHasCleanEndline", "(", "*", "a", ")", "&&", "elem", ".", "Kind", "==", "FodderLineEnd", "{", "if", "len", "(", "elem", ".", "Comment", ")", ">", "0", ...
// FodderAppend appends to the fodder but preserves constraints. // // See FodderConcat below.
[ "FodderAppend", "appends", "to", "the", "fodder", "but", "preserves", "constraints", ".", "See", "FodderConcat", "below", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L107-L124
train
google/go-jsonnet
ast/fodder.go
FodderConcat
func FodderConcat(a Fodder, b Fodder) Fodder { if len(a) == 0 { return b } if len(b) == 0 { return a } r := a // Carefully add the first element of b. FodderAppend(&r, b[0]) // Add the rest of b. for i := 1; i < len(b); i++ { r = append(r, b[i]) } return r }
go
func FodderConcat(a Fodder, b Fodder) Fodder { if len(a) == 0 { return b } if len(b) == 0 { return a } r := a // Carefully add the first element of b. FodderAppend(&r, b[0]) // Add the rest of b. for i := 1; i < len(b); i++ { r = append(r, b[i]) } return r }
[ "func", "FodderConcat", "(", "a", "Fodder", ",", "b", "Fodder", ")", "Fodder", "{", "if", "len", "(", "a", ")", "==", "0", "{", "return", "b", "\n", "}", "\n", "if", "len", "(", "b", ")", "==", "0", "{", "return", "a", "\n", "}", "\n", "r", ...
// FodderConcat concats the two fodders but also preserves constraints. // // Namely, a FodderLineEnd is not allowed to follow a FodderParagraph or a FodderLineEnd.
[ "FodderConcat", "concats", "the", "two", "fodders", "but", "also", "preserves", "constraints", ".", "Namely", "a", "FodderLineEnd", "is", "not", "allowed", "to", "follow", "a", "FodderParagraph", "or", "a", "FodderLineEnd", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L129-L144
train
google/go-jsonnet
ast/fodder.go
FodderMoveFront
func FodderMoveFront(a *Fodder, b *Fodder) { *a = FodderConcat(*b, *a) *b = Fodder{} }
go
func FodderMoveFront(a *Fodder, b *Fodder) { *a = FodderConcat(*b, *a) *b = Fodder{} }
[ "func", "FodderMoveFront", "(", "a", "*", "Fodder", ",", "b", "*", "Fodder", ")", "{", "*", "a", "=", "FodderConcat", "(", "*", "b", ",", "*", "a", ")", "\n", "*", "b", "=", "Fodder", "{", "}", "\n", "}" ]
// FodderMoveFront moves b to the front of a.
[ "FodderMoveFront", "moves", "b", "to", "the", "front", "of", "a", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L147-L150
train
google/go-jsonnet
ast/fodder.go
FodderEnsureCleanNewline
func FodderEnsureCleanNewline(fodder *Fodder) { if !FodderHasCleanEndline(*fodder) { FodderAppend(fodder, MakeFodderElement(FodderLineEnd, 0, 0, []string{})) } }
go
func FodderEnsureCleanNewline(fodder *Fodder) { if !FodderHasCleanEndline(*fodder) { FodderAppend(fodder, MakeFodderElement(FodderLineEnd, 0, 0, []string{})) } }
[ "func", "FodderEnsureCleanNewline", "(", "fodder", "*", "Fodder", ")", "{", "if", "!", "FodderHasCleanEndline", "(", "*", "fodder", ")", "{", "FodderAppend", "(", "fodder", ",", "MakeFodderElement", "(", "FodderLineEnd", ",", "0", ",", "0", ",", "[", "]", ...
// FodderEnsureCleanNewline adds a LineEnd to the fodder if necessary.
[ "FodderEnsureCleanNewline", "adds", "a", "LineEnd", "to", "the", "fodder", "if", "necessary", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L153-L157
train
google/go-jsonnet
ast/fodder.go
FodderElementCountNewlines
func FodderElementCountNewlines(elem FodderElement) int { switch elem.Kind { case FodderInterstitial: return 0 case FodderLineEnd: return 1 case FodderParagraph: return len(elem.Comment) + elem.Blanks } panic(fmt.Sprintf("Unknown FodderElement kind %d", elem.Kind)) }
go
func FodderElementCountNewlines(elem FodderElement) int { switch elem.Kind { case FodderInterstitial: return 0 case FodderLineEnd: return 1 case FodderParagraph: return len(elem.Comment) + elem.Blanks } panic(fmt.Sprintf("Unknown FodderElement kind %d", elem.Kind)) }
[ "func", "FodderElementCountNewlines", "(", "elem", "FodderElement", ")", "int", "{", "switch", "elem", ".", "Kind", "{", "case", "FodderInterstitial", ":", "return", "0", "\n", "case", "FodderLineEnd", ":", "return", "1", "\n", "case", "FodderParagraph", ":", ...
// FodderElementCountNewlines returns the number of new line chars represented by the fodder element
[ "FodderElementCountNewlines", "returns", "the", "number", "of", "new", "line", "chars", "represented", "by", "the", "fodder", "element" ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L160-L170
train
google/go-jsonnet
ast/fodder.go
FodderCountNewlines
func FodderCountNewlines(fodder Fodder) int { sum := 0 for _, elem := range fodder { sum += FodderElementCountNewlines(elem) } return sum }
go
func FodderCountNewlines(fodder Fodder) int { sum := 0 for _, elem := range fodder { sum += FodderElementCountNewlines(elem) } return sum }
[ "func", "FodderCountNewlines", "(", "fodder", "Fodder", ")", "int", "{", "sum", ":=", "0", "\n", "for", "_", ",", "elem", ":=", "range", "fodder", "{", "sum", "+=", "FodderElementCountNewlines", "(", "elem", ")", "\n", "}", "\n", "return", "sum", "\n", ...
// FodderCountNewlines returns the number of new line chars represented by the fodder.
[ "FodderCountNewlines", "returns", "the", "number", "of", "new", "line", "chars", "represented", "by", "the", "fodder", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/fodder.go#L173-L179
train
google/go-jsonnet
parser/literalfield_set.go
NewLiteralFieldSet
func NewLiteralFieldSet(a ...LiteralField) LiteralFieldSet { s := make(LiteralFieldSet) for _, i := range a { s.Add(i) } return s }
go
func NewLiteralFieldSet(a ...LiteralField) LiteralFieldSet { s := make(LiteralFieldSet) for _, i := range a { s.Add(i) } return s }
[ "func", "NewLiteralFieldSet", "(", "a", "...", "LiteralField", ")", "LiteralFieldSet", "{", "s", ":=", "make", "(", "LiteralFieldSet", ")", "\n", "for", "_", ",", "i", ":=", "range", "a", "{", "s", ".", "Add", "(", "i", ")", "\n", "}", "\n", "return"...
// NewLiteralFieldSet creates and returns a reference to an empty set.
[ "NewLiteralFieldSet", "creates", "and", "returns", "a", "reference", "to", "an", "empty", "set", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/literalfield_set.go#L15-L21
train
google/go-jsonnet
parser/literalfield_set.go
Iter
func (set LiteralFieldSet) Iter() <-chan LiteralField { ch := make(chan LiteralField) go func() { for elem := range set { ch <- elem } close(ch) }() return ch }
go
func (set LiteralFieldSet) Iter() <-chan LiteralField { ch := make(chan LiteralField) go func() { for elem := range set { ch <- elem } close(ch) }() return ch }
[ "func", "(", "set", "LiteralFieldSet", ")", "Iter", "(", ")", "<-", "chan", "LiteralField", "{", "ch", ":=", "make", "(", "chan", "LiteralField", ")", "\n", "go", "func", "(", ")", "{", "for", "elem", ":=", "range", "set", "{", "ch", "<-", "elem", ...
// Iter returns a channel of type LiteralField that you can range over.
[ "Iter", "returns", "a", "channel", "of", "type", "LiteralField", "that", "you", "can", "range", "over", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/literalfield_set.go#L137-L147
train
google/go-jsonnet
parser/parser.go
astVarToIdentifier
func astVarToIdentifier(node ast.Node) (*ast.Identifier, bool) { v, ok := node.(*ast.Var) if ok { return &v.Id, true } return nil, false }
go
func astVarToIdentifier(node ast.Node) (*ast.Identifier, bool) { v, ok := node.(*ast.Var) if ok { return &v.Id, true } return nil, false }
[ "func", "astVarToIdentifier", "(", "node", "ast", ".", "Node", ")", "(", "*", "ast", ".", "Identifier", ",", "bool", ")", "{", "v", ",", "ok", ":=", "node", ".", "(", "*", "ast", ".", "Var", ")", "\n", "if", "ok", "{", "return", "&", "v", ".", ...
// in some cases it's convenient to parse something as an expression, and later // decide that it should be just an identifer
[ "in", "some", "cases", "it", "s", "convenient", "to", "parse", "something", "as", "an", "expression", "and", "later", "decide", "that", "it", "should", "be", "just", "an", "identifer" ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/parser/parser.go#L125-L131
train
google/go-jsonnet
interpreter.go
popIfExists
func (s *callStack) popIfExists(whichFrame int) { if len(s.stack) == whichFrame { if s.top().isCall { s.calls-- } s.stack = s.stack[:len(s.stack)-1] } }
go
func (s *callStack) popIfExists(whichFrame int) { if len(s.stack) == whichFrame { if s.top().isCall { s.calls-- } s.stack = s.stack[:len(s.stack)-1] } }
[ "func", "(", "s", "*", "callStack", ")", "popIfExists", "(", "whichFrame", "int", ")", "{", "if", "len", "(", "s", ".", "stack", ")", "==", "whichFrame", "{", "if", "s", ".", "top", "(", ")", ".", "isCall", "{", "s", ".", "calls", "--", "\n", "...
// It might've been popped already by tail call optimization. // We check if it was trimmed by comparing the current stack size to the position // of the frame we want to pop.
[ "It", "might", "ve", "been", "popped", "already", "by", "tail", "call", "optimization", ".", "We", "check", "if", "it", "was", "trimmed", "by", "comparing", "the", "current", "stack", "size", "to", "the", "position", "of", "the", "frame", "we", "want", "...
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L119-L126
train
google/go-jsonnet
interpreter.go
tailCallTrimStack
func (s *callStack) tailCallTrimStack() { for i := len(s.stack) - 1; i >= 0; i-- { if s.stack[i].isCall { if !s.stack[i].trimmable { return } // Remove this stack frame and everything above it s.stack = s.stack[:i] s.calls-- return } } }
go
func (s *callStack) tailCallTrimStack() { for i := len(s.stack) - 1; i >= 0; i-- { if s.stack[i].isCall { if !s.stack[i].trimmable { return } // Remove this stack frame and everything above it s.stack = s.stack[:i] s.calls-- return } } }
[ "func", "(", "s", "*", "callStack", ")", "tailCallTrimStack", "(", ")", "{", "for", "i", ":=", "len", "(", "s", ".", "stack", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "if", "s", ".", "stack", "[", "i", "]", ".", "isCall", "{...
/** If there is a trimmable frame followed by some locals, pop them all. */
[ "If", "there", "is", "a", "trimmable", "frame", "followed", "by", "some", "locals", "pop", "them", "all", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L129-L141
train
google/go-jsonnet
interpreter.go
getSelfBinding
func (s *callStack) getSelfBinding() selfBinding { for i := len(s.stack) - 1; i >= 0; i-- { if s.stack[i].isCall { return s.stack[i].env.selfBinding } } panic(fmt.Sprintf("malformed stack %v", dumpCallStack(s))) }
go
func (s *callStack) getSelfBinding() selfBinding { for i := len(s.stack) - 1; i >= 0; i-- { if s.stack[i].isCall { return s.stack[i].env.selfBinding } } panic(fmt.Sprintf("malformed stack %v", dumpCallStack(s))) }
[ "func", "(", "s", "*", "callStack", ")", "getSelfBinding", "(", ")", "selfBinding", "{", "for", "i", ":=", "len", "(", "s", ".", "stack", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "if", "s", ".", "stack", "[", "i", "]", ".", ...
// getSelfBinding resolves the self construct
[ "getSelfBinding", "resolves", "the", "self", "construct" ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L167-L174
train
google/go-jsonnet
interpreter.go
lookUpVar
func (s *callStack) lookUpVar(id ast.Identifier) *cachedThunk { for i := len(s.stack) - 1; i >= 0; i-- { bind, present := s.stack[i].env.upValues[id] if present { return bind } if s.stack[i].isCall { // Nothing beyond the captured environment of the thunk / closure. break } } return nil }
go
func (s *callStack) lookUpVar(id ast.Identifier) *cachedThunk { for i := len(s.stack) - 1; i >= 0; i-- { bind, present := s.stack[i].env.upValues[id] if present { return bind } if s.stack[i].isCall { // Nothing beyond the captured environment of the thunk / closure. break } } return nil }
[ "func", "(", "s", "*", "callStack", ")", "lookUpVar", "(", "id", "ast", ".", "Identifier", ")", "*", "cachedThunk", "{", "for", "i", ":=", "len", "(", "s", ".", "stack", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "bind", ",", "p...
// lookUpVar finds for the closest variable in scope that matches the given name.
[ "lookUpVar", "finds", "for", "the", "closest", "variable", "in", "scope", "that", "matches", "the", "given", "name", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L177-L189
train
google/go-jsonnet
interpreter.go
capture
func (s *callStack) capture(freeVars ast.Identifiers) bindingFrame { env := make(bindingFrame) for _, fv := range freeVars { env[fv] = s.lookUpVarOrPanic(fv) } return env }
go
func (s *callStack) capture(freeVars ast.Identifiers) bindingFrame { env := make(bindingFrame) for _, fv := range freeVars { env[fv] = s.lookUpVarOrPanic(fv) } return env }
[ "func", "(", "s", "*", "callStack", ")", "capture", "(", "freeVars", "ast", ".", "Identifiers", ")", "bindingFrame", "{", "env", ":=", "make", "(", "bindingFrame", ")", "\n", "for", "_", ",", "fv", ":=", "range", "freeVars", "{", "env", "[", "fv", "]...
// Build a binding frame containing specified variables.
[ "Build", "a", "binding", "frame", "containing", "specified", "variables", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L207-L213
train
google/go-jsonnet
interpreter.go
addBindings
func addBindings(a, b bindingFrame) bindingFrame { result := make(bindingFrame) for k, v := range a { result[k] = v } for k, v := range b { result[k] = v } return result }
go
func addBindings(a, b bindingFrame) bindingFrame { result := make(bindingFrame) for k, v := range a { result[k] = v } for k, v := range b { result[k] = v } return result }
[ "func", "addBindings", "(", "a", ",", "b", "bindingFrame", ")", "bindingFrame", "{", "result", ":=", "make", "(", "bindingFrame", ")", "\n\n", "for", "k", ",", "v", ":=", "range", "a", "{", "result", "[", "k", "]", "=", "v", "\n", "}", "\n\n", "for...
// Map union, b takes precedence when keys collide.
[ "Map", "union", "b", "takes", "precedence", "when", "keys", "collide", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L243-L255
train
google/go-jsonnet
interpreter.go
unparseString
func unparseString(v string) string { var buf bytes.Buffer buf.WriteString("\"") for _, c := range v { switch c { case '"': buf.WriteString("\\\"") case '\\': buf.WriteString("\\\\") case '\b': buf.WriteString("\\b") case '\f': buf.WriteString("\\f") case '\n': buf.WriteString("\\n") cas...
go
func unparseString(v string) string { var buf bytes.Buffer buf.WriteString("\"") for _, c := range v { switch c { case '"': buf.WriteString("\\\"") case '\\': buf.WriteString("\\\\") case '\b': buf.WriteString("\\b") case '\f': buf.WriteString("\\f") case '\n': buf.WriteString("\\n") cas...
[ "func", "unparseString", "(", "v", "string", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "buf", ".", "WriteString", "(", "\"", "\\\"", "\"", ")", "\n", "for", "_", ",", "c", ":=", "range", "v", "{", "switch", "c", "{", "case", ...
// unparseString Wraps in "" and escapes stuff to make the string JSON-compliant and human-readable.
[ "unparseString", "Wraps", "in", "and", "escapes", "stuff", "to", "make", "the", "string", "JSON", "-", "compliant", "and", "human", "-", "readable", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L569-L600
train
google/go-jsonnet
interpreter.go
manifestString
func (i *interpreter) manifestString(buf *bytes.Buffer, trace TraceElement, v value) error { switch v := v.(type) { case *valueString: buf.WriteString(v.getString()) return nil default: return makeRuntimeError(fmt.Sprintf("expected string result, got: %s", v.getType().name), i.getCurrentStackTrace(trace)) } }
go
func (i *interpreter) manifestString(buf *bytes.Buffer, trace TraceElement, v value) error { switch v := v.(type) { case *valueString: buf.WriteString(v.getString()) return nil default: return makeRuntimeError(fmt.Sprintf("expected string result, got: %s", v.getType().name), i.getCurrentStackTrace(trace)) } }
[ "func", "(", "i", "*", "interpreter", ")", "manifestString", "(", "buf", "*", "bytes", ".", "Buffer", ",", "trace", "TraceElement", ",", "v", "value", ")", "error", "{", "switch", "v", ":=", "v", ".", "(", "type", ")", "{", "case", "*", "valueString"...
// manifestString expects the value to be a string and returns it.
[ "manifestString", "expects", "the", "value", "to", "be", "a", "string", "and", "returns", "it", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/interpreter.go#L790-L798
train
google/go-jsonnet
ast/location.go
LocationRangeBetween
func LocationRangeBetween(a, b *LocationRange) LocationRange { if a.file != b.file { panic("Cannot create a LocationRange between different files") } return MakeLocationRange(a.FileName, a.file, a.Begin, b.End) }
go
func LocationRangeBetween(a, b *LocationRange) LocationRange { if a.file != b.file { panic("Cannot create a LocationRange between different files") } return MakeLocationRange(a.FileName, a.file, a.Begin, b.End) }
[ "func", "LocationRangeBetween", "(", "a", ",", "b", "*", "LocationRange", ")", "LocationRange", "{", "if", "a", ".", "file", "!=", "b", ".", "file", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "MakeLocationRange", "(", "a", ".", "F...
// LocationRangeBetween returns a LocationRange containing both a and b.
[ "LocationRangeBetween", "returns", "a", "LocationRange", "containing", "both", "a", "and", "b", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/location.go#L67-L72
train
google/go-jsonnet
ast/location.go
MakeLocationRange
func MakeLocationRange(fn string, fc *Source, begin Location, end Location) LocationRange { return LocationRange{FileName: fn, file: fc, Begin: begin, End: end} }
go
func MakeLocationRange(fn string, fc *Source, begin Location, end Location) LocationRange { return LocationRange{FileName: fn, file: fc, Begin: begin, End: end} }
[ "func", "MakeLocationRange", "(", "fn", "string", ",", "fc", "*", "Source", ",", "begin", "Location", ",", "end", "Location", ")", "LocationRange", "{", "return", "LocationRange", "{", "FileName", ":", "fn", ",", "file", ":", "fc", ",", "Begin", ":", "be...
// MakeLocationRange creates a LocationRange.
[ "MakeLocationRange", "creates", "a", "LocationRange", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/location.go#L112-L114
train
google/go-jsonnet
ast/location.go
GetSnippet
func (sp *SourceProvider) GetSnippet(loc LocationRange) string { var result bytes.Buffer if loc.Begin.Line == 0 { return "" } for i := loc.Begin.Line; i <= loc.End.Line; i++ { inLineRange := trimToLine(loc, i) for j := inLineRange.Begin.Column; j < inLineRange.End.Column; j++ { result.WriteByte(loc.file.li...
go
func (sp *SourceProvider) GetSnippet(loc LocationRange) string { var result bytes.Buffer if loc.Begin.Line == 0 { return "" } for i := loc.Begin.Line; i <= loc.End.Line; i++ { inLineRange := trimToLine(loc, i) for j := inLineRange.Begin.Column; j < inLineRange.End.Column; j++ { result.WriteByte(loc.file.li...
[ "func", "(", "sp", "*", "SourceProvider", ")", "GetSnippet", "(", "loc", "LocationRange", ")", "string", "{", "var", "result", "bytes", ".", "Buffer", "\n", "if", "loc", ".", "Begin", ".", "Line", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n"...
// GetSnippet returns a code snippet corresponding to loc.
[ "GetSnippet", "returns", "a", "code", "snippet", "corresponding", "to", "loc", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/location.go#L122-L137
train
google/go-jsonnet
ast/ast.go
NewNodeBase
func NewNodeBase(loc LocationRange, freeVariables Identifiers) NodeBase { return NodeBase{ loc: loc, freeVariables: freeVariables, } }
go
func NewNodeBase(loc LocationRange, freeVariables Identifiers) NodeBase { return NodeBase{ loc: loc, freeVariables: freeVariables, } }
[ "func", "NewNodeBase", "(", "loc", "LocationRange", ",", "freeVariables", "Identifiers", ")", "NodeBase", "{", "return", "NodeBase", "{", "loc", ":", "loc", ",", "freeVariables", ":", "freeVariables", ",", "}", "\n", "}" ]
// NewNodeBase creates a new NodeBase from initial LocationRange and // Identifiers.
[ "NewNodeBase", "creates", "a", "new", "NodeBase", "from", "initial", "LocationRange", "and", "Identifiers", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/ast.go#L62-L67
train
google/go-jsonnet
ast/ast.go
FullyEscaped
func (k LiteralStringKind) FullyEscaped() bool { switch k { case StringSingle, StringDouble: return true case StringBlock, VerbatimStringDouble, VerbatimStringSingle: return false } panic(fmt.Sprintf("Unknown string kind: %v", k)) }
go
func (k LiteralStringKind) FullyEscaped() bool { switch k { case StringSingle, StringDouble: return true case StringBlock, VerbatimStringDouble, VerbatimStringSingle: return false } panic(fmt.Sprintf("Unknown string kind: %v", k)) }
[ "func", "(", "k", "LiteralStringKind", ")", "FullyEscaped", "(", ")", "bool", "{", "switch", "k", "{", "case", "StringSingle", ",", "StringDouble", ":", "return", "true", "\n", "case", "StringBlock", ",", "VerbatimStringDouble", ",", "VerbatimStringSingle", ":",...
// FullyEscaped returns true iff the literal string kind may contain escape // sequences that require unescaping.
[ "FullyEscaped", "returns", "true", "iff", "the", "literal", "string", "kind", "may", "contain", "escape", "sequences", "that", "require", "unescaping", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/ast.go#L453-L461
train
google/go-jsonnet
ast/ast.go
ObjectFieldLocalNoMethod
func ObjectFieldLocalNoMethod(id *Identifier, body Node) ObjectField { return ObjectField{ObjectLocal, ObjectFieldVisible, false, false, nil, nil, id, nil, false, body, nil} }
go
func ObjectFieldLocalNoMethod(id *Identifier, body Node) ObjectField { return ObjectField{ObjectLocal, ObjectFieldVisible, false, false, nil, nil, id, nil, false, body, nil} }
[ "func", "ObjectFieldLocalNoMethod", "(", "id", "*", "Identifier", ",", "body", "Node", ")", "ObjectField", "{", "return", "ObjectField", "{", "ObjectLocal", ",", "ObjectFieldVisible", ",", "false", ",", "false", ",", "nil", ",", "nil", ",", "id", ",", "nil",...
// ObjectFieldLocalNoMethod creates a non-method local object field.
[ "ObjectFieldLocalNoMethod", "creates", "a", "non", "-", "method", "local", "object", "field", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/ast.go#L514-L516
train
google/go-jsonnet
ast/clone.go
cloneForSpec
func cloneForSpec(specPtr *ForSpec) { clone(&specPtr.Expr) oldOuter := specPtr.Outer if oldOuter != nil { specPtr.Outer = new(ForSpec) *specPtr.Outer = *oldOuter cloneForSpec(specPtr.Outer) } for i := range specPtr.Conditions { clone(&specPtr.Conditions[i].Expr) } }
go
func cloneForSpec(specPtr *ForSpec) { clone(&specPtr.Expr) oldOuter := specPtr.Outer if oldOuter != nil { specPtr.Outer = new(ForSpec) *specPtr.Outer = *oldOuter cloneForSpec(specPtr.Outer) } for i := range specPtr.Conditions { clone(&specPtr.Conditions[i].Expr) } }
[ "func", "cloneForSpec", "(", "specPtr", "*", "ForSpec", ")", "{", "clone", "(", "&", "specPtr", ".", "Expr", ")", "\n", "oldOuter", ":=", "specPtr", ".", "Outer", "\n", "if", "oldOuter", "!=", "nil", "{", "specPtr", ".", "Outer", "=", "new", "(", "Fo...
// Updates fields of specPtr to point to deep clones.
[ "Updates", "fields", "of", "specPtr", "to", "point", "to", "deep", "clones", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/clone.go#L25-L36
train
google/go-jsonnet
ast/clone.go
cloneParameters
func cloneParameters(params *Parameters) { if params == nil { return } params.Optional = append(make([]NamedParameter, 0), params.Optional...) for i := range params.Optional { clone(&params.Optional[i].DefaultArg) } }
go
func cloneParameters(params *Parameters) { if params == nil { return } params.Optional = append(make([]NamedParameter, 0), params.Optional...) for i := range params.Optional { clone(&params.Optional[i].DefaultArg) } }
[ "func", "cloneParameters", "(", "params", "*", "Parameters", ")", "{", "if", "params", "==", "nil", "{", "return", "\n", "}", "\n", "params", ".", "Optional", "=", "append", "(", "make", "(", "[", "]", "NamedParameter", ",", "0", ")", ",", "params", ...
// Updates fields of params to point to deep clones.
[ "Updates", "fields", "of", "params", "to", "point", "to", "deep", "clones", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/clone.go#L39-L47
train
google/go-jsonnet
ast/clone.go
cloneField
func cloneField(field *ObjectField) { if field.Method != nil { field.Method = Clone(field.Method).(*Function) } oldParams := field.Params if oldParams != nil { field.Params = new(Parameters) *field.Params = *oldParams } cloneParameters(field.Params) clone(&field.Expr1) clone(&field.Expr2) clone(&field....
go
func cloneField(field *ObjectField) { if field.Method != nil { field.Method = Clone(field.Method).(*Function) } oldParams := field.Params if oldParams != nil { field.Params = new(Parameters) *field.Params = *oldParams } cloneParameters(field.Params) clone(&field.Expr1) clone(&field.Expr2) clone(&field....
[ "func", "cloneField", "(", "field", "*", "ObjectField", ")", "{", "if", "field", ".", "Method", "!=", "nil", "{", "field", ".", "Method", "=", "Clone", "(", "field", ".", "Method", ")", ".", "(", "*", "Function", ")", "\n", "}", "\n\n", "oldParams", ...
// Updates fields of field to point to deep clones.
[ "Updates", "fields", "of", "field", "to", "point", "to", "deep", "clones", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/clone.go#L50-L65
train
google/go-jsonnet
ast/clone.go
cloneNodeBase
func cloneNodeBase(astPtr Node) { if astPtr.Context() != nil { newContext := new(string) *newContext = *astPtr.Context() astPtr.SetContext(newContext) } astPtr.SetFreeVariables(append(make(Identifiers, 0), astPtr.FreeVariables()...)) }
go
func cloneNodeBase(astPtr Node) { if astPtr.Context() != nil { newContext := new(string) *newContext = *astPtr.Context() astPtr.SetContext(newContext) } astPtr.SetFreeVariables(append(make(Identifiers, 0), astPtr.FreeVariables()...)) }
[ "func", "cloneNodeBase", "(", "astPtr", "Node", ")", "{", "if", "astPtr", ".", "Context", "(", ")", "!=", "nil", "{", "newContext", ":=", "new", "(", "string", ")", "\n", "*", "newContext", "=", "*", "astPtr", ".", "Context", "(", ")", "\n", "astPtr"...
// Updates the NodeBase fields of astPtr to point to deep clones.
[ "Updates", "the", "NodeBase", "fields", "of", "astPtr", "to", "point", "to", "deep", "clones", "." ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/ast/clone.go#L74-L81
train
google/go-jsonnet
dump/pointermap.go
getAllAndReusedPointers
func (pm *pointerMap) getAllAndReusedPointers(v reflect.Value) { if v.Kind() == reflect.Invalid { return } if isPointerValue(v) && v.Pointer() != 0 { // pointer is 0 for unexported fields reused := pm.addPointer(v.Pointer()) if reused { // No use descending inside this value, since it have been seen before ...
go
func (pm *pointerMap) getAllAndReusedPointers(v reflect.Value) { if v.Kind() == reflect.Invalid { return } if isPointerValue(v) && v.Pointer() != 0 { // pointer is 0 for unexported fields reused := pm.addPointer(v.Pointer()) if reused { // No use descending inside this value, since it have been seen before ...
[ "func", "(", "pm", "*", "pointerMap", ")", "getAllAndReusedPointers", "(", "v", "reflect", ".", "Value", ")", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Invalid", "{", "return", "\n", "}", "\n", "if", "isPointerValue", "(", "v", ")...
// Recursively consider v and each of its children, updating pointer information
[ "Recursively", "consider", "v", "and", "each", "of", "its", "children", "updating", "pointer", "information" ]
181c86d8157c7de54d052305b318be18b34d27d0
https://github.com/google/go-jsonnet/blob/181c86d8157c7de54d052305b318be18b34d27d0/dump/pointermap.go#L81-L119
train
gobuffalo/pop
associations/associations_for_struct.go
ForStruct
func ForStruct(s interface{}, fields ...string) (Associations, error) { associations := Associations{} innerAssociations := InnerAssociations{} t, v := getModelDefinition(s) fields = trimFields(fields) // validate if fields contains a non existing field in struct. // and vefiry is it has inner associations. fo...
go
func ForStruct(s interface{}, fields ...string) (Associations, error) { associations := Associations{} innerAssociations := InnerAssociations{} t, v := getModelDefinition(s) fields = trimFields(fields) // validate if fields contains a non existing field in struct. // and vefiry is it has inner associations. fo...
[ "func", "ForStruct", "(", "s", "interface", "{", "}", ",", "fields", "...", "string", ")", "(", "Associations", ",", "error", ")", "{", "associations", ":=", "Associations", "{", "}", "\n", "innerAssociations", ":=", "InnerAssociations", "{", "}", "\n\n", ...
// ForStruct returns all associations for // the struct specified. It takes into account tags // associations like has_many, belongs_to, has_one. // it throws an error when it finds a field that does // not exist for a model.
[ "ForStruct", "returns", "all", "associations", "for", "the", "struct", "specified", ".", "It", "takes", "into", "account", "tags", "associations", "like", "has_many", "belongs_to", "has_one", ".", "it", "throws", "an", "error", "when", "it", "finds", "a", "fie...
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/associations/associations_for_struct.go#L42-L106
train
gobuffalo/pop
slices/uuid.go
Scan
func (s *UUID) Scan(src interface{}) error { b, ok := src.([]byte) if !ok { return errors.New("Scan source was not []byte") } us, err := strSliceToUUIDSlice(strToUUID(string(b))) if err != nil { return errors.WithStack(err) } *s = us return nil }
go
func (s *UUID) Scan(src interface{}) error { b, ok := src.([]byte) if !ok { return errors.New("Scan source was not []byte") } us, err := strSliceToUUIDSlice(strToUUID(string(b))) if err != nil { return errors.WithStack(err) } *s = us return nil }
[ "func", "(", "s", "*", "UUID", ")", "Scan", "(", "src", "interface", "{", "}", ")", "error", "{", "b", ",", "ok", ":=", "src", ".", "(", "[", "]", "byte", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")"...
// Scan implements the sql.Scanner interface. // It allows to read the UUID slice from the database value.
[ "Scan", "implements", "the", "sql", ".", "Scanner", "interface", ".", "It", "allows", "to", "read", "the", "UUID", "slice", "from", "the", "database", "value", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/slices/uuid.go#L25-L36
train
gobuffalo/pop
slices/uuid.go
Value
func (s UUID) Value() (driver.Value, error) { ss := make([]string, len(s)) for i, u := range s { ss[i] = u.String() } return fmt.Sprintf("{%s}", strings.Join(ss, ",")), nil }
go
func (s UUID) Value() (driver.Value, error) { ss := make([]string, len(s)) for i, u := range s { ss[i] = u.String() } return fmt.Sprintf("{%s}", strings.Join(ss, ",")), nil }
[ "func", "(", "s", "UUID", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "ss", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "s", ")", ")", "\n", "for", "i", ",", "u", ":=", "range", "s", "{", "ss", ...
// Value implements the driver.Valuer interface. // It allows to convert the UUID slice to a driver.value.
[ "Value", "implements", "the", "driver", ".", "Valuer", "interface", ".", "It", "allows", "to", "convert", "the", "UUID", "slice", "to", "a", "driver", ".", "value", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/slices/uuid.go#L40-L46
train
gobuffalo/pop
slices/uuid.go
UnmarshalJSON
func (s *UUID) UnmarshalJSON(data []byte) error { var ss []string if err := json.Unmarshal(data, &ss); err != nil { return err } us, err := strSliceToUUIDSlice(ss) if err != nil { return errors.WithStack(err) } *s = us return nil }
go
func (s *UUID) UnmarshalJSON(data []byte) error { var ss []string if err := json.Unmarshal(data, &ss); err != nil { return err } us, err := strSliceToUUIDSlice(ss) if err != nil { return errors.WithStack(err) } *s = us return nil }
[ "func", "(", "s", "*", "UUID", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ss", "[", "]", "string", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "ss", ")", ";", "err", "!=", "nil"...
// UnmarshalJSON will unmarshall JSON value into // the UUID slice representation of this value.
[ "UnmarshalJSON", "will", "unmarshall", "JSON", "value", "into", "the", "UUID", "slice", "representation", "of", "this", "value", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/slices/uuid.go#L50-L61
train
gobuffalo/pop
slices/uuid.go
UnmarshalText
func (s *UUID) UnmarshalText(text []byte) error { var ss []string for _, x := range strings.Split(string(text), ",") { ss = append(ss, strings.TrimSpace(x)) } us, err := strSliceToUUIDSlice(ss) if err != nil { return errors.WithStack(err) } *s = us return nil }
go
func (s *UUID) UnmarshalText(text []byte) error { var ss []string for _, x := range strings.Split(string(text), ",") { ss = append(ss, strings.TrimSpace(x)) } us, err := strSliceToUUIDSlice(ss) if err != nil { return errors.WithStack(err) } *s = us return nil }
[ "func", "(", "s", "*", "UUID", ")", "UnmarshalText", "(", "text", "[", "]", "byte", ")", "error", "{", "var", "ss", "[", "]", "string", "\n", "for", "_", ",", "x", ":=", "range", "strings", ".", "Split", "(", "string", "(", "text", ")", ",", "\...
// UnmarshalText will unmarshall text value into // the UUID slice representation of this value.
[ "UnmarshalText", "will", "unmarshall", "text", "value", "into", "the", "UUID", "slice", "representation", "of", "this", "value", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/slices/uuid.go#L65-L76
train
gobuffalo/pop
migration.go
MigrationCreate
func MigrationCreate(path, name, ext string, up, down []byte) error { g := makr.New() n := time.Now().UTC() s := n.Format("20060102150405") upf := filepath.Join(path, fmt.Sprintf("%s_%s.up.%s", s, name, ext)) g.Add(makr.NewFile(upf, string(up))) downf := filepath.Join(path, fmt.Sprintf("%s_%s.down.%s", s, name,...
go
func MigrationCreate(path, name, ext string, up, down []byte) error { g := makr.New() n := time.Now().UTC() s := n.Format("20060102150405") upf := filepath.Join(path, fmt.Sprintf("%s_%s.up.%s", s, name, ext)) g.Add(makr.NewFile(upf, string(up))) downf := filepath.Join(path, fmt.Sprintf("%s_%s.down.%s", s, name,...
[ "func", "MigrationCreate", "(", "path", ",", "name", ",", "ext", "string", ",", "up", ",", "down", "[", "]", "byte", ")", "error", "{", "g", ":=", "makr", ".", "New", "(", ")", "\n", "n", ":=", "time", ".", "Now", "(", ")", ".", "UTC", "(", "...
// MigrationCreate writes contents for a given migration in normalized files
[ "MigrationCreate", "writes", "contents", "for", "a", "given", "migration", "in", "normalized", "files" ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/migration.go#L14-L26
train
gobuffalo/pop
migrator.go
NewMigrator
func NewMigrator(c *Connection) Migrator { return Migrator{ Connection: c, Migrations: map[string]Migrations{ "up": {}, "down": {}, }, } }
go
func NewMigrator(c *Connection) Migrator { return Migrator{ Connection: c, Migrations: map[string]Migrations{ "up": {}, "down": {}, }, } }
[ "func", "NewMigrator", "(", "c", "*", "Connection", ")", "Migrator", "{", "return", "Migrator", "{", "Connection", ":", "c", ",", "Migrations", ":", "map", "[", "string", "]", "Migrations", "{", "\"", "\"", ":", "{", "}", ",", "\"", "\"", ":", "{", ...
// NewMigrator returns a new "blank" migrator. It is recommended // to use something like MigrationBox or FileMigrator. A "blank" // Migrator should only be used as the basis for a new type of // migration system.
[ "NewMigrator", "returns", "a", "new", "blank", "migrator", ".", "It", "is", "recommended", "to", "use", "something", "like", "MigrationBox", "or", "FileMigrator", ".", "A", "blank", "Migrator", "should", "only", "be", "used", "as", "the", "basis", "for", "a"...
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/migrator.go#L22-L30
train
gobuffalo/pop
migrator.go
UpLogOnly
func (m Migrator) UpLogOnly() error { c := m.Connection return m.exec(func() error { mtn := c.MigrationTableName() mfs := m.Migrations["up"] sort.Sort(mfs) return c.Transaction(func(tx *Connection) error { for _, mi := range mfs { if mi.DBType != "all" && mi.DBType != c.Dialect.Name() { // Skip mi...
go
func (m Migrator) UpLogOnly() error { c := m.Connection return m.exec(func() error { mtn := c.MigrationTableName() mfs := m.Migrations["up"] sort.Sort(mfs) return c.Transaction(func(tx *Connection) error { for _, mi := range mfs { if mi.DBType != "all" && mi.DBType != c.Dialect.Name() { // Skip mi...
[ "func", "(", "m", "Migrator", ")", "UpLogOnly", "(", ")", "error", "{", "c", ":=", "m", ".", "Connection", "\n", "return", "m", ".", "exec", "(", "func", "(", ")", "error", "{", "mtn", ":=", "c", ".", "MigrationTableName", "(", ")", "\n", "mfs", ...
// UpLogOnly insert pending "up" migrations logs only, without applying the patch. // It's used when loading the schema dump, instead of the migrations.
[ "UpLogOnly", "insert", "pending", "up", "migrations", "logs", "only", "without", "applying", "the", "patch", ".", "It", "s", "used", "when", "loading", "the", "schema", "dump", "instead", "of", "the", "migrations", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/migrator.go#L44-L71
train
gobuffalo/pop
migrator.go
Up
func (m Migrator) Up() error { c := m.Connection return m.exec(func() error { mtn := c.MigrationTableName() mfs := m.Migrations["up"] sort.Sort(mfs) applied := 0 for _, mi := range mfs { if mi.DBType != "all" && mi.DBType != c.Dialect.Name() { // Skip migration for non-matching dialect continue ...
go
func (m Migrator) Up() error { c := m.Connection return m.exec(func() error { mtn := c.MigrationTableName() mfs := m.Migrations["up"] sort.Sort(mfs) applied := 0 for _, mi := range mfs { if mi.DBType != "all" && mi.DBType != c.Dialect.Name() { // Skip migration for non-matching dialect continue ...
[ "func", "(", "m", "Migrator", ")", "Up", "(", ")", "error", "{", "c", ":=", "m", ".", "Connection", "\n", "return", "m", ".", "exec", "(", "func", "(", ")", "error", "{", "mtn", ":=", "c", ".", "MigrationTableName", "(", ")", "\n", "mfs", ":=", ...
// Up runs pending "up" migrations and applies them to the database.
[ "Up", "runs", "pending", "up", "migrations", "and", "applies", "them", "to", "the", "database", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/migrator.go#L74-L112
train
gobuffalo/pop
migrator.go
Down
func (m Migrator) Down(step int) error { c := m.Connection return m.exec(func() error { mtn := c.MigrationTableName() count, err := c.Count(mtn) if err != nil { return errors.Wrap(err, "migration down: unable count existing migration") } mfs := m.Migrations["down"] sort.Sort(sort.Reverse(mfs)) // ski...
go
func (m Migrator) Down(step int) error { c := m.Connection return m.exec(func() error { mtn := c.MigrationTableName() count, err := c.Count(mtn) if err != nil { return errors.Wrap(err, "migration down: unable count existing migration") } mfs := m.Migrations["down"] sort.Sort(sort.Reverse(mfs)) // ski...
[ "func", "(", "m", "Migrator", ")", "Down", "(", "step", "int", ")", "error", "{", "c", ":=", "m", ".", "Connection", "\n", "return", "m", ".", "exec", "(", "func", "(", ")", "error", "{", "mtn", ":=", "c", ".", "MigrationTableName", "(", ")", "\n...
// Down runs pending "down" migrations and rolls back the // database by the specified number of steps.
[ "Down", "runs", "pending", "down", "migrations", "and", "rolls", "back", "the", "database", "by", "the", "specified", "number", "of", "steps", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/migrator.go#L116-L155
train
gobuffalo/pop
migrator.go
Reset
func (m Migrator) Reset() error { err := m.Down(-1) if err != nil { return errors.WithStack(err) } return m.Up() }
go
func (m Migrator) Reset() error { err := m.Down(-1) if err != nil { return errors.WithStack(err) } return m.Up() }
[ "func", "(", "m", "Migrator", ")", "Reset", "(", ")", "error", "{", "err", ":=", "m", ".", "Down", "(", "-", "1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "return", "m", ...
// Reset the database by running the down migrations followed by the up migrations.
[ "Reset", "the", "database", "by", "running", "the", "down", "migrations", "followed", "by", "the", "up", "migrations", "." ]
9eeaaa184b5e2f2d98ba1a306447621f64bc1826
https://github.com/gobuffalo/pop/blob/9eeaaa184b5e2f2d98ba1a306447621f64bc1826/migrator.go#L158-L164
train