id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
18,100
instana/go-sensor
event.go
SendHostEvent
func SendHostEvent(title string, text string, sev severity, duration time.Duration) { sendEvent(&EventData{ Title: title, Text: text, Duration: int(duration / time.Millisecond), Severity: int(sev), }) }
go
func SendHostEvent(title string, text string, sev severity, duration time.Duration) { sendEvent(&EventData{ Title: title, Text: text, Duration: int(duration / time.Millisecond), Severity: int(sev), }) }
[ "func", "SendHostEvent", "(", "title", "string", ",", "text", "string", ",", "sev", "severity", ",", "duration", "time", ".", "Duration", ")", "{", "sendEvent", "(", "&", "EventData", "{", "Title", ":", "title", ",", "Text", ":", "text", ",", "Duration",...
// SendHostEvent send an event on the current host
[ "SendHostEvent", "send", "an", "event", "on", "the", "current", "host" ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/event.go#L60-L67
18,101
instana/go-sensor
tracer.go
NewTracerWithOptions
func NewTracerWithOptions(options *Options) ot.Tracer { InitSensor(options) return NewTracerWithEverything(options, NewRecorder()) }
go
func NewTracerWithOptions(options *Options) ot.Tracer { InitSensor(options) return NewTracerWithEverything(options, NewRecorder()) }
[ "func", "NewTracerWithOptions", "(", "options", "*", "Options", ")", "ot", ".", "Tracer", "{", "InitSensor", "(", "options", ")", "\n\n", "return", "NewTracerWithEverything", "(", "options", ",", "NewRecorder", "(", ")", ")", "\n", "}" ]
// NewTracerWithOptions Get a new Tracer with the specified options.
[ "NewTracerWithOptions", "Get", "a", "new", "Tracer", "with", "the", "specified", "options", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/tracer.go#L103-L107
18,102
instana/go-sensor
tracer.go
NewTracerWithEverything
func NewTracerWithEverything(options *Options, recorder SpanRecorder) ot.Tracer { InitSensor(options) ret := &tracerS{options: TracerOptions{ Recorder: recorder, ShouldSample: shouldSample, MaxLogsPerSpan: MaxLogsPerSpan}} ret.textPropagator = &textMapPropagator{ret} return ret }
go
func NewTracerWithEverything(options *Options, recorder SpanRecorder) ot.Tracer { InitSensor(options) ret := &tracerS{options: TracerOptions{ Recorder: recorder, ShouldSample: shouldSample, MaxLogsPerSpan: MaxLogsPerSpan}} ret.textPropagator = &textMapPropagator{ret} return ret }
[ "func", "NewTracerWithEverything", "(", "options", "*", "Options", ",", "recorder", "SpanRecorder", ")", "ot", ".", "Tracer", "{", "InitSensor", "(", "options", ")", "\n", "ret", ":=", "&", "tracerS", "{", "options", ":", "TracerOptions", "{", "Recorder", ":...
// NewTracerWithEverything Get a new Tracer with the works.
[ "NewTracerWithEverything", "Get", "a", "new", "Tracer", "with", "the", "works", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/tracer.go#L110-L119
18,103
instana/go-sensor
recorder.go
RecordSpan
func (r *Recorder) RecordSpan(span *spanS) { // If we're not announced and not in test mode then just // return if !r.testMode && !sensor.agent.canSend() { return } var data = &jsonData{} kindTag := span.getSpanKindTag() data.SDK = &jsonSDKData{ Name: span.Operation, Type: kindTag, Custom: &jsonCus...
go
func (r *Recorder) RecordSpan(span *spanS) { // If we're not announced and not in test mode then just // return if !r.testMode && !sensor.agent.canSend() { return } var data = &jsonData{} kindTag := span.getSpanKindTag() data.SDK = &jsonSDKData{ Name: span.Operation, Type: kindTag, Custom: &jsonCus...
[ "func", "(", "r", "*", "Recorder", ")", "RecordSpan", "(", "span", "*", "spanS", ")", "{", "// If we're not announced and not in test mode then just", "// return", "if", "!", "r", ".", "testMode", "&&", "!", "sensor", ".", "agent", ".", "canSend", "(", ")", ...
// RecordSpan accepts spans to be recorded and and added to the span queue // for eventual reporting to the host agent.
[ "RecordSpan", "accepts", "spans", "to", "be", "recorded", "and", "and", "added", "to", "the", "span", "queue", "for", "eventual", "reporting", "to", "the", "host", "agent", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/recorder.go#L58-L122
18,104
instana/go-sensor
recorder.go
QueuedSpansCount
func (r *Recorder) QueuedSpansCount() int { r.RLock() defer r.RUnlock() return len(r.spans) }
go
func (r *Recorder) QueuedSpansCount() int { r.RLock() defer r.RUnlock() return len(r.spans) }
[ "func", "(", "r", "*", "Recorder", ")", "QueuedSpansCount", "(", ")", "int", "{", "r", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "RUnlock", "(", ")", "\n", "return", "len", "(", "r", ".", "spans", ")", "\n", "}" ]
// QueuedSpansCount returns the number of queued spans // Used only in tests currently.
[ "QueuedSpansCount", "returns", "the", "number", "of", "queued", "spans", "Used", "only", "in", "tests", "currently", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/recorder.go#L126-L130
18,105
instana/go-sensor
recorder.go
GetQueuedSpans
func (r *Recorder) GetQueuedSpans() []jsonSpan { r.Lock() defer r.Unlock() // Copy queued spans queuedSpans := make([]jsonSpan, len(r.spans)) copy(queuedSpans, r.spans) // and clear out the source r.clearQueuedSpans() return queuedSpans }
go
func (r *Recorder) GetQueuedSpans() []jsonSpan { r.Lock() defer r.Unlock() // Copy queued spans queuedSpans := make([]jsonSpan, len(r.spans)) copy(queuedSpans, r.spans) // and clear out the source r.clearQueuedSpans() return queuedSpans }
[ "func", "(", "r", "*", "Recorder", ")", "GetQueuedSpans", "(", ")", "[", "]", "jsonSpan", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", "// Copy queued spans", "queuedSpans", ":=", "make", "(", "[", "]", "jsonS...
// GetQueuedSpans returns a copy of the queued spans and clears the queue.
[ "GetQueuedSpans", "returns", "a", "copy", "of", "the", "queued", "spans", "and", "clears", "the", "queue", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/recorder.go#L133-L144
18,106
instana/go-sensor
recorder.go
send
func (r *Recorder) send() { spansToSend := r.GetQueuedSpans() if len(spansToSend) > 0 { go func() { _, err := sensor.agent.request(sensor.agent.makeURL(agentTracesURL), "POST", spansToSend) if err != nil { log.debug("Posting traces failed in send(): ", err) sensor.agent.reset() } }() } }
go
func (r *Recorder) send() { spansToSend := r.GetQueuedSpans() if len(spansToSend) > 0 { go func() { _, err := sensor.agent.request(sensor.agent.makeURL(agentTracesURL), "POST", spansToSend) if err != nil { log.debug("Posting traces failed in send(): ", err) sensor.agent.reset() } }() } }
[ "func", "(", "r", "*", "Recorder", ")", "send", "(", ")", "{", "spansToSend", ":=", "r", ".", "GetQueuedSpans", "(", ")", "\n", "if", "len", "(", "spansToSend", ")", ">", "0", "{", "go", "func", "(", ")", "{", "_", ",", "err", ":=", "sensor", "...
// Retrieve the queued spans and post them to the host agent asynchronously.
[ "Retrieve", "the", "queued", "spans", "and", "post", "them", "to", "the", "host", "agent", "asynchronously", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/recorder.go#L165-L176
18,107
mitchellh/go-vnc
client.go
CutText
func (c *ClientConn) CutText(text string) error { var buf bytes.Buffer // This is the fixed size data we'll send fixedData := []interface{}{ uint8(6), uint8(0), uint8(0), uint8(0), uint32(len(text)), } for _, val := range fixedData { if err := binary.Write(&buf, binary.BigEndian, val); err != nil { ...
go
func (c *ClientConn) CutText(text string) error { var buf bytes.Buffer // This is the fixed size data we'll send fixedData := []interface{}{ uint8(6), uint8(0), uint8(0), uint8(0), uint32(len(text)), } for _, val := range fixedData { if err := binary.Write(&buf, binary.BigEndian, val); err != nil { ...
[ "func", "(", "c", "*", "ClientConn", ")", "CutText", "(", "text", "string", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "// This is the fixed size data we'll send", "fixedData", ":=", "[", "]", "interface", "{", "}", "{", "uint8", "(", ...
// CutText tells the server that the client has new text in its cut buffer. // The text string MUST only contain Latin-1 characters. This encoding // is compatible with Go's native string format, but can only use up to // unicode.MaxLatin values. // // See RFC 6143 Section 7.5.6
[ "CutText", "tells", "the", "server", "that", "the", "client", "has", "new", "text", "in", "its", "cut", "buffer", ".", "The", "text", "string", "MUST", "only", "contain", "Latin", "-", "1", "characters", ".", "This", "encoding", "is", "compatible", "with",...
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L95-L129
18,108
mitchellh/go-vnc
client.go
FramebufferUpdateRequest
func (c *ClientConn) FramebufferUpdateRequest(incremental bool, x, y, width, height uint16) error { var buf bytes.Buffer var incrementalByte uint8 = 0 if incremental { incrementalByte = 1 } data := []interface{}{ uint8(3), incrementalByte, x, y, width, height, } for _, val := range data { if err := ...
go
func (c *ClientConn) FramebufferUpdateRequest(incremental bool, x, y, width, height uint16) error { var buf bytes.Buffer var incrementalByte uint8 = 0 if incremental { incrementalByte = 1 } data := []interface{}{ uint8(3), incrementalByte, x, y, width, height, } for _, val := range data { if err := ...
[ "func", "(", "c", "*", "ClientConn", ")", "FramebufferUpdateRequest", "(", "incremental", "bool", ",", "x", ",", "y", ",", "width", ",", "height", "uint16", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "var", "incrementalByte", "uint8", ...
// Requests a framebuffer update from the server. There may be an indefinite // time between the request and the actual framebuffer update being // received. // // See RFC 6143 Section 7.5.3
[ "Requests", "a", "framebuffer", "update", "from", "the", "server", ".", "There", "may", "be", "an", "indefinite", "time", "between", "the", "request", "and", "the", "actual", "framebuffer", "update", "being", "received", ".", "See", "RFC", "6143", "Section", ...
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L136-L161
18,109
mitchellh/go-vnc
client.go
KeyEvent
func (c *ClientConn) KeyEvent(keysym uint32, down bool) error { var downFlag uint8 = 0 if down { downFlag = 1 } data := []interface{}{ uint8(4), downFlag, uint8(0), uint8(0), keysym, } for _, val := range data { if err := binary.Write(c.c, binary.BigEndian, val); err != nil { return err } } ...
go
func (c *ClientConn) KeyEvent(keysym uint32, down bool) error { var downFlag uint8 = 0 if down { downFlag = 1 } data := []interface{}{ uint8(4), downFlag, uint8(0), uint8(0), keysym, } for _, val := range data { if err := binary.Write(c.c, binary.BigEndian, val); err != nil { return err } } ...
[ "func", "(", "c", "*", "ClientConn", ")", "KeyEvent", "(", "keysym", "uint32", ",", "down", "bool", ")", "error", "{", "var", "downFlag", "uint8", "=", "0", "\n", "if", "down", "{", "downFlag", "=", "1", "\n", "}", "\n\n", "data", ":=", "[", "]", ...
// KeyEvent indiciates a key press or release and sends it to the server. // The key is indicated using the X Window System "keysym" value. Use // Google to find a reference of these values. To simulate a key press, // you must send a key with both a down event, and a non-down event. // // See 7.5.4.
[ "KeyEvent", "indiciates", "a", "key", "press", "or", "release", "and", "sends", "it", "to", "the", "server", ".", "The", "key", "is", "indicated", "using", "the", "X", "Window", "System", "keysym", "value", ".", "Use", "Google", "to", "find", "a", "refer...
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L169-L190
18,110
mitchellh/go-vnc
client.go
PointerEvent
func (c *ClientConn) PointerEvent(mask ButtonMask, x, y uint16) error { var buf bytes.Buffer data := []interface{}{ uint8(5), uint8(mask), x, y, } for _, val := range data { if err := binary.Write(&buf, binary.BigEndian, val); err != nil { return err } } if _, err := c.c.Write(buf.Bytes()[0:6]);...
go
func (c *ClientConn) PointerEvent(mask ButtonMask, x, y uint16) error { var buf bytes.Buffer data := []interface{}{ uint8(5), uint8(mask), x, y, } for _, val := range data { if err := binary.Write(&buf, binary.BigEndian, val); err != nil { return err } } if _, err := c.c.Write(buf.Bytes()[0:6]);...
[ "func", "(", "c", "*", "ClientConn", ")", "PointerEvent", "(", "mask", "ButtonMask", ",", "x", ",", "y", "uint16", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "data", ":=", "[", "]", "interface", "{", "}", "{", "uint8", "(", "5...
// PointerEvent indicates that pointer movement or a pointer button // press or release. // // The mask is a bitwise mask of various ButtonMask values. When a button // is set, it is pressed, when it is unset, it is released. // // See RFC 6143 Section 7.5.5
[ "PointerEvent", "indicates", "that", "pointer", "movement", "or", "a", "pointer", "button", "press", "or", "release", ".", "The", "mask", "is", "a", "bitwise", "mask", "of", "various", "ButtonMask", "values", ".", "When", "a", "button", "is", "set", "it", ...
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L199-L220
18,111
mitchellh/go-vnc
client.go
SetEncodings
func (c *ClientConn) SetEncodings(encs []Encoding) error { data := make([]interface{}, 3+len(encs)) data[0] = uint8(2) data[1] = uint8(0) data[2] = uint16(len(encs)) for i, enc := range encs { data[3+i] = int32(enc.Type()) } var buf bytes.Buffer for _, val := range data { if err := binary.Write(&buf, bina...
go
func (c *ClientConn) SetEncodings(encs []Encoding) error { data := make([]interface{}, 3+len(encs)) data[0] = uint8(2) data[1] = uint8(0) data[2] = uint16(len(encs)) for i, enc := range encs { data[3+i] = int32(enc.Type()) } var buf bytes.Buffer for _, val := range data { if err := binary.Write(&buf, bina...
[ "func", "(", "c", "*", "ClientConn", ")", "SetEncodings", "(", "encs", "[", "]", "Encoding", ")", "error", "{", "data", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "3", "+", "len", "(", "encs", ")", ")", "\n", "data", "[", "0", "]"...
// SetEncodings sets the encoding types in which the pixel data can // be sent from the server. After calling this method, the encs slice // given should not be modified. // // See RFC 6143 Section 7.5.2
[ "SetEncodings", "sets", "the", "encoding", "types", "in", "which", "the", "pixel", "data", "can", "be", "sent", "from", "the", "server", ".", "After", "calling", "this", "method", "the", "encs", "slice", "given", "should", "not", "be", "modified", ".", "Se...
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L227-L252
18,112
mitchellh/go-vnc
client.go
SetPixelFormat
func (c *ClientConn) SetPixelFormat(format *PixelFormat) error { var keyEvent [20]byte keyEvent[0] = 0 pfBytes, err := writePixelFormat(format) if err != nil { return err } // Copy the pixel format bytes into the proper slice location copy(keyEvent[4:], pfBytes) // Send the data down the connection if _, ...
go
func (c *ClientConn) SetPixelFormat(format *PixelFormat) error { var keyEvent [20]byte keyEvent[0] = 0 pfBytes, err := writePixelFormat(format) if err != nil { return err } // Copy the pixel format bytes into the proper slice location copy(keyEvent[4:], pfBytes) // Send the data down the connection if _, ...
[ "func", "(", "c", "*", "ClientConn", ")", "SetPixelFormat", "(", "format", "*", "PixelFormat", ")", "error", "{", "var", "keyEvent", "[", "20", "]", "byte", "\n", "keyEvent", "[", "0", "]", "=", "0", "\n\n", "pfBytes", ",", "err", ":=", "writePixelForm...
// SetPixelFormat sets the format in which pixel values should be sent // in FramebufferUpdate messages from the server. // // See RFC 6143 Section 7.5.1
[ "SetPixelFormat", "sets", "the", "format", "in", "which", "pixel", "values", "should", "be", "sent", "in", "FramebufferUpdate", "messages", "from", "the", "server", ".", "See", "RFC", "6143", "Section", "7", ".", "5", ".", "1" ]
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L258-L280
18,113
mitchellh/go-vnc
client.go
mainLoop
func (c *ClientConn) mainLoop() { defer c.Close() // Build the map of available server messages typeMap := make(map[uint8]ServerMessage) defaultMessages := []ServerMessage{ new(FramebufferUpdateMessage), new(SetColorMapEntriesMessage), new(BellMessage), new(ServerCutTextMessage), } for _, msg := range ...
go
func (c *ClientConn) mainLoop() { defer c.Close() // Build the map of available server messages typeMap := make(map[uint8]ServerMessage) defaultMessages := []ServerMessage{ new(FramebufferUpdateMessage), new(SetColorMapEntriesMessage), new(BellMessage), new(ServerCutTextMessage), } for _, msg := range ...
[ "func", "(", "c", "*", "ClientConn", ")", "mainLoop", "(", ")", "{", "defer", "c", ".", "Close", "(", ")", "\n\n", "// Build the map of available server messages", "typeMap", ":=", "make", "(", "map", "[", "uint8", "]", "ServerMessage", ")", "\n\n", "default...
// mainLoop reads messages sent from the server and routes them to the // proper channels for users of the client to read.
[ "mainLoop", "reads", "messages", "sent", "from", "the", "server", "and", "routes", "them", "to", "the", "proper", "channels", "for", "users", "of", "the", "client", "to", "read", "." ]
723ed9867aed0f3209a81151e52ddc61681f0b01
https://github.com/mitchellh/go-vnc/blob/723ed9867aed0f3209a81151e52ddc61681f0b01/client.go#L422-L468
18,114
RackSec/srslog
dialer.go
unixDialer
func (w *Writer) unixDialer() (serverConn, string, error) { sc, err := unixSyslog() hostname := w.hostname if hostname == "" { hostname = "localhost" } return sc, hostname, err }
go
func (w *Writer) unixDialer() (serverConn, string, error) { sc, err := unixSyslog() hostname := w.hostname if hostname == "" { hostname = "localhost" } return sc, hostname, err }
[ "func", "(", "w", "*", "Writer", ")", "unixDialer", "(", ")", "(", "serverConn", ",", "string", ",", "error", ")", "{", "sc", ",", "err", ":=", "unixSyslog", "(", ")", "\n", "hostname", ":=", "w", ".", "hostname", "\n", "if", "hostname", "==", "\""...
// unixDialer uses the unixSyslog method to open a connection to the syslog // daemon running on the local machine.
[ "unixDialer", "uses", "the", "unixSyslog", "method", "to", "open", "a", "connection", "to", "the", "syslog", "daemon", "running", "on", "the", "local", "machine", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/dialer.go#L51-L58
18,115
RackSec/srslog
dialer.go
tlsDialer
func (w *Writer) tlsDialer() (serverConn, string, error) { c, err := tls.Dial("tcp", w.raddr, w.tlsConfig) var sc serverConn hostname := w.hostname if err == nil { sc = &netConn{conn: c} if hostname == "" { hostname = c.LocalAddr().String() } } return sc, hostname, err }
go
func (w *Writer) tlsDialer() (serverConn, string, error) { c, err := tls.Dial("tcp", w.raddr, w.tlsConfig) var sc serverConn hostname := w.hostname if err == nil { sc = &netConn{conn: c} if hostname == "" { hostname = c.LocalAddr().String() } } return sc, hostname, err }
[ "func", "(", "w", "*", "Writer", ")", "tlsDialer", "(", ")", "(", "serverConn", ",", "string", ",", "error", ")", "{", "c", ",", "err", ":=", "tls", ".", "Dial", "(", "\"", "\"", ",", "w", ".", "raddr", ",", "w", ".", "tlsConfig", ")", "\n", ...
// tlsDialer connects to TLS over TCP, and is used for the "tcp+tls" network // type.
[ "tlsDialer", "connects", "to", "TLS", "over", "TCP", "and", "is", "used", "for", "the", "tcp", "+", "tls", "network", "type", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/dialer.go#L62-L73
18,116
RackSec/srslog
dialer.go
basicDialer
func (w *Writer) basicDialer() (serverConn, string, error) { c, err := net.Dial(w.network, w.raddr) var sc serverConn hostname := w.hostname if err == nil { sc = &netConn{conn: c} if hostname == "" { hostname = c.LocalAddr().String() } } return sc, hostname, err }
go
func (w *Writer) basicDialer() (serverConn, string, error) { c, err := net.Dial(w.network, w.raddr) var sc serverConn hostname := w.hostname if err == nil { sc = &netConn{conn: c} if hostname == "" { hostname = c.LocalAddr().String() } } return sc, hostname, err }
[ "func", "(", "w", "*", "Writer", ")", "basicDialer", "(", ")", "(", "serverConn", ",", "string", ",", "error", ")", "{", "c", ",", "err", ":=", "net", ".", "Dial", "(", "w", ".", "network", ",", "w", ".", "raddr", ")", "\n", "var", "sc", "serve...
// basicDialer is the most common dialer for syslog, and supports both TCP and // UDP connections.
[ "basicDialer", "is", "the", "most", "common", "dialer", "for", "syslog", "and", "supports", "both", "TCP", "and", "UDP", "connections", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/dialer.go#L77-L88
18,117
RackSec/srslog
dialer.go
customDialer
func (w *Writer) customDialer() (serverConn, string, error) { c, err := w.customDial(w.network, w.raddr) var sc serverConn hostname := w.hostname if err == nil { sc = &netConn{conn: c} if hostname == "" { hostname = c.LocalAddr().String() } } return sc, hostname, err }
go
func (w *Writer) customDialer() (serverConn, string, error) { c, err := w.customDial(w.network, w.raddr) var sc serverConn hostname := w.hostname if err == nil { sc = &netConn{conn: c} if hostname == "" { hostname = c.LocalAddr().String() } } return sc, hostname, err }
[ "func", "(", "w", "*", "Writer", ")", "customDialer", "(", ")", "(", "serverConn", ",", "string", ",", "error", ")", "{", "c", ",", "err", ":=", "w", ".", "customDial", "(", "w", ".", "network", ",", "w", ".", "raddr", ")", "\n", "var", "sc", "...
// customDialer uses the custom dialer when the Writer was created // giving developers total control over how connections are made and returned. // Note it does not check if cdialer is nil, as it should only be referenced from getDialer.
[ "customDialer", "uses", "the", "custom", "dialer", "when", "the", "Writer", "was", "created", "giving", "developers", "total", "control", "over", "how", "connections", "are", "made", "and", "returned", ".", "Note", "it", "does", "not", "check", "if", "cdialer"...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/dialer.go#L93-L104
18,118
RackSec/srslog
writer.go
getConn
func (w *Writer) getConn() serverConn { w.mu.RLock() conn := w.conn w.mu.RUnlock() return conn }
go
func (w *Writer) getConn() serverConn { w.mu.RLock() conn := w.conn w.mu.RUnlock() return conn }
[ "func", "(", "w", "*", "Writer", ")", "getConn", "(", ")", "serverConn", "{", "w", ".", "mu", ".", "RLock", "(", ")", "\n", "conn", ":=", "w", ".", "conn", "\n", "w", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "conn", "\n", "}" ]
// getConn provides access to the internal conn, protected by a mutex. The // conn is threadsafe, so it can be used while unlocked, but we want to avoid // race conditions on grabbing a reference to it.
[ "getConn", "provides", "access", "to", "the", "internal", "conn", "protected", "by", "a", "mutex", ".", "The", "conn", "is", "threadsafe", "so", "it", "can", "be", "used", "while", "unlocked", "but", "we", "want", "to", "avoid", "race", "conditions", "on",...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L30-L35
18,119
RackSec/srslog
writer.go
setConn
func (w *Writer) setConn(c serverConn) { w.mu.Lock() w.conn = c w.mu.Unlock() }
go
func (w *Writer) setConn(c serverConn) { w.mu.Lock() w.conn = c w.mu.Unlock() }
[ "func", "(", "w", "*", "Writer", ")", "setConn", "(", "c", "serverConn", ")", "{", "w", ".", "mu", ".", "Lock", "(", ")", "\n", "w", ".", "conn", "=", "c", "\n", "w", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
// setConn updates the internal conn, protected by a mutex.
[ "setConn", "updates", "the", "internal", "conn", "protected", "by", "a", "mutex", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L38-L42
18,120
RackSec/srslog
writer.go
connect
func (w *Writer) connect() (serverConn, error) { conn := w.getConn() if conn != nil { // ignore err from close, it makes sense to continue anyway conn.close() w.setConn(nil) } var hostname string var err error dialer := w.getDialer() conn, hostname, err = dialer.Call() if err == nil { w.setConn(conn) ...
go
func (w *Writer) connect() (serverConn, error) { conn := w.getConn() if conn != nil { // ignore err from close, it makes sense to continue anyway conn.close() w.setConn(nil) } var hostname string var err error dialer := w.getDialer() conn, hostname, err = dialer.Call() if err == nil { w.setConn(conn) ...
[ "func", "(", "w", "*", "Writer", ")", "connect", "(", ")", "(", "serverConn", ",", "error", ")", "{", "conn", ":=", "w", ".", "getConn", "(", ")", "\n", "if", "conn", "!=", "nil", "{", "// ignore err from close, it makes sense to continue anyway", "conn", ...
// connect makes a connection to the syslog server.
[ "connect", "makes", "a", "connection", "to", "the", "syslog", "server", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L45-L65
18,121
RackSec/srslog
writer.go
WriteWithPriority
func (w *Writer) WriteWithPriority(p Priority, b []byte) (int, error) { return w.writeAndRetryWithPriority(p, string(b)) }
go
func (w *Writer) WriteWithPriority(p Priority, b []byte) (int, error) { return w.writeAndRetryWithPriority(p, string(b)) }
[ "func", "(", "w", "*", "Writer", ")", "WriteWithPriority", "(", "p", "Priority", ",", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "w", ".", "writeAndRetryWithPriority", "(", "p", ",", "string", "(", "b", ")", ")", "\n"...
// WriteWithPriority sends a log message with a custom priority.
[ "WriteWithPriority", "sends", "a", "log", "message", "with", "a", "custom", "priority", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L89-L91
18,122
RackSec/srslog
writer.go
writeAndRetry
func (w *Writer) writeAndRetry(severity Priority, s string) (int, error) { pr := (w.priority & facilityMask) | (severity & severityMask) return w.writeAndRetryWithPriority(pr, s) }
go
func (w *Writer) writeAndRetry(severity Priority, s string) (int, error) { pr := (w.priority & facilityMask) | (severity & severityMask) return w.writeAndRetryWithPriority(pr, s) }
[ "func", "(", "w", "*", "Writer", ")", "writeAndRetry", "(", "severity", "Priority", ",", "s", "string", ")", "(", "int", ",", "error", ")", "{", "pr", ":=", "(", "w", ".", "priority", "&", "facilityMask", ")", "|", "(", "severity", "&", "severityMask...
// writeAndRetry takes a severity and the string to write. Any facility passed to // it as part of the severity Priority will be ignored.
[ "writeAndRetry", "takes", "a", "severity", "and", "the", "string", "to", "write", ".", "Any", "facility", "passed", "to", "it", "as", "part", "of", "the", "severity", "Priority", "will", "be", "ignored", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L162-L166
18,123
RackSec/srslog
writer.go
writeAndRetryWithPriority
func (w *Writer) writeAndRetryWithPriority(p Priority, s string) (int, error) { conn := w.getConn() if conn != nil { if n, err := w.write(conn, p, s); err == nil { return n, err } } var err error if conn, err = w.connect(); err != nil { return 0, err } return w.write(conn, p, s) }
go
func (w *Writer) writeAndRetryWithPriority(p Priority, s string) (int, error) { conn := w.getConn() if conn != nil { if n, err := w.write(conn, p, s); err == nil { return n, err } } var err error if conn, err = w.connect(); err != nil { return 0, err } return w.write(conn, p, s) }
[ "func", "(", "w", "*", "Writer", ")", "writeAndRetryWithPriority", "(", "p", "Priority", ",", "s", "string", ")", "(", "int", ",", "error", ")", "{", "conn", ":=", "w", ".", "getConn", "(", ")", "\n", "if", "conn", "!=", "nil", "{", "if", "n", ",...
// writeAndRetryWithPriority differs from writeAndRetry in that it allows setting // of both the facility and the severity.
[ "writeAndRetryWithPriority", "differs", "from", "writeAndRetry", "in", "that", "it", "allows", "setting", "of", "both", "the", "facility", "and", "the", "severity", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L170-L183
18,124
RackSec/srslog
writer.go
write
func (w *Writer) write(conn serverConn, p Priority, msg string) (int, error) { // ensure it ends in a \n if !strings.HasSuffix(msg, "\n") { msg += "\n" } err := conn.writeString(w.framer, w.formatter, p, w.hostname, w.tag, msg) if err != nil { return 0, err } // Note: return the length of the input, not the...
go
func (w *Writer) write(conn serverConn, p Priority, msg string) (int, error) { // ensure it ends in a \n if !strings.HasSuffix(msg, "\n") { msg += "\n" } err := conn.writeString(w.framer, w.formatter, p, w.hostname, w.tag, msg) if err != nil { return 0, err } // Note: return the length of the input, not the...
[ "func", "(", "w", "*", "Writer", ")", "write", "(", "conn", "serverConn", ",", "p", "Priority", ",", "msg", "string", ")", "(", "int", ",", "error", ")", "{", "// ensure it ends in a \\n", "if", "!", "strings", ".", "HasSuffix", "(", "msg", ",", "\"", ...
// write generates and writes a syslog formatted string. It formats the // message based on the current Formatter and Framer.
[ "write", "generates", "and", "writes", "a", "syslog", "formatted", "string", ".", "It", "formats", "the", "message", "based", "on", "the", "current", "Formatter", "and", "Framer", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/writer.go#L187-L201
18,125
RackSec/srslog
net_conn.go
writeString
func (n *netConn) writeString(framer Framer, formatter Formatter, p Priority, hostname, tag, msg string) error { if framer == nil { framer = DefaultFramer } if formatter == nil { formatter = DefaultFormatter } formattedMessage := framer(formatter(p, hostname, tag, msg)) _, err := n.conn.Write([]byte(formatted...
go
func (n *netConn) writeString(framer Framer, formatter Formatter, p Priority, hostname, tag, msg string) error { if framer == nil { framer = DefaultFramer } if formatter == nil { formatter = DefaultFormatter } formattedMessage := framer(formatter(p, hostname, tag, msg)) _, err := n.conn.Write([]byte(formatted...
[ "func", "(", "n", "*", "netConn", ")", "writeString", "(", "framer", "Framer", ",", "formatter", "Formatter", ",", "p", "Priority", ",", "hostname", ",", "tag", ",", "msg", "string", ")", "error", "{", "if", "framer", "==", "nil", "{", "framer", "=", ...
// writeString formats syslog messages using time.RFC3339 and includes the // hostname, and sends the message to the connection.
[ "writeString", "formats", "syslog", "messages", "using", "time", ".", "RFC3339", "and", "includes", "the", "hostname", "and", "sends", "the", "message", "to", "the", "connection", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/net_conn.go#L15-L25
18,126
RackSec/srslog
formatter.go
UnixFormatter
func UnixFormatter(p Priority, hostname, tag, content string) string { timestamp := time.Now().Format(time.Stamp) msg := fmt.Sprintf("<%d>%s %s[%d]: %s", p, timestamp, tag, os.Getpid(), content) return msg }
go
func UnixFormatter(p Priority, hostname, tag, content string) string { timestamp := time.Now().Format(time.Stamp) msg := fmt.Sprintf("<%d>%s %s[%d]: %s", p, timestamp, tag, os.Getpid(), content) return msg }
[ "func", "UnixFormatter", "(", "p", "Priority", ",", "hostname", ",", "tag", ",", "content", "string", ")", "string", "{", "timestamp", ":=", "time", ".", "Now", "(", ")", ".", "Format", "(", "time", ".", "Stamp", ")", "\n", "msg", ":=", "fmt", ".", ...
// UnixFormatter omits the hostname, because it is only used locally.
[ "UnixFormatter", "omits", "the", "hostname", "because", "it", "is", "only", "used", "locally", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/formatter.go#L27-L32
18,127
RackSec/srslog
formatter.go
truncateStartStr
func truncateStartStr(s string, max int) string { if (len(s) > max) { return s[len(s) - max:] } return s }
go
func truncateStartStr(s string, max int) string { if (len(s) > max) { return s[len(s) - max:] } return s }
[ "func", "truncateStartStr", "(", "s", "string", ",", "max", "int", ")", "string", "{", "if", "(", "len", "(", "s", ")", ">", "max", ")", "{", "return", "s", "[", "len", "(", "s", ")", "-", "max", ":", "]", "\n", "}", "\n", "return", "s", "\n"...
// if string's length is greater than max, then use the last part
[ "if", "string", "s", "length", "is", "greater", "than", "max", "then", "use", "the", "last", "part" ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/formatter.go#L43-L48
18,128
RackSec/srslog
formatter.go
RFC5424Formatter
func RFC5424Formatter(p Priority, hostname, tag, content string) string { timestamp := time.Now().Format(time.RFC3339) pid := os.Getpid() appName := truncateStartStr(os.Args[0], appNameMaxLength) msg := fmt.Sprintf("<%d>%d %s %s %s %d %s - %s", p, 1, timestamp, hostname, appName, pid, tag, content) return msg }
go
func RFC5424Formatter(p Priority, hostname, tag, content string) string { timestamp := time.Now().Format(time.RFC3339) pid := os.Getpid() appName := truncateStartStr(os.Args[0], appNameMaxLength) msg := fmt.Sprintf("<%d>%d %s %s %s %d %s - %s", p, 1, timestamp, hostname, appName, pid, tag, content) return msg }
[ "func", "RFC5424Formatter", "(", "p", "Priority", ",", "hostname", ",", "tag", ",", "content", "string", ")", "string", "{", "timestamp", ":=", "time", ".", "Now", "(", ")", ".", "Format", "(", "time", ".", "RFC3339", ")", "\n", "pid", ":=", "os", "....
// RFC5424Formatter provides an RFC 5424 compliant message.
[ "RFC5424Formatter", "provides", "an", "RFC", "5424", "compliant", "message", "." ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/formatter.go#L51-L58
18,129
RackSec/srslog
srslog.go
Dial
func Dial(network, raddr string, priority Priority, tag string) (*Writer, error) { return DialWithTLSConfig(network, raddr, priority, tag, nil) }
go
func Dial(network, raddr string, priority Priority, tag string) (*Writer, error) { return DialWithTLSConfig(network, raddr, priority, tag, nil) }
[ "func", "Dial", "(", "network", ",", "raddr", "string", ",", "priority", "Priority", ",", "tag", "string", ")", "(", "*", "Writer", ",", "error", ")", "{", "return", "DialWithTLSConfig", "(", "network", ",", "raddr", ",", "priority", ",", "tag", ",", "...
// Dial establishes a connection to a log daemon by connecting to // address raddr on the specified network. Each write to the returned // Writer sends a log message with the given facility, severity and // tag. // If network is empty, Dial will connect to the local syslog server.
[ "Dial", "establishes", "a", "connection", "to", "a", "log", "daemon", "by", "connecting", "to", "address", "raddr", "on", "the", "specified", "network", ".", "Each", "write", "to", "the", "returned", "Writer", "sends", "a", "log", "message", "with", "the", ...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L36-L38
18,130
RackSec/srslog
srslog.go
DialWithCustomDialer
func DialWithCustomDialer(network, raddr string, priority Priority, tag string, customDial DialFunc) (*Writer, error) { if customDial == nil { return nil, ErrNilDialFunc } return dialAllParameters(network, raddr, priority, tag, nil, customDial) }
go
func DialWithCustomDialer(network, raddr string, priority Priority, tag string, customDial DialFunc) (*Writer, error) { if customDial == nil { return nil, ErrNilDialFunc } return dialAllParameters(network, raddr, priority, tag, nil, customDial) }
[ "func", "DialWithCustomDialer", "(", "network", ",", "raddr", "string", ",", "priority", "Priority", ",", "tag", "string", ",", "customDial", "DialFunc", ")", "(", "*", "Writer", ",", "error", ")", "{", "if", "customDial", "==", "nil", "{", "return", "nil"...
// DialWithCustomDialer establishes a connection by calling customDial. // Each write to the returned Writer sends a log message with the given facility, severity and tag. // Network must be "custom" in order for this package to use customDial. // While network and raddr will be passed to customDial, it is allowed for ...
[ "DialWithCustomDialer", "establishes", "a", "connection", "by", "calling", "customDial", ".", "Each", "write", "to", "the", "returned", "Writer", "sends", "a", "log", "message", "with", "the", "given", "facility", "severity", "and", "tag", ".", "Network", "must"...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L49-L54
18,131
RackSec/srslog
srslog.go
DialWithTLSCertPath
func DialWithTLSCertPath(network, raddr string, priority Priority, tag, certPath string) (*Writer, error) { serverCert, err := ioutil.ReadFile(certPath) if err != nil { return nil, err } return DialWithTLSCert(network, raddr, priority, tag, serverCert) }
go
func DialWithTLSCertPath(network, raddr string, priority Priority, tag, certPath string) (*Writer, error) { serverCert, err := ioutil.ReadFile(certPath) if err != nil { return nil, err } return DialWithTLSCert(network, raddr, priority, tag, serverCert) }
[ "func", "DialWithTLSCertPath", "(", "network", ",", "raddr", "string", ",", "priority", "Priority", ",", "tag", ",", "certPath", "string", ")", "(", "*", "Writer", ",", "error", ")", "{", "serverCert", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "c...
// DialWithTLSCertPath establishes a secure connection to a log daemon by connecting to // address raddr on the specified network. It uses certPath to load TLS certificates and configure // the secure connection.
[ "DialWithTLSCertPath", "establishes", "a", "secure", "connection", "to", "a", "log", "daemon", "by", "connecting", "to", "address", "raddr", "on", "the", "specified", "network", ".", "It", "uses", "certPath", "to", "load", "TLS", "certificates", "and", "configur...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L59-L66
18,132
RackSec/srslog
srslog.go
DialWithTLSCert
func DialWithTLSCert(network, raddr string, priority Priority, tag string, serverCert []byte) (*Writer, error) { pool := x509.NewCertPool() pool.AppendCertsFromPEM(serverCert) config := tls.Config{ RootCAs: pool, } return DialWithTLSConfig(network, raddr, priority, tag, &config) }
go
func DialWithTLSCert(network, raddr string, priority Priority, tag string, serverCert []byte) (*Writer, error) { pool := x509.NewCertPool() pool.AppendCertsFromPEM(serverCert) config := tls.Config{ RootCAs: pool, } return DialWithTLSConfig(network, raddr, priority, tag, &config) }
[ "func", "DialWithTLSCert", "(", "network", ",", "raddr", "string", ",", "priority", "Priority", ",", "tag", "string", ",", "serverCert", "[", "]", "byte", ")", "(", "*", "Writer", ",", "error", ")", "{", "pool", ":=", "x509", ".", "NewCertPool", "(", "...
// DialWIthTLSCert establishes a secure connection to a log daemon by connecting to // address raddr on the specified network. It uses serverCert to load a TLS certificate // and configure the secure connection.
[ "DialWIthTLSCert", "establishes", "a", "secure", "connection", "to", "a", "log", "daemon", "by", "connecting", "to", "address", "raddr", "on", "the", "specified", "network", ".", "It", "uses", "serverCert", "to", "load", "a", "TLS", "certificate", "and", "conf...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L71-L79
18,133
RackSec/srslog
srslog.go
DialWithTLSConfig
func DialWithTLSConfig(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config) (*Writer, error) { return dialAllParameters(network, raddr, priority, tag, tlsConfig, nil) }
go
func DialWithTLSConfig(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config) (*Writer, error) { return dialAllParameters(network, raddr, priority, tag, tlsConfig, nil) }
[ "func", "DialWithTLSConfig", "(", "network", ",", "raddr", "string", ",", "priority", "Priority", ",", "tag", "string", ",", "tlsConfig", "*", "tls", ".", "Config", ")", "(", "*", "Writer", ",", "error", ")", "{", "return", "dialAllParameters", "(", "netwo...
// DialWithTLSConfig establishes a secure connection to a log daemon by connecting to // address raddr on the specified network. It uses tlsConfig to configure the secure connection.
[ "DialWithTLSConfig", "establishes", "a", "secure", "connection", "to", "a", "log", "daemon", "by", "connecting", "to", "address", "raddr", "on", "the", "specified", "network", ".", "It", "uses", "tlsConfig", "to", "configure", "the", "secure", "connection", "." ...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L83-L85
18,134
RackSec/srslog
srslog.go
dialAllParameters
func dialAllParameters(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config, customDial DialFunc) (*Writer, error) { if err := validatePriority(priority); err != nil { return nil, err } if tag == "" { tag = os.Args[0] } hostname, _ := os.Hostname() w := &Writer{ priority: priority...
go
func dialAllParameters(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config, customDial DialFunc) (*Writer, error) { if err := validatePriority(priority); err != nil { return nil, err } if tag == "" { tag = os.Args[0] } hostname, _ := os.Hostname() w := &Writer{ priority: priority...
[ "func", "dialAllParameters", "(", "network", ",", "raddr", "string", ",", "priority", "Priority", ",", "tag", "string", ",", "tlsConfig", "*", "tls", ".", "Config", ",", "customDial", "DialFunc", ")", "(", "*", "Writer", ",", "error", ")", "{", "if", "er...
// implementation of the various functions above
[ "implementation", "of", "the", "various", "functions", "above" ]
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L88-L113
18,135
RackSec/srslog
srslog.go
NewLogger
func NewLogger(p Priority, logFlag int) (*log.Logger, error) { s, err := New(p, "") if err != nil { return nil, err } return log.New(s, "", logFlag), nil }
go
func NewLogger(p Priority, logFlag int) (*log.Logger, error) { s, err := New(p, "") if err != nil { return nil, err } return log.New(s, "", logFlag), nil }
[ "func", "NewLogger", "(", "p", "Priority", ",", "logFlag", "int", ")", "(", "*", "log", ".", "Logger", ",", "error", ")", "{", "s", ",", "err", ":=", "New", "(", "p", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// NewLogger creates a log.Logger whose output is written to // the system log service with the specified priority. The logFlag // argument is the flag set passed through to log.New to create // the Logger.
[ "NewLogger", "creates", "a", "log", ".", "Logger", "whose", "output", "is", "written", "to", "the", "system", "log", "service", "with", "the", "specified", "priority", ".", "The", "logFlag", "argument", "is", "the", "flag", "set", "passed", "through", "to", ...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog.go#L119-L125
18,136
RackSec/srslog
srslog_unix.go
unixSyslog
func unixSyslog() (conn serverConn, err error) { logTypes := []string{"unixgram", "unix"} logPaths := []string{"/dev/log", "/var/run/syslog", "/var/run/log"} for _, network := range logTypes { for _, path := range logPaths { conn, err := net.Dial(network, path) if err != nil { continue } else { re...
go
func unixSyslog() (conn serverConn, err error) { logTypes := []string{"unixgram", "unix"} logPaths := []string{"/dev/log", "/var/run/syslog", "/var/run/log"} for _, network := range logTypes { for _, path := range logPaths { conn, err := net.Dial(network, path) if err != nil { continue } else { re...
[ "func", "unixSyslog", "(", ")", "(", "conn", "serverConn", ",", "err", "error", ")", "{", "logTypes", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", "\n", "logPaths", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ...
// unixSyslog opens a connection to the syslog daemon running on the // local machine using a Unix domain socket. This function exists because of // Solaris support as implemented by gccgo. On Solaris you can not // simply open a TCP connection to the syslog daemon. The gccgo // sources have a syslog_solaris.go file ...
[ "unixSyslog", "opens", "a", "connection", "to", "the", "syslog", "daemon", "running", "on", "the", "local", "machine", "using", "a", "Unix", "domain", "socket", ".", "This", "function", "exists", "because", "of", "Solaris", "support", "as", "implemented", "by"...
a4725f04ec91af1a91b380da679d6e0c2f061e59
https://github.com/RackSec/srslog/blob/a4725f04ec91af1a91b380da679d6e0c2f061e59/srslog_unix.go#L16-L30
18,137
percona/go-mysql
dsn/dsn.go
GetSocketFromTCPConnection
func GetSocketFromTCPConnection(ctx context.Context, dsn string) (socket string, err error) { db, err := sql.Open("mysql", dsn) if err != nil { return "", ErrNoSocket } defer db.Close() err = db.QueryRowContext(ctx, "SELECT @@socket").Scan(socket) if err != nil { return "", ErrNoSocket } if !path.IsAbs(soc...
go
func GetSocketFromTCPConnection(ctx context.Context, dsn string) (socket string, err error) { db, err := sql.Open("mysql", dsn) if err != nil { return "", ErrNoSocket } defer db.Close() err = db.QueryRowContext(ctx, "SELECT @@socket").Scan(socket) if err != nil { return "", ErrNoSocket } if !path.IsAbs(soc...
[ "func", "GetSocketFromTCPConnection", "(", "ctx", "context", ".", "Context", ",", "dsn", "string", ")", "(", "socket", "string", ",", "err", "error", ")", "{", "db", ",", "err", ":=", "sql", ".", "Open", "(", "\"", "\"", ",", "dsn", ")", "\n", "if", ...
// GetSocketFromTCPConnection will try to get socket path by connecting to MySQL localhost TCP port. // This is not reliable as TCP connections may be not allowed.
[ "GetSocketFromTCPConnection", "will", "try", "to", "get", "socket", "path", "by", "connecting", "to", "MySQL", "localhost", "TCP", "port", ".", "This", "is", "not", "reliable", "as", "TCP", "connections", "may", "be", "not", "allowed", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/dsn/dsn.go#L209-L228
18,138
percona/go-mysql
dsn/dsn.go
GetSocket
func GetSocket(ctx context.Context, dsn string) (string, error) { var socket string var err error socket, err = GetSocketFromTCPConnection(ctx, dsn) if err != nil { socket, err = GetSocketFromProcessList(ctx) if err != nil { socket, err = GetSocketFromNetstat(ctx) } } return socket, err }
go
func GetSocket(ctx context.Context, dsn string) (string, error) { var socket string var err error socket, err = GetSocketFromTCPConnection(ctx, dsn) if err != nil { socket, err = GetSocketFromProcessList(ctx) if err != nil { socket, err = GetSocketFromNetstat(ctx) } } return socket, err }
[ "func", "GetSocket", "(", "ctx", "context", ".", "Context", ",", "dsn", "string", ")", "(", "string", ",", "error", ")", "{", "var", "socket", "string", "\n", "var", "err", "error", "\n", "socket", ",", "err", "=", "GetSocketFromTCPConnection", "(", "ctx...
// GetSocket tries to detect and return path to the MySQL socket.
[ "GetSocket", "tries", "to", "detect", "and", "return", "path", "to", "the", "MySQL", "socket", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/dsn/dsn.go#L330-L341
18,139
percona/go-mysql
event/aggregator.go
AddEvent
func (a *Aggregator) AddEvent(event *log.Event, id, fingerprint string) { if a.rateLimit != event.RateLimit { a.rateLimit = event.RateLimit } outlier := false if a.outlierTime > 0 && event.TimeMetrics["Query_time"] > a.outlierTime { outlier = true } a.global.AddEvent(event, outlier) class, ok := a.classes...
go
func (a *Aggregator) AddEvent(event *log.Event, id, fingerprint string) { if a.rateLimit != event.RateLimit { a.rateLimit = event.RateLimit } outlier := false if a.outlierTime > 0 && event.TimeMetrics["Query_time"] > a.outlierTime { outlier = true } a.global.AddEvent(event, outlier) class, ok := a.classes...
[ "func", "(", "a", "*", "Aggregator", ")", "AddEvent", "(", "event", "*", "log", ".", "Event", ",", "id", ",", "fingerprint", "string", ")", "{", "if", "a", ".", "rateLimit", "!=", "event", ".", "RateLimit", "{", "a", ".", "rateLimit", "=", "event", ...
// AddEvent adds the event to the aggregator, automatically creating new classes // as needed.
[ "AddEvent", "adds", "the", "event", "to", "the", "aggregator", "automatically", "creating", "new", "classes", "as", "needed", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/aggregator.go#L63-L81
18,140
percona/go-mysql
event/aggregator.go
Finalize
func (a *Aggregator) Finalize() Result { a.global.Finalize(a.rateLimit) a.global.UniqueQueries = uint(len(a.classes)) for _, class := range a.classes { class.Finalize(a.rateLimit) class.UniqueQueries = 1 if class.Example != nil && class.Example.Ts != "" { if t, err := time.Parse("2006-01-02 15:04:05", class...
go
func (a *Aggregator) Finalize() Result { a.global.Finalize(a.rateLimit) a.global.UniqueQueries = uint(len(a.classes)) for _, class := range a.classes { class.Finalize(a.rateLimit) class.UniqueQueries = 1 if class.Example != nil && class.Example.Ts != "" { if t, err := time.Parse("2006-01-02 15:04:05", class...
[ "func", "(", "a", "*", "Aggregator", ")", "Finalize", "(", ")", "Result", "{", "a", ".", "global", ".", "Finalize", "(", "a", ".", "rateLimit", ")", "\n", "a", ".", "global", ".", "UniqueQueries", "=", "uint", "(", "len", "(", "a", ".", "classes", ...
// Finalize calculates all metric statistics and returns a Result. // Call this function when done adding events to the aggregator.
[ "Finalize", "calculates", "all", "metric", "statistics", "and", "returns", "a", "Result", ".", "Call", "this", "function", "when", "done", "adding", "events", "to", "the", "aggregator", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/aggregator.go#L85-L104
18,141
percona/go-mysql
log/slow/parser.go
NewSlowLogParser
func NewSlowLogParser(file *os.File, opt log.Options) *SlowLogParser { if opt.DefaultLocation == nil { // Old MySQL format assumes time is taken from SYSTEM. opt.DefaultLocation = time.Local } p := &SlowLogParser{ file: file, opt: opt, // -- stopChan: make(chan bool, 1), eventChan: make(chan *log...
go
func NewSlowLogParser(file *os.File, opt log.Options) *SlowLogParser { if opt.DefaultLocation == nil { // Old MySQL format assumes time is taken from SYSTEM. opt.DefaultLocation = time.Local } p := &SlowLogParser{ file: file, opt: opt, // -- stopChan: make(chan bool, 1), eventChan: make(chan *log...
[ "func", "NewSlowLogParser", "(", "file", "*", "os", ".", "File", ",", "opt", "log", ".", "Options", ")", "*", "SlowLogParser", "{", "if", "opt", ".", "DefaultLocation", "==", "nil", "{", "// Old MySQL format assumes time is taken from SYSTEM.", "opt", ".", "Defa...
// NewSlowLogParser returns a new SlowLogParser that reads from the open file.
[ "NewSlowLogParser", "returns", "a", "new", "SlowLogParser", "that", "reads", "from", "the", "open", "file", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/log/slow/parser.go#L67-L87
18,142
percona/go-mysql
log/slow/parser.go
Stop
func (p *SlowLogParser) Stop() { if p.opt.Debug { l.Println("stopping") } p.stopChan <- true return }
go
func (p *SlowLogParser) Stop() { if p.opt.Debug { l.Println("stopping") } p.stopChan <- true return }
[ "func", "(", "p", "*", "SlowLogParser", ")", "Stop", "(", ")", "{", "if", "p", ".", "opt", ".", "Debug", "{", "l", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "p", ".", "stopChan", "<-", "true", "\n", "return", "\n", "}" ]
// Stop stops the parser before parsing the next event or while blocked on // sending the current event to the event channel.
[ "Stop", "stops", "the", "parser", "before", "parsing", "the", "next", "event", "or", "while", "blocked", "on", "sending", "the", "current", "event", "to", "the", "event", "channel", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/log/slow/parser.go#L97-L103
18,143
percona/go-mysql
log/slow/parser.go
Start
func (p *SlowLogParser) Start() error { if p.opt.Debug { l.SetFlags(l.Ltime | l.Lmicroseconds) fmt.Println() l.Println("parsing " + p.file.Name()) } // Seek to the offset, if any. // @todo error if start off > file size if p.opt.StartOffset > 0 { if _, err := p.file.Seek(int64(p.opt.StartOffset), os.SEEK_...
go
func (p *SlowLogParser) Start() error { if p.opt.Debug { l.SetFlags(l.Ltime | l.Lmicroseconds) fmt.Println() l.Println("parsing " + p.file.Name()) } // Seek to the offset, if any. // @todo error if start off > file size if p.opt.StartOffset > 0 { if _, err := p.file.Seek(int64(p.opt.StartOffset), os.SEEK_...
[ "func", "(", "p", "*", "SlowLogParser", ")", "Start", "(", ")", "error", "{", "if", "p", ".", "opt", ".", "Debug", "{", "l", ".", "SetFlags", "(", "l", ".", "Ltime", "|", "l", ".", "Lmicroseconds", ")", "\n", "fmt", ".", "Println", "(", ")", "\...
// Start starts the parser. Events are sent to the unbuffered event channel. // Parsing stops on EOF, error, or call to Stop. The event channel is closed // when parsing stops. The file is not closed.
[ "Start", "starts", "the", "parser", ".", "Events", "are", "sent", "to", "the", "unbuffered", "event", "channel", ".", "Parsing", "stops", "on", "EOF", "error", "or", "call", "to", "Stop", ".", "The", "event", "channel", "is", "closed", "when", "parsing", ...
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/log/slow/parser.go#L108-L194
18,144
percona/go-mysql
event/class.go
NewClass
func NewClass(id, fingerprint string, sample bool) *Class { class := &Class{ Id: id, Fingerprint: fingerprint, Metrics: NewMetrics(), TotalQueries: 0, Example: &Example{}, sample: sample, } return class }
go
func NewClass(id, fingerprint string, sample bool) *Class { class := &Class{ Id: id, Fingerprint: fingerprint, Metrics: NewMetrics(), TotalQueries: 0, Example: &Example{}, sample: sample, } return class }
[ "func", "NewClass", "(", "id", ",", "fingerprint", "string", ",", "sample", "bool", ")", "*", "Class", "{", "class", ":=", "&", "Class", "{", "Id", ":", "id", ",", "Fingerprint", ":", "fingerprint", ",", "Metrics", ":", "NewMetrics", "(", ")", ",", "...
// NewClass returns a new Class for the class ID and fingerprint. // If sample is true, the query with the greatest Query_time is saved.
[ "NewClass", "returns", "a", "new", "Class", "for", "the", "class", "ID", "and", "fingerprint", ".", "If", "sample", "is", "true", "the", "query", "with", "the", "greatest", "Query_time", "is", "saved", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/class.go#L61-L71
18,145
percona/go-mysql
event/class.go
AddEvent
func (c *Class) AddEvent(e *log.Event, outlier bool) { if outlier { c.outliers++ } else { c.TotalQueries++ } c.Metrics.AddEvent(e, outlier) // Save last db seen for this query. This helps ensure the sample query // has a db. if e.Db != "" { c.lastDb = e.Db } if c.sample { if n, ok := e.TimeMetrics["Q...
go
func (c *Class) AddEvent(e *log.Event, outlier bool) { if outlier { c.outliers++ } else { c.TotalQueries++ } c.Metrics.AddEvent(e, outlier) // Save last db seen for this query. This helps ensure the sample query // has a db. if e.Db != "" { c.lastDb = e.Db } if c.sample { if n, ok := e.TimeMetrics["Q...
[ "func", "(", "c", "*", "Class", ")", "AddEvent", "(", "e", "*", "log", ".", "Event", ",", "outlier", "bool", ")", "{", "if", "outlier", "{", "c", ".", "outliers", "++", "\n", "}", "else", "{", "c", ".", "TotalQueries", "++", "\n", "}", "\n\n", ...
// AddEvent adds an event to the query class.
[ "AddEvent", "adds", "an", "event", "to", "the", "query", "class", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/class.go#L74-L110
18,146
percona/go-mysql
event/class.go
AddClass
func (c *Class) AddClass(newClass *Class) { c.UniqueQueries++ c.TotalQueries += newClass.TotalQueries c.Example = nil for newMetric, newStats := range newClass.Metrics.TimeMetrics { stats, ok := c.Metrics.TimeMetrics[newMetric] if !ok { m := *newStats c.Metrics.TimeMetrics[newMetric] = &m } else { s...
go
func (c *Class) AddClass(newClass *Class) { c.UniqueQueries++ c.TotalQueries += newClass.TotalQueries c.Example = nil for newMetric, newStats := range newClass.Metrics.TimeMetrics { stats, ok := c.Metrics.TimeMetrics[newMetric] if !ok { m := *newStats c.Metrics.TimeMetrics[newMetric] = &m } else { s...
[ "func", "(", "c", "*", "Class", ")", "AddClass", "(", "newClass", "*", "Class", ")", "{", "c", ".", "UniqueQueries", "++", "\n", "c", ".", "TotalQueries", "+=", "newClass", ".", "TotalQueries", "\n", "c", ".", "Example", "=", "nil", "\n\n", "for", "n...
// AddClass adds a Class to the current class. This is used with Performance // Schema which returns pre-aggregated classes instead of events.
[ "AddClass", "adds", "a", "Class", "to", "the", "current", "class", ".", "This", "is", "used", "with", "Performance", "Schema", "which", "returns", "pre", "-", "aggregated", "classes", "instead", "of", "events", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/class.go#L114-L162
18,147
percona/go-mysql
event/class.go
Finalize
func (c *Class) Finalize(rateLimit uint) { if rateLimit == 0 { rateLimit = 1 } c.TotalQueries = (c.TotalQueries * rateLimit) + c.outliers c.Metrics.Finalize(rateLimit, c.TotalQueries) if c.Example.QueryTime == 0 { c.Example = nil } }
go
func (c *Class) Finalize(rateLimit uint) { if rateLimit == 0 { rateLimit = 1 } c.TotalQueries = (c.TotalQueries * rateLimit) + c.outliers c.Metrics.Finalize(rateLimit, c.TotalQueries) if c.Example.QueryTime == 0 { c.Example = nil } }
[ "func", "(", "c", "*", "Class", ")", "Finalize", "(", "rateLimit", "uint", ")", "{", "if", "rateLimit", "==", "0", "{", "rateLimit", "=", "1", "\n", "}", "\n", "c", ".", "TotalQueries", "=", "(", "c", ".", "TotalQueries", "*", "rateLimit", ")", "+"...
// Finalize calculates all metric statistics. Call this function when done // adding events to the class.
[ "Finalize", "calculates", "all", "metric", "statistics", ".", "Call", "this", "function", "when", "done", "adding", "events", "to", "the", "class", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/class.go#L166-L175
18,148
percona/go-mysql
log/log.go
NewEvent
func NewEvent() *Event { event := new(Event) event.TimeMetrics = make(map[string]float64) event.NumberMetrics = make(map[string]uint64) event.BoolMetrics = make(map[string]bool) return event }
go
func NewEvent() *Event { event := new(Event) event.TimeMetrics = make(map[string]float64) event.NumberMetrics = make(map[string]uint64) event.BoolMetrics = make(map[string]bool) return event }
[ "func", "NewEvent", "(", ")", "*", "Event", "{", "event", ":=", "new", "(", "Event", ")", "\n", "event", ".", "TimeMetrics", "=", "make", "(", "map", "[", "string", "]", "float64", ")", "\n", "event", ".", "NumberMetrics", "=", "make", "(", "map", ...
// NewEvent returns a new Event with initialized metric maps.
[ "NewEvent", "returns", "a", "new", "Event", "with", "initialized", "metric", "maps", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/log/log.go#L50-L56
18,149
percona/go-mysql
query/query.go
Id
func Id(fingerprint string) string { id := md5.New() io.WriteString(id, fingerprint) h := fmt.Sprintf("%x", id.Sum(nil)) return strings.ToUpper(h[16:32]) }
go
func Id(fingerprint string) string { id := md5.New() io.WriteString(id, fingerprint) h := fmt.Sprintf("%x", id.Sum(nil)) return strings.ToUpper(h[16:32]) }
[ "func", "Id", "(", "fingerprint", "string", ")", "string", "{", "id", ":=", "md5", ".", "New", "(", ")", "\n", "io", ".", "WriteString", "(", "id", ",", "fingerprint", ")", "\n", "h", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ".", ...
// Id returns the right-most 16 characters of the MD5 checksum of fingerprint. // Query IDs are the shortest way to uniquely identify queries.
[ "Id", "returns", "the", "right", "-", "most", "16", "characters", "of", "the", "MD5", "checksum", "of", "fingerprint", ".", "Query", "IDs", "are", "the", "shortest", "way", "to", "uniquely", "identify", "queries", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/query/query.go#L800-L805
18,150
percona/go-mysql
event/metrics.go
NewMetrics
func NewMetrics() *Metrics { m := &Metrics{ TimeMetrics: make(map[string]*TimeStats), NumberMetrics: make(map[string]*NumberStats), BoolMetrics: make(map[string]*BoolStats), } return m }
go
func NewMetrics() *Metrics { m := &Metrics{ TimeMetrics: make(map[string]*TimeStats), NumberMetrics: make(map[string]*NumberStats), BoolMetrics: make(map[string]*BoolStats), } return m }
[ "func", "NewMetrics", "(", ")", "*", "Metrics", "{", "m", ":=", "&", "Metrics", "{", "TimeMetrics", ":", "make", "(", "map", "[", "string", "]", "*", "TimeStats", ")", ",", "NumberMetrics", ":", "make", "(", "map", "[", "string", "]", "*", "NumberSta...
// NewMetrics returns a pointer to an initialized Metrics structure.
[ "NewMetrics", "returns", "a", "pointer", "to", "an", "initialized", "Metrics", "structure", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/metrics.go#L64-L71
18,151
percona/go-mysql
event/metrics.go
AddEvent
func (m *Metrics) AddEvent(e *log.Event, outlier bool) { for metric, val := range e.TimeMetrics { stats, seenMetric := m.TimeMetrics[metric] if !seenMetric { m.TimeMetrics[metric] = &TimeStats{ vals: []float64{}, } stats = m.TimeMetrics[metric] } if outlier { stats.outlierSum += val } else {...
go
func (m *Metrics) AddEvent(e *log.Event, outlier bool) { for metric, val := range e.TimeMetrics { stats, seenMetric := m.TimeMetrics[metric] if !seenMetric { m.TimeMetrics[metric] = &TimeStats{ vals: []float64{}, } stats = m.TimeMetrics[metric] } if outlier { stats.outlierSum += val } else {...
[ "func", "(", "m", "*", "Metrics", ")", "AddEvent", "(", "e", "*", "log", ".", "Event", ",", "outlier", "bool", ")", "{", "for", "metric", ",", "val", ":=", "range", "e", ".", "TimeMetrics", "{", "stats", ",", "seenMetric", ":=", "m", ".", "TimeMetr...
// AddEvent saves all the metrics of the event.
[ "AddEvent", "saves", "all", "the", "metrics", "of", "the", "event", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/metrics.go#L74-L122
18,152
percona/go-mysql
event/metrics.go
Finalize
func (m *Metrics) Finalize(rateLimit uint, totalQueries uint) { if rateLimit == 0 { rateLimit = 1 } for _, s := range m.TimeMetrics { sort.Float64s(s.vals) cnt := len(s.vals) s.Min = Float64(s.vals[0]) s.Med = Float64(s.vals[(50*cnt)/100]) // median = 50th percentile s.P95 = Float64(s.vals[(95*cnt)/100...
go
func (m *Metrics) Finalize(rateLimit uint, totalQueries uint) { if rateLimit == 0 { rateLimit = 1 } for _, s := range m.TimeMetrics { sort.Float64s(s.vals) cnt := len(s.vals) s.Min = Float64(s.vals[0]) s.Med = Float64(s.vals[(50*cnt)/100]) // median = 50th percentile s.P95 = Float64(s.vals[(95*cnt)/100...
[ "func", "(", "m", "*", "Metrics", ")", "Finalize", "(", "rateLimit", "uint", ",", "totalQueries", "uint", ")", "{", "if", "rateLimit", "==", "0", "{", "rateLimit", "=", "1", "\n", "}", "\n\n", "for", "_", ",", "s", ":=", "range", "m", ".", "TimeMet...
// Finalize calculates the statistics of the added metrics. Call this function // when done adding events.
[ "Finalize", "calculates", "the", "statistics", "of", "the", "added", "metrics", ".", "Call", "this", "function", "when", "done", "adding", "events", "." ]
f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6
https://github.com/percona/go-mysql/blob/f5cfaf6a5e55b754b7b106f4488e1bc24cb8c2d6/event/metrics.go#L134-L166
18,153
d2r2/go-dht
dht.go
String
func (v SensorType) String() string { if v == DHT11 { return "DHT11" } else if v == DHT12 { return "DHT12" } else if v == DHT22 || v == AM2302 { return "DHT22|AM2302" } else { return "!!! unknown !!!" } }
go
func (v SensorType) String() string { if v == DHT11 { return "DHT11" } else if v == DHT12 { return "DHT12" } else if v == DHT22 || v == AM2302 { return "DHT22|AM2302" } else { return "!!! unknown !!!" } }
[ "func", "(", "v", "SensorType", ")", "String", "(", ")", "string", "{", "if", "v", "==", "DHT11", "{", "return", "\"", "\"", "\n", "}", "else", "if", "v", "==", "DHT12", "{", "return", "\"", "\"", "\n", "}", "else", "if", "v", "==", "DHT22", "|...
// String implement Stringer interface.
[ "String", "implement", "Stringer", "interface", "." ]
b6103ae97a4b34d2876c04261ed37fce8cbbcc2d
https://github.com/d2r2/go-dht/blob/b6103ae97a4b34d2876c04261ed37fce8cbbcc2d/dht.go#L45-L55
18,154
d2r2/go-dht
dht.go
GetHandshakeDuration
func (v SensorType) GetHandshakeDuration() time.Duration { if v == DHT11 { return 18 * time.Millisecond } else if v == DHT12 { return 200 * time.Millisecond } else if v == DHT22 || v == AM2302 { return 18 * time.Millisecond } else { return 0 } }
go
func (v SensorType) GetHandshakeDuration() time.Duration { if v == DHT11 { return 18 * time.Millisecond } else if v == DHT12 { return 200 * time.Millisecond } else if v == DHT22 || v == AM2302 { return 18 * time.Millisecond } else { return 0 } }
[ "func", "(", "v", "SensorType", ")", "GetHandshakeDuration", "(", ")", "time", ".", "Duration", "{", "if", "v", "==", "DHT11", "{", "return", "18", "*", "time", ".", "Millisecond", "\n", "}", "else", "if", "v", "==", "DHT12", "{", "return", "200", "*...
// GetHandshakeDuration specify signal duration necessary // to initiate sensor response.
[ "GetHandshakeDuration", "specify", "signal", "duration", "necessary", "to", "initiate", "sensor", "response", "." ]
b6103ae97a4b34d2876c04261ed37fce8cbbcc2d
https://github.com/d2r2/go-dht/blob/b6103ae97a4b34d2876c04261ed37fce8cbbcc2d/dht.go#L59-L69
18,155
d2r2/go-dht
dht.go
dialDHTxxAndGetResponse
func dialDHTxxAndGetResponse(pin int, handshakeDur time.Duration, boostPerfFlag bool) ([]Pulse, error) { var arr *C.int32_t var arrLen C.int32_t var list []int32 var hsDurUsec C.int32_t = C.int32_t(handshakeDur / time.Microsecond) var boost C.int32_t = 0 var err2 *C.Error if boostPerfFlag { boost = 1 } // ...
go
func dialDHTxxAndGetResponse(pin int, handshakeDur time.Duration, boostPerfFlag bool) ([]Pulse, error) { var arr *C.int32_t var arrLen C.int32_t var list []int32 var hsDurUsec C.int32_t = C.int32_t(handshakeDur / time.Microsecond) var boost C.int32_t = 0 var err2 *C.Error if boostPerfFlag { boost = 1 } // ...
[ "func", "dialDHTxxAndGetResponse", "(", "pin", "int", ",", "handshakeDur", "time", ".", "Duration", ",", "boostPerfFlag", "bool", ")", "(", "[", "]", "Pulse", ",", "error", ")", "{", "var", "arr", "*", "C", ".", "int32_t", "\n", "var", "arrLen", "C", "...
// Activate sensor and get back bunch of pulses for further decoding. // C function call wrapper.
[ "Activate", "sensor", "and", "get", "back", "bunch", "of", "pulses", "for", "further", "decoding", ".", "C", "function", "call", "wrapper", "." ]
b6103ae97a4b34d2876c04261ed37fce8cbbcc2d
https://github.com/d2r2/go-dht/blob/b6103ae97a4b34d2876c04261ed37fce8cbbcc2d/dht.go#L96-L140
18,156
d2r2/go-dht
dht.go
decodeByte
func decodeByte(tLow, tHigh0, tHigh1 time.Duration, start int, pulses []Pulse) (byte, error) { if len(pulses)-start < 16 { return 0, fmt.Errorf("Can't decode byte, since range between "+ "index and array length is less than 16: %d, %d", start, len(pulses)) } HIGH_DUR_MAX := tLow + tHigh1 HIGH_LOW_DUR_AVG := ((...
go
func decodeByte(tLow, tHigh0, tHigh1 time.Duration, start int, pulses []Pulse) (byte, error) { if len(pulses)-start < 16 { return 0, fmt.Errorf("Can't decode byte, since range between "+ "index and array length is less than 16: %d, %d", start, len(pulses)) } HIGH_DUR_MAX := tLow + tHigh1 HIGH_LOW_DUR_AVG := ((...
[ "func", "decodeByte", "(", "tLow", ",", "tHigh0", ",", "tHigh1", "time", ".", "Duration", ",", "start", "int", ",", "pulses", "[", "]", "Pulse", ")", "(", "byte", ",", "error", ")", "{", "if", "len", "(", "pulses", ")", "-", "start", "<", "16", "...
// decodeByte decode data byte from specific pulse array position.
[ "decodeByte", "decode", "data", "byte", "from", "specific", "pulse", "array", "position", "." ]
b6103ae97a4b34d2876c04261ed37fce8cbbcc2d
https://github.com/d2r2/go-dht/blob/b6103ae97a4b34d2876c04261ed37fce8cbbcc2d/dht.go#L143-L174
18,157
sebest/xff
xff.go
toMasks
func toMasks(ips []string) (masks []net.IPNet, err error) { for _, cidr := range ips { var network *net.IPNet _, network, err = net.ParseCIDR(cidr) if err != nil { return } masks = append(masks, *network) } return }
go
func toMasks(ips []string) (masks []net.IPNet, err error) { for _, cidr := range ips { var network *net.IPNet _, network, err = net.ParseCIDR(cidr) if err != nil { return } masks = append(masks, *network) } return }
[ "func", "toMasks", "(", "ips", "[", "]", "string", ")", "(", "masks", "[", "]", "net", ".", "IPNet", ",", "err", "error", ")", "{", "for", "_", ",", "cidr", ":=", "range", "ips", "{", "var", "network", "*", "net", ".", "IPNet", "\n", "_", ",", ...
// converts a list of subnets' string to a list of net.IPNet.
[ "converts", "a", "list", "of", "subnets", "string", "to", "a", "list", "of", "net", ".", "IPNet", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L21-L31
18,158
sebest/xff
xff.go
ipInMasks
func ipInMasks(ip net.IP, masks []net.IPNet) bool { for _, mask := range masks { if mask.Contains(ip) { return true } } return false }
go
func ipInMasks(ip net.IP, masks []net.IPNet) bool { for _, mask := range masks { if mask.Contains(ip) { return true } } return false }
[ "func", "ipInMasks", "(", "ip", "net", ".", "IP", ",", "masks", "[", "]", "net", ".", "IPNet", ")", "bool", "{", "for", "_", ",", "mask", ":=", "range", "masks", "{", "if", "mask", ".", "Contains", "(", "ip", ")", "{", "return", "true", "\n", "...
// checks if a net.IP is in a list of net.IPNet
[ "checks", "if", "a", "net", ".", "IP", "is", "in", "a", "list", "of", "net", ".", "IPNet" ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L34-L41
18,159
sebest/xff
xff.go
IsPublicIP
func IsPublicIP(ip net.IP) bool { if !ip.IsGlobalUnicast() { return false } return !ipInMasks(ip, privateMasks) }
go
func IsPublicIP(ip net.IP) bool { if !ip.IsGlobalUnicast() { return false } return !ipInMasks(ip, privateMasks) }
[ "func", "IsPublicIP", "(", "ip", "net", ".", "IP", ")", "bool", "{", "if", "!", "ip", ".", "IsGlobalUnicast", "(", ")", "{", "return", "false", "\n", "}", "\n", "return", "!", "ipInMasks", "(", "ip", ",", "privateMasks", ")", "\n", "}" ]
// IsPublicIP returns true if the given IP can be routed on the Internet.
[ "IsPublicIP", "returns", "true", "if", "the", "given", "IP", "can", "be", "routed", "on", "the", "Internet", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L44-L49
18,160
sebest/xff
xff.go
Parse
func Parse(ipList string) string { for _, ip := range strings.Split(ipList, ",") { ip = strings.TrimSpace(ip) if IP := net.ParseIP(ip); IP != nil && IsPublicIP(IP) { return ip } } return "" }
go
func Parse(ipList string) string { for _, ip := range strings.Split(ipList, ",") { ip = strings.TrimSpace(ip) if IP := net.ParseIP(ip); IP != nil && IsPublicIP(IP) { return ip } } return "" }
[ "func", "Parse", "(", "ipList", "string", ")", "string", "{", "for", "_", ",", "ip", ":=", "range", "strings", ".", "Split", "(", "ipList", ",", "\"", "\"", ")", "{", "ip", "=", "strings", ".", "TrimSpace", "(", "ip", ")", "\n", "if", "IP", ":=",...
// Parse parses the value of the X-Forwarded-For Header and returns the IP address.
[ "Parse", "parses", "the", "value", "of", "the", "X", "-", "Forwarded", "-", "For", "Header", "and", "returns", "the", "IP", "address", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L52-L60
18,161
sebest/xff
xff.go
GetRemoteAddr
func GetRemoteAddr(r *http.Request) string { return GetRemoteAddrIfAllowed(r, func(sip string) bool { return true }) }
go
func GetRemoteAddr(r *http.Request) string { return GetRemoteAddrIfAllowed(r, func(sip string) bool { return true }) }
[ "func", "GetRemoteAddr", "(", "r", "*", "http", ".", "Request", ")", "string", "{", "return", "GetRemoteAddrIfAllowed", "(", "r", ",", "func", "(", "sip", "string", ")", "bool", "{", "return", "true", "}", ")", "\n", "}" ]
// GetRemoteAddr parses the given request, resolves the X-Forwarded-For header // and returns the resolved remote address.
[ "GetRemoteAddr", "parses", "the", "given", "request", "resolves", "the", "X", "-", "Forwarded", "-", "For", "header", "and", "returns", "the", "resolved", "remote", "address", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L64-L66
18,162
sebest/xff
xff.go
GetRemoteAddrIfAllowed
func GetRemoteAddrIfAllowed(r *http.Request, allowed func(sip string) bool) string { if xffh := r.Header.Get("X-Forwarded-For"); xffh != "" { if sip, sport, err := net.SplitHostPort(r.RemoteAddr); err == nil && sip != "" { if allowed(sip) { if xip := Parse(xffh); xip != "" { return net.JoinHostPort(xip, ...
go
func GetRemoteAddrIfAllowed(r *http.Request, allowed func(sip string) bool) string { if xffh := r.Header.Get("X-Forwarded-For"); xffh != "" { if sip, sport, err := net.SplitHostPort(r.RemoteAddr); err == nil && sip != "" { if allowed(sip) { if xip := Parse(xffh); xip != "" { return net.JoinHostPort(xip, ...
[ "func", "GetRemoteAddrIfAllowed", "(", "r", "*", "http", ".", "Request", ",", "allowed", "func", "(", "sip", "string", ")", "bool", ")", "string", "{", "if", "xffh", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ";", "xffh", "!=", "\"...
// GetRemoteAddrIfAllowed parses the given request, resolves the X-Forwarded-For header // and returns the resolved remote address if allowed.
[ "GetRemoteAddrIfAllowed", "parses", "the", "given", "request", "resolves", "the", "X", "-", "Forwarded", "-", "For", "header", "and", "returns", "the", "resolved", "remote", "address", "if", "allowed", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L70-L81
18,163
sebest/xff
xff.go
New
func New(options Options) (*XFF, error) { allowedMasks, err := toMasks(options.AllowedSubnets) if err != nil { return nil, err } xff := &XFF{ allowAll: len(options.AllowedSubnets) == 0, allowedMasks: allowedMasks, } if options.Debug { xff.Log = log.New(os.Stdout, "[xff] ", log.LstdFlags) } return xf...
go
func New(options Options) (*XFF, error) { allowedMasks, err := toMasks(options.AllowedSubnets) if err != nil { return nil, err } xff := &XFF{ allowAll: len(options.AllowedSubnets) == 0, allowedMasks: allowedMasks, } if options.Debug { xff.Log = log.New(os.Stdout, "[xff] ", log.LstdFlags) } return xf...
[ "func", "New", "(", "options", "Options", ")", "(", "*", "XFF", ",", "error", ")", "{", "allowedMasks", ",", "err", ":=", "toMasks", "(", "options", ".", "AllowedSubnets", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// New creates a new XFF handler with the provided options.
[ "New", "creates", "a", "new", "XFF", "handler", "with", "the", "provided", "options", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L104-L117
18,164
sebest/xff
xff.go
Handler
func (xff *XFF) Handler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.RemoteAddr = GetRemoteAddrIfAllowed(r, xff.allowed) h.ServeHTTP(w, r) }) }
go
func (xff *XFF) Handler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.RemoteAddr = GetRemoteAddrIfAllowed(r, xff.allowed) h.ServeHTTP(w, r) }) }
[ "func", "(", "xff", "*", "XFF", ")", "Handler", "(", "h", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", "...
// Handler updates RemoteAdd from X-Fowarded-For Headers.
[ "Handler", "updates", "RemoteAdd", "from", "X", "-", "Fowarded", "-", "For", "Headers", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L125-L130
18,165
sebest/xff
xff.go
ServeHTTP
func (xff *XFF) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { r.RemoteAddr = GetRemoteAddrIfAllowed(r, xff.allowed) next(w, r) }
go
func (xff *XFF) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { r.RemoteAddr = GetRemoteAddrIfAllowed(r, xff.allowed) next(w, r) }
[ "func", "(", "xff", "*", "XFF", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "next", "http", ".", "HandlerFunc", ")", "{", "r", ".", "RemoteAddr", "=", "GetRemoteAddrIfAllowed", "(", "r", ",", ...
// Negroni compatible interface
[ "Negroni", "compatible", "interface" ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L133-L136
18,166
sebest/xff
xff.go
allowed
func (xff *XFF) allowed(sip string) bool { if xff.allowAll { return true } else if ip := net.ParseIP(sip); ip != nil && ipInMasks(ip, xff.allowedMasks) { return true } return false }
go
func (xff *XFF) allowed(sip string) bool { if xff.allowAll { return true } else if ip := net.ParseIP(sip); ip != nil && ipInMasks(ip, xff.allowedMasks) { return true } return false }
[ "func", "(", "xff", "*", "XFF", ")", "allowed", "(", "sip", "string", ")", "bool", "{", "if", "xff", ".", "allowAll", "{", "return", "true", "\n", "}", "else", "if", "ip", ":=", "net", ".", "ParseIP", "(", "sip", ")", ";", "ip", "!=", "nil", "&...
// checks that the IP is allowed.
[ "checks", "that", "the", "IP", "is", "allowed", "." ]
6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f
https://github.com/sebest/xff/blob/6c115e0ffa35d6a2e3f7a9e797c9cf07f0da4b9f/xff.go#L144-L151
18,167
emicklei/forest
error_color.go
Errorf
func Errorf(t *testing.T, format string, args ...interface{}) { t.Error(Scolorf(ErrorColorSyntaxCode, format, args...)) }
go
func Errorf(t *testing.T, format string, args ...interface{}) { t.Error(Scolorf(ErrorColorSyntaxCode, format, args...)) }
[ "func", "Errorf", "(", "t", "*", "testing", ".", "T", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "t", ".", "Error", "(", "Scolorf", "(", "ErrorColorSyntaxCode", ",", "format", ",", "args", "...", ")", ")", "\n", "...
// Errorf calls Error on t with a colorized message
[ "Errorf", "calls", "Error", "on", "t", "with", "a", "colorized", "message" ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/error_color.go#L54-L56
18,168
emicklei/forest
error_color.go
Fatalf
func Fatalf(t *testing.T, format string, args ...interface{}) { t.Fatal(Scolorf(FatalColorSyntaxCode, format, args...)) }
go
func Fatalf(t *testing.T, format string, args ...interface{}) { t.Fatal(Scolorf(FatalColorSyntaxCode, format, args...)) }
[ "func", "Fatalf", "(", "t", "*", "testing", ".", "T", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "t", ".", "Fatal", "(", "Scolorf", "(", "FatalColorSyntaxCode", ",", "format", ",", "args", "...", ")", ")", "\n", "...
// Fatalf calls Fatal on t with a colorized message
[ "Fatalf", "calls", "Fatal", "on", "t", "with", "a", "colorized", "message" ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/error_color.go#L59-L61
18,169
emicklei/forest
helpers.go
Dump
func Dump(t T, resp *http.Response) { // dump request var buffer bytes.Buffer buffer.WriteString("\n") buffer.WriteString(fmt.Sprintf("%v %v\n", resp.Request.Method, resp.Request.URL)) for k, v := range resp.Request.Header { if IsMaskedHeader(k) { v = []string{strings.Repeat(MaskChar, len(v[0]))} } if len...
go
func Dump(t T, resp *http.Response) { // dump request var buffer bytes.Buffer buffer.WriteString("\n") buffer.WriteString(fmt.Sprintf("%v %v\n", resp.Request.Method, resp.Request.URL)) for k, v := range resp.Request.Header { if IsMaskedHeader(k) { v = []string{strings.Repeat(MaskChar, len(v[0]))} } if len...
[ "func", "Dump", "(", "t", "T", ",", "resp", "*", "http", ".", "Response", ")", "{", "// dump request", "var", "buffer", "bytes", ".", "Buffer", "\n", "buffer", ".", "WriteString", "(", "\"", "\\n", "\"", ")", "\n", "buffer", ".", "WriteString", "(", ...
// Dump is a convenient method to log the full contents of a request and its response.
[ "Dump", "is", "a", "convenient", "method", "to", "log", "the", "full", "contents", "of", "a", "request", "and", "its", "response", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/helpers.go#L34-L94
18,170
emicklei/forest
helpers.go
SkipUnless
func SkipUnless(t skippeable, labels ...string) { env := strings.Split(os.Getenv("LABELS"), ",") for _, each := range labels { for _, other := range env { if each == other { return } } } t.Skipf("skipped because provided LABELS=%v does not include any of %v", env, labels) }
go
func SkipUnless(t skippeable, labels ...string) { env := strings.Split(os.Getenv("LABELS"), ",") for _, each := range labels { for _, other := range env { if each == other { return } } } t.Skipf("skipped because provided LABELS=%v does not include any of %v", env, labels) }
[ "func", "SkipUnless", "(", "t", "skippeable", ",", "labels", "...", "string", ")", "{", "env", ":=", "strings", ".", "Split", "(", "os", ".", "Getenv", "(", "\"", "\"", ")", ",", "\"", "\"", ")", "\n", "for", "_", ",", "each", ":=", "range", "lab...
// SkipUnless will Skip the test unless the LABELS environment variable includes any of the provided labels. // // LABELS=integration,nightly go test -v //
[ "SkipUnless", "will", "Skip", "the", "test", "unless", "the", "LABELS", "environment", "variable", "includes", "any", "of", "the", "provided", "labels", ".", "LABELS", "=", "integration", "nightly", "go", "test", "-", "v" ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/helpers.go#L104-L114
18,171
emicklei/forest
logger.go
Logf
func (l Logger) Logf(format string, args ...interface{}) { if l.InfoEnabled { LoggingPrintf("\tinfo : "+tabify(format)+"\n", args...) } }
go
func (l Logger) Logf(format string, args ...interface{}) { if l.InfoEnabled { LoggingPrintf("\tinfo : "+tabify(format)+"\n", args...) } }
[ "func", "(", "l", "Logger", ")", "Logf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "InfoEnabled", "{", "LoggingPrintf", "(", "\"", "\\t", "\"", "+", "tabify", "(", "format", ")", "+", "\"", "\\n",...
// Logf formats its arguments according to the format, analogous to Printf, and records the text in the error log. // The text will be printed only if the test fails or the -test.v flag is set.
[ "Logf", "formats", "its", "arguments", "according", "to", "the", "format", "analogous", "to", "Printf", "and", "records", "the", "text", "in", "the", "error", "log", ".", "The", "text", "will", "be", "printed", "only", "if", "the", "test", "fails", "or", ...
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/logger.go#L18-L22
18,172
emicklei/forest
logger.go
Fatal
func (l Logger) Fatal(args ...interface{}) { if l.ErrorEnabled { LoggingPrintf("\tfatal: "+tabify("%s")+"\n", args...) } if l.ExitOnFatal { os.Exit(1) } }
go
func (l Logger) Fatal(args ...interface{}) { if l.ErrorEnabled { LoggingPrintf("\tfatal: "+tabify("%s")+"\n", args...) } if l.ExitOnFatal { os.Exit(1) } }
[ "func", "(", "l", "Logger", ")", "Fatal", "(", "args", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "ErrorEnabled", "{", "LoggingPrintf", "(", "\"", "\\t", "\"", "+", "tabify", "(", "\"", "\"", ")", "+", "\"", "\\n", "\"", ",", "args",...
// Fatal is equivalent to Log followed by FailNow.
[ "Fatal", "is", "equivalent", "to", "Log", "followed", "by", "FailNow", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/logger.go#L32-L39
18,173
emicklei/forest
expectations.go
CheckError
func CheckError(t T, err error) bool { if err != nil { logerror(t, serrorf("CheckError: did not expect to receive err: %v", err)) } return err != nil }
go
func CheckError(t T, err error) bool { if err != nil { logerror(t, serrorf("CheckError: did not expect to receive err: %v", err)) } return err != nil }
[ "func", "CheckError", "(", "t", "T", ",", "err", "error", ")", "bool", "{", "if", "err", "!=", "nil", "{", "logerror", "(", "t", ",", "serrorf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n", "return", "err", "!=", "nil", "\n", "}" ]
// CheckError simply tests the error and fail is not undefined. // This is implicity called after sending a Http request. // Return true if there was an error.
[ "CheckError", "simply", "tests", "the", "error", "and", "fail", "is", "not", "undefined", ".", "This", "is", "implicity", "called", "after", "sending", "a", "Http", "request", ".", "Return", "true", "if", "there", "was", "an", "error", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/expectations.go#L40-L45
18,174
emicklei/forest
expectations.go
ExpectHeader
func ExpectHeader(t T, r *http.Response, name, value string) bool { if r == nil { logerror(t, serrorf("ExpectHeader: got nil but want a Http response")) return false } rname := r.Header.Get(name) if rname != value { logerror(t, serrorf("ExpectHeader: got header %s=%s but want %s", name, rname, value)) } ret...
go
func ExpectHeader(t T, r *http.Response, name, value string) bool { if r == nil { logerror(t, serrorf("ExpectHeader: got nil but want a Http response")) return false } rname := r.Header.Get(name) if rname != value { logerror(t, serrorf("ExpectHeader: got header %s=%s but want %s", name, rname, value)) } ret...
[ "func", "ExpectHeader", "(", "t", "T", ",", "r", "*", "http", ".", "Response", ",", "name", ",", "value", "string", ")", "bool", "{", "if", "r", "==", "nil", "{", "logerror", "(", "t", ",", "serrorf", "(", "\"", "\"", ")", ")", "\n", "return", ...
// ExpectHeader inspects the header of the response. // Return true if the header matches.
[ "ExpectHeader", "inspects", "the", "header", "of", "the", "response", ".", "Return", "true", "if", "the", "header", "matches", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/expectations.go#L49-L59
18,175
emicklei/forest
expectations.go
ExpectJSONHash
func ExpectJSONHash(t T, r *http.Response, callback func(hash map[string]interface{})) bool { if r == nil { logerror(t, serrorf("ExpectJSONHash: no response available")) return false } if r.Body == nil { logerror(t, serrorf("ExpectJSONHash: no body to read")) return false } data, err := ioutil.ReadAll(r.Bo...
go
func ExpectJSONHash(t T, r *http.Response, callback func(hash map[string]interface{})) bool { if r == nil { logerror(t, serrorf("ExpectJSONHash: no response available")) return false } if r.Body == nil { logerror(t, serrorf("ExpectJSONHash: no body to read")) return false } data, err := ioutil.ReadAll(r.Bo...
[ "func", "ExpectJSONHash", "(", "t", "T", ",", "r", "*", "http", ".", "Response", ",", "callback", "func", "(", "hash", "map", "[", "string", "]", "interface", "{", "}", ")", ")", "bool", "{", "if", "r", "==", "nil", "{", "logerror", "(", "t", ","...
// ExpectJSONHash tries to unmarshal the response body into a Go map callback parameter. // Fail if the body could not be read or if unmarshalling was not possible. // Returns true if the callback was executed with a map.
[ "ExpectJSONHash", "tries", "to", "unmarshal", "the", "response", "body", "into", "a", "Go", "map", "callback", "parameter", ".", "Fail", "if", "the", "body", "could", "not", "be", "read", "or", "if", "unmarshalling", "was", "not", "possible", ".", "Returns",...
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/expectations.go#L64-L96
18,176
emicklei/forest
expectations.go
ExpectJSONArray
func ExpectJSONArray(t T, r *http.Response, callback func(array []interface{})) bool { if r == nil { logerror(t, serrorf("ExpectJSONArray: no response available")) return false } if r.Body == nil { logerror(t, serrorf("ExpectJSONArray: no body to read")) return false } data, err := ioutil.ReadAll(r.Body) ...
go
func ExpectJSONArray(t T, r *http.Response, callback func(array []interface{})) bool { if r == nil { logerror(t, serrorf("ExpectJSONArray: no response available")) return false } if r.Body == nil { logerror(t, serrorf("ExpectJSONArray: no body to read")) return false } data, err := ioutil.ReadAll(r.Body) ...
[ "func", "ExpectJSONArray", "(", "t", "T", ",", "r", "*", "http", ".", "Response", ",", "callback", "func", "(", "array", "[", "]", "interface", "{", "}", ")", ")", "bool", "{", "if", "r", "==", "nil", "{", "logerror", "(", "t", ",", "serrorf", "(...
// ExpectJSONArray tries to unmarshal the response body into a Go slice callback parameter. // Fail if the body could not be read or if unmarshalling was not possible. // Returns true if the callback was executed with an array.
[ "ExpectJSONArray", "tries", "to", "unmarshal", "the", "response", "body", "into", "a", "Go", "slice", "callback", "parameter", ".", "Fail", "if", "the", "body", "could", "not", "be", "read", "or", "if", "unmarshalling", "was", "not", "possible", ".", "Return...
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/expectations.go#L101-L133
18,177
emicklei/forest
expectations.go
ExpectString
func ExpectString(t T, r *http.Response, callback func(content string)) bool { if r == nil { logerror(t, serrorf("ExpectString: no response available")) return false } if r.Body == nil { logerror(t, serrorf("ExpectString: no body to read")) return false } data, err := ioutil.ReadAll(r.Body) defer r.Body.C...
go
func ExpectString(t T, r *http.Response, callback func(content string)) bool { if r == nil { logerror(t, serrorf("ExpectString: no response available")) return false } if r.Body == nil { logerror(t, serrorf("ExpectString: no body to read")) return false } data, err := ioutil.ReadAll(r.Body) defer r.Body.C...
[ "func", "ExpectString", "(", "t", "T", ",", "r", "*", "http", ".", "Response", ",", "callback", "func", "(", "content", "string", ")", ")", "bool", "{", "if", "r", "==", "nil", "{", "logerror", "(", "t", ",", "serrorf", "(", "\"", "\"", ")", ")",...
// ExpectString reads the response body into a Go string callback parameter. // Fail if the body could not be read or unmarshalled. // Returns true if a response body was read.
[ "ExpectString", "reads", "the", "response", "body", "into", "a", "Go", "string", "callback", "parameter", ".", "Fail", "if", "the", "body", "could", "not", "be", "read", "or", "unmarshalled", ".", "Returns", "true", "if", "a", "response", "body", "was", "r...
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/expectations.go#L138-L161
18,178
emicklei/forest
request_config.go
NewConfig
func NewConfig(pathTemplate string, pathParams ...interface{}) *RequestConfig { cfg := &RequestConfig{ HeaderMap: http.Header{}, Values: url.Values{}, } cfg.Path(pathTemplate, pathParams...) return cfg }
go
func NewConfig(pathTemplate string, pathParams ...interface{}) *RequestConfig { cfg := &RequestConfig{ HeaderMap: http.Header{}, Values: url.Values{}, } cfg.Path(pathTemplate, pathParams...) return cfg }
[ "func", "NewConfig", "(", "pathTemplate", "string", ",", "pathParams", "...", "interface", "{", "}", ")", "*", "RequestConfig", "{", "cfg", ":=", "&", "RequestConfig", "{", "HeaderMap", ":", "http", ".", "Header", "{", "}", ",", "Values", ":", "url", "."...
// NewConfig returns a new RequestConfig with initialized empty headers and query parameters. // See Path for an explanation of the function parameters.
[ "NewConfig", "returns", "a", "new", "RequestConfig", "with", "initialized", "empty", "headers", "and", "query", "parameters", ".", "See", "Path", "for", "an", "explanation", "of", "the", "function", "parameters", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/request_config.go#L30-L37
18,179
emicklei/forest
request_config.go
Do
func (r *RequestConfig) Do(block func(config *RequestConfig)) *RequestConfig { block(r) return r }
go
func (r *RequestConfig) Do(block func(config *RequestConfig)) *RequestConfig { block(r) return r }
[ "func", "(", "r", "*", "RequestConfig", ")", "Do", "(", "block", "func", "(", "config", "*", "RequestConfig", ")", ")", "*", "RequestConfig", "{", "block", "(", "r", ")", "\n", "return", "r", "\n", "}" ]
// Do calls the one-argument function parameter with the receiver. // This allows for custom convenience functions without breaking the fluent programming style.
[ "Do", "calls", "the", "one", "-", "argument", "function", "parameter", "with", "the", "receiver", ".", "This", "allows", "for", "custom", "convenience", "functions", "without", "breaking", "the", "fluent", "programming", "style", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/request_config.go#L41-L44
18,180
emicklei/forest
request_config.go
Query
func (r *RequestConfig) Query(name string, value interface{}) *RequestConfig { r.Values.Add(name, fmt.Sprintf("%v", value)) return r }
go
func (r *RequestConfig) Query(name string, value interface{}) *RequestConfig { r.Values.Add(name, fmt.Sprintf("%v", value)) return r }
[ "func", "(", "r", "*", "RequestConfig", ")", "Query", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "*", "RequestConfig", "{", "r", ".", "Values", ".", "Add", "(", "name", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "value"...
// Query adds a name=value pair to the list of query parameters.
[ "Query", "adds", "a", "name", "=", "value", "pair", "to", "the", "list", "of", "query", "parameters", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/request_config.go#L92-L95
18,181
emicklei/forest
request_config.go
Header
func (r *RequestConfig) Header(name, value string) *RequestConfig { r.HeaderMap.Add(name, value) return r }
go
func (r *RequestConfig) Header(name, value string) *RequestConfig { r.HeaderMap.Add(name, value) return r }
[ "func", "(", "r", "*", "RequestConfig", ")", "Header", "(", "name", ",", "value", "string", ")", "*", "RequestConfig", "{", "r", ".", "HeaderMap", ".", "Add", "(", "name", ",", "value", ")", "\n", "return", "r", "\n", "}" ]
// Header adds a name=value pair to the list of header parameters.
[ "Header", "adds", "a", "name", "=", "value", "pair", "to", "the", "list", "of", "header", "parameters", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/request_config.go#L98-L101
18,182
emicklei/forest
request_config.go
Body
func (r *RequestConfig) Body(body string) *RequestConfig { r.BodyReader = strings.NewReader(body) return r }
go
func (r *RequestConfig) Body(body string) *RequestConfig { r.BodyReader = strings.NewReader(body) return r }
[ "func", "(", "r", "*", "RequestConfig", ")", "Body", "(", "body", "string", ")", "*", "RequestConfig", "{", "r", ".", "BodyReader", "=", "strings", ".", "NewReader", "(", "body", ")", "\n", "return", "r", "\n", "}" ]
// Body sets the playload as is. No content type is set. // It sets the BodyReader field of the RequestConfig.
[ "Body", "sets", "the", "playload", "as", "is", ".", "No", "content", "type", "is", "set", ".", "It", "sets", "the", "BodyReader", "field", "of", "the", "RequestConfig", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/request_config.go#L105-L108
18,183
emicklei/forest
request_config.go
Read
func (r *RequestConfig) Read(bodyReader io.Reader) *RequestConfig { r.BodyReader = bodyReader return r }
go
func (r *RequestConfig) Read(bodyReader io.Reader) *RequestConfig { r.BodyReader = bodyReader return r }
[ "func", "(", "r", "*", "RequestConfig", ")", "Read", "(", "bodyReader", "io", ".", "Reader", ")", "*", "RequestConfig", "{", "r", ".", "BodyReader", "=", "bodyReader", "\n", "return", "r", "\n", "}" ]
// Read sets the BodyReader for content to send with the request.
[ "Read", "sets", "the", "BodyReader", "for", "content", "to", "send", "with", "the", "request", "." ]
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/request_config.go#L165-L168
18,184
emicklei/forest
template.go
ProcessTemplate
func ProcessTemplate(t T, templateContent string, value interface{}) string { tmp, err := template.New("temporary").Parse(templateContent) if err != nil { logfatal(t, sfatalf("failed to parse:%v", err)) return "" } var buf bytes.Buffer err = tmp.Execute(&buf, value) if err != nil { logfatal(t, sfatalf("fail...
go
func ProcessTemplate(t T, templateContent string, value interface{}) string { tmp, err := template.New("temporary").Parse(templateContent) if err != nil { logfatal(t, sfatalf("failed to parse:%v", err)) return "" } var buf bytes.Buffer err = tmp.Execute(&buf, value) if err != nil { logfatal(t, sfatalf("fail...
[ "func", "ProcessTemplate", "(", "t", "T", ",", "templateContent", "string", ",", "value", "interface", "{", "}", ")", "string", "{", "tmp", ",", "err", ":=", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "templateContent", ")", "\n",...
// ProcessTemplate creates a new text Template and executes it using the provided value. // Returns the string result of applying this template. // Failures in the template are reported using t.
[ "ProcessTemplate", "creates", "a", "new", "text", "Template", "and", "executes", "it", "using", "the", "provided", "value", ".", "Returns", "the", "string", "result", "of", "applying", "this", "template", ".", "Failures", "in", "the", "template", "are", "repor...
dc111550dbc4ef569b15c0766f1cd69a8c218f6d
https://github.com/emicklei/forest/blob/dc111550dbc4ef569b15c0766f1cd69a8c218f6d/template.go#L11-L24
18,185
subosito/twilio
util.go
structToMapString
func structToMapString(i interface{}) map[string][]string { ms := map[string][]string{} iv := reflect.ValueOf(i).Elem() tp := iv.Type() for i := 0; i < iv.NumField(); i++ { k := tp.Field(i).Name f := iv.Field(i) ms[k] = valueToString(f) } return ms }
go
func structToMapString(i interface{}) map[string][]string { ms := map[string][]string{} iv := reflect.ValueOf(i).Elem() tp := iv.Type() for i := 0; i < iv.NumField(); i++ { k := tp.Field(i).Name f := iv.Field(i) ms[k] = valueToString(f) } return ms }
[ "func", "structToMapString", "(", "i", "interface", "{", "}", ")", "map", "[", "string", "]", "[", "]", "string", "{", "ms", ":=", "map", "[", "string", "]", "[", "]", "string", "{", "}", "\n", "iv", ":=", "reflect", ".", "ValueOf", "(", "i", ")"...
// structToMapString converts struct as map string
[ "structToMapString", "converts", "struct", "as", "map", "string" ]
ef2f13504366093ed052627008181166612c646d
https://github.com/subosito/twilio/blob/ef2f13504366093ed052627008181166612c646d/util.go#L44-L56
18,186
subosito/twilio
util.go
valueToString
func valueToString(f reflect.Value) []string { var v []string switch reflect.TypeOf(f.Interface()).Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: v = []string{strconv.FormatInt(f.Int(), 10)} case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: ...
go
func valueToString(f reflect.Value) []string { var v []string switch reflect.TypeOf(f.Interface()).Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: v = []string{strconv.FormatInt(f.Int(), 10)} case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: ...
[ "func", "valueToString", "(", "f", "reflect", ".", "Value", ")", "[", "]", "string", "{", "var", "v", "[", "]", "string", "\n\n", "switch", "reflect", ".", "TypeOf", "(", "f", ".", "Interface", "(", ")", ")", ".", "Kind", "(", ")", "{", "case", "...
// valueToString converts supported type of f as slice string
[ "valueToString", "converts", "supported", "type", "of", "f", "as", "slice", "string" ]
ef2f13504366093ed052627008181166612c646d
https://github.com/subosito/twilio/blob/ef2f13504366093ed052627008181166612c646d/util.go#L59-L84
18,187
subosito/twilio
message.go
SendSMS
func (s *MessageService) SendSMS(from, to, body string) (*Message, *Response, error) { return s.Send(from, to, MessageParams{Body: body}) }
go
func (s *MessageService) SendSMS(from, to, body string) (*Message, *Response, error) { return s.Send(from, to, MessageParams{Body: body}) }
[ "func", "(", "s", "*", "MessageService", ")", "SendSMS", "(", "from", ",", "to", ",", "body", "string", ")", "(", "*", "Message", ",", "*", "Response", ",", "error", ")", "{", "return", "s", ".", "Send", "(", "from", ",", "to", ",", "MessageParams"...
// Shortcut for sending SMS with no optional parameters support.
[ "Shortcut", "for", "sending", "SMS", "with", "no", "optional", "parameters", "support", "." ]
ef2f13504366093ed052627008181166612c646d
https://github.com/subosito/twilio/blob/ef2f13504366093ed052627008181166612c646d/message.go#L69-L71
18,188
subosito/twilio
client.go
NewClient
func NewClient(accountSid, authToken string, httpClient *http.Client) *Client { if httpClient == nil { httpClient = http.DefaultClient } baseURL, _ := url.Parse(apiBaseURL) c := &Client{ client: httpClient, UserAgent: userAgent, BaseURL: baseURL, AccountSid: accountSid, AuthToken: authToken, ...
go
func NewClient(accountSid, authToken string, httpClient *http.Client) *Client { if httpClient == nil { httpClient = http.DefaultClient } baseURL, _ := url.Parse(apiBaseURL) c := &Client{ client: httpClient, UserAgent: userAgent, BaseURL: baseURL, AccountSid: accountSid, AuthToken: authToken, ...
[ "func", "NewClient", "(", "accountSid", ",", "authToken", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "*", "Client", "{", "if", "httpClient", "==", "nil", "{", "httpClient", "=", "http", ".", "DefaultClient", "\n", "}", "\n\n", "baseURL",...
// NewClient returns a new Twilio API client. This will load default http.Client if httpClient is nil.
[ "NewClient", "returns", "a", "new", "Twilio", "API", "client", ".", "This", "will", "load", "default", "http", ".", "Client", "if", "httpClient", "is", "nil", "." ]
ef2f13504366093ed052627008181166612c646d
https://github.com/subosito/twilio/blob/ef2f13504366093ed052627008181166612c646d/client.go#L32-L50
18,189
sassoftware/go-rpmutils
header.go
getInts
func (hdr *rpmHeader) getInts(tag int) (buf interface{}, n int, err error) { ent, ok := hdr.entries[tag] if !ok { return nil, 0, NewNoSuchTagError(tag) } n = len(ent.contents) switch ent.dataType { case RPM_INT8_TYPE: buf = make([]uint8, n) case RPM_INT16_TYPE: n >>= 1 buf = make([]uint16, n) case RPM_I...
go
func (hdr *rpmHeader) getInts(tag int) (buf interface{}, n int, err error) { ent, ok := hdr.entries[tag] if !ok { return nil, 0, NewNoSuchTagError(tag) } n = len(ent.contents) switch ent.dataType { case RPM_INT8_TYPE: buf = make([]uint8, n) case RPM_INT16_TYPE: n >>= 1 buf = make([]uint16, n) case RPM_I...
[ "func", "(", "hdr", "*", "rpmHeader", ")", "getInts", "(", "tag", "int", ")", "(", "buf", "interface", "{", "}", ",", "n", "int", ",", "err", "error", ")", "{", "ent", ",", "ok", ":=", "hdr", ".", "entries", "[", "tag", "]", "\n", "if", "!", ...
// get an int array using whatever the appropriate sized type is
[ "get", "an", "int", "array", "using", "whatever", "the", "appropriate", "sized", "type", "is" ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/header.go#L201-L226
18,190
sassoftware/go-rpmutils
header.go
GetInts
func (hdr *rpmHeader) GetInts(tag int) ([]int, error) { buf, n, err := hdr.getInts(tag) if err != nil { return nil, err } out := make([]int, n) switch bvals := buf.(type) { case []uint8: for i, v := range bvals { out[i] = int(v) } case []uint16: for i, v := range bvals { out[i] = int(v) } case [...
go
func (hdr *rpmHeader) GetInts(tag int) ([]int, error) { buf, n, err := hdr.getInts(tag) if err != nil { return nil, err } out := make([]int, n) switch bvals := buf.(type) { case []uint8: for i, v := range bvals { out[i] = int(v) } case []uint16: for i, v := range bvals { out[i] = int(v) } case [...
[ "func", "(", "hdr", "*", "rpmHeader", ")", "GetInts", "(", "tag", "int", ")", "(", "[", "]", "int", ",", "error", ")", "{", "buf", ",", "n", ",", "err", ":=", "hdr", ".", "getInts", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// Get an int array using the default 'int' type. DEPRECATED because all rpm // integers are unsigned, so some int32 values might not fit. Returns an error // in case of overflow.
[ "Get", "an", "int", "array", "using", "the", "default", "int", "type", ".", "DEPRECATED", "because", "all", "rpm", "integers", "are", "unsigned", "so", "some", "int32", "values", "might", "not", "fit", ".", "Returns", "an", "error", "in", "case", "of", "...
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/header.go#L231-L257
18,191
sassoftware/go-rpmutils
header.go
GetUint32s
func (hdr *rpmHeader) GetUint32s(tag int) ([]uint32, error) { buf, n, err := hdr.getInts(tag) if err != nil { return nil, err } if out, ok := buf.([]uint32); ok { return out, nil } out := make([]uint32, n) switch bvals := buf.(type) { case []uint8: for i, v := range bvals { out[i] = uint32(v) } case...
go
func (hdr *rpmHeader) GetUint32s(tag int) ([]uint32, error) { buf, n, err := hdr.getInts(tag) if err != nil { return nil, err } if out, ok := buf.([]uint32); ok { return out, nil } out := make([]uint32, n) switch bvals := buf.(type) { case []uint8: for i, v := range bvals { out[i] = uint32(v) } case...
[ "func", "(", "hdr", "*", "rpmHeader", ")", "GetUint32s", "(", "tag", "int", ")", "(", "[", "]", "uint32", ",", "error", ")", "{", "buf", ",", "n", ",", "err", ":=", "hdr", ".", "getInts", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Get an int array as a uint32 slice. This can accomodate any int type other // than INT64.
[ "Get", "an", "int", "array", "as", "a", "uint32", "slice", ".", "This", "can", "accomodate", "any", "int", "type", "other", "than", "INT64", "." ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/header.go#L261-L283
18,192
sassoftware/go-rpmutils
header.go
GetUint64s
func (hdr *rpmHeader) GetUint64s(tag int) ([]uint64, error) { buf, n, err := hdr.getInts(tag) if err != nil { return nil, err } if out, ok := buf.([]uint64); ok { return out, nil } out := make([]uint64, n) switch bvals := buf.(type) { case []uint8: for i, v := range bvals { out[i] = uint64(v) } case...
go
func (hdr *rpmHeader) GetUint64s(tag int) ([]uint64, error) { buf, n, err := hdr.getInts(tag) if err != nil { return nil, err } if out, ok := buf.([]uint64); ok { return out, nil } out := make([]uint64, n) switch bvals := buf.(type) { case []uint8: for i, v := range bvals { out[i] = uint64(v) } case...
[ "func", "(", "hdr", "*", "rpmHeader", ")", "GetUint64s", "(", "tag", "int", ")", "(", "[", "]", "uint64", ",", "error", ")", "{", "buf", ",", "n", ",", "err", ":=", "hdr", ".", "getInts", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Get an int array as a uint64 slice. This can accomodate all int types.
[ "Get", "an", "int", "array", "as", "a", "uint64", "slice", ".", "This", "can", "accomodate", "all", "int", "types", "." ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/header.go#L286-L310
18,193
sassoftware/go-rpmutils
header.go
GetUint64Fallback
func (hdr *rpmHeader) GetUint64Fallback(intTag, longTag int) ([]uint64, error) { if _, ok := hdr.entries[longTag]; ok { return hdr.GetUint64s(longTag) } else { return hdr.GetUint64s(intTag) } }
go
func (hdr *rpmHeader) GetUint64Fallback(intTag, longTag int) ([]uint64, error) { if _, ok := hdr.entries[longTag]; ok { return hdr.GetUint64s(longTag) } else { return hdr.GetUint64s(intTag) } }
[ "func", "(", "hdr", "*", "rpmHeader", ")", "GetUint64Fallback", "(", "intTag", ",", "longTag", "int", ")", "(", "[", "]", "uint64", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "hdr", ".", "entries", "[", "longTag", "]", ";", "ok", "{", "r...
// Get longTag if it exists, otherwise intTag
[ "Get", "longTag", "if", "it", "exists", "otherwise", "intTag" ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/header.go#L313-L319
18,194
sassoftware/go-rpmutils
rpmutils.go
InstalledSize
func (hdr *RpmHeader) InstalledSize() (int64, error) { u, err := hdr.GetUint64Fallback(SIZE, LONGSIZE) if err != nil { return -1, err } return int64(u), nil }
go
func (hdr *RpmHeader) InstalledSize() (int64, error) { u, err := hdr.GetUint64Fallback(SIZE, LONGSIZE) if err != nil { return -1, err } return int64(u), nil }
[ "func", "(", "hdr", "*", "RpmHeader", ")", "InstalledSize", "(", ")", "(", "int64", ",", "error", ")", "{", "u", ",", "err", ":=", "hdr", ".", "GetUint64Fallback", "(", "SIZE", ",", "LONGSIZE", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-...
// Return the approximate disk space needed to install the package
[ "Return", "the", "approximate", "disk", "space", "needed", "to", "install", "the", "package" ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/rpmutils.go#L201-L207
18,195
sassoftware/go-rpmutils
rpmutils.go
PayloadSize
func (hdr *RpmHeader) PayloadSize() (int64, error) { u, err := hdr.sigHeader.GetUint64Fallback(SIG_PAYLOADSIZE-_SIGHEADER_TAG_BASE, SIG_LONGARCHIVESIZE) if err != nil { return -1, err } else if len(u) != 1 { return -1, errors.New("incorrect number of values") } return int64(u[0]), err }
go
func (hdr *RpmHeader) PayloadSize() (int64, error) { u, err := hdr.sigHeader.GetUint64Fallback(SIG_PAYLOADSIZE-_SIGHEADER_TAG_BASE, SIG_LONGARCHIVESIZE) if err != nil { return -1, err } else if len(u) != 1 { return -1, errors.New("incorrect number of values") } return int64(u[0]), err }
[ "func", "(", "hdr", "*", "RpmHeader", ")", "PayloadSize", "(", ")", "(", "int64", ",", "error", ")", "{", "u", ",", "err", ":=", "hdr", ".", "sigHeader", ".", "GetUint64Fallback", "(", "SIG_PAYLOADSIZE", "-", "_SIGHEADER_TAG_BASE", ",", "SIG_LONGARCHIVESIZE"...
// Return the size of the uncompressed payload in bytes
[ "Return", "the", "size", "of", "the", "uncompressed", "payload", "in", "bytes" ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/rpmutils.go#L210-L218
18,196
sassoftware/go-rpmutils
signatures.go
SignRpmStream
func SignRpmStream(stream io.Reader, key *packet.PrivateKey, opts *SignatureOptions) (header *RpmHeader, err error) { lead, sigHeader, err := readSignatureHeader(stream) if err != nil { return } // parse the general header and also tee it into a buffer genHeaderBuf := new(bytes.Buffer) headerTee := io.TeeReader...
go
func SignRpmStream(stream io.Reader, key *packet.PrivateKey, opts *SignatureOptions) (header *RpmHeader, err error) { lead, sigHeader, err := readSignatureHeader(stream) if err != nil { return } // parse the general header and also tee it into a buffer genHeaderBuf := new(bytes.Buffer) headerTee := io.TeeReader...
[ "func", "SignRpmStream", "(", "stream", "io", ".", "Reader", ",", "key", "*", "packet", ".", "PrivateKey", ",", "opts", "*", "SignatureOptions", ")", "(", "header", "*", "RpmHeader", ",", "err", "error", ")", "{", "lead", ",", "sigHeader", ",", "err", ...
// Read an RPM and sign it, returning the set of headers updated with the new signature.
[ "Read", "an", "RPM", "and", "sign", "it", "returning", "the", "set", "of", "headers", "updated", "with", "the", "new", "signature", "." ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/signatures.go#L114-L149
18,197
sassoftware/go-rpmutils
signatures.go
SignRpmFileIntoStream
func SignRpmFileIntoStream(outstream io.Writer, infile io.ReadSeeker, key *packet.PrivateKey, opts *SignatureOptions) error { header, err := SignRpmStream(infile, key, opts) if err != nil { return err } delete(header.sigHeader.entries, SIG_RESERVEDSPACE-_SIGHEADER_TAG_BASE) return writeRpm(infile, outstream, hea...
go
func SignRpmFileIntoStream(outstream io.Writer, infile io.ReadSeeker, key *packet.PrivateKey, opts *SignatureOptions) error { header, err := SignRpmStream(infile, key, opts) if err != nil { return err } delete(header.sigHeader.entries, SIG_RESERVEDSPACE-_SIGHEADER_TAG_BASE) return writeRpm(infile, outstream, hea...
[ "func", "SignRpmFileIntoStream", "(", "outstream", "io", ".", "Writer", ",", "infile", "io", ".", "ReadSeeker", ",", "key", "*", "packet", ".", "PrivateKey", ",", "opts", "*", "SignatureOptions", ")", "error", "{", "header", ",", "err", ":=", "SignRpmStream"...
// SignRpmFileIntoStream signs the rpmfile represented by infile with the // provided private key and sig options. The entire signed RPM file is then // written to the outstream.
[ "SignRpmFileIntoStream", "signs", "the", "rpmfile", "represented", "by", "infile", "with", "the", "provided", "private", "key", "and", "sig", "options", ".", "The", "entire", "signed", "RPM", "file", "is", "then", "written", "to", "the", "outstream", "." ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/signatures.go#L175-L182
18,198
sassoftware/go-rpmutils
uncompress.go
uncompressRpmPayloadReader
func uncompressRpmPayloadReader(r io.Reader, hdr *RpmHeader) (io.Reader, error) { // Check to make sure payload format is a cpio archive. If the tag does // not exist, assume archive is cpio. if hdr.HasTag(PAYLOADFORMAT) { val, err := hdr.GetString(PAYLOADFORMAT) if err != nil { return nil, err } if val !...
go
func uncompressRpmPayloadReader(r io.Reader, hdr *RpmHeader) (io.Reader, error) { // Check to make sure payload format is a cpio archive. If the tag does // not exist, assume archive is cpio. if hdr.HasTag(PAYLOADFORMAT) { val, err := hdr.GetString(PAYLOADFORMAT) if err != nil { return nil, err } if val !...
[ "func", "uncompressRpmPayloadReader", "(", "r", "io", ".", "Reader", ",", "hdr", "*", "RpmHeader", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "// Check to make sure payload format is a cpio archive. If the tag does", "// not exist, assume archive is cpio.", "i...
// Wrap RPM payload with uncompress reader, assumes that header has // already been read.
[ "Wrap", "RPM", "payload", "with", "uncompress", "reader", "assumes", "that", "header", "has", "already", "been", "read", "." ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/uncompress.go#L30-L77
18,199
sassoftware/go-rpmutils
vercmp.go
Less
func (vs VersionSlice) Less(i, j int) bool { return Vercmp(vs[i], vs[j]) == -1 }
go
func (vs VersionSlice) Less(i, j int) bool { return Vercmp(vs[i], vs[j]) == -1 }
[ "func", "(", "vs", "VersionSlice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "Vercmp", "(", "vs", "[", "i", "]", ",", "vs", "[", "j", "]", ")", "==", "-", "1", "\n", "}" ]
// Less reports wheather the element with index i should sort before the // element with index j.
[ "Less", "reports", "wheather", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "." ]
c37ab0fd127a1e43f40d0ba2250302e20eaee937
https://github.com/sassoftware/go-rpmutils/blob/c37ab0fd127a1e43f40d0ba2250302e20eaee937/vercmp.go#L40-L42