id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
141,400
djherbis/nio
sync.go
CloseWithError
func (r *PipeReader) CloseWithError(err error) error { if err == nil { err = io.ErrClosedPipe } r.bufpipe.l.Lock() defer r.bufpipe.l.Unlock() if r.bufpipe.rerr == nil { r.bufpipe.rerr = err r.bufpipe.rwait.Signal() r.bufpipe.wwait.Signal() } return nil }
go
func (r *PipeReader) CloseWithError(err error) error { if err == nil { err = io.ErrClosedPipe } r.bufpipe.l.Lock() defer r.bufpipe.l.Unlock() if r.bufpipe.rerr == nil { r.bufpipe.rerr = err r.bufpipe.rwait.Signal() r.bufpipe.wwait.Signal() } return nil }
[ "func", "(", "r", "*", "PipeReader", ")", "CloseWithError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "err", "=", "io", ".", "ErrClosedPipe", "\n", "}", "\n", "r", ".", "bufpipe", ".", "l", ".", "Lock", "(", ")", "\n"...
// CloseWithError closes the reader; subsequent writes to the write half of the pipe will return the error err.
[ "CloseWithError", "closes", "the", "reader", ";", "subsequent", "writes", "to", "the", "write", "half", "of", "the", "pipe", "will", "return", "the", "error", "err", "." ]
6c5b9b79551263eaa2fbdf53e87b8b981539dbe2
https://github.com/djherbis/nio/blob/6c5b9b79551263eaa2fbdf53e87b8b981539dbe2/sync.go#L14-L26
141,401
djherbis/nio
sync.go
CloseWithError
func (w *PipeWriter) CloseWithError(err error) error { if err == nil { err = io.EOF } w.bufpipe.l.Lock() defer w.bufpipe.l.Unlock() if w.bufpipe.werr == nil { w.bufpipe.werr = err w.bufpipe.rwait.Signal() w.bufpipe.wwait.Signal() } return nil }
go
func (w *PipeWriter) CloseWithError(err error) error { if err == nil { err = io.EOF } w.bufpipe.l.Lock() defer w.bufpipe.l.Unlock() if w.bufpipe.werr == nil { w.bufpipe.werr = err w.bufpipe.rwait.Signal() w.bufpipe.wwait.Signal() } return nil }
[ "func", "(", "w", "*", "PipeWriter", ")", "CloseWithError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "err", "=", "io", ".", "EOF", "\n", "}", "\n", "w", ".", "bufpipe", ".", "l", ".", "Lock", "(", ")", "\n", "defer...
// CloseWithError closes the writer; once the buffer is empty subsequent reads from the read half of the pipe will return // no bytes and the error err, or io.EOF if err is nil. CloseWithError always returns nil.
[ "CloseWithError", "closes", "the", "writer", ";", "once", "the", "buffer", "is", "empty", "subsequent", "reads", "from", "the", "read", "half", "of", "the", "pipe", "will", "return", "no", "bytes", "and", "the", "error", "err", "or", "io", ".", "EOF", "i...
6c5b9b79551263eaa2fbdf53e87b8b981539dbe2
https://github.com/djherbis/nio/blob/6c5b9b79551263eaa2fbdf53e87b8b981539dbe2/sync.go#L40-L52
141,402
kataras/pio
nop.go
IsNop
func IsNop(w io.Writer) bool { if isN, ok := w.(interface { IsNop() bool }); ok { return isN.IsNop() } return false }
go
func IsNop(w io.Writer) bool { if isN, ok := w.(interface { IsNop() bool }); ok { return isN.IsNop() } return false }
[ "func", "IsNop", "(", "w", "io", ".", "Writer", ")", "bool", "{", "if", "isN", ",", "ok", ":=", "w", ".", "(", "interface", "{", "IsNop", "(", ")", "bool", "\n", "}", ")", ";", "ok", "{", "return", "isN", ".", "IsNop", "(", ")", "\n", "}", ...
// IsNop can check wether an `w` io.Writer // is a NopOutput.
[ "IsNop", "can", "check", "wether", "an", "w", "io", ".", "Writer", "is", "a", "NopOutput", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/nop.go#L9-L16
141,403
kataras/pio
hijacker.go
Store
func (ctx *Ctx) Store(result []byte, err error) { ctx.marshalResult.b = result ctx.marshalResult.err = err }
go
func (ctx *Ctx) Store(result []byte, err error) { ctx.marshalResult.b = result ctx.marshalResult.err = err }
[ "func", "(", "ctx", "*", "Ctx", ")", "Store", "(", "result", "[", "]", "byte", ",", "err", "error", ")", "{", "ctx", ".", "marshalResult", ".", "b", "=", "result", "\n", "ctx", ".", "marshalResult", ".", "err", "=", "err", "\n", "}" ]
// Store bypasses the marshaler and sets the result explicitly. // If any of the next hijackers try to call the `MarshalValue` then it will // return the results that had set here.
[ "Store", "bypasses", "the", "marshaler", "and", "sets", "the", "result", "explicitly", ".", "If", "any", "of", "the", "next", "hijackers", "try", "to", "call", "the", "MarshalValue", "then", "it", "will", "return", "the", "results", "that", "had", "set", "...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/hijacker.go#L83-L86
141,404
kataras/pio
registry.go
Get
func (reg *Registry) Get(printerName string) *Printer { reg.mu.Lock() defer reg.mu.Unlock() for _, p := range reg.printers { if p.Name == printerName { return p } } return nil }
go
func (reg *Registry) Get(printerName string) *Printer { reg.mu.Lock() defer reg.mu.Unlock() for _, p := range reg.printers { if p.Name == printerName { return p } } return nil }
[ "func", "(", "reg", "*", "Registry", ")", "Get", "(", "printerName", "string", ")", "*", "Printer", "{", "reg", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "reg", ".", "mu", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "p", ":=", "range...
// Get returns a Printer based on the "printerName". // If printer with this name can't be found then // this function will return nil, so a check for // nil is always a good practice.
[ "Get", "returns", "a", "Printer", "based", "on", "the", "printerName", ".", "If", "printer", "with", "this", "name", "can", "t", "be", "found", "then", "this", "function", "will", "return", "nil", "so", "a", "check", "for", "nil", "is", "always", "a", ...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/registry.go#L81-L90
141,405
kataras/pio
registry.go
Remove
func (reg *Registry) Remove(printerName string) *Registry { reg.mu.Lock() for i, p := range reg.printers { if p.Name == printerName { reg.printers = append(reg.printers[:i], reg.printers[i+1:]...) break } } reg.mu.Unlock() return reg }
go
func (reg *Registry) Remove(printerName string) *Registry { reg.mu.Lock() for i, p := range reg.printers { if p.Name == printerName { reg.printers = append(reg.printers[:i], reg.printers[i+1:]...) break } } reg.mu.Unlock() return reg }
[ "func", "(", "reg", "*", "Registry", ")", "Remove", "(", "printerName", "string", ")", "*", "Registry", "{", "reg", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "i", ",", "p", ":=", "range", "reg", ".", "printers", "{", "if", "p", ".", "Name", ...
// Remove deletes a printer item from the printers collection // by its name. // // Returns this Registry, so it can be used as builder.
[ "Remove", "deletes", "a", "printer", "item", "from", "the", "printers", "collection", "by", "its", "name", ".", "Returns", "this", "Registry", "so", "it", "can", "be", "used", "as", "builder", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/registry.go#L96-L106
141,406
kataras/pio
registry.go
Print
func (reg *Registry) Print(v interface{}) (n int, err error) { return reg.printAll(v, false) }
go
func (reg *Registry) Print(v interface{}) (n int, err error) { return reg.printAll(v, false) }
[ "func", "(", "reg", "*", "Registry", ")", "Print", "(", "v", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "reg", ".", "printAll", "(", "v", ",", "false", ")", "\n", "}" ]
// Print accepts a value of "v", // tries to marshal its contents and flushes the result // to all available printers.
[ "Print", "accepts", "a", "value", "of", "v", "tries", "to", "marshal", "its", "contents", "and", "flushes", "the", "result", "to", "all", "available", "printers", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/registry.go#L111-L113
141,407
kataras/pio
registry.go
Println
func (reg *Registry) Println(v interface{}) (n int, err error) { return reg.printAll(v, true) }
go
func (reg *Registry) Println(v interface{}) (n int, err error) { return reg.printAll(v, true) }
[ "func", "(", "reg", "*", "Registry", ")", "Println", "(", "v", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "reg", ".", "printAll", "(", "v", ",", "true", ")", "\n", "}" ]
// Println accepts a value of "v", // tries to marshal its contents and flushes the result // to all available printers, it adds a new line at the ending, // the result doesn't contain this new line, therefore result's contents kept as expected.
[ "Println", "accepts", "a", "value", "of", "v", "tries", "to", "marshal", "its", "contents", "and", "flushes", "the", "result", "to", "all", "available", "printers", "it", "adds", "a", "new", "line", "at", "the", "ending", "the", "result", "doesn", "t", "...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/registry.go#L119-L121
141,408
kataras/pio
printer.go
MarshalFunc
func (p *Printer) MarshalFunc(marshaler func(v interface{}) ([]byte, error)) *Printer { p.mu.Lock() defer p.mu.Unlock() if p.marshal == nil { p.marshal = marshaler return p } oldM := p.marshal newM := marshaler // false on first failure p.marshal = func(v interface{}) ([]byte, error) { b, err := oldM(v...
go
func (p *Printer) MarshalFunc(marshaler func(v interface{}) ([]byte, error)) *Printer { p.mu.Lock() defer p.mu.Unlock() if p.marshal == nil { p.marshal = marshaler return p } oldM := p.marshal newM := marshaler // false on first failure p.marshal = func(v interface{}) ([]byte, error) { b, err := oldM(v...
[ "func", "(", "p", "*", "Printer", ")", "MarshalFunc", "(", "marshaler", "func", "(", "v", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", ")", "*", "Printer", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p",...
// MarshalFunc adds a "marshaler" to the printer. // Returns itself.
[ "MarshalFunc", "adds", "a", "marshaler", "to", "the", "printer", ".", "Returns", "itself", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L171-L201
141,409
kataras/pio
printer.go
WithMarshalers
func (p *Printer) WithMarshalers(marshalers ...Marshaler) *Printer { if len(marshalers) == 0 { return p } for _, marshaler := range marshalers { p.Marshal(marshaler) } return p }
go
func (p *Printer) WithMarshalers(marshalers ...Marshaler) *Printer { if len(marshalers) == 0 { return p } for _, marshaler := range marshalers { p.Marshal(marshaler) } return p }
[ "func", "(", "p", "*", "Printer", ")", "WithMarshalers", "(", "marshalers", "...", "Marshaler", ")", "*", "Printer", "{", "if", "len", "(", "marshalers", ")", "==", "0", "{", "return", "p", "\n", "}", "\n\n", "for", "_", ",", "marshaler", ":=", "rang...
// WithMarshalers same as `Marshal` but accepts more than one marshalers // and returns the Printer itself in order to be used side by side with the creational // function.
[ "WithMarshalers", "same", "as", "Marshal", "but", "accepts", "more", "than", "one", "marshalers", "and", "returns", "the", "Printer", "itself", "in", "order", "to", "be", "used", "side", "by", "side", "with", "the", "creational", "function", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L206-L216
141,410
kataras/pio
printer.go
AddOutput
func (p *Printer) AddOutput(writers ...io.Writer) *Printer { p.mu.Lock() defer p.mu.Unlock() for _, w := range writers { // set is terminal to false // if at least one of the writers // is not a terminal-based. if !terminal.IsTerminal(w) { p.IsTerminal = false break } } w := io.MultiWriter(append...
go
func (p *Printer) AddOutput(writers ...io.Writer) *Printer { p.mu.Lock() defer p.mu.Unlock() for _, w := range writers { // set is terminal to false // if at least one of the writers // is not a terminal-based. if !terminal.IsTerminal(w) { p.IsTerminal = false break } } w := io.MultiWriter(append...
[ "func", "(", "p", "*", "Printer", ")", "AddOutput", "(", "writers", "...", "io", ".", "Writer", ")", "*", "Printer", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", ...
// AddOutput adds one or more io.Writer to the Printer. // Returns itself. // // Look `OutputFrom` and `Wrap` too.
[ "AddOutput", "adds", "one", "or", "more", "io", ".", "Writer", "to", "the", "Printer", ".", "Returns", "itself", ".", "Look", "OutputFrom", "and", "Wrap", "too", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L222-L255
141,411
kataras/pio
printer.go
SetOutput
func (p *Printer) SetOutput(writers ...io.Writer) *Printer { var w io.Writer if l := len(writers); l == 0 { return p } else if l == 1 { w = writers[0] } else { w = io.MultiWriter(writers...) } p.mu.Lock() p.Output = w p.IsTerminal = terminal.IsTerminal(w) p.mu.Unlock() return p }
go
func (p *Printer) SetOutput(writers ...io.Writer) *Printer { var w io.Writer if l := len(writers); l == 0 { return p } else if l == 1 { w = writers[0] } else { w = io.MultiWriter(writers...) } p.mu.Lock() p.Output = w p.IsTerminal = terminal.IsTerminal(w) p.mu.Unlock() return p }
[ "func", "(", "p", "*", "Printer", ")", "SetOutput", "(", "writers", "...", "io", ".", "Writer", ")", "*", "Printer", "{", "var", "w", "io", ".", "Writer", "\n", "if", "l", ":=", "len", "(", "writers", ")", ";", "l", "==", "0", "{", "return", "p...
// SetOutput sets accepts one or more io.Writer // and set a multi-writter instance to the Printer's Output. // Returns itself. // // Look `OutputFrom` too.
[ "SetOutput", "sets", "accepts", "one", "or", "more", "io", ".", "Writer", "and", "set", "a", "multi", "-", "writter", "instance", "to", "the", "Printer", "s", "Output", ".", "Returns", "itself", ".", "Look", "OutputFrom", "too", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L262-L277
141,412
kataras/pio
printer.go
EnableDirectOutput
func (p *Printer) EnableDirectOutput() *Printer { p.mu.Lock() p.DirectOutput = true p.mu.Unlock() return p }
go
func (p *Printer) EnableDirectOutput() *Printer { p.mu.Lock() p.DirectOutput = true p.mu.Unlock() return p }
[ "func", "(", "p", "*", "Printer", ")", "EnableDirectOutput", "(", ")", "*", "Printer", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "p", ".", "DirectOutput", "=", "true", "\n", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "p", ...
// EnableDirectOutput will output the contents and flush them as fast as possible, // without storing them to the buffer to complete the `ReadWriteCloser` std interface. // Enable this if you need performance and you don't use the standard functions like `TeeReader`. // Returns itself.
[ "EnableDirectOutput", "will", "output", "the", "contents", "and", "flush", "them", "as", "fast", "as", "possible", "without", "storing", "them", "to", "the", "buffer", "to", "complete", "the", "ReadWriteCloser", "std", "interface", ".", "Enable", "this", "if", ...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L283-L288
141,413
kataras/pio
printer.go
Println
func (p *Printer) Println(v interface{}) (int, error) { return p.print(v, true) }
go
func (p *Printer) Println(v interface{}) (int, error) { return p.print(v, true) }
[ "func", "(", "p", "*", "Printer", ")", "Println", "(", "v", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "return", "p", ".", "print", "(", "v", ",", "true", ")", "\n", "}" ]
// Println accepts a value of "v", // tries to marshal its contents and flushes the result // to this "p" Printer, it adds a new line at the ending, // the result doesn't contain this new line, therefore result's contents kept as expected.
[ "Println", "accepts", "a", "value", "of", "v", "tries", "to", "marshal", "its", "contents", "and", "flushes", "the", "result", "to", "this", "p", "Printer", "it", "adds", "a", "new", "line", "at", "the", "ending", "the", "result", "doesn", "t", "contain"...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L308-L310
141,414
kataras/pio
printer.go
Flush
func (p *Printer) Flush() ([]byte, error) { p.mu.Lock() defer p.mu.Unlock() b, err := p.readAndConsume() if err != nil { return nil, err } _, err = p.Output.Write(b) return b, err }
go
func (p *Printer) Flush() ([]byte, error) { p.mu.Lock() defer p.mu.Unlock() b, err := p.readAndConsume() if err != nil { return nil, err } _, err = p.Output.Write(b) return b, err }
[ "func", "(", "p", "*", "Printer", ")", "Flush", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "b", ",", "err", ":=", "p", ".",...
// Flush will consume and flush the Printer's current contents.
[ "Flush", "will", "consume", "and", "flush", "the", "Printer", "s", "current", "contents", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L352-L363
141,415
kataras/pio
printer.go
Store
func (p *Printer) Store(v interface{}, appendNewLine bool) error { _, err := p.WriteTo(v, p.Writer, appendNewLine) return err }
go
func (p *Printer) Store(v interface{}, appendNewLine bool) error { _, err := p.WriteTo(v, p.Writer, appendNewLine) return err }
[ "func", "(", "p", "*", "Printer", ")", "Store", "(", "v", "interface", "{", "}", ",", "appendNewLine", "bool", ")", "error", "{", "_", ",", "err", ":=", "p", ".", "WriteTo", "(", "v", ",", "p", ".", "Writer", ",", "appendNewLine", ")", "\n\n", "r...
// Store will store-only the contents of "v". // Returns a PrintResult type in order to the final contents // be accessible by third-party tools. // // If you want to Print and Flush to the Printer's Output use `Print` instead. // // If "appendNewLine" is true then it writes a new line to the // Printer's output. Note ...
[ "Store", "will", "store", "-", "only", "the", "contents", "of", "v", ".", "Returns", "a", "PrintResult", "type", "in", "order", "to", "the", "final", "contents", "be", "accessible", "by", "third", "-", "party", "tools", ".", "If", "you", "want", "to", ...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L375-L379
141,416
kataras/pio
printer.go
WriteTo
func (p *Printer) WriteTo(v interface{}, w io.Writer, appendNewLine bool) ([]byte, error) { p.mu.Lock() defer p.mu.Unlock() var marshaler Marshaler // check if implements the Marshaled if m, ok := v.(Marshaled); ok { marshaler = fromMarshaled(m) // check if implements the Marshaler } else if m, ok := v.(Mar...
go
func (p *Printer) WriteTo(v interface{}, w io.Writer, appendNewLine bool) ([]byte, error) { p.mu.Lock() defer p.mu.Unlock() var marshaler Marshaler // check if implements the Marshaled if m, ok := v.(Marshaled); ok { marshaler = fromMarshaled(m) // check if implements the Marshaler } else if m, ok := v.(Mar...
[ "func", "(", "p", "*", "Printer", ")", "WriteTo", "(", "v", "interface", "{", "}", ",", "w", "io", ".", "Writer", ",", "appendNewLine", "bool", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "...
// WriteTo marshals and writes the "v" to the "w" writer. // // Returns this WriteTo's result information such as error, written.
[ "WriteTo", "marshals", "and", "writes", "the", "v", "to", "the", "w", "writer", ".", "Returns", "this", "WriteTo", "s", "result", "information", "such", "as", "error", "written", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L384-L444
141,417
kataras/pio
printer.go
Hijack
func (p *Printer) Hijack(cb func(ctx *Ctx)) *Printer { p.mu.Lock() defer p.mu.Unlock() if p.hijack == nil { p.hijack = cb return p } oldCb := p.hijack newCb := cb // return the first failure p.hijack = func(ctx *Ctx) { oldCb(ctx) if ctx.continueToNext { newCb(ctx) } } return p }
go
func (p *Printer) Hijack(cb func(ctx *Ctx)) *Printer { p.mu.Lock() defer p.mu.Unlock() if p.hijack == nil { p.hijack = cb return p } oldCb := p.hijack newCb := cb // return the first failure p.hijack = func(ctx *Ctx) { oldCb(ctx) if ctx.continueToNext { newCb(ctx) } } return p }
[ "func", "(", "p", "*", "Printer", ")", "Hijack", "(", "cb", "func", "(", "ctx", "*", "Ctx", ")", ")", "*", "Printer", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "p", "."...
// Hijack registers a callback which is executed // when ever `Print` or `WriteTo` is called, // this callback can intercept the final result // which will be written or be printed. // // Returns itself.
[ "Hijack", "registers", "a", "callback", "which", "is", "executed", "when", "ever", "Print", "or", "WriteTo", "is", "called", "this", "callback", "can", "intercept", "the", "final", "result", "which", "will", "be", "written", "or", "be", "printed", ".", "Retu...
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L452-L473
141,418
kataras/pio
printer.go
IsOK
func (p PrintResult) IsOK() bool { return p.Error == nil && len(p.Contents) > 0 }
go
func (p PrintResult) IsOK() bool { return p.Error == nil && len(p.Contents) > 0 }
[ "func", "(", "p", "PrintResult", ")", "IsOK", "(", ")", "bool", "{", "return", "p", ".", "Error", "==", "nil", "&&", "len", "(", "p", ".", "Contents", ")", ">", "0", "\n", "}" ]
// IsOK returns true if result's content is available, // otherwise false.
[ "IsOK", "returns", "true", "if", "result", "s", "content", "is", "available", "otherwise", "false", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L486-L488
141,419
kataras/pio
printer.go
Scan
func (p *Printer) Scan(r io.Reader, addNewLine bool) (cancel func()) { var canceled uint32 shouldCancel := func() bool { return atomic.LoadUint32(&canceled) > 0 } cancel = func() { atomic.StoreUint32(&canceled, 1) } go func() { scanner := bufio.NewScanner(r) for { if shouldCancel() { break } ...
go
func (p *Printer) Scan(r io.Reader, addNewLine bool) (cancel func()) { var canceled uint32 shouldCancel := func() bool { return atomic.LoadUint32(&canceled) > 0 } cancel = func() { atomic.StoreUint32(&canceled, 1) } go func() { scanner := bufio.NewScanner(r) for { if shouldCancel() { break } ...
[ "func", "(", "p", "*", "Printer", ")", "Scan", "(", "r", "io", ".", "Reader", ",", "addNewLine", "bool", ")", "(", "cancel", "func", "(", ")", ")", "{", "var", "canceled", "uint32", "\n", "shouldCancel", ":=", "func", "(", ")", "bool", "{", "return...
// Scan scans everything from "r" and prints // its new contents to the "p" Printer, // forever or until the returning "cancel" is fired, once.
[ "Scan", "scans", "everything", "from", "r", "and", "prints", "its", "new", "contents", "to", "the", "p", "Printer", "forever", "or", "until", "the", "returning", "cancel", "is", "fired", "once", "." ]
ea782b38602d1e5df3c2b891978a1f80d917a6bd
https://github.com/kataras/pio/blob/ea782b38602d1e5df3c2b891978a1f80d917a6bd/printer.go#L544-L580
141,420
captncraig/cors
cors.go
HandleRequest
func (c *Config) HandleRequest(w http.ResponseWriter, r *http.Request) { requestOrigin := r.Header.Get(originKey) if requestOrigin == "" { return } //check origin against allowed origins for _, ao := range c.AllowedOrigins { if ao == "*" || ao == requestOrigin { responseOrigin := "*" if ao != "*" { ...
go
func (c *Config) HandleRequest(w http.ResponseWriter, r *http.Request) { requestOrigin := r.Header.Get(originKey) if requestOrigin == "" { return } //check origin against allowed origins for _, ao := range c.AllowedOrigins { if ao == "*" || ao == requestOrigin { responseOrigin := "*" if ao != "*" { ...
[ "func", "(", "c", "*", "Config", ")", "HandleRequest", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "requestOrigin", ":=", "r", ".", "Header", ".", "Get", "(", "originKey", ")", "\n", "if", "requestOrigin", ...
// Read the request, setting response headers as appropriate. // Will NOT write anything to response in any circumstances.
[ "Read", "the", "request", "setting", "response", "headers", "as", "appropriate", ".", "Will", "NOT", "write", "anything", "to", "response", "in", "any", "circumstances", "." ]
48080ede89fe41f3e3ba556770d0f3fd6ed02e38
https://github.com/captncraig/cors/blob/48080ede89fe41f3e3ba556770d0f3fd6ed02e38/cors.go#L48-L98
141,421
lytics/base62
base62.go
NewEncoding
func NewEncoding(encoder string) *Encoding { e := new(Encoding) e.encode = encoder for i := 0; i < len(e.decodeMap); i++ { e.decodeMap[i] = 0xFF } for i := 0; i < len(encoder); i++ { e.decodeMap[encoder[i]] = byte(i) } return e }
go
func NewEncoding(encoder string) *Encoding { e := new(Encoding) e.encode = encoder for i := 0; i < len(e.decodeMap); i++ { e.decodeMap[i] = 0xFF } for i := 0; i < len(encoder); i++ { e.decodeMap[encoder[i]] = byte(i) } return e }
[ "func", "NewEncoding", "(", "encoder", "string", ")", "*", "Encoding", "{", "e", ":=", "new", "(", "Encoding", ")", "\n", "e", ".", "encode", "=", "encoder", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "e", ".", "decodeMap", ")", ";",...
// NewEncoding returns a new Encoding defined by the given alphabet, // which must be a 62-byte string.
[ "NewEncoding", "returns", "a", "new", "Encoding", "defined", "by", "the", "given", "alphabet", "which", "must", "be", "a", "62", "-", "byte", "string", "." ]
0ee4de5a5d6d26db3daa72bd80a860ff2332b437
https://github.com/lytics/base62/blob/0ee4de5a5d6d26db3daa72bd80a860ff2332b437/base62.go#L22-L32
141,422
lytics/base62
base62.go
NewEncoder
func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser { return &encoder{enc: enc, w: w} }
go
func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser { return &encoder{enc: enc, w: w} }
[ "func", "NewEncoder", "(", "enc", "*", "Encoding", ",", "w", "io", ".", "Writer", ")", "io", ".", "WriteCloser", "{", "return", "&", "encoder", "{", "enc", ":", "enc", ",", "w", ":", "w", "}", "\n", "}" ]
// NewEncoder returns a new base62 stream encoder. Data written to // the returned writer will be encoded using enc and then written to w. // Base62 encodings operate in 4-byte blocks; when finished // writing, the caller must Close the returned encoder to flush any // partially written blocks.
[ "NewEncoder", "returns", "a", "new", "base62", "stream", "encoder", ".", "Data", "written", "to", "the", "returned", "writer", "will", "be", "encoded", "using", "enc", "and", "then", "written", "to", "w", ".", "Base62", "encodings", "operate", "in", "4", "...
0ee4de5a5d6d26db3daa72bd80a860ff2332b437
https://github.com/lytics/base62/blob/0ee4de5a5d6d26db3daa72bd80a860ff2332b437/base62.go#L175-L177
141,423
lytics/base62
base62.go
NewDecoder
func NewDecoder(enc *Encoding, r io.Reader) io.Reader { return &decoder{enc: enc, r: r} }
go
func NewDecoder(enc *Encoding, r io.Reader) io.Reader { return &decoder{enc: enc, r: r} }
[ "func", "NewDecoder", "(", "enc", "*", "Encoding", ",", "r", "io", ".", "Reader", ")", "io", ".", "Reader", "{", "return", "&", "decoder", "{", "enc", ":", "enc", ",", "r", ":", "r", "}", "\n", "}" ]
// NewDecoder constructs a new base62 stream decoder.
[ "NewDecoder", "constructs", "a", "new", "base62", "stream", "decoder", "." ]
0ee4de5a5d6d26db3daa72bd80a860ff2332b437
https://github.com/lytics/base62/blob/0ee4de5a5d6d26db3daa72bd80a860ff2332b437/base62.go#L323-L325
141,424
multiplay/go-slack
chat/field.go
NewField
func NewField(title, value string) *Field { return &Field{Title: title, Value: value, Short: len(value) < ShortFieldLen} }
go
func NewField(title, value string) *Field { return &Field{Title: title, Value: value, Short: len(value) < ShortFieldLen} }
[ "func", "NewField", "(", "title", ",", "value", "string", ")", "*", "Field", "{", "return", "&", "Field", "{", "Title", ":", "title", ",", "Value", ":", "value", ",", "Short", ":", "len", "(", "value", ")", "<", "ShortFieldLen", "}", "\n", "}" ]
// NewField returns a fully initialised field with Short set to true if the length of value is less than ShortFieldLen.
[ "NewField", "returns", "a", "fully", "initialised", "field", "with", "Short", "set", "to", "true", "if", "the", "length", "of", "value", "is", "less", "than", "ShortFieldLen", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/chat/field.go#L24-L26
141,425
multiplay/go-slack
chat/message.go
NewAttachment
func (m *Message) NewAttachment() *Attachment { a := &Attachment{} m.AddAttachment(a) return a }
go
func (m *Message) NewAttachment() *Attachment { a := &Attachment{} m.AddAttachment(a) return a }
[ "func", "(", "m", "*", "Message", ")", "NewAttachment", "(", ")", "*", "Attachment", "{", "a", ":=", "&", "Attachment", "{", "}", "\n", "m", ".", "AddAttachment", "(", "a", ")", "\n\n", "return", "a", "\n", "}" ]
// NewAttachment creates a new empty attachment adds it to the message and returns it.
[ "NewAttachment", "creates", "a", "new", "empty", "attachment", "adds", "it", "to", "the", "message", "and", "returns", "it", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/chat/message.go#L69-L74
141,426
multiplay/go-slack
chat/message.go
AddAttachment
func (m *Message) AddAttachment(a *Attachment) { m.Attachments = append(m.Attachments, a) }
go
func (m *Message) AddAttachment(a *Attachment) { m.Attachments = append(m.Attachments, a) }
[ "func", "(", "m", "*", "Message", ")", "AddAttachment", "(", "a", "*", "Attachment", ")", "{", "m", ".", "Attachments", "=", "append", "(", "m", ".", "Attachments", ",", "a", ")", "\n", "}" ]
// AddAttachment adds a to the message's attachments.
[ "AddAttachment", "adds", "a", "to", "the", "message", "s", "attachments", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/chat/message.go#L77-L79
141,427
multiplay/go-slack
chat/message.go
Send
func (m *Message) Send(c slack.Client) (*MessageResponse, error) { resp := &MessageResponse{} if err := c.Send(PostMessageEndpoint, m, resp); err != nil { return nil, err } return resp, nil }
go
func (m *Message) Send(c slack.Client) (*MessageResponse, error) { resp := &MessageResponse{} if err := c.Send(PostMessageEndpoint, m, resp); err != nil { return nil, err } return resp, nil }
[ "func", "(", "m", "*", "Message", ")", "Send", "(", "c", "slack", ".", "Client", ")", "(", "*", "MessageResponse", ",", "error", ")", "{", "resp", ":=", "&", "MessageResponse", "{", "}", "\n", "if", "err", ":=", "c", ".", "Send", "(", "PostMessageE...
// Send sends the msg to slack using the client c.
[ "Send", "sends", "the", "msg", "to", "slack", "using", "the", "client", "c", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/chat/message.go#L82-L89
141,428
multiplay/go-slack
webhook/client.go
Send
func (c *Client) Send(url string, msg, resp interface{}) error { b, err := json.Marshal(msg) if err != nil { return err } r, err := http.Post(c.URL, "application/json; charset=utf-8", bytes.NewReader(b)) if err != nil { return err } defer r.Body.Close() if r.StatusCode != http.StatusOK { b, _ := ioutil....
go
func (c *Client) Send(url string, msg, resp interface{}) error { b, err := json.Marshal(msg) if err != nil { return err } r, err := http.Post(c.URL, "application/json; charset=utf-8", bytes.NewReader(b)) if err != nil { return err } defer r.Body.Close() if r.StatusCode != http.StatusOK { b, _ := ioutil....
[ "func", "(", "c", "*", "Client", ")", "Send", "(", "url", "string", ",", "msg", ",", "resp", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "msg", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// Send sends the request to slack using the webhook protocol. // The url parameter only exists to satisfy the slack.Client interface // and is not used by the webhook Client.
[ "Send", "sends", "the", "request", "to", "slack", "using", "the", "webhook", "protocol", ".", "The", "url", "parameter", "only", "exists", "to", "satisfy", "the", "slack", ".", "Client", "interface", "and", "is", "not", "used", "by", "the", "webhook", "Cli...
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/webhook/client.go#L31-L70
141,429
multiplay/go-slack
chat/attachment.go
NewField
func (a *Attachment) NewField(title, value string) *Field { f := NewField(title, value) a.AddField(f) return f }
go
func (a *Attachment) NewField(title, value string) *Field { f := NewField(title, value) a.AddField(f) return f }
[ "func", "(", "a", "*", "Attachment", ")", "NewField", "(", "title", ",", "value", "string", ")", "*", "Field", "{", "f", ":=", "NewField", "(", "title", ",", "value", ")", "\n", "a", ".", "AddField", "(", "f", ")", "\n\n", "return", "f", "\n", "}...
// NewField creates a new field, adds it to the attachment and then returns it.
[ "NewField", "creates", "a", "new", "field", "adds", "it", "to", "the", "attachment", "and", "then", "returns", "it", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/chat/attachment.go#L57-L62
141,430
multiplay/go-slack
lrhook/hook.go
SetConfigDefaults
func SetConfigDefaults(cfg *Config) { if len(cfg.LevelColors) == 0 { cfg.LevelColors = DefaultLevelColors } if cfg.UnknownColor == "" { cfg.UnknownColor = DefaultUnknownColor } }
go
func SetConfigDefaults(cfg *Config) { if len(cfg.LevelColors) == 0 { cfg.LevelColors = DefaultLevelColors } if cfg.UnknownColor == "" { cfg.UnknownColor = DefaultUnknownColor } }
[ "func", "SetConfigDefaults", "(", "cfg", "*", "Config", ")", "{", "if", "len", "(", "cfg", ".", "LevelColors", ")", "==", "0", "{", "cfg", ".", "LevelColors", "=", "DefaultLevelColors", "\n", "}", "\n", "if", "cfg", ".", "UnknownColor", "==", "\"", "\"...
// SetConfigDefaults sets defaults on the configuration if needed to ensure the cfg is valid.
[ "SetConfigDefaults", "sets", "defaults", "on", "the", "configuration", "if", "needed", "to", "ensure", "the", "cfg", "is", "valid", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/lrhook/hook.go#L78-L85
141,431
multiplay/go-slack
lrhook/hook.go
New
func New(cfg Config, url string) *Hook { return NewClient(cfg, webhook.New(url)) }
go
func New(cfg Config, url string) *Hook { return NewClient(cfg, webhook.New(url)) }
[ "func", "New", "(", "cfg", "Config", ",", "url", "string", ")", "*", "Hook", "{", "return", "NewClient", "(", "cfg", ",", "webhook", ".", "New", "(", "url", ")", ")", "\n", "}" ]
// New returns a new Hook with the given configuration that posts messages using the webhook URL. // It ensures that the cfg is valid by calling SetConfigDefaults on the cfg.
[ "New", "returns", "a", "new", "Hook", "with", "the", "given", "configuration", "that", "posts", "messages", "using", "the", "webhook", "URL", ".", "It", "ensures", "that", "the", "cfg", "is", "valid", "by", "calling", "SetConfigDefaults", "on", "the", "cfg",...
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/lrhook/hook.go#L89-L91
141,432
multiplay/go-slack
lrhook/hook.go
NewClient
func NewClient(cfg Config, client slack.Client) *Hook { SetConfigDefaults(&cfg) c := &Hook{Config: cfg, client: client} if cfg.Limit != 0 { c.limiter = rate.NewLimiter(cfg.Limit, cfg.Burst) } return c }
go
func NewClient(cfg Config, client slack.Client) *Hook { SetConfigDefaults(&cfg) c := &Hook{Config: cfg, client: client} if cfg.Limit != 0 { c.limiter = rate.NewLimiter(cfg.Limit, cfg.Burst) } return c }
[ "func", "NewClient", "(", "cfg", "Config", ",", "client", "slack", ".", "Client", ")", "*", "Hook", "{", "SetConfigDefaults", "(", "&", "cfg", ")", "\n\n", "c", ":=", "&", "Hook", "{", "Config", ":", "cfg", ",", "client", ":", "client", "}", "\n", ...
// NewClient returns a new Hook with the given configuration using the slack.Client c. // It ensures that the cfg is valid by calling SetConfigDefaults on the cfg.
[ "NewClient", "returns", "a", "new", "Hook", "with", "the", "given", "configuration", "using", "the", "slack", ".", "Client", "c", ".", "It", "ensures", "that", "the", "cfg", "is", "valid", "by", "calling", "SetConfigDefaults", "on", "the", "cfg", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/lrhook/hook.go#L95-L104
141,433
multiplay/go-slack
lrhook/hook.go
Levels
func (sh *Hook) Levels() []logrus.Level { lvls := make([]logrus.Level, 0, len(logrus.AllLevels)) for _, l := range logrus.AllLevels { if sh.MinLevel >= l { lvls = append(lvls, l) } } return lvls }
go
func (sh *Hook) Levels() []logrus.Level { lvls := make([]logrus.Level, 0, len(logrus.AllLevels)) for _, l := range logrus.AllLevels { if sh.MinLevel >= l { lvls = append(lvls, l) } } return lvls }
[ "func", "(", "sh", "*", "Hook", ")", "Levels", "(", ")", "[", "]", "logrus", ".", "Level", "{", "lvls", ":=", "make", "(", "[", "]", "logrus", ".", "Level", ",", "0", ",", "len", "(", "logrus", ".", "AllLevels", ")", ")", "\n", "for", "_", ",...
// Levels implements logrus.Hook. // It returns the logrus.Level's that are lower or equal to that of MinLevel. // This means setting MinLevel to logrus.ErrorLevel will send slack messages for log entries at Error, Fatal and Panic.
[ "Levels", "implements", "logrus", ".", "Hook", ".", "It", "returns", "the", "logrus", ".", "Level", "s", "that", "are", "lower", "or", "equal", "to", "that", "of", "MinLevel", ".", "This", "means", "setting", "MinLevel", "to", "logrus", ".", "ErrorLevel", ...
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/lrhook/hook.go#L109-L118
141,434
multiplay/go-slack
lrhook/hook.go
Fire
func (sh *Hook) Fire(e *logrus.Entry) error { if sh.limiter != nil && !sh.limiter.Allow() { // We've hit the configured limit, just ignore. return nil } m := sh.Message a := sh.Attachment m.AddAttachment(&a) a.Fallback = e.Message a.Color = sh.LevelColors[e.Level.String()] if a.Color == "" { a.Color = sh...
go
func (sh *Hook) Fire(e *logrus.Entry) error { if sh.limiter != nil && !sh.limiter.Allow() { // We've hit the configured limit, just ignore. return nil } m := sh.Message a := sh.Attachment m.AddAttachment(&a) a.Fallback = e.Message a.Color = sh.LevelColors[e.Level.String()] if a.Color == "" { a.Color = sh...
[ "func", "(", "sh", "*", "Hook", ")", "Fire", "(", "e", "*", "logrus", ".", "Entry", ")", "error", "{", "if", "sh", ".", "limiter", "!=", "nil", "&&", "!", "sh", ".", "limiter", ".", "Allow", "(", ")", "{", "// We've hit the configured limit, just ignor...
// Fire implements logrus.Hook. // It sends a slack message for the log entry e.
[ "Fire", "implements", "logrus", ".", "Hook", ".", "It", "sends", "a", "slack", "message", "for", "the", "log", "entry", "e", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/lrhook/hook.go#L122-L148
141,435
multiplay/go-slack
errors.go
NewError
func NewError(statuscode int, msg string) *Error { return &Error{StatusCode: statuscode, Message: msg} }
go
func NewError(statuscode int, msg string) *Error { return &Error{StatusCode: statuscode, Message: msg} }
[ "func", "NewError", "(", "statuscode", "int", ",", "msg", "string", ")", "*", "Error", "{", "return", "&", "Error", "{", "StatusCode", ":", "statuscode", ",", "Message", ":", "msg", "}", "\n", "}" ]
// NewError returns a new slack error with statuscode and msg.
[ "NewError", "returns", "a", "new", "slack", "error", "with", "statuscode", "and", "msg", "." ]
6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5
https://github.com/multiplay/go-slack/blob/6f89412cdb8cc2c5d6e58ff736b97d82a86d25d5/errors.go#L17-L19
141,436
segmentio/events
netevents/listener.go
NewListener
func NewListener(listener net.Listener) net.Listener { return NewListenerWith(events.DefaultLogger, listener) }
go
func NewListener(listener net.Listener) net.Listener { return NewListenerWith(events.DefaultLogger, listener) }
[ "func", "NewListener", "(", "listener", "net", ".", "Listener", ")", "net", ".", "Listener", "{", "return", "NewListenerWith", "(", "events", ".", "DefaultLogger", ",", "listener", ")", "\n", "}" ]
// NewListener returns a wrapped version of listener which logs with the default // logger all accept and close events that occur on the listener.
[ "NewListener", "returns", "a", "wrapped", "version", "of", "listener", "which", "logs", "with", "the", "default", "logger", "all", "accept", "and", "close", "events", "that", "occur", "on", "the", "listener", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/listener.go#L12-L14
141,437
segmentio/events
netevents/listener.go
NewListenerWith
func NewListenerWith(logger *events.Logger, listener net.Listener) net.Listener { return &listenerLogger{ Listener: listener, Logger: logger, } }
go
func NewListenerWith(logger *events.Logger, listener net.Listener) net.Listener { return &listenerLogger{ Listener: listener, Logger: logger, } }
[ "func", "NewListenerWith", "(", "logger", "*", "events", ".", "Logger", ",", "listener", "net", ".", "Listener", ")", "net", ".", "Listener", "{", "return", "&", "listenerLogger", "{", "Listener", ":", "listener", ",", "Logger", ":", "logger", ",", "}", ...
// NewListenerWith returns a wrapped version of listener which logs with logger // all accept and close events that occur on the listener.
[ "NewListenerWith", "returns", "a", "wrapped", "version", "of", "listener", "which", "logs", "with", "logger", "all", "accept", "and", "close", "events", "that", "occur", "on", "the", "listener", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/listener.go#L18-L23
141,438
segmentio/events
text/handler.go
NewHandler
func NewHandler(prefix string, output io.Writer) *Handler { return &Handler{ Output: output, Prefix: prefix, TimeFormat: DefaultTimeFormat, } }
go
func NewHandler(prefix string, output io.Writer) *Handler { return &Handler{ Output: output, Prefix: prefix, TimeFormat: DefaultTimeFormat, } }
[ "func", "NewHandler", "(", "prefix", "string", ",", "output", "io", ".", "Writer", ")", "*", "Handler", "{", "return", "&", "Handler", "{", "Output", ":", "output", ",", "Prefix", ":", "prefix", ",", "TimeFormat", ":", "DefaultTimeFormat", ",", "}", "\n"...
// NewHandler creates a new handler which writes to output with a prefix on each // line.
[ "NewHandler", "creates", "a", "new", "handler", "which", "writes", "to", "output", "with", "a", "prefix", "on", "each", "line", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/text/handler.go#L38-L44
141,439
segmentio/events
signal.go
SignalWith
func SignalWith(handler Handler, sigchan <-chan os.Signal) <-chan os.Signal { output := make(chan os.Signal) // We capture the stack frame here instead of in the goroutine because it // gives a more meaningful value (the caller of Signal, which usually is // the application itself). var pc [1]uintptr runtime.Cal...
go
func SignalWith(handler Handler, sigchan <-chan os.Signal) <-chan os.Signal { output := make(chan os.Signal) // We capture the stack frame here instead of in the goroutine because it // gives a more meaningful value (the caller of Signal, which usually is // the application itself). var pc [1]uintptr runtime.Cal...
[ "func", "SignalWith", "(", "handler", "Handler", ",", "sigchan", "<-", "chan", "os", ".", "Signal", ")", "<-", "chan", "os", ".", "Signal", "{", "output", ":=", "make", "(", "chan", "os", ".", "Signal", ")", "\n\n", "// We capture the stack frame here instea...
// SignalWith triggers events on handler for every signal that arrives on // sigchan. // The function returns a channel on which signals are forwarded, the program // should use this channel instead of sigchan to receive signals.
[ "SignalWith", "triggers", "events", "on", "handler", "for", "every", "signal", "that", "arrives", "on", "sigchan", ".", "The", "function", "returns", "a", "channel", "on", "which", "signals", "are", "forwarded", "the", "program", "should", "use", "this", "chan...
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/signal.go#L27-L58
141,440
segmentio/events
signal.go
WithSignals
func WithSignals(ctx context.Context, signals ...os.Signal) (context.Context, context.CancelFunc) { done := make(chan struct{}) sigchan := make(chan os.Signal) sigrecv := Signal(sigchan) signal.Notify(sigchan, signals...) sig := &signalCtx{ parent: ctx, done: done, } go func() { select { case s := <-...
go
func WithSignals(ctx context.Context, signals ...os.Signal) (context.Context, context.CancelFunc) { done := make(chan struct{}) sigchan := make(chan os.Signal) sigrecv := Signal(sigchan) signal.Notify(sigchan, signals...) sig := &signalCtx{ parent: ctx, done: done, } go func() { select { case s := <-...
[ "func", "WithSignals", "(", "ctx", "context", ".", "Context", ",", "signals", "...", "os", ".", "Signal", ")", "(", "context", ".", "Context", ",", "context", ".", "CancelFunc", ")", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\...
// WithSignals returns a copy of the given context which may be canceled if any // of the given signals is received by the program.
[ "WithSignals", "returns", "a", "copy", "of", "the", "given", "context", "which", "may", "be", "canceled", "if", "any", "of", "the", "given", "signals", "is", "received", "by", "the", "program", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/signal.go#L62-L96
141,441
segmentio/events
httpevents/handler.go
NewHandler
func NewHandler(handler http.Handler) http.Handler { return NewHandlerWith(events.DefaultLogger, handler) }
go
func NewHandler(handler http.Handler) http.Handler { return NewHandlerWith(events.DefaultLogger, handler) }
[ "func", "NewHandler", "(", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "NewHandlerWith", "(", "events", ".", "DefaultLogger", ",", "handler", ")", "\n", "}" ]
// NewHandler wraps the HTTP handler and returns a new handler which logs all // requests with the default logger.
[ "NewHandler", "wraps", "the", "HTTP", "handler", "and", "returns", "a", "new", "handler", "which", "logs", "all", "requests", "with", "the", "default", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/httpevents/handler.go#L14-L16
141,442
segmentio/events
httpevents/handler.go
NewHandlerWith
func NewHandlerWith(logger *events.Logger, handler http.Handler) http.Handler { return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { var laddr string if value, ok := req.Context().Value(http.LocalAddrContextKey).(net.Addr); ok { laddr = value.String() } w := responseWriterPool.Get()....
go
func NewHandlerWith(logger *events.Logger, handler http.Handler) http.Handler { return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { var laddr string if value, ok := req.Context().Value(http.LocalAddrContextKey).(net.Addr); ok { laddr = value.String() } w := responseWriterPool.Get()....
[ "func", "NewHandlerWith", "(", "logger", "*", "events", ".", "Logger", ",", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "res", "http", ".", "ResponseWriter", ",", "req", "*"...
// NewHandlerWith wraps the HTTP handler and returns a new handler which logs all // requests with logger. // // Panics from handler are intercepted and trigger a 500 response if no response // header was sent yet. The panic is not silenced tho and is propagated to the // parent handler.
[ "NewHandlerWith", "wraps", "the", "HTTP", "handler", "and", "returns", "a", "new", "handler", "which", "logs", "all", "requests", "with", "logger", ".", "Panics", "from", "handler", "are", "intercepted", "and", "trigger", "a", "500", "response", "if", "no", ...
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/httpevents/handler.go#L24-L69
141,443
segmentio/events
source.go
SourceForPC
func SourceForPC(pc uintptr) (file string, line int) { var name string file, line, name = fileLineFunc(pc) file = trimGOPATH(name, file) return }
go
func SourceForPC(pc uintptr) (file string, line int) { var name string file, line, name = fileLineFunc(pc) file = trimGOPATH(name, file) return }
[ "func", "SourceForPC", "(", "pc", "uintptr", ")", "(", "file", "string", ",", "line", "int", ")", "{", "var", "name", "string", "\n", "file", ",", "line", ",", "name", "=", "fileLineFunc", "(", "pc", ")", "\n", "file", "=", "trimGOPATH", "(", "name",...
// SourceForPC returns the file and line given a program counter address. // The file path is in the canonical form for Go programs, starting with // the package path.
[ "SourceForPC", "returns", "the", "file", "and", "line", "given", "a", "program", "counter", "address", ".", "The", "file", "path", "is", "in", "the", "canonical", "form", "for", "Go", "programs", "starting", "with", "the", "package", "path", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/source.go#L8-L13
141,444
segmentio/events
log/log.go
NewLogger
func NewLogger(prefix string, flags int, handler events.Handler) *log.Logger { return log.New(NewWriter(prefix, flags, handler), prefix, flags) }
go
func NewLogger(prefix string, flags int, handler events.Handler) *log.Logger { return log.New(NewWriter(prefix, flags, handler), prefix, flags) }
[ "func", "NewLogger", "(", "prefix", "string", ",", "flags", "int", ",", "handler", "events", ".", "Handler", ")", "*", "log", ".", "Logger", "{", "return", "log", ".", "New", "(", "NewWriter", "(", "prefix", ",", "flags", ",", "handler", ")", ",", "p...
// NewLogger creates a new logger. The prefix and flags arguments configure the // behavior of the logger, while handler sets the destination to which log // events are sent.
[ "NewLogger", "creates", "a", "new", "logger", ".", "The", "prefix", "and", "flags", "arguments", "configure", "the", "behavior", "of", "the", "logger", "while", "handler", "sets", "the", "destination", "to", "which", "log", "events", "are", "sent", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/log/log.go#L24-L26
141,445
segmentio/events
log/log.go
SetOutput
func SetOutput(w io.Writer) { handler := NewHandler(w) defaultWriter.mutex.Lock() defaultWriter.handler = handler defaultWriter.mutex.Unlock() }
go
func SetOutput(w io.Writer) { handler := NewHandler(w) defaultWriter.mutex.Lock() defaultWriter.handler = handler defaultWriter.mutex.Unlock() }
[ "func", "SetOutput", "(", "w", "io", ".", "Writer", ")", "{", "handler", ":=", "NewHandler", "(", "w", ")", "\n", "defaultWriter", ".", "mutex", ".", "Lock", "(", ")", "\n", "defaultWriter", ".", "handler", "=", "handler", "\n", "defaultWriter", ".", "...
// SetOutput sets the output destination for the standard logger.
[ "SetOutput", "sets", "the", "output", "destination", "for", "the", "standard", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/log/log.go#L108-L113
141,446
segmentio/events
log/log.go
SetFlags
func SetFlags(flags int) { defaultWriter.mutex.Lock() log.SetFlags(flags) defaultWriter.flags = flags defaultWriter.mutex.Unlock() }
go
func SetFlags(flags int) { defaultWriter.mutex.Lock() log.SetFlags(flags) defaultWriter.flags = flags defaultWriter.mutex.Unlock() }
[ "func", "SetFlags", "(", "flags", "int", ")", "{", "defaultWriter", ".", "mutex", ".", "Lock", "(", ")", "\n", "log", ".", "SetFlags", "(", "flags", ")", "\n", "defaultWriter", ".", "flags", "=", "flags", "\n", "defaultWriter", ".", "mutex", ".", "Unlo...
// SetFlags sets the output flags for the standard logger.
[ "SetFlags", "sets", "the", "output", "flags", "for", "the", "standard", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/log/log.go#L121-L126
141,447
segmentio/events
log/log.go
SetPrefix
func SetPrefix(prefix string) { defaultWriter.mutex.Lock() log.SetPrefix(prefix) // Special case if the default writer is backed by a text handler so we can // make it output the right prefix. if h, ok := defaultWriter.handler.(*text.Handler); ok { h.Prefix = prefix } defaultWriter.prefix = prefix defaultWr...
go
func SetPrefix(prefix string) { defaultWriter.mutex.Lock() log.SetPrefix(prefix) // Special case if the default writer is backed by a text handler so we can // make it output the right prefix. if h, ok := defaultWriter.handler.(*text.Handler); ok { h.Prefix = prefix } defaultWriter.prefix = prefix defaultWr...
[ "func", "SetPrefix", "(", "prefix", "string", ")", "{", "defaultWriter", ".", "mutex", ".", "Lock", "(", ")", "\n", "log", ".", "SetPrefix", "(", "prefix", ")", "\n\n", "// Special case if the default writer is backed by a text handler so we can", "// make it output the...
// SetPrefix sets the output prefix for the standard logger.
[ "SetPrefix", "sets", "the", "output", "prefix", "for", "the", "standard", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/log/log.go#L134-L146
141,448
segmentio/events
log/log.go
Output
func Output(calldepth int, s string) error { return log.Output(calldepth+1, s) // +1 for this frame. }
go
func Output(calldepth int, s string) error { return log.Output(calldepth+1, s) // +1 for this frame. }
[ "func", "Output", "(", "calldepth", "int", ",", "s", "string", ")", "error", "{", "return", "log", ".", "Output", "(", "calldepth", "+", "1", ",", "s", ")", "// +1 for this frame.", "\n", "}" ]
// Output writes the output for a logging event. The string s contains // the text to print after the prefix specified by the flags of the // Logger. A newline is appended if the last character of s is not // already a newline. Calldepth is the count of the number of // frames to skip when computing the file name and l...
[ "Output", "writes", "the", "output", "for", "a", "logging", "event", ".", "The", "string", "s", "contains", "the", "text", "to", "print", "after", "the", "prefix", "specified", "by", "the", "flags", "of", "the", "Logger", ".", "A", "newline", "is", "appe...
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/log/log.go#L212-L214
141,449
segmentio/events
logger.go
NewLogger
func NewLogger(handler Handler) *Logger { return &Logger{ Handler: handler, EnableSource: true, EnableDebug: true, } }
go
func NewLogger(handler Handler) *Logger { return &Logger{ Handler: handler, EnableSource: true, EnableDebug: true, } }
[ "func", "NewLogger", "(", "handler", "Handler", ")", "*", "Logger", "{", "return", "&", "Logger", "{", "Handler", ":", "handler", ",", "EnableSource", ":", "true", ",", "EnableDebug", ":", "true", ",", "}", "\n", "}" ]
// NewLogger allocates and returns a new logger which sends events to handler.
[ "NewLogger", "allocates", "and", "returns", "a", "new", "logger", "which", "sends", "events", "to", "handler", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/logger.go#L78-L84
141,450
segmentio/events
logger.go
Log
func (l *Logger) Log(format string, args ...interface{}) { l.log(1, false, format, args...) }
go
func (l *Logger) Log(format string, args ...interface{}) { l.log(1, false, format, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Log", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "log", "(", "1", ",", "false", ",", "format", ",", "args", "...", ")", "\n", "}" ]
// Log formats an event and sends it to the logger's handler.
[ "Log", "formats", "an", "event", "and", "sends", "it", "to", "the", "logger", "s", "handler", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/logger.go#L87-L89
141,451
segmentio/events
logger.go
Debug
func (l *Logger) Debug(format string, args ...interface{}) { l.debug(1, format, args...) }
go
func (l *Logger) Debug(format string, args ...interface{}) { l.debug(1, format, args...) }
[ "func", "(", "l", "*", "Logger", ")", "Debug", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "l", ".", "debug", "(", "1", ",", "format", ",", "args", "...", ")", "\n", "}" ]
// Debug is like Log but only produces events if the logger has debugging // enabled.
[ "Debug", "is", "like", "Log", "but", "only", "produces", "events", "if", "the", "logger", "has", "debugging", "enabled", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/logger.go#L150-L152
141,452
segmentio/events
logger.go
With
func (l *Logger) With(args Args) *Logger { var newArgs Args var newLen = len(l.Args) + len(args) if newLen != 0 { newArgs = make(Args, 0, newLen) newArgs = append(newArgs, l.Args...) newArgs = append(newArgs, args...) } return &Logger{ Args: newArgs, Handler: l.Handler, EnableSource: l.E...
go
func (l *Logger) With(args Args) *Logger { var newArgs Args var newLen = len(l.Args) + len(args) if newLen != 0 { newArgs = make(Args, 0, newLen) newArgs = append(newArgs, l.Args...) newArgs = append(newArgs, args...) } return &Logger{ Args: newArgs, Handler: l.Handler, EnableSource: l.E...
[ "func", "(", "l", "*", "Logger", ")", "With", "(", "args", "Args", ")", "*", "Logger", "{", "var", "newArgs", "Args", "\n", "var", "newLen", "=", "len", "(", "l", ".", "Args", ")", "+", "len", "(", "args", ")", "\n\n", "if", "newLen", "!=", "0"...
// With returns a new Logger which is a copy of l augmented with args.
[ "With", "returns", "a", "new", "Logger", "which", "is", "a", "copy", "of", "l", "augmented", "with", "args", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/logger.go#L161-L177
141,453
segmentio/events
event.go
Clone
func (e *Event) Clone() *Event { var a Args var m []byte var s []byte if n := len(e.Args); n != 0 { a = make(Args, n) for i := range a { a[i].Name = e.Args[i].Name a[i].Value = clone(e.Args[i].Value) } } if n := len(e.Message); n != 0 { m = make([]byte, n) copy(m, e.Message) } if n := len(e.S...
go
func (e *Event) Clone() *Event { var a Args var m []byte var s []byte if n := len(e.Args); n != 0 { a = make(Args, n) for i := range a { a[i].Name = e.Args[i].Name a[i].Value = clone(e.Args[i].Value) } } if n := len(e.Message); n != 0 { m = make([]byte, n) copy(m, e.Message) } if n := len(e.S...
[ "func", "(", "e", "*", "Event", ")", "Clone", "(", ")", "*", "Event", "{", "var", "a", "Args", "\n", "var", "m", "[", "]", "byte", "\n", "var", "s", "[", "]", "byte", "\n\n", "if", "n", ":=", "len", "(", "e", ".", "Args", ")", ";", "n", "...
// Clone makes a deep copy of the event, the returned value doesn't shared any // pointer with the original.
[ "Clone", "makes", "a", "deep", "copy", "of", "the", "event", "the", "returned", "value", "doesn", "t", "shared", "any", "pointer", "with", "the", "original", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/event.go#L31-L61
141,454
segmentio/events
event.go
Get
func (args Args) Get(name string) (v interface{}, ok bool) { for _, arg := range args { if arg.Name == name { v, ok = arg.Value, true break } } return }
go
func (args Args) Get(name string) (v interface{}, ok bool) { for _, arg := range args { if arg.Name == name { v, ok = arg.Value, true break } } return }
[ "func", "(", "args", "Args", ")", "Get", "(", "name", "string", ")", "(", "v", "interface", "{", "}", ",", "ok", "bool", ")", "{", "for", "_", ",", "arg", ":=", "range", "args", "{", "if", "arg", ".", "Name", "==", "name", "{", "v", ",", "ok"...
// Get returns the value of the argument with name within args.
[ "Get", "returns", "the", "value", "of", "the", "argument", "with", "name", "within", "args", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/event.go#L84-L92
141,455
segmentio/events
event.go
Map
func (args Args) Map() map[string]interface{} { m := make(map[string]interface{}) for _, arg := range args { m[arg.Name] = arg.Value } return m }
go
func (args Args) Map() map[string]interface{} { m := make(map[string]interface{}) for _, arg := range args { m[arg.Name] = arg.Value } return m }
[ "func", "(", "args", "Args", ")", "Map", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "for", "_", ",", "arg", ":=", "range", "args", "{", ...
// Map converts an argument list to a map representation. In cases where the // list contains multiple arguments with the same name the value of the last // one will be seen in the map.
[ "Map", "converts", "an", "argument", "list", "to", "a", "map", "representation", ".", "In", "cases", "where", "the", "list", "contains", "multiple", "arguments", "with", "the", "same", "name", "the", "value", "of", "the", "last", "one", "will", "be", "seen...
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/event.go#L97-L103
141,456
segmentio/events
event.go
A
func A(m map[string]interface{}) Args { args := make(Args, 0, len(m)) for name, value := range m { args = append(args, Arg{name, value}) } return args }
go
func A(m map[string]interface{}) Args { args := make(Args, 0, len(m)) for name, value := range m { args = append(args, Arg{name, value}) } return args }
[ "func", "A", "(", "m", "map", "[", "string", "]", "interface", "{", "}", ")", "Args", "{", "args", ":=", "make", "(", "Args", ",", "0", ",", "len", "(", "m", ")", ")", "\n", "for", "name", ",", "value", ":=", "range", "m", "{", "args", "=", ...
// A constructs an argument list from a map.
[ "A", "constructs", "an", "argument", "list", "from", "a", "map", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/event.go#L106-L112
141,457
segmentio/events
handler.go
MultiHandler
func MultiHandler(handlers ...Handler) Handler { c := make([]Handler, len(handlers)) copy(c, handlers) return &multiHandler{ handlers: c, } }
go
func MultiHandler(handlers ...Handler) Handler { c := make([]Handler, len(handlers)) copy(c, handlers) return &multiHandler{ handlers: c, } }
[ "func", "MultiHandler", "(", "handlers", "...", "Handler", ")", "Handler", "{", "c", ":=", "make", "(", "[", "]", "Handler", ",", "len", "(", "handlers", ")", ")", "\n", "copy", "(", "c", ",", "handlers", ")", "\n", "return", "&", "multiHandler", "{"...
// MultiHandler returns a new Handler which broadcasts the events it receives // to its list of handlers.
[ "MultiHandler", "returns", "a", "new", "Handler", "which", "broadcasts", "the", "events", "it", "receives", "to", "its", "list", "of", "handlers", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/handler.go#L26-L32
141,458
segmentio/events
netevents/dial.go
DialFunc
func DialFunc(dial func(string, string) (net.Conn, error)) func(string, string) (net.Conn, error) { return DialFuncWith(events.DefaultLogger, dial) }
go
func DialFunc(dial func(string, string) (net.Conn, error)) func(string, string) (net.Conn, error) { return DialFuncWith(events.DefaultLogger, dial) }
[ "func", "DialFunc", "(", "dial", "func", "(", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", ")", "func", "(", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "return", "DialFuncWith", "(", ...
// DialFunc returns a wrapper for dial which logs with the default logger all // opening and closing events that occur on the connections returned by the dial // function.
[ "DialFunc", "returns", "a", "wrapper", "for", "dial", "which", "logs", "with", "the", "default", "logger", "all", "opening", "and", "closing", "events", "that", "occur", "on", "the", "connections", "returned", "by", "the", "dial", "function", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/dial.go#L14-L16
141,459
segmentio/events
netevents/dial.go
DialFuncWith
func DialFuncWith(logger *events.Logger, dial func(string, string) (net.Conn, error)) func(string, string) (net.Conn, error) { dialContext := dialContextFunc(1, logger, func(ctx context.Context, network string, address string) (net.Conn, error) { return dial(network, address) }, ) return func(network string, ...
go
func DialFuncWith(logger *events.Logger, dial func(string, string) (net.Conn, error)) func(string, string) (net.Conn, error) { dialContext := dialContextFunc(1, logger, func(ctx context.Context, network string, address string) (net.Conn, error) { return dial(network, address) }, ) return func(network string, ...
[ "func", "DialFuncWith", "(", "logger", "*", "events", ".", "Logger", ",", "dial", "func", "(", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", ")", "func", "(", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", ...
// DialFuncWith returns a wrapper for dial which logs with logger all opening // and closing events that occur on the connections returned by the dial // function.
[ "DialFuncWith", "returns", "a", "wrapper", "for", "dial", "which", "logs", "with", "logger", "all", "opening", "and", "closing", "events", "that", "occur", "on", "the", "connections", "returned", "by", "the", "dial", "function", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/dial.go#L21-L30
141,460
segmentio/events
netevents/dial.go
DialContextFunc
func DialContextFunc(dial func(context.Context, string, string) (net.Conn, error)) func(context.Context, string, string) (net.Conn, error) { return DialContextFuncWith(events.DefaultLogger, dial) }
go
func DialContextFunc(dial func(context.Context, string, string) (net.Conn, error)) func(context.Context, string, string) (net.Conn, error) { return DialContextFuncWith(events.DefaultLogger, dial) }
[ "func", "DialContextFunc", "(", "dial", "func", "(", "context", ".", "Context", ",", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", ")", "func", "(", "context", ".", "Context", ",", "string", ",", "string", ")", "(", "net",...
// DialContextFunc returns a wrapper for dial which logs with the default // logger all opening and closing events that occur on the connections returned // by the dial function.
[ "DialContextFunc", "returns", "a", "wrapper", "for", "dial", "which", "logs", "with", "the", "default", "logger", "all", "opening", "and", "closing", "events", "that", "occur", "on", "the", "connections", "returned", "by", "the", "dial", "function", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/dial.go#L35-L37
141,461
segmentio/events
netevents/dial.go
DialContextFuncWith
func DialContextFuncWith(logger *events.Logger, dial func(context.Context, string, string) (net.Conn, error)) func(context.Context, string, string) (net.Conn, error) { return dialContextFunc(0, logger, dial) }
go
func DialContextFuncWith(logger *events.Logger, dial func(context.Context, string, string) (net.Conn, error)) func(context.Context, string, string) (net.Conn, error) { return dialContextFunc(0, logger, dial) }
[ "func", "DialContextFuncWith", "(", "logger", "*", "events", ".", "Logger", ",", "dial", "func", "(", "context", ".", "Context", ",", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", ")", "func", "(", "context", ".", "Context",...
// DialContextFuncWith returns a wrapper for dial which logs with logger all // opening and closing events that occur on the connections returned by the // dial function.
[ "DialContextFuncWith", "returns", "a", "wrapper", "for", "dial", "which", "logs", "with", "logger", "all", "opening", "and", "closing", "events", "that", "occur", "on", "the", "connections", "returned", "by", "the", "dial", "function", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/dial.go#L42-L44
141,462
segmentio/events
netevents/handler.go
NewHandlerWith
func NewHandlerWith(logger *events.Logger, handler Handler) Handler { if logger == nil { panic("cannot send network events to a nil logger") } if handler == nil { panic("cannot capture network events of a nil handler") } return &handlerLogger{ Handler: handler, Logger: logger, } }
go
func NewHandlerWith(logger *events.Logger, handler Handler) Handler { if logger == nil { panic("cannot send network events to a nil logger") } if handler == nil { panic("cannot capture network events of a nil handler") } return &handlerLogger{ Handler: handler, Logger: logger, } }
[ "func", "NewHandlerWith", "(", "logger", "*", "events", ".", "Logger", ",", "handler", "Handler", ")", "Handler", "{", "if", "logger", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "handler", "==", "nil", "{", "panic", "("...
// NewHandlerWith returns a wrapped handler which logs with logger all // opening and closing events that occur on the connections served by the // handler with logger.
[ "NewHandlerWith", "returns", "a", "wrapped", "handler", "which", "logs", "with", "logger", "all", "opening", "and", "closing", "events", "that", "occur", "on", "the", "connections", "served", "by", "the", "handler", "with", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/netevents/handler.go#L26-L39
141,463
segmentio/events
log/writer.go
NewWriter
func NewWriter(prefix string, flags int, handler events.Handler) *Writer { return &Writer{ handler: handler, prefix: prefix, flags: flags, } }
go
func NewWriter(prefix string, flags int, handler events.Handler) *Writer { return &Writer{ handler: handler, prefix: prefix, flags: flags, } }
[ "func", "NewWriter", "(", "prefix", "string", ",", "flags", "int", ",", "handler", "events", ".", "Handler", ")", "*", "Writer", "{", "return", "&", "Writer", "{", "handler", ":", "handler", ",", "prefix", ":", "prefix", ",", "flags", ":", "flags", ","...
// NewWriter constructs a new Writer value which is intended to be set on a // logger configured with prefix and flags, the output forwards events to the // given handler.
[ "NewWriter", "constructs", "a", "new", "Writer", "value", "which", "is", "intended", "to", "be", "set", "on", "a", "logger", "configured", "with", "prefix", "and", "flags", "the", "output", "forwards", "events", "to", "the", "given", "handler", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/log/writer.go#L31-L37
141,464
segmentio/events
httpevents/transport.go
NewTransport
func NewTransport(roundTripper http.RoundTripper) http.RoundTripper { return NewTransportWith(events.DefaultLogger, roundTripper) }
go
func NewTransport(roundTripper http.RoundTripper) http.RoundTripper { return NewTransportWith(events.DefaultLogger, roundTripper) }
[ "func", "NewTransport", "(", "roundTripper", "http", ".", "RoundTripper", ")", "http", ".", "RoundTripper", "{", "return", "NewTransportWith", "(", "events", ".", "DefaultLogger", ",", "roundTripper", ")", "\n", "}" ]
// NewTransportWith wraps roundTripper and returns a new transport which logs // all submitted requests with the default logger.
[ "NewTransportWith", "wraps", "roundTripper", "and", "returns", "a", "new", "transport", "which", "logs", "all", "submitted", "requests", "with", "the", "default", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/httpevents/transport.go#L11-L13
141,465
segmentio/events
httpevents/transport.go
NewTransportWith
func NewTransportWith(logger *events.Logger, roundTripper http.RoundTripper) http.RoundTripper { return &transport{roundTripper, logger} }
go
func NewTransportWith(logger *events.Logger, roundTripper http.RoundTripper) http.RoundTripper { return &transport{roundTripper, logger} }
[ "func", "NewTransportWith", "(", "logger", "*", "events", ".", "Logger", ",", "roundTripper", "http", ".", "RoundTripper", ")", "http", ".", "RoundTripper", "{", "return", "&", "transport", "{", "roundTripper", ",", "logger", "}", "\n", "}" ]
// NewTransportWith wraps roundTripper and returns a new transport which logs // all submitted requests with logger.
[ "NewTransportWith", "wraps", "roundTripper", "and", "returns", "a", "new", "transport", "which", "logs", "all", "submitted", "requests", "with", "logger", "." ]
e62248bd4df28ce3b028d5d557cec210098797c1
https://github.com/segmentio/events/blob/e62248bd4df28ce3b028d5d557cec210098797c1/httpevents/transport.go#L17-L19
141,466
multiformats/go-multiaddr-net
convert.go
FromNetAddr
func FromNetAddr(a net.Addr) (ma.Multiaddr, error) { return defaultCodecs.FromNetAddr(a) }
go
func FromNetAddr(a net.Addr) (ma.Multiaddr, error) { return defaultCodecs.FromNetAddr(a) }
[ "func", "FromNetAddr", "(", "a", "net", ".", "Addr", ")", "(", "ma", ".", "Multiaddr", ",", "error", ")", "{", "return", "defaultCodecs", ".", "FromNetAddr", "(", "a", ")", "\n", "}" ]
// FromNetAddr converts a net.Addr type to a Multiaddr.
[ "FromNetAddr", "converts", "a", "net", ".", "Addr", "type", "to", "a", "Multiaddr", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/convert.go#L15-L17
141,467
multiformats/go-multiaddr-net
convert.go
FromNetAddr
func (cm *CodecMap) FromNetAddr(a net.Addr) (ma.Multiaddr, error) { if a == nil { return nil, fmt.Errorf("nil multiaddr") } p, err := cm.getAddrParser(a.Network()) if err != nil { return nil, err } return p(a) }
go
func (cm *CodecMap) FromNetAddr(a net.Addr) (ma.Multiaddr, error) { if a == nil { return nil, fmt.Errorf("nil multiaddr") } p, err := cm.getAddrParser(a.Network()) if err != nil { return nil, err } return p(a) }
[ "func", "(", "cm", "*", "CodecMap", ")", "FromNetAddr", "(", "a", "net", ".", "Addr", ")", "(", "ma", ".", "Multiaddr", ",", "error", ")", "{", "if", "a", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n",...
// FromNetAddr converts a net.Addr to Multiaddress.
[ "FromNetAddr", "converts", "a", "net", ".", "Addr", "to", "Multiaddress", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/convert.go#L20-L30
141,468
multiformats/go-multiaddr-net
convert.go
ToNetAddr
func (cm *CodecMap) ToNetAddr(maddr ma.Multiaddr) (net.Addr, error) { protos := maddr.Protocols() final := protos[len(protos)-1] p, err := cm.getMaddrParser(final.Name) if err != nil { return nil, err } return p(maddr) }
go
func (cm *CodecMap) ToNetAddr(maddr ma.Multiaddr) (net.Addr, error) { protos := maddr.Protocols() final := protos[len(protos)-1] p, err := cm.getMaddrParser(final.Name) if err != nil { return nil, err } return p(maddr) }
[ "func", "(", "cm", "*", "CodecMap", ")", "ToNetAddr", "(", "maddr", "ma", ".", "Multiaddr", ")", "(", "net", ".", "Addr", ",", "error", ")", "{", "protos", ":=", "maddr", ".", "Protocols", "(", ")", "\n", "final", ":=", "protos", "[", "len", "(", ...
// ToNetAddr converts a Multiaddress to a standard net.Addr.
[ "ToNetAddr", "converts", "a", "Multiaddress", "to", "a", "standard", "net", ".", "Addr", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/convert.go#L40-L50
141,469
multiformats/go-multiaddr-net
private.go
IsPublicAddr
func IsPublicAddr(a ma.Multiaddr) bool { isPublic := false ma.ForEach(a, func(c ma.Component) bool { switch c.Protocol().Code { case ma.P_IP6ZONE: return true default: return false case ma.P_IP4: ip := net.IP(c.RawValue()) isPublic = !inAddrRange(ip, Private4) && !inAddrRange(ip, Unroutable4) ca...
go
func IsPublicAddr(a ma.Multiaddr) bool { isPublic := false ma.ForEach(a, func(c ma.Component) bool { switch c.Protocol().Code { case ma.P_IP6ZONE: return true default: return false case ma.P_IP4: ip := net.IP(c.RawValue()) isPublic = !inAddrRange(ip, Private4) && !inAddrRange(ip, Unroutable4) ca...
[ "func", "IsPublicAddr", "(", "a", "ma", ".", "Multiaddr", ")", "bool", "{", "isPublic", ":=", "false", "\n", "ma", ".", "ForEach", "(", "a", ",", "func", "(", "c", "ma", ".", "Component", ")", "bool", "{", "switch", "c", ".", "Protocol", "(", ")", ...
// IsPublicAddr retruns true if the IP part of the multiaddr is a publicly routable address
[ "IsPublicAddr", "retruns", "true", "if", "the", "IP", "part", "of", "the", "multiaddr", "is", "a", "publicly", "routable", "address" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/private.go#L69-L87
141,470
multiformats/go-multiaddr-net
private.go
IsPrivateAddr
func IsPrivateAddr(a ma.Multiaddr) bool { isPrivate := false ma.ForEach(a, func(c ma.Component) bool { switch c.Protocol().Code { case ma.P_IP6ZONE: return true default: return false case ma.P_IP4: isPrivate = inAddrRange(net.IP(c.RawValue()), Private4) case ma.P_IP6: isPrivate = inAddrRange(net...
go
func IsPrivateAddr(a ma.Multiaddr) bool { isPrivate := false ma.ForEach(a, func(c ma.Component) bool { switch c.Protocol().Code { case ma.P_IP6ZONE: return true default: return false case ma.P_IP4: isPrivate = inAddrRange(net.IP(c.RawValue()), Private4) case ma.P_IP6: isPrivate = inAddrRange(net...
[ "func", "IsPrivateAddr", "(", "a", "ma", ".", "Multiaddr", ")", "bool", "{", "isPrivate", ":=", "false", "\n", "ma", ".", "ForEach", "(", "a", ",", "func", "(", "c", "ma", ".", "Component", ")", "bool", "{", "switch", "c", ".", "Protocol", "(", ")"...
// IsPrivateAddr returns true if the IP part of the mutiaddr is in a private network
[ "IsPrivateAddr", "returns", "true", "if", "the", "IP", "part", "of", "the", "mutiaddr", "is", "in", "a", "private", "network" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/private.go#L90-L106
141,471
multiformats/go-multiaddr-net
registry.go
NewCodecMap
func NewCodecMap() *CodecMap { return &CodecMap{ addrParsers: make(map[string]FromNetAddrFunc), maddrParsers: make(map[string]ToNetAddrFunc), } }
go
func NewCodecMap() *CodecMap { return &CodecMap{ addrParsers: make(map[string]FromNetAddrFunc), maddrParsers: make(map[string]ToNetAddrFunc), } }
[ "func", "NewCodecMap", "(", ")", "*", "CodecMap", "{", "return", "&", "CodecMap", "{", "addrParsers", ":", "make", "(", "map", "[", "string", "]", "FromNetAddrFunc", ")", ",", "maddrParsers", ":", "make", "(", "map", "[", "string", "]", "ToNetAddrFunc", ...
// NewCodecMap initializes and returns a CodecMap object.
[ "NewCodecMap", "initializes", "and", "returns", "a", "CodecMap", "object", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/registry.go#L41-L46
141,472
multiformats/go-multiaddr-net
registry.go
RegisterNetCodec
func (cm *CodecMap) RegisterNetCodec(a *NetCodec) { cm.lk.Lock() defer cm.lk.Unlock() for _, n := range a.NetAddrNetworks { cm.addrParsers[n] = a.ParseNetAddr } cm.maddrParsers[a.ProtocolName] = a.ConvertMultiaddr }
go
func (cm *CodecMap) RegisterNetCodec(a *NetCodec) { cm.lk.Lock() defer cm.lk.Unlock() for _, n := range a.NetAddrNetworks { cm.addrParsers[n] = a.ParseNetAddr } cm.maddrParsers[a.ProtocolName] = a.ConvertMultiaddr }
[ "func", "(", "cm", "*", "CodecMap", ")", "RegisterNetCodec", "(", "a", "*", "NetCodec", ")", "{", "cm", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "lk", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "n", ":=", "range", "a", ...
// RegisterNetCodec adds a new NetCodec to the CodecMap. This function is // thread safe.
[ "RegisterNetCodec", "adds", "a", "new", "NetCodec", "to", "the", "CodecMap", ".", "This", "function", "is", "thread", "safe", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/registry.go#L83-L91
141,473
multiformats/go-multiaddr-net
registry.go
RegisterFromNetAddr
func (cm *CodecMap) RegisterFromNetAddr(from FromNetAddrFunc, networks ...string) { cm.lk.Lock() defer cm.lk.Unlock() for _, n := range networks { cm.addrParsers[n] = from } }
go
func (cm *CodecMap) RegisterFromNetAddr(from FromNetAddrFunc, networks ...string) { cm.lk.Lock() defer cm.lk.Unlock() for _, n := range networks { cm.addrParsers[n] = from } }
[ "func", "(", "cm", "*", "CodecMap", ")", "RegisterFromNetAddr", "(", "from", "FromNetAddrFunc", ",", "networks", "...", "string", ")", "{", "cm", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "lk", ".", "Unlock", "(", ")", "\n\n", "for"...
// RegisterFromNetAddr registers a conversion from net.Addr instances to multiaddrs
[ "RegisterFromNetAddr", "registers", "a", "conversion", "from", "net", ".", "Addr", "instances", "to", "multiaddrs" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/registry.go#L94-L101
141,474
multiformats/go-multiaddr-net
registry.go
RegisterToNetAddr
func (cm *CodecMap) RegisterToNetAddr(to ToNetAddrFunc, protocols ...string) { cm.lk.Lock() defer cm.lk.Unlock() for _, p := range protocols { cm.maddrParsers[p] = to } }
go
func (cm *CodecMap) RegisterToNetAddr(to ToNetAddrFunc, protocols ...string) { cm.lk.Lock() defer cm.lk.Unlock() for _, p := range protocols { cm.maddrParsers[p] = to } }
[ "func", "(", "cm", "*", "CodecMap", ")", "RegisterToNetAddr", "(", "to", "ToNetAddrFunc", ",", "protocols", "...", "string", ")", "{", "cm", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "lk", ".", "Unlock", "(", ")", "\n\n", "for", "...
// RegisterToNetAddr registers a conversion from multiaddrs to net.Addr instances
[ "RegisterToNetAddr", "registers", "a", "conversion", "from", "multiaddrs", "to", "net", ".", "Addr", "instances" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/registry.go#L104-L111
141,475
multiformats/go-multiaddr-net
net.go
Accept
func (l *maListener) Accept() (Conn, error) { nconn, err := l.Listener.Accept() if err != nil { return nil, err } var raddr ma.Multiaddr // This block protects us in transports (i.e. unix sockets) that don't have // remote addresses for inbound connections. if nconn.RemoteAddr().String() != "" { raddr, err ...
go
func (l *maListener) Accept() (Conn, error) { nconn, err := l.Listener.Accept() if err != nil { return nil, err } var raddr ma.Multiaddr // This block protects us in transports (i.e. unix sockets) that don't have // remote addresses for inbound connections. if nconn.RemoteAddr().String() != "" { raddr, err ...
[ "func", "(", "l", "*", "maListener", ")", "Accept", "(", ")", "(", "Conn", ",", "error", ")", "{", "nconn", ",", "err", ":=", "l", ".", "Listener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n",...
// Accept waits for and returns the next connection to the listener. // Returns a Multiaddr friendly Conn
[ "Accept", "waits", "for", "and", "returns", "the", "next", "connection", "to", "the", "listener", ".", "Returns", "a", "Multiaddr", "friendly", "Conn" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/net.go#L242-L259
141,476
multiformats/go-multiaddr-net
net.go
WrapNetListener
func WrapNetListener(nl net.Listener) (Listener, error) { if nla, ok := nl.(*netListenerAdapter); ok { return nla.Listener, nil } laddr, err := FromNetAddr(nl.Addr()) if err != nil { return nil, err } return &maListener{ Listener: nl, laddr: laddr, }, nil }
go
func WrapNetListener(nl net.Listener) (Listener, error) { if nla, ok := nl.(*netListenerAdapter); ok { return nla.Listener, nil } laddr, err := FromNetAddr(nl.Addr()) if err != nil { return nil, err } return &maListener{ Listener: nl, laddr: laddr, }, nil }
[ "func", "WrapNetListener", "(", "nl", "net", ".", "Listener", ")", "(", "Listener", ",", "error", ")", "{", "if", "nla", ",", "ok", ":=", "nl", ".", "(", "*", "netListenerAdapter", ")", ";", "ok", "{", "return", "nla", ".", "Listener", ",", "nil", ...
// WrapNetListener wraps a net.Listener with a manet.Listener.
[ "WrapNetListener", "wraps", "a", "net", ".", "Listener", "with", "a", "manet", ".", "Listener", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/net.go#L294-L308
141,477
multiformats/go-multiaddr-net
net.go
ListenPacket
func ListenPacket(laddr ma.Multiaddr) (PacketConn, error) { lnet, lnaddr, err := DialArgs(laddr) if err != nil { return nil, err } pc, err := net.ListenPacket(lnet, lnaddr) if err != nil { return nil, err } // We want to fetch the new multiaddr from the listener, as it may // have resolved to some other v...
go
func ListenPacket(laddr ma.Multiaddr) (PacketConn, error) { lnet, lnaddr, err := DialArgs(laddr) if err != nil { return nil, err } pc, err := net.ListenPacket(lnet, lnaddr) if err != nil { return nil, err } // We want to fetch the new multiaddr from the listener, as it may // have resolved to some other v...
[ "func", "ListenPacket", "(", "laddr", "ma", ".", "Multiaddr", ")", "(", "PacketConn", ",", "error", ")", "{", "lnet", ",", "lnaddr", ",", "err", ":=", "DialArgs", "(", "laddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// ListenPacket announces on the local network address laddr. // The Multiaddr must be a packet driven network, like udp4 or udp6. // See Dial for the syntax of laddr.
[ "ListenPacket", "announces", "on", "the", "local", "network", "address", "laddr", ".", "The", "Multiaddr", "must", "be", "a", "packet", "driven", "network", "like", "udp4", "or", "udp6", ".", "See", "Dial", "for", "the", "syntax", "of", "laddr", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/net.go#L356-L370
141,478
multiformats/go-multiaddr-net
net.go
WrapPacketConn
func WrapPacketConn(pc net.PacketConn) (PacketConn, error) { laddr, err := FromNetAddr(pc.LocalAddr()) if err != nil { return nil, err } return &maPacketConn{ PacketConn: pc, laddr: laddr, }, nil }
go
func WrapPacketConn(pc net.PacketConn) (PacketConn, error) { laddr, err := FromNetAddr(pc.LocalAddr()) if err != nil { return nil, err } return &maPacketConn{ PacketConn: pc, laddr: laddr, }, nil }
[ "func", "WrapPacketConn", "(", "pc", "net", ".", "PacketConn", ")", "(", "PacketConn", ",", "error", ")", "{", "laddr", ",", "err", ":=", "FromNetAddr", "(", "pc", ".", "LocalAddr", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil",...
// WrapPacketConn wraps a net.PacketConn with a manet.PacketConn.
[ "WrapPacketConn", "wraps", "a", "net", ".", "PacketConn", "with", "a", "manet", ".", "PacketConn", "." ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/net.go#L373-L383
141,479
multiformats/go-multiaddr-net
net.go
InterfaceMultiaddrs
func InterfaceMultiaddrs() ([]ma.Multiaddr, error) { addrs, err := net.InterfaceAddrs() if err != nil { return nil, err } maddrs := make([]ma.Multiaddr, len(addrs)) for i, a := range addrs { maddrs[i], err = FromNetAddr(a) if err != nil { return nil, err } } return maddrs, nil }
go
func InterfaceMultiaddrs() ([]ma.Multiaddr, error) { addrs, err := net.InterfaceAddrs() if err != nil { return nil, err } maddrs := make([]ma.Multiaddr, len(addrs)) for i, a := range addrs { maddrs[i], err = FromNetAddr(a) if err != nil { return nil, err } } return maddrs, nil }
[ "func", "InterfaceMultiaddrs", "(", ")", "(", "[", "]", "ma", ".", "Multiaddr", ",", "error", ")", "{", "addrs", ",", "err", ":=", "net", ".", "InterfaceAddrs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// InterfaceMultiaddrs will return the addresses matching net.InterfaceAddrs
[ "InterfaceMultiaddrs", "will", "return", "the", "addresses", "matching", "net", ".", "InterfaceAddrs" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/net.go#L386-L400
141,480
multiformats/go-multiaddr-net
net.go
AddrMatch
func AddrMatch(match ma.Multiaddr, addrs []ma.Multiaddr) []ma.Multiaddr { // we should match transports entirely. p1s := match.Protocols() out := make([]ma.Multiaddr, 0, len(addrs)) for _, a := range addrs { p2s := a.Protocols() if len(p1s) != len(p2s) { continue } match := true for i, p2 := range p...
go
func AddrMatch(match ma.Multiaddr, addrs []ma.Multiaddr) []ma.Multiaddr { // we should match transports entirely. p1s := match.Protocols() out := make([]ma.Multiaddr, 0, len(addrs)) for _, a := range addrs { p2s := a.Protocols() if len(p1s) != len(p2s) { continue } match := true for i, p2 := range p...
[ "func", "AddrMatch", "(", "match", "ma", ".", "Multiaddr", ",", "addrs", "[", "]", "ma", ".", "Multiaddr", ")", "[", "]", "ma", ".", "Multiaddr", "{", "// we should match transports entirely.", "p1s", ":=", "match", ".", "Protocols", "(", ")", "\n\n", "out...
// AddrMatch returns the Multiaddrs that match the protocol stack on addr
[ "AddrMatch", "returns", "the", "Multiaddrs", "that", "match", "the", "protocol", "stack", "on", "addr" ]
bd61b0499a3cfc893a8eb109c5669342b1671881
https://github.com/multiformats/go-multiaddr-net/blob/bd61b0499a3cfc893a8eb109c5669342b1671881/net.go#L403-L427
141,481
lestrrat-go/jsval
enum.go
Validate
func (c *EnumConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("EnumConstraint.Validate (%s)", v).BindError(&err) defer g.End() } for _, e := range c.enums { if e == v { return nil } } return errors.New("value is not in enumeration") }
go
func (c *EnumConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("EnumConstraint.Validate (%s)", v).BindError(&err) defer g.End() } for _, e := range c.enums { if e == v { return nil } } return errors.New("value is not in enumeration") }
[ "func", "(", "c", "*", "EnumConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ",", "v", ")", ".", "BindErro...
// Validate validates the value against the list of enumerations
[ "Validate", "validates", "the", "value", "against", "the", "list", "of", "enumerations" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/enum.go#L21-L32
141,482
lestrrat-go/jsval
combinations.go
Validate
func (c *AnyConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("AnyConstraint.Validate").BindError(&err) defer g.End() } for _, celem := range c.constraints { if err := celem.Validate(v); err == nil { return nil } } return errors.New("could not validate against any ...
go
func (c *AnyConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("AnyConstraint.Validate").BindError(&err) defer g.End() } for _, celem := range c.constraints { if err := celem.Validate(v); err == nil { return nil } } return errors.New("could not validate against any ...
[ "func", "(", "c", "*", "AnyConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ")", ".", "BindError", "(", "&...
// Validate validates the value against the input value. // For AnyConstraints, it will return success the moment // one child Constraint succeeds. It will return an error // if none of the child Constraints succeeds
[ "Validate", "validates", "the", "value", "against", "the", "input", "value", ".", "For", "AnyConstraints", "it", "will", "return", "success", "the", "moment", "one", "child", "Constraint", "succeeds", ".", "It", "will", "return", "an", "error", "if", "none", ...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/combinations.go#L49-L60
141,483
lestrrat-go/jsval
combinations.go
Validate
func (c *AllConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("AllConstraint.Validate").BindError(&err) defer g.End() } for _, celem := range c.constraints { if err := celem.Validate(v); err != nil { return err } } return nil }
go
func (c *AllConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("AllConstraint.Validate").BindError(&err) defer g.End() } for _, celem := range c.constraints { if err := celem.Validate(v); err != nil { return err } } return nil }
[ "func", "(", "c", "*", "AllConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ")", ".", "BindError", "(", "&...
// Validate validates the value against the input value. // For AllConstraints, it will only return success if // all of the child Constraints succeeded.
[ "Validate", "validates", "the", "value", "against", "the", "input", "value", ".", "For", "AllConstraints", "it", "will", "only", "return", "success", "if", "all", "of", "the", "child", "Constraints", "succeeded", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/combinations.go#L82-L94
141,484
lestrrat-go/jsval
jsval.go
Validate
func (v *JSVal) Validate(x interface{}) error { name := v.Name if len(name) == 0 { return errors.Wrapf(v.root.Validate(x), "validator %p failed", v) } return errors.Wrapf(v.root.Validate(x), "validator %s failed", name) }
go
func (v *JSVal) Validate(x interface{}) error { name := v.Name if len(name) == 0 { return errors.Wrapf(v.root.Validate(x), "validator %p failed", v) } return errors.Wrapf(v.root.Validate(x), "validator %s failed", name) }
[ "func", "(", "v", "*", "JSVal", ")", "Validate", "(", "x", "interface", "{", "}", ")", "error", "{", "name", ":=", "v", ".", "Name", "\n", "if", "len", "(", "name", ")", "==", "0", "{", "return", "errors", ".", "Wrapf", "(", "v", ".", "root", ...
// Validate validates the input, and return an error // if any of the validations fail
[ "Validate", "validates", "the", "input", "and", "return", "an", "error", "if", "any", "of", "the", "validations", "fail" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/jsval.go#L22-L28
141,485
lestrrat-go/jsval
jsval.go
SetName
func (v *JSVal) SetName(s string) *JSVal { v.Name = s return v }
go
func (v *JSVal) SetName(s string) *JSVal { v.Name = s return v }
[ "func", "(", "v", "*", "JSVal", ")", "SetName", "(", "s", "string", ")", "*", "JSVal", "{", "v", ".", "Name", "=", "s", "\n", "return", "v", "\n", "}" ]
// SetName sets the name for the validator
[ "SetName", "sets", "the", "name", "for", "the", "validator" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/jsval.go#L31-L34
141,486
lestrrat-go/jsval
jsval.go
SetRoot
func (v *JSVal) SetRoot(c Constraint) *JSVal { v.root = c return v }
go
func (v *JSVal) SetRoot(c Constraint) *JSVal { v.root = c return v }
[ "func", "(", "v", "*", "JSVal", ")", "SetRoot", "(", "c", "Constraint", ")", "*", "JSVal", "{", "v", ".", "root", "=", "c", "\n", "return", "v", "\n", "}" ]
// SetRoot sets the root Constraint object.
[ "SetRoot", "sets", "the", "root", "Constraint", "object", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/jsval.go#L37-L40
141,487
lestrrat-go/jsval
jsval.go
SetConstraintMap
func (v *JSVal) SetConstraintMap(cm *ConstraintMap) *JSVal { v.ConstraintMap = cm return v }
go
func (v *JSVal) SetConstraintMap(cm *ConstraintMap) *JSVal { v.ConstraintMap = cm return v }
[ "func", "(", "v", "*", "JSVal", ")", "SetConstraintMap", "(", "cm", "*", "ConstraintMap", ")", "*", "JSVal", "{", "v", ".", "ConstraintMap", "=", "cm", "\n", "return", "v", "\n", "}" ]
// SetConstraintMap allows you to set the map that is referred to // when resolving JSON references within constraints. By setting // this to a common map, for example, you can share the same references // to save you some memory space and sanity. See an example in the // `generated_validator_test.go` file.
[ "SetConstraintMap", "allows", "you", "to", "set", "the", "map", "that", "is", "referred", "to", "when", "resolving", "JSON", "references", "within", "constraints", ".", "By", "setting", "this", "to", "a", "common", "map", "for", "example", "you", "can", "sha...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/jsval.go#L52-L55
141,488
lestrrat-go/jsval
number.go
Enum
func (nc *NumberConstraint) Enum(l ...interface{}) *NumberConstraint { if nc.enums == nil { nc.enums = Enum() } nc.enums.Enum(l...) return nc }
go
func (nc *NumberConstraint) Enum(l ...interface{}) *NumberConstraint { if nc.enums == nil { nc.enums = Enum() } nc.enums.Enum(l...) return nc }
[ "func", "(", "nc", "*", "NumberConstraint", ")", "Enum", "(", "l", "...", "interface", "{", "}", ")", "*", "NumberConstraint", "{", "if", "nc", ".", "enums", "==", "nil", "{", "nc", ".", "enums", "=", "Enum", "(", ")", "\n", "}", "\n", "nc", ".",...
// Enum specifies the values that this constraint can have
[ "Enum", "specifies", "the", "values", "that", "this", "constraint", "can", "have" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/number.go#L12-L18
141,489
lestrrat-go/jsval
number.go
Maximum
func (nc *NumberConstraint) Maximum(n float64) *NumberConstraint { nc.applyMaximum = true nc.maximum = n return nc }
go
func (nc *NumberConstraint) Maximum(n float64) *NumberConstraint { nc.applyMaximum = true nc.maximum = n return nc }
[ "func", "(", "nc", "*", "NumberConstraint", ")", "Maximum", "(", "n", "float64", ")", "*", "NumberConstraint", "{", "nc", ".", "applyMaximum", "=", "true", "\n", "nc", ".", "maximum", "=", "n", "\n", "return", "nc", "\n", "}" ]
// Maximum sepcifies the maximum value that the constraint can allow
[ "Maximum", "sepcifies", "the", "maximum", "value", "that", "the", "constraint", "can", "allow" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/number.go#L28-L32
141,490
lestrrat-go/jsval
number.go
Validate
func (nc *NumberConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.IPrintf("START NumberConstraint.Validate") defer func() { if err == nil { g.IRelease("END NumberConstraint.Validate (PASS)") } else { g.IRelease("END NumberConstraint.Validate (FAIL): %s", err) } }(...
go
func (nc *NumberConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.IPrintf("START NumberConstraint.Validate") defer func() { if err == nil { g.IRelease("END NumberConstraint.Validate (PASS)") } else { g.IRelease("END NumberConstraint.Validate (FAIL): %s", err) } }(...
[ "func", "(", "nc", "*", "NumberConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "IPrintf", "(", "\"", "\"", ")", "\n", "defer", "func",...
// Validate validates the value against this constraint
[ "Validate", "validates", "the", "value", "against", "this", "constraint" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/number.go#L65-L140
141,491
lestrrat-go/jsval
number.go
Integer
func Integer() *IntegerConstraint { c := &IntegerConstraint{} c.applyMinimum = false c.applyMaximum = false return c }
go
func Integer() *IntegerConstraint { c := &IntegerConstraint{} c.applyMinimum = false c.applyMaximum = false return c }
[ "func", "Integer", "(", ")", "*", "IntegerConstraint", "{", "c", ":=", "&", "IntegerConstraint", "{", "}", "\n", "c", ".", "applyMinimum", "=", "false", "\n", "c", ".", "applyMaximum", "=", "false", "\n", "return", "c", "\n", "}" ]
// Integer creates a new IntegerrConstraint
[ "Integer", "creates", "a", "new", "IntegerrConstraint" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/number.go#L151-L156
141,492
lestrrat-go/jsval
number.go
Maximum
func (ic *IntegerConstraint) Maximum(n float64) *IntegerConstraint { ic.applyMaximum = true ic.maximum = n return ic }
go
func (ic *IntegerConstraint) Maximum(n float64) *IntegerConstraint { ic.applyMaximum = true ic.maximum = n return ic }
[ "func", "(", "ic", "*", "IntegerConstraint", ")", "Maximum", "(", "n", "float64", ")", "*", "IntegerConstraint", "{", "ic", ".", "applyMaximum", "=", "true", "\n", "ic", ".", "maximum", "=", "n", "\n", "return", "ic", "\n", "}" ]
// Maximum sepcifies the maximum value that the constraint can allow // Maximum sepcifies the maximum value that the constraint can allow
[ "Maximum", "sepcifies", "the", "maximum", "value", "that", "the", "constraint", "can", "allow", "Maximum", "sepcifies", "the", "maximum", "value", "that", "the", "constraint", "can", "allow" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/number.go#L166-L170
141,493
lestrrat-go/jsval
string.go
Default
func (sc *StringConstraint) Default(v interface{}) *StringConstraint { sc.defaultValue.initialized = true sc.defaultValue.value = v return sc }
go
func (sc *StringConstraint) Default(v interface{}) *StringConstraint { sc.defaultValue.initialized = true sc.defaultValue.value = v return sc }
[ "func", "(", "sc", "*", "StringConstraint", ")", "Default", "(", "v", "interface", "{", "}", ")", "*", "StringConstraint", "{", "sc", ".", "defaultValue", ".", "initialized", "=", "true", "\n", "sc", ".", "defaultValue", ".", "value", "=", "v", "\n", "...
// Default sets the default value for this constraint.
[ "Default", "sets", "the", "default", "value", "for", "this", "constraint", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/string.go#L17-L21
141,494
lestrrat-go/jsval
string.go
Enum
func (sc *StringConstraint) Enum(l ...interface{}) *StringConstraint { if sc.enums == nil { sc.enums = Enum() } sc.enums.Enum(l...) return sc }
go
func (sc *StringConstraint) Enum(l ...interface{}) *StringConstraint { if sc.enums == nil { sc.enums = Enum() } sc.enums.Enum(l...) return sc }
[ "func", "(", "sc", "*", "StringConstraint", ")", "Enum", "(", "l", "...", "interface", "{", "}", ")", "*", "StringConstraint", "{", "if", "sc", ".", "enums", "==", "nil", "{", "sc", ".", "enums", "=", "Enum", "(", ")", "\n", "}", "\n", "sc", ".",...
// Enum specifies the enumeration of the possible values
[ "Enum", "specifies", "the", "enumeration", "of", "the", "possible", "values" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/string.go#L184-L190
141,495
lestrrat-go/jsval
string.go
MaxLength
func (sc *StringConstraint) MaxLength(l int) *StringConstraint { sc.maxLength = l return sc }
go
func (sc *StringConstraint) MaxLength(l int) *StringConstraint { sc.maxLength = l return sc }
[ "func", "(", "sc", "*", "StringConstraint", ")", "MaxLength", "(", "l", "int", ")", "*", "StringConstraint", "{", "sc", ".", "maxLength", "=", "l", "\n", "return", "sc", "\n", "}" ]
// MaxLength specifies the maximum length the passed value can have
[ "MaxLength", "specifies", "the", "maximum", "length", "the", "passed", "value", "can", "have" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/string.go#L193-L196
141,496
lestrrat-go/jsval
string.go
MinLength
func (sc *StringConstraint) MinLength(l int) *StringConstraint { sc.minLength = l return sc }
go
func (sc *StringConstraint) MinLength(l int) *StringConstraint { sc.minLength = l return sc }
[ "func", "(", "sc", "*", "StringConstraint", ")", "MinLength", "(", "l", "int", ")", "*", "StringConstraint", "{", "sc", ".", "minLength", "=", "l", "\n", "return", "sc", "\n", "}" ]
// MinLength specifies the minimum length the passed value must have
[ "MinLength", "specifies", "the", "minimum", "length", "the", "passed", "value", "must", "have" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/string.go#L199-L202
141,497
lestrrat-go/jsval
string.go
RegexpString
func (sc *StringConstraint) RegexpString(pat string) *StringConstraint { return sc.Regexp(regexp.MustCompile(pat)) }
go
func (sc *StringConstraint) RegexpString(pat string) *StringConstraint { return sc.Regexp(regexp.MustCompile(pat)) }
[ "func", "(", "sc", "*", "StringConstraint", ")", "RegexpString", "(", "pat", "string", ")", "*", "StringConstraint", "{", "return", "sc", ".", "Regexp", "(", "regexp", ".", "MustCompile", "(", "pat", ")", ")", "\n", "}" ]
// RegexpString is the same as Regexp method, except this one // takes a string and compiles it.
[ "RegexpString", "is", "the", "same", "as", "Regexp", "method", "except", "this", "one", "takes", "a", "string", "and", "compiles", "it", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/string.go#L206-L208
141,498
lestrrat-go/jsval
string.go
Format
func (sc *StringConstraint) Format(f string) *StringConstraint { sc.format = f return sc }
go
func (sc *StringConstraint) Format(f string) *StringConstraint { sc.format = f return sc }
[ "func", "(", "sc", "*", "StringConstraint", ")", "Format", "(", "f", "string", ")", "*", "StringConstraint", "{", "sc", ".", "format", "=", "f", "\n", "return", "sc", "\n", "}" ]
// Format specifies the format that passed value must conform to
[ "Format", "specifies", "the", "format", "that", "passed", "value", "must", "conform", "to" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/string.go#L218-L221
141,499
lestrrat-go/jsval
builder/builder.go
Build
func (b *Builder) Build(s *schema.Schema) (v *jsval.JSVal, err error) { if pdebug.Enabled { g := pdebug.IPrintf("START Builder.Build") defer func() { if err == nil { g.IRelease("END Builder.Build (OK)") } else { g.IRelease("END Builder.Build (FAIL): %s", err) } }() } if s == nil { return ni...
go
func (b *Builder) Build(s *schema.Schema) (v *jsval.JSVal, err error) { if pdebug.Enabled { g := pdebug.IPrintf("START Builder.Build") defer func() { if err == nil { g.IRelease("END Builder.Build (OK)") } else { g.IRelease("END Builder.Build (FAIL): %s", err) } }() } if s == nil { return ni...
[ "func", "(", "b", "*", "Builder", ")", "Build", "(", "s", "*", "schema", ".", "Schema", ")", "(", "v", "*", "jsval", ".", "JSVal", ",", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "IPrintf", "(", "\"...
// Build creates a new validator from the specified schema
[ "Build", "creates", "a", "new", "validator", "from", "the", "specified", "schema" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/builder/builder.go#L34-L51