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
137,800
masci/flickr
upload.go
NewUploadParams
func NewUploadParams() *UploadParams { ret := &UploadParams{} ret.ContentType = 1 // photo ret.Hidden = 2 // hidden from public searchesi ret.SafetyLevel = 1 // safe return ret }
go
func NewUploadParams() *UploadParams { ret := &UploadParams{} ret.ContentType = 1 // photo ret.Hidden = 2 // hidden from public searchesi ret.SafetyLevel = 1 // safe return ret }
[ "func", "NewUploadParams", "(", ")", "*", "UploadParams", "{", "ret", ":=", "&", "UploadParams", "{", "}", "\n", "ret", ".", "ContentType", "=", "1", "// photo", "\n", "ret", ".", "Hidden", "=", "2", "// hidden from public searchesi", "\n", "ret", ".", "Sa...
// NewUploadParams provides meaningful default values
[ "NewUploadParams", "provides", "meaningful", "default", "values" ]
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/upload.go#L74-L80
137,801
masci/flickr
upload.go
fillArgsWithParams
func fillArgsWithParams(client *FlickrClient, params *UploadParams) { if params.Title != "" { client.Args.Set("title", params.Title) } if params.Description != "" { client.Args.Set("description", params.Description) } if len(params.Tags) > 0 { client.Args.Set("tags", strings.Join(params.Tags, " ")) } va...
go
func fillArgsWithParams(client *FlickrClient, params *UploadParams) { if params.Title != "" { client.Args.Set("title", params.Title) } if params.Description != "" { client.Args.Set("description", params.Description) } if len(params.Tags) > 0 { client.Args.Set("tags", strings.Join(params.Tags, " ")) } va...
[ "func", "fillArgsWithParams", "(", "client", "*", "FlickrClient", ",", "params", "*", "UploadParams", ")", "{", "if", "params", ".", "Title", "!=", "\"", "\"", "{", "client", ".", "Args", ".", "Set", "(", "\"", "\"", ",", "params", ".", "Title", ")", ...
// Set client query arguments based on the contents of the UploadParams struct
[ "Set", "client", "query", "arguments", "based", "on", "the", "contents", "of", "the", "UploadParams", "struct" ]
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/upload.go#L89-L123
137,802
masci/flickr
upload.go
UploadFile
func UploadFile(client *FlickrClient, path string, optionalParams *UploadParams) (*UploadResponse, error) { file, err := os.Open(path) if err != nil { return nil, err } defer file.Close() return UploadReader(client, file, file.Name(), optionalParams) }
go
func UploadFile(client *FlickrClient, path string, optionalParams *UploadParams) (*UploadResponse, error) { file, err := os.Open(path) if err != nil { return nil, err } defer file.Close() return UploadReader(client, file, file.Name(), optionalParams) }
[ "func", "UploadFile", "(", "client", "*", "FlickrClient", ",", "path", "string", ",", "optionalParams", "*", "UploadParams", ")", "(", "*", "UploadResponse", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "...
// UploadFile performs a file upload using the Flickr API. If optionalParams is nil, // no parameters will be added to the request and Flickr will set User's // default preferences. // This call must be signed with write permissions
[ "UploadFile", "performs", "a", "file", "upload", "using", "the", "Flickr", "API", ".", "If", "optionalParams", "is", "nil", "no", "parameters", "will", "be", "added", "to", "the", "request", "and", "Flickr", "will", "set", "User", "s", "default", "preference...
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/upload.go#L129-L137
137,803
masci/flickr
upload.go
UploadReader
func UploadReader(client *FlickrClient, photoReader io.Reader, name string, optionalParams *UploadParams) (*UploadResponse, error) { return UploadReaderWithClient(client, photoReader, name, optionalParams, nil) }
go
func UploadReader(client *FlickrClient, photoReader io.Reader, name string, optionalParams *UploadParams) (*UploadResponse, error) { return UploadReaderWithClient(client, photoReader, name, optionalParams, nil) }
[ "func", "UploadReader", "(", "client", "*", "FlickrClient", ",", "photoReader", "io", ".", "Reader", ",", "name", "string", ",", "optionalParams", "*", "UploadParams", ")", "(", "*", "UploadResponse", ",", "error", ")", "{", "return", "UploadReaderWithClient", ...
// UploadReader does same as UploadFile but the photo file is passed as an io.Reader instead of a file path
[ "UploadReader", "does", "same", "as", "UploadFile", "but", "the", "photo", "file", "is", "passed", "as", "an", "io", ".", "Reader", "instead", "of", "a", "file", "path" ]
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/upload.go#L140-L142
137,804
masci/flickr
upload.go
UploadReaderWithClient
func UploadReaderWithClient(client *FlickrClient, photoReader io.Reader, name string, optionalParams *UploadParams, httpClient *http.Client) (*UploadResponse, error) { client.Init() client.EndpointUrl = UPLOAD_ENDPOINT client.HTTPVerb = "POST" if optionalParams != nil { fillArgsWithParams(client, optionalParams)...
go
func UploadReaderWithClient(client *FlickrClient, photoReader io.Reader, name string, optionalParams *UploadParams, httpClient *http.Client) (*UploadResponse, error) { client.Init() client.EndpointUrl = UPLOAD_ENDPOINT client.HTTPVerb = "POST" if optionalParams != nil { fillArgsWithParams(client, optionalParams)...
[ "func", "UploadReaderWithClient", "(", "client", "*", "FlickrClient", ",", "photoReader", "io", ".", "Reader", ",", "name", "string", ",", "optionalParams", "*", "UploadParams", ",", "httpClient", "*", "http", ".", "Client", ")", "(", "*", "UploadResponse", ",...
// UploadReaderWithClient does same as UploadReader but allows passing a custom httpClient
[ "UploadReaderWithClient", "does", "same", "as", "UploadReader", "but", "allows", "passing", "a", "custom", "httpClient" ]
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/upload.go#L145-L195
137,805
masci/flickr
flickr.go
DoGet
func DoGet(client *FlickrClient, r FlickrResponse) error { res, err := client.HTTPClient.Get(client.GetUrl()) if err != nil { return err } return parseApiResponse(res, r) }
go
func DoGet(client *FlickrClient, r FlickrResponse) error { res, err := client.HTTPClient.Get(client.GetUrl()) if err != nil { return err } return parseApiResponse(res, r) }
[ "func", "DoGet", "(", "client", "*", "FlickrClient", ",", "r", "FlickrResponse", ")", "error", "{", "res", ",", "err", ":=", "client", ".", "HTTPClient", ".", "Get", "(", "client", ".", "GetUrl", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Perform a GET request to the Flickr API with the configured FlickrClient passed as first // parameter. Results will be unmarshalled to fill in a FlickrResponse struct passed as // second parameter.
[ "Perform", "a", "GET", "request", "to", "the", "Flickr", "API", "with", "the", "configured", "FlickrClient", "passed", "as", "first", "parameter", ".", "Results", "will", "be", "unmarshalled", "to", "fill", "in", "a", "FlickrResponse", "struct", "passed", "as"...
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/flickr.go#L20-L27
137,806
masci/flickr
flickr.go
DoPostBody
func DoPostBody(client *FlickrClient, body *bytes.Buffer, bodyType string, r FlickrResponse) error { res, err := client.HTTPClient.Post(client.EndpointUrl, bodyType, body) if err != nil { return err } return parseApiResponse(res, r) }
go
func DoPostBody(client *FlickrClient, body *bytes.Buffer, bodyType string, r FlickrResponse) error { res, err := client.HTTPClient.Post(client.EndpointUrl, bodyType, body) if err != nil { return err } return parseApiResponse(res, r) }
[ "func", "DoPostBody", "(", "client", "*", "FlickrClient", ",", "body", "*", "bytes", ".", "Buffer", ",", "bodyType", "string", ",", "r", "FlickrResponse", ")", "error", "{", "res", ",", "err", ":=", "client", ".", "HTTPClient", ".", "Post", "(", "client"...
// Perform a POST request to the Flickr API with the configured FlickrClient, the // request body and the body content type. Results will be unmarshalled in a FlickrResponse // struct.
[ "Perform", "a", "POST", "request", "to", "the", "Flickr", "API", "with", "the", "configured", "FlickrClient", "the", "request", "body", "and", "the", "body", "content", "type", ".", "Results", "will", "be", "unmarshalled", "in", "a", "FlickrResponse", "struct"...
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/flickr.go#L32-L39
137,807
masci/flickr
flickr.go
DoPost
func DoPost(client *FlickrClient, r FlickrResponse) error { // instance an empty request body body := &bytes.Buffer{} // multipart writer to fill the body writer := multipart.NewWriter(body) // dump params for key, val := range client.Args { _ = writer.WriteField(key, val[0]) } err := writer.Close() if err !...
go
func DoPost(client *FlickrClient, r FlickrResponse) error { // instance an empty request body body := &bytes.Buffer{} // multipart writer to fill the body writer := multipart.NewWriter(body) // dump params for key, val := range client.Args { _ = writer.WriteField(key, val[0]) } err := writer.Close() if err !...
[ "func", "DoPost", "(", "client", "*", "FlickrClient", ",", "r", "FlickrResponse", ")", "error", "{", "// instance an empty request body", "body", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "// multipart writer to fill the body", "writer", ":=", "multipart", ...
// Perform a POST request to the Flickr API with the configured FlickrClient, // dumping client Args into the request Body.
[ "Perform", "a", "POST", "request", "to", "the", "Flickr", "API", "with", "the", "configured", "FlickrClient", "dumping", "client", "Args", "into", "the", "request", "Body", "." ]
3cc496dc15cd2a9460265656665423635e0a4a0b
https://github.com/masci/flickr/blob/3cc496dc15cd2a9460265656665423635e0a4a0b/flickr.go#L43-L60
137,808
xiaonanln/goTimer
timer.go
AddTimer
func AddTimer(d time.Duration, callback CallbackFunc) *Timer { if d < MIN_TIMER_INTERVAL { d = MIN_TIMER_INTERVAL } t := &Timer{ fireTime: time.Now().Add(d), interval: d, callback: callback, repeat: true, } timerHeapLock.Lock() t.addseq = nextAddSeq // set addseq when locked nextAddSeq += 1 heap.P...
go
func AddTimer(d time.Duration, callback CallbackFunc) *Timer { if d < MIN_TIMER_INTERVAL { d = MIN_TIMER_INTERVAL } t := &Timer{ fireTime: time.Now().Add(d), interval: d, callback: callback, repeat: true, } timerHeapLock.Lock() t.addseq = nextAddSeq // set addseq when locked nextAddSeq += 1 heap.P...
[ "func", "AddTimer", "(", "d", "time", ".", "Duration", ",", "callback", "CallbackFunc", ")", "*", "Timer", "{", "if", "d", "<", "MIN_TIMER_INTERVAL", "{", "d", "=", "MIN_TIMER_INTERVAL", "\n", "}", "\n\n", "t", ":=", "&", "Timer", "{", "fireTime", ":", ...
// Add a timer which calls callback periodly
[ "Add", "a", "timer", "which", "calls", "callback", "periodly" ]
2ebf09cd62e91c7cab7358a259ec2d8c34a2f711
https://github.com/xiaonanln/goTimer/blob/2ebf09cd62e91c7cab7358a259ec2d8c34a2f711/timer.go#L105-L123
137,809
xiaonanln/goTimer
timer.go
Tick
func Tick() { now := time.Now() timerHeapLock.Lock() for { if timerHeap.Len() <= 0 { break } nextFireTime := timerHeap.timers[0].fireTime //fmt.Printf(">>> nextFireTime %s, now is %s\n", nextFireTime, now) if nextFireTime.After(now) { break } t := heap.Pop(&timerHeap).(*Timer) callback := t...
go
func Tick() { now := time.Now() timerHeapLock.Lock() for { if timerHeap.Len() <= 0 { break } nextFireTime := timerHeap.timers[0].fireTime //fmt.Printf(">>> nextFireTime %s, now is %s\n", nextFireTime, now) if nextFireTime.After(now) { break } t := heap.Pop(&timerHeap).(*Timer) callback := t...
[ "func", "Tick", "(", ")", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "timerHeapLock", ".", "Lock", "(", ")", "\n\n", "for", "{", "if", "timerHeap", ".", "Len", "(", ")", "<=", "0", "{", "break", "\n", "}", "\n\n", "nextFireTime", ":=",...
// Tick once for timers
[ "Tick", "once", "for", "timers" ]
2ebf09cd62e91c7cab7358a259ec2d8c34a2f711
https://github.com/xiaonanln/goTimer/blob/2ebf09cd62e91c7cab7358a259ec2d8c34a2f711/timer.go#L126-L168
137,810
h2so5/utp
ucat/ucat.go
Listen
func Listen(localAddr string) error { laddr, err := utp.ResolveAddr("utp", localAddr) if err != nil { return fmt.Errorf("failed to resolve address %s", localAddr) } l, err := utp.Listen("utp", laddr) if err != nil { return err } log("listening at %s", l.Addr()) c, err := l.Accept() if err != nil { retur...
go
func Listen(localAddr string) error { laddr, err := utp.ResolveAddr("utp", localAddr) if err != nil { return fmt.Errorf("failed to resolve address %s", localAddr) } l, err := utp.Listen("utp", laddr) if err != nil { return err } log("listening at %s", l.Addr()) c, err := l.Accept() if err != nil { retur...
[ "func", "Listen", "(", "localAddr", "string", ")", "error", "{", "laddr", ",", "err", ":=", "utp", ".", "ResolveAddr", "(", "\"", "\"", ",", "localAddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ","...
// Listen listens and accepts one incoming uTP connection on a given port, // and pipes all incoming data to os.Stdout.
[ "Listen", "listens", "and", "accepts", "one", "incoming", "uTP", "connection", "on", "a", "given", "port", "and", "pipes", "all", "incoming", "data", "to", "os", ".", "Stdout", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/ucat/ucat.go#L113-L136
137,811
chmduquesne/rollinghash
roll/main.go
sum64
func sum64(h hash.Hash) (res uint64) { buf := make([]byte, 0, 8) s := h.Sum(buf) for _, b := range s { res <<= 8 res |= uint64(b) } return }
go
func sum64(h hash.Hash) (res uint64) { buf := make([]byte, 0, 8) s := h.Sum(buf) for _, b := range s { res <<= 8 res |= uint64(b) } return }
[ "func", "sum64", "(", "h", "hash", ".", "Hash", ")", "(", "res", "uint64", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "8", ")", "\n", "s", ":=", "h", ".", "Sum", "(", "buf", ")", "\n", "for", "_", ",", "b", ":=",...
// Gets the hash sum as a uint64
[ "Gets", "the", "hash", "sum", "as", "a", "uint64" ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/roll/main.go#L39-L47
137,812
h2so5/utp
conn.go
RemoteAddr
func (c *Conn) RemoteAddr() net.Addr { if !c.ok() { return nil } return c.raddr }
go
func (c *Conn) RemoteAddr() net.Addr { if !c.ok() { return nil } return c.raddr }
[ "func", "(", "c", "*", "Conn", ")", "RemoteAddr", "(", ")", "net", ".", "Addr", "{", "if", "!", "c", ".", "ok", "(", ")", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "raddr", "\n", "}" ]
// RemoteAddr returns the remote network address.
[ "RemoteAddr", "returns", "the", "remote", "network", "address", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/conn.go#L127-L132
137,813
h2so5/utp
conn.go
Read
func (c *Conn) Read(b []byte) (int, error) { if !c.ok() { return 0, syscall.EINVAL } if !c.isOpen() { return 0, &net.OpError{ Op: "read", Net: c.LocalAddr().Network(), Addr: c.LocalAddr(), Err: errClosing, } } s := c.readbuf.space() c.deadlineMutex.RLock() d := timeToDeadline(c.rdeadline) ...
go
func (c *Conn) Read(b []byte) (int, error) { if !c.ok() { return 0, syscall.EINVAL } if !c.isOpen() { return 0, &net.OpError{ Op: "read", Net: c.LocalAddr().Network(), Addr: c.LocalAddr(), Err: errClosing, } } s := c.readbuf.space() c.deadlineMutex.RLock() d := timeToDeadline(c.rdeadline) ...
[ "func", "(", "c", "*", "Conn", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "!", "c", ".", "ok", "(", ")", "{", "return", "0", ",", "syscall", ".", "EINVAL", "\n", "}", "\n", "if", "!", "c", ".",...
// Read implements the Conn Read method.
[ "Read", "implements", "the", "Conn", "Read", "method", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/conn.go#L135-L159
137,814
h2so5/utp
conn.go
Write
func (c *Conn) Write(b []byte) (int, error) { if !c.ok() { return 0, syscall.EINVAL } if !c.isOpen() { return 0, &net.OpError{ Op: "write", Net: c.LocalAddr().Network(), Addr: c.LocalAddr(), Err: errClosing, } } c.deadlineMutex.RLock() d := timeToDeadline(c.wdeadline) c.deadlineMutex.RUnloc...
go
func (c *Conn) Write(b []byte) (int, error) { if !c.ok() { return 0, syscall.EINVAL } if !c.isOpen() { return 0, &net.OpError{ Op: "write", Net: c.LocalAddr().Network(), Addr: c.LocalAddr(), Err: errClosing, } } c.deadlineMutex.RLock() d := timeToDeadline(c.wdeadline) c.deadlineMutex.RUnloc...
[ "func", "(", "c", "*", "Conn", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "!", "c", ".", "ok", "(", ")", "{", "return", "0", ",", "syscall", ".", "EINVAL", "\n", "}", "\n", "if", "!", "c", "."...
// Write implements the Conn Write method.
[ "Write", "implements", "the", "Conn", "Write", "method", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/conn.go#L173-L189
137,815
h2so5/utp
conn.go
SetDeadline
func (c *Conn) SetDeadline(t time.Time) error { if !c.ok() { return syscall.EINVAL } err := c.SetReadDeadline(t) if err != nil { return err } return c.SetWriteDeadline(t) }
go
func (c *Conn) SetDeadline(t time.Time) error { if !c.ok() { return syscall.EINVAL } err := c.SetReadDeadline(t) if err != nil { return err } return c.SetWriteDeadline(t) }
[ "func", "(", "c", "*", "Conn", ")", "SetDeadline", "(", "t", "time", ".", "Time", ")", "error", "{", "if", "!", "c", ".", "ok", "(", ")", "{", "return", "syscall", ".", "EINVAL", "\n", "}", "\n", "err", ":=", "c", ".", "SetReadDeadline", "(", "...
// SetDeadline implements the Conn SetDeadline method.
[ "SetDeadline", "implements", "the", "Conn", "SetDeadline", "method", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/conn.go#L192-L201
137,816
h2so5/utp
conn.go
SetKeepAlive
func (c *Conn) SetKeepAlive(d time.Duration) error { if !c.ok() { return syscall.EINVAL } if !c.isOpen() { return errClosing } c.keepalivech <- d return nil }
go
func (c *Conn) SetKeepAlive(d time.Duration) error { if !c.ok() { return syscall.EINVAL } if !c.isOpen() { return errClosing } c.keepalivech <- d return nil }
[ "func", "(", "c", "*", "Conn", ")", "SetKeepAlive", "(", "d", "time", ".", "Duration", ")", "error", "{", "if", "!", "c", ".", "ok", "(", ")", "{", "return", "syscall", ".", "EINVAL", "\n", "}", "\n", "if", "!", "c", ".", "isOpen", "(", ")", ...
// SetKeepAlive sets the keepalive interval associated with the connection.
[ "SetKeepAlive", "sets", "the", "keepalive", "interval", "associated", "with", "the", "connection", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/conn.go#L226-L235
137,817
h2so5/utp
buffer.go
all
func (b *packetBuffer) all() []*packet { var a []*packet for p := b.root; p != nil; p = p.next { if p.p != nil { a = append(a, p.p) } } return a }
go
func (b *packetBuffer) all() []*packet { var a []*packet for p := b.root; p != nil; p = p.next { if p.p != nil { a = append(a, p.p) } } return a }
[ "func", "(", "b", "*", "packetBuffer", ")", "all", "(", ")", "[", "]", "*", "packet", "{", "var", "a", "[", "]", "*", "packet", "\n", "for", "p", ":=", "b", ".", "root", ";", "p", "!=", "nil", ";", "p", "=", "p", ".", "next", "{", "if", "...
// test use only
[ "test", "use", "only" ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/buffer.go#L124-L132
137,818
chmduquesne/rollinghash
rabinkarp64/polynomials.go
Deg
func (x Pol) Deg() int { // the degree of 0 is -1 if x == 0 { return -1 } // see https://graphics.stanford.edu/~seander/bithacks.html#IntegerLog r := 0 if uint64(x)&0xffffffff00000000 > 0 { x >>= 32 r |= 32 } if uint64(x)&0xffff0000 > 0 { x >>= 16 r |= 16 } if uint64(x)&0xff00 > 0 { x >>= 8 ...
go
func (x Pol) Deg() int { // the degree of 0 is -1 if x == 0 { return -1 } // see https://graphics.stanford.edu/~seander/bithacks.html#IntegerLog r := 0 if uint64(x)&0xffffffff00000000 > 0 { x >>= 32 r |= 32 } if uint64(x)&0xffff0000 > 0 { x >>= 16 r |= 16 } if uint64(x)&0xff00 > 0 { x >>= 8 ...
[ "func", "(", "x", "Pol", ")", "Deg", "(", ")", "int", "{", "// the degree of 0 is -1", "if", "x", "==", "0", "{", "return", "-", "1", "\n", "}", "\n\n", "// see https://graphics.stanford.edu/~seander/bithacks.html#IntegerLog", "r", ":=", "0", "\n", "if", "uint...
// Deg returns the degree of the polynomial x. If x is zero, -1 is returned.
[ "Deg", "returns", "the", "degree", "of", "the", "polynomial", "x", ".", "If", "x", "is", "zero", "-", "1", "is", "returned", "." ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/rabinkarp64/polynomials.go#L90-L130
137,819
chmduquesne/rollinghash
buzhash32/buzhash32.go
GenerateHashes
func GenerateHashes(seed int64) (res [256]uint32) { random := rand.New(rand.NewSource(seed)) used := make(map[uint32]bool) for i, _ := range res { x := uint32(random.Int63()) for used[x] { x = uint32(random.Int63()) } used[x] = true res[i] = x } return res }
go
func GenerateHashes(seed int64) (res [256]uint32) { random := rand.New(rand.NewSource(seed)) used := make(map[uint32]bool) for i, _ := range res { x := uint32(random.Int63()) for used[x] { x = uint32(random.Int63()) } used[x] = true res[i] = x } return res }
[ "func", "GenerateHashes", "(", "seed", "int64", ")", "(", "res", "[", "256", "]", "uint32", ")", "{", "random", ":=", "rand", ".", "New", "(", "rand", ".", "NewSource", "(", "seed", ")", ")", "\n", "used", ":=", "make", "(", "map", "[", "uint32", ...
// GenerateHashes generates a list of hashes to use with buzhash
[ "GenerateHashes", "generates", "a", "list", "of", "hashes", "to", "use", "with", "buzhash" ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/buzhash32/buzhash32.go#L44-L56
137,820
chmduquesne/rollinghash
buzhash32/buzhash32.go
NewFromUint32Array
func NewFromUint32Array(b [256]uint32) *Buzhash32 { return &Buzhash32{ sum: 0, window: make([]byte, 0, rollinghash.DefaultWindowCap), oldest: 0, bytehash: b, } }
go
func NewFromUint32Array(b [256]uint32) *Buzhash32 { return &Buzhash32{ sum: 0, window: make([]byte, 0, rollinghash.DefaultWindowCap), oldest: 0, bytehash: b, } }
[ "func", "NewFromUint32Array", "(", "b", "[", "256", "]", "uint32", ")", "*", "Buzhash32", "{", "return", "&", "Buzhash32", "{", "sum", ":", "0", ",", "window", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "rollinghash", ".", "DefaultWindowCap", ...
// NewFromUint32Array returns a buzhash based on the provided table uint32 values.
[ "NewFromUint32Array", "returns", "a", "buzhash", "based", "on", "the", "provided", "table", "uint32", "values", "." ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/buzhash32/buzhash32.go#L65-L72
137,821
h2so5/utp
listener.go
Listen
func Listen(n string, laddr *Addr) (*Listener, error) { conn, err := newBaseConn(n, laddr) if err != nil { return nil, err } l := &Listener{ RawConn: conn, conn: conn, } conn.Register(-1, nil) return l, nil }
go
func Listen(n string, laddr *Addr) (*Listener, error) { conn, err := newBaseConn(n, laddr) if err != nil { return nil, err } l := &Listener{ RawConn: conn, conn: conn, } conn.Register(-1, nil) return l, nil }
[ "func", "Listen", "(", "n", "string", ",", "laddr", "*", "Addr", ")", "(", "*", "Listener", ",", "error", ")", "{", "conn", ",", "err", ":=", "newBaseConn", "(", "n", ",", "laddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// Listen announces on the UTP address laddr and returns a UTP // listener. Net must be "utp", "utp4", or "utp6". If laddr has a // port of 0, ListenUTP will choose an available port. The caller can // use the Addr method of Listener to retrieve the chosen address.
[ "Listen", "announces", "on", "the", "UTP", "address", "laddr", "and", "returns", "a", "UTP", "listener", ".", "Net", "must", "be", "utp", "utp4", "or", "utp6", ".", "If", "laddr", "has", "a", "port", "of", "0", "ListenUTP", "will", "choose", "an", "ava...
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/listener.go#L32-L43
137,822
h2so5/utp
listener.go
AcceptUTP
func (l *Listener) AcceptUTP() (*Conn, error) { if !l.ok() { return nil, syscall.EINVAL } if !l.isOpen() { return nil, &net.OpError{ Op: "accept", Net: l.conn.LocalAddr().Network(), Addr: l.conn.LocalAddr(), Err: errClosing, } } l.deadlineMutex.RLock() d := timeToDeadline(l.deadline) l.dead...
go
func (l *Listener) AcceptUTP() (*Conn, error) { if !l.ok() { return nil, syscall.EINVAL } if !l.isOpen() { return nil, &net.OpError{ Op: "accept", Net: l.conn.LocalAddr().Network(), Addr: l.conn.LocalAddr(), Err: errClosing, } } l.deadlineMutex.RLock() d := timeToDeadline(l.deadline) l.dead...
[ "func", "(", "l", "*", "Listener", ")", "AcceptUTP", "(", ")", "(", "*", "Conn", ",", "error", ")", "{", "if", "!", "l", ".", "ok", "(", ")", "{", "return", "nil", ",", "syscall", ".", "EINVAL", "\n", "}", "\n", "if", "!", "l", ".", "isOpen",...
// AcceptUTP accepts the next incoming call and returns the new // connection.
[ "AcceptUTP", "accepts", "the", "next", "incoming", "call", "and", "returns", "the", "new", "connection", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/listener.go#L53-L97
137,823
h2so5/utp
listener.go
Close
func (l *Listener) Close() error { if !l.ok() { return syscall.EINVAL } if !l.close() { return &net.OpError{ Op: "close", Net: l.conn.LocalAddr().Network(), Addr: l.conn.LocalAddr(), Err: errClosing, } } return nil }
go
func (l *Listener) Close() error { if !l.ok() { return syscall.EINVAL } if !l.close() { return &net.OpError{ Op: "close", Net: l.conn.LocalAddr().Network(), Addr: l.conn.LocalAddr(), Err: errClosing, } } return nil }
[ "func", "(", "l", "*", "Listener", ")", "Close", "(", ")", "error", "{", "if", "!", "l", ".", "ok", "(", ")", "{", "return", "syscall", ".", "EINVAL", "\n", "}", "\n", "if", "!", "l", ".", "close", "(", ")", "{", "return", "&", "net", ".", ...
// Close stops listening on the UTP address. // Already Accepted connections are not closed.
[ "Close", "stops", "listening", "on", "the", "UTP", "address", ".", "Already", "Accepted", "connections", "are", "not", "closed", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/listener.go#L109-L122
137,824
chmduquesne/rollinghash
adler32/adler32.go
Reset
func (d *Adler32) Reset() { d.window = d.window[:0] // Reset the size but don't reallocate d.oldest = 0 d.a = 1 d.b = 0 d.n = 0 d.vanilla.Reset() }
go
func (d *Adler32) Reset() { d.window = d.window[:0] // Reset the size but don't reallocate d.oldest = 0 d.a = 1 d.b = 0 d.n = 0 d.vanilla.Reset() }
[ "func", "(", "d", "*", "Adler32", ")", "Reset", "(", ")", "{", "d", ".", "window", "=", "d", ".", "window", "[", ":", "0", "]", "// Reset the size but don't reallocate", "\n", "d", ".", "oldest", "=", "0", "\n", "d", ".", "a", "=", "1", "\n", "d"...
// Reset resets the digest to its initial state.
[ "Reset", "resets", "the", "digest", "to", "its", "initial", "state", "." ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/adler32/adler32.go#L32-L39
137,825
chmduquesne/rollinghash
adler32/adler32.go
New
func New() *Adler32 { return &Adler32{ a: 1, b: 0, n: 0, window: make([]byte, 0, rollinghash.DefaultWindowCap), oldest: 0, vanilla: vanilla.New(), } }
go
func New() *Adler32 { return &Adler32{ a: 1, b: 0, n: 0, window: make([]byte, 0, rollinghash.DefaultWindowCap), oldest: 0, vanilla: vanilla.New(), } }
[ "func", "New", "(", ")", "*", "Adler32", "{", "return", "&", "Adler32", "{", "a", ":", "1", ",", "b", ":", "0", ",", "n", ":", "0", ",", "window", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "rollinghash", ".", "DefaultWindowCap", ")", ...
// New returns a new Adler32 digest
[ "New", "returns", "a", "new", "Adler32", "digest" ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/adler32/adler32.go#L42-L51
137,826
h2so5/utp
dial.go
DialUTP
func DialUTP(n string, laddr, raddr *Addr) (*Conn, error) { return DialUTPTimeout(n, laddr, raddr, 0) }
go
func DialUTP(n string, laddr, raddr *Addr) (*Conn, error) { return DialUTPTimeout(n, laddr, raddr, 0) }
[ "func", "DialUTP", "(", "n", "string", ",", "laddr", ",", "raddr", "*", "Addr", ")", "(", "*", "Conn", ",", "error", ")", "{", "return", "DialUTPTimeout", "(", "n", ",", "laddr", ",", "raddr", ",", "0", ")", "\n", "}" ]
// DialUTP connects to the remote address raddr on the network net, // which must be "utp", "utp4", or "utp6". If laddr is not nil, it is // used as the local address for the connection.
[ "DialUTP", "connects", "to", "the", "remote", "address", "raddr", "on", "the", "network", "net", "which", "must", "be", "utp", "utp4", "or", "utp6", ".", "If", "laddr", "is", "not", "nil", "it", "is", "used", "as", "the", "local", "address", "for", "th...
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/dial.go#L14-L16
137,827
h2so5/utp
dial.go
DialUTPTimeout
func DialUTPTimeout(n string, laddr, raddr *Addr, timeout time.Duration) (*Conn, error) { conn, err := getSharedBaseConn(n, laddr) if err != nil { return nil, err } id := uint16(rand.Intn(math.MaxUint16)) c := newConn() c.conn = conn c.raddr = raddr.Addr c.rid = id c.sid = id + 1 c.seq = 1 c.state = state...
go
func DialUTPTimeout(n string, laddr, raddr *Addr, timeout time.Duration) (*Conn, error) { conn, err := getSharedBaseConn(n, laddr) if err != nil { return nil, err } id := uint16(rand.Intn(math.MaxUint16)) c := newConn() c.conn = conn c.raddr = raddr.Addr c.rid = id c.sid = id + 1 c.seq = 1 c.state = state...
[ "func", "DialUTPTimeout", "(", "n", "string", ",", "laddr", ",", "raddr", "*", "Addr", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "getSharedBaseConn", "(", "n", ",", "laddr", ")",...
// DialUTPTimeout acts like Dial but takes a timeout. // The timeout includes name resolution, if required.
[ "DialUTPTimeout", "acts", "like", "Dial", "but", "takes", "a", "timeout", ".", "The", "timeout", "includes", "name", "resolution", "if", "required", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/dial.go#L20-L57
137,828
h2so5/utp
dial.go
Dial
func (d *Dialer) Dial(n, addr string) (*Conn, error) { raddr, err := ResolveAddr(n, addr) if err != nil { return nil, err } var laddr *Addr if d.LocalAddr != nil { var ok bool laddr, ok = d.LocalAddr.(*Addr) if !ok { return nil, errors.New("Dialer.LocalAddr is not a Addr") } } return DialUTPTimeou...
go
func (d *Dialer) Dial(n, addr string) (*Conn, error) { raddr, err := ResolveAddr(n, addr) if err != nil { return nil, err } var laddr *Addr if d.LocalAddr != nil { var ok bool laddr, ok = d.LocalAddr.(*Addr) if !ok { return nil, errors.New("Dialer.LocalAddr is not a Addr") } } return DialUTPTimeou...
[ "func", "(", "d", "*", "Dialer", ")", "Dial", "(", "n", ",", "addr", "string", ")", "(", "*", "Conn", ",", "error", ")", "{", "raddr", ",", "err", ":=", "ResolveAddr", "(", "n", ",", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Dial connects to the address on the named network. // // See func Dial for a description of the network and address parameters.
[ "Dial", "connects", "to", "the", "address", "on", "the", "named", "network", ".", "See", "func", "Dial", "for", "a", "description", "of", "the", "network", "and", "address", "parameters", "." ]
6ca83358f5c331028feb9b97c445e9c7354967b0
https://github.com/h2so5/utp/blob/6ca83358f5c331028feb9b97c445e9c7354967b0/dial.go#L86-L102
137,829
chmduquesne/rollinghash
buzhash64/buzhash64.go
NewFromUint64Array
func NewFromUint64Array(b [256]uint64) *Buzhash64 { return &Buzhash64{ sum: 0, window: make([]byte, 0, rollinghash.DefaultWindowCap), oldest: 0, bytehash: b, } }
go
func NewFromUint64Array(b [256]uint64) *Buzhash64 { return &Buzhash64{ sum: 0, window: make([]byte, 0, rollinghash.DefaultWindowCap), oldest: 0, bytehash: b, } }
[ "func", "NewFromUint64Array", "(", "b", "[", "256", "]", "uint64", ")", "*", "Buzhash64", "{", "return", "&", "Buzhash64", "{", "sum", ":", "0", ",", "window", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "rollinghash", ".", "DefaultWindowCap", ...
// NewFromUint64Array returns a buzhash based on the provided table uint64 values.
[ "NewFromUint64Array", "returns", "a", "buzhash", "based", "on", "the", "provided", "table", "uint64", "values", "." ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/buzhash64/buzhash64.go#L65-L72
137,830
chmduquesne/rollinghash
rabinkarp64/rabinkarp64.go
New
func New() *RabinKarp64 { p, err := RandomPolynomial(1) if err != nil { panic(err) } return NewFromPol(p) }
go
func New() *RabinKarp64 { p, err := RandomPolynomial(1) if err != nil { panic(err) } return NewFromPol(p) }
[ "func", "New", "(", ")", "*", "RabinKarp64", "{", "p", ",", "err", ":=", "RandomPolynomial", "(", "1", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "NewFromPol", "(", "p", ")", "\n", "}" ]
// New returns a RabinKarp64 digest from the default polynomial obtained // when using RandomPolynomial with the seed 1.
[ "New", "returns", "a", "RabinKarp64", "digest", "from", "the", "default", "polynomial", "obtained", "when", "using", "RandomPolynomial", "with", "the", "seed", "1", "." ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/rabinkarp64/rabinkarp64.go#L154-L160
137,831
chmduquesne/rollinghash
rabinkarp64/rabinkarp64.go
Reset
func (d *RabinKarp64) Reset() { d.tables = nil d.value = 0 d.window = d.window[:0] d.oldest = 0 d.updateTables() }
go
func (d *RabinKarp64) Reset() { d.tables = nil d.value = 0 d.window = d.window[:0] d.oldest = 0 d.updateTables() }
[ "func", "(", "d", "*", "RabinKarp64", ")", "Reset", "(", ")", "{", "d", ".", "tables", "=", "nil", "\n", "d", ".", "value", "=", "0", "\n", "d", ".", "window", "=", "d", ".", "window", "[", ":", "0", "]", "\n", "d", ".", "oldest", "=", "0",...
// Reset resets the running hash to its initial state
[ "Reset", "resets", "the", "running", "hash", "to", "its", "initial", "state" ]
a60f8e7142b536ea61bb5d84014171189eeaaa81
https://github.com/chmduquesne/rollinghash/blob/a60f8e7142b536ea61bb5d84014171189eeaaa81/rabinkarp64/rabinkarp64.go#L163-L169
137,832
BPing/aliyun-live-go-sdk
util/signature.go
CreateSignatureForStreamUrlWithA
func CreateSignatureForStreamUrlWithA(uri, rand, uid, privateKey string, timeout time.Duration) (authKey string, timestamp int64) { //timestamp for timeout timestamp = time.Now().Add(timeout).Unix() //Signature string sstring := fmt.Sprintf("%s-%d-%s-%s-%s", uri, timestamp, rand, uid, privateKey) //Crypto by HMAC-...
go
func CreateSignatureForStreamUrlWithA(uri, rand, uid, privateKey string, timeout time.Duration) (authKey string, timestamp int64) { //timestamp for timeout timestamp = time.Now().Add(timeout).Unix() //Signature string sstring := fmt.Sprintf("%s-%d-%s-%s-%s", uri, timestamp, rand, uid, privateKey) //Crypto by HMAC-...
[ "func", "CreateSignatureForStreamUrlWithA", "(", "uri", ",", "rand", ",", "uid", ",", "privateKey", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "authKey", "string", ",", "timestamp", "int64", ")", "{", "//timestamp for timeout", "timestamp", "="...
// CreateSignatureForStreamUrlWithA creates signature for Url string whit method A
[ "CreateSignatureForStreamUrlWithA", "creates", "signature", "for", "Url", "string", "whit", "method", "A" ]
70ca68674d5c2d01747f5f8d7eea303fec385288
https://github.com/BPing/aliyun-live-go-sdk/blob/70ca68674d5c2d01747f5f8d7eea303fec385288/util/signature.go#L47-L59
137,833
tendermint/abci
example/kvstore/persistent_kvstore.go
updateValidator
func (app *PersistentKVStoreApplication) updateValidator(v types.Validator) types.ResponseDeliverTx { key := []byte("val:" + string(v.PubKey.Data)) if v.Power == 0 { // remove validator if !app.app.state.db.Has(key) { return types.ResponseDeliverTx{ Code: code.CodeTypeUnauthorized, Log: fmt.Sprintf("C...
go
func (app *PersistentKVStoreApplication) updateValidator(v types.Validator) types.ResponseDeliverTx { key := []byte("val:" + string(v.PubKey.Data)) if v.Power == 0 { // remove validator if !app.app.state.db.Has(key) { return types.ResponseDeliverTx{ Code: code.CodeTypeUnauthorized, Log: fmt.Sprintf("C...
[ "func", "(", "app", "*", "PersistentKVStoreApplication", ")", "updateValidator", "(", "v", "types", ".", "Validator", ")", "types", ".", "ResponseDeliverTx", "{", "key", ":=", "[", "]", "byte", "(", "\"", "\"", "+", "string", "(", "v", ".", "PubKey", "."...
// add, update, or remove a validator
[ "add", "update", "or", "remove", "a", "validator" ]
7857efac3cf65bfc528b4fac0bc42fe9e6564dd7
https://github.com/tendermint/abci/blob/7857efac3cf65bfc528b4fac0bc42fe9e6564dd7/example/kvstore/persistent_kvstore.go#L175-L200
137,834
tendermint/abci
cmd/abci-cli/abci-cli.go
cmdSetOption
func cmdSetOption(cmd *cobra.Command, args []string) error { if len(args) < 2 { printResponse(cmd, args, response{ Code: codeBad, Log: "want at least arguments of the form: <key> <value>", }) return nil } key, val := args[0], args[1] _, err := client.SetOptionSync(types.RequestSetOption{key, val}) if...
go
func cmdSetOption(cmd *cobra.Command, args []string) error { if len(args) < 2 { printResponse(cmd, args, response{ Code: codeBad, Log: "want at least arguments of the form: <key> <value>", }) return nil } key, val := args[0], args[1] _, err := client.SetOptionSync(types.RequestSetOption{key, val}) if...
[ "func", "cmdSetOption", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", "<", "2", "{", "printResponse", "(", "cmd", ",", "args", ",", "response", "{", "Code", ":", "codeBa...
// Set an option on the application
[ "Set", "an", "option", "on", "the", "application" ]
7857efac3cf65bfc528b4fac0bc42fe9e6564dd7
https://github.com/tendermint/abci/blob/7857efac3cf65bfc528b4fac0bc42fe9e6564dd7/cmd/abci-cli/abci-cli.go#L530-L546
137,835
cloudfoundry/libbuildpack
util.go
CopyDirectory
func CopyDirectory(srcDir, destDir string) error { destExists, _ := FileExists(destDir) if !destExists { return errors.New("destination dir must exist") } files, err := ioutil.ReadDir(srcDir) if err != nil { return err } for _, f := range files { src := filepath.Join(srcDir, f.Name()) dest := filepath....
go
func CopyDirectory(srcDir, destDir string) error { destExists, _ := FileExists(destDir) if !destExists { return errors.New("destination dir must exist") } files, err := ioutil.ReadDir(srcDir) if err != nil { return err } for _, f := range files { src := filepath.Join(srcDir, f.Name()) dest := filepath....
[ "func", "CopyDirectory", "(", "srcDir", ",", "destDir", "string", ")", "error", "{", "destExists", ",", "_", ":=", "FileExists", "(", "destDir", ")", "\n", "if", "!", "destExists", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// CopyDirectory copies srcDir to destDir
[ "CopyDirectory", "copies", "srcDir", "to", "destDir" ]
ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002
https://github.com/cloudfoundry/libbuildpack/blob/ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002/util.go#L64-L107
137,836
cloudfoundry/libbuildpack
util.go
ExtractZip
func ExtractZip(zipfile, destDir string) error { r, err := zip.OpenReader(zipfile) if err != nil { return err } defer r.Close() for _, f := range r.File { path := filepath.Join(destDir, filepath.Clean(f.Name)) rc, err := f.Open() if err != nil { return err } if f.FileInfo().IsDir() { err = os....
go
func ExtractZip(zipfile, destDir string) error { r, err := zip.OpenReader(zipfile) if err != nil { return err } defer r.Close() for _, f := range r.File { path := filepath.Join(destDir, filepath.Clean(f.Name)) rc, err := f.Open() if err != nil { return err } if f.FileInfo().IsDir() { err = os....
[ "func", "ExtractZip", "(", "zipfile", ",", "destDir", "string", ")", "error", "{", "r", ",", "err", ":=", "zip", ".", "OpenReader", "(", "zipfile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "r", ".", "Clos...
// ExtractZip extracts zipfile to destDir
[ "ExtractZip", "extracts", "zipfile", "to", "destDir" ]
ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002
https://github.com/cloudfoundry/libbuildpack/blob/ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002/util.go#L121-L149
137,837
cloudfoundry/libbuildpack
util.go
GetBuildpackDir
func GetBuildpackDir() (string, error) { var err error bpDir := os.Getenv("BUILDPACK_DIR") if bpDir == "" { bpDir, err = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "..")) if err != nil { return "", err } } return bpDir, nil }
go
func GetBuildpackDir() (string, error) { var err error bpDir := os.Getenv("BUILDPACK_DIR") if bpDir == "" { bpDir, err = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "..")) if err != nil { return "", err } } return bpDir, nil }
[ "func", "GetBuildpackDir", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "error", "\n\n", "bpDir", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n\n", "if", "bpDir", "==", "\"", "\"", "{", "bpDir", ",", "err", "=", "filepath",...
// Gets the buildpack directory
[ "Gets", "the", "buildpack", "directory" ]
ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002
https://github.com/cloudfoundry/libbuildpack/blob/ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002/util.go#L178-L192
137,838
cloudfoundry/libbuildpack
util.go
ExtractTarGz
func ExtractTarGz(tarfile, destDir string) error { file, err := os.Open(tarfile) if err != nil { return err } defer file.Close() gz, err := gzip.NewReader(file) if err != nil { return err } defer gz.Close() return extractTar(gz, destDir) }
go
func ExtractTarGz(tarfile, destDir string) error { file, err := os.Open(tarfile) if err != nil { return err } defer file.Close() gz, err := gzip.NewReader(file) if err != nil { return err } defer gz.Close() return extractTar(gz, destDir) }
[ "func", "ExtractTarGz", "(", "tarfile", ",", "destDir", "string", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "tarfile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Clo...
// ExtractTarGz extracts tar.gz to destDir
[ "ExtractTarGz", "extracts", "tar", ".", "gz", "to", "destDir" ]
ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002
https://github.com/cloudfoundry/libbuildpack/blob/ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002/util.go#L195-L207
137,839
cloudfoundry/libbuildpack
util.go
CopyFile
func CopyFile(source, destFile string) error { fh, err := os.Open(source) if err != nil { return err } fileInfo, err := fh.Stat() if err != nil { return err } defer fh.Close() return writeToFile(fh, destFile, fileInfo.Mode()) }
go
func CopyFile(source, destFile string) error { fh, err := os.Open(source) if err != nil { return err } fileInfo, err := fh.Stat() if err != nil { return err } defer fh.Close() return writeToFile(fh, destFile, fileInfo.Mode()) }
[ "func", "CopyFile", "(", "source", ",", "destFile", "string", ")", "error", "{", "fh", ",", "err", ":=", "os", ".", "Open", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fileInfo", ",", "err", ":=", ...
// CopyFile copies source file to destFile, creating all intermediate directories in destFile
[ "CopyFile", "copies", "source", "file", "to", "destFile", "creating", "all", "intermediate", "directories", "in", "destFile" ]
ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002
https://github.com/cloudfoundry/libbuildpack/blob/ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002/util.go#L210-L224
137,840
cloudfoundry/libbuildpack
packager/cfbindata.go
OurRestoreAsset
func OurRestoreAsset(dir, name string, funcMap template.FuncMap, shas map[string]string, force bool) error { data, err := Asset(name) if err != nil { return err } info, err := AssetInfo(name) if err != nil { return err } t, err := template.New("").Funcs(funcMap).Parse(string(data)) if err != nil { retu...
go
func OurRestoreAsset(dir, name string, funcMap template.FuncMap, shas map[string]string, force bool) error { data, err := Asset(name) if err != nil { return err } info, err := AssetInfo(name) if err != nil { return err } t, err := template.New("").Funcs(funcMap).Parse(string(data)) if err != nil { retu...
[ "func", "OurRestoreAsset", "(", "dir", ",", "name", "string", ",", "funcMap", "template", ".", "FuncMap", ",", "shas", "map", "[", "string", "]", "string", ",", "force", "bool", ")", "error", "{", "data", ",", "err", ":=", "Asset", "(", "name", ")", ...
// cfbindata.go is a collection of a few functions from bindata.go that we copied so that we could make our own changes to them. // We don't want to make these changes within bindata.go because bindata.go is an auto-generated file // These changes allow us to use go templating to setup the scaffold directory // Restore...
[ "cfbindata", ".", "go", "is", "a", "collection", "of", "a", "few", "functions", "from", "bindata", ".", "go", "that", "we", "copied", "so", "that", "we", "could", "make", "our", "own", "changes", "to", "them", ".", "We", "don", "t", "want", "to", "ma...
ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002
https://github.com/cloudfoundry/libbuildpack/blob/ff7a186ed9a26ef2f33e6ee7cb423d1fd2724002/packager/cfbindata.go#L23-L88
137,841
go-openapi/validate
spec.go
NewSpecValidator
func NewSpecValidator(schema *spec.Schema, formats strfmt.Registry) *SpecValidator { return &SpecValidator{ schema: schema, KnownFormats: formats, Options: defaultOpts, } }
go
func NewSpecValidator(schema *spec.Schema, formats strfmt.Registry) *SpecValidator { return &SpecValidator{ schema: schema, KnownFormats: formats, Options: defaultOpts, } }
[ "func", "NewSpecValidator", "(", "schema", "*", "spec", ".", "Schema", ",", "formats", "strfmt", ".", "Registry", ")", "*", "SpecValidator", "{", "return", "&", "SpecValidator", "{", "schema", ":", "schema", ",", "KnownFormats", ":", "formats", ",", "Options...
// NewSpecValidator creates a new swagger spec validator instance
[ "NewSpecValidator", "creates", "a", "new", "swagger", "spec", "validator", "instance" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/spec.go#L65-L71
137,842
go-openapi/validate
spec.go
Validate
func (s *SpecValidator) Validate(data interface{}) (errs *Result, warnings *Result) { var sd *loads.Document errs = new(Result) switch v := data.(type) { case *loads.Document: sd = v } if sd == nil { errs.AddErrors(invalidDocumentMsg()) return } s.spec = sd s.analyzer = analysis.New(sd.Spec()) warning...
go
func (s *SpecValidator) Validate(data interface{}) (errs *Result, warnings *Result) { var sd *loads.Document errs = new(Result) switch v := data.(type) { case *loads.Document: sd = v } if sd == nil { errs.AddErrors(invalidDocumentMsg()) return } s.spec = sd s.analyzer = analysis.New(sd.Spec()) warning...
[ "func", "(", "s", "*", "SpecValidator", ")", "Validate", "(", "data", "interface", "{", "}", ")", "(", "errs", "*", "Result", ",", "warnings", "*", "Result", ")", "{", "var", "sd", "*", "loads", ".", "Document", "\n", "errs", "=", "new", "(", "Resu...
// Validate validates the swagger spec
[ "Validate", "validates", "the", "swagger", "spec" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/spec.go#L74-L151
137,843
go-openapi/validate
spec.go
validateSchemaItems
func (s *SpecValidator) validateSchemaItems(schema spec.Schema, prefix, opID string) *Result { res := new(Result) if !schema.Type.Contains("array") { return res } if schema.Items == nil || schema.Items.Len() == 0 { res.AddErrors(arrayRequiresItemsMsg(prefix, opID)) return res } if schema.Items.Schema != n...
go
func (s *SpecValidator) validateSchemaItems(schema spec.Schema, prefix, opID string) *Result { res := new(Result) if !schema.Type.Contains("array") { return res } if schema.Items == nil || schema.Items.Len() == 0 { res.AddErrors(arrayRequiresItemsMsg(prefix, opID)) return res } if schema.Items.Schema != n...
[ "func", "(", "s", "*", "SpecValidator", ")", "validateSchemaItems", "(", "schema", "spec", ".", "Schema", ",", "prefix", ",", "opID", "string", ")", "*", "Result", "{", "res", ":=", "new", "(", "Result", ")", "\n", "if", "!", "schema", ".", "Type", "...
// Verifies constraints on array type
[ "Verifies", "constraints", "on", "array", "type" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/spec.go#L391-L411
137,844
go-openapi/validate
default_validator.go
Validate
func (d *defaultValidator) Validate() (errs *Result) { errs = new(Result) if d == nil || d.SpecValidator == nil { return errs } d.resetVisited() errs.Merge(d.validateDefaultValueValidAgainstSchema()) // error - return errs }
go
func (d *defaultValidator) Validate() (errs *Result) { errs = new(Result) if d == nil || d.SpecValidator == nil { return errs } d.resetVisited() errs.Merge(d.validateDefaultValueValidAgainstSchema()) // error - return errs }
[ "func", "(", "d", "*", "defaultValidator", ")", "Validate", "(", ")", "(", "errs", "*", "Result", ")", "{", "errs", "=", "new", "(", "Result", ")", "\n", "if", "d", "==", "nil", "||", "d", ".", "SpecValidator", "==", "nil", "{", "return", "errs", ...
// Validate validates the default values declared in the swagger spec
[ "Validate", "validates", "the", "default", "values", "declared", "in", "the", "swagger", "spec" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/default_validator.go#L74-L82
137,845
go-openapi/validate
values.go
Enum
func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation { val := reflect.ValueOf(enum) if val.Kind() != reflect.Slice { return nil } var values []interface{} for i := 0; i < val.Len(); i++ { ele := val.Index(i) enumValue := ele.Interface() if data != nil { if reflect.DeepEqual...
go
func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation { val := reflect.ValueOf(enum) if val.Kind() != reflect.Slice { return nil } var values []interface{} for i := 0; i < val.Len(); i++ { ele := val.Index(i) enumValue := ele.Interface() if data != nil { if reflect.DeepEqual...
[ "func", "Enum", "(", "path", ",", "in", "string", ",", "data", "interface", "{", "}", ",", "enum", "interface", "{", "}", ")", "*", "errors", ".", "Validation", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "enum", ")", "\n", "if", "val", ".", ...
// Enum validates if the data is a member of the enum
[ "Enum", "validates", "if", "the", "data", "is", "a", "member", "of", "the", "enum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L28-L57
137,846
go-openapi/validate
values.go
MinItems
func MinItems(path, in string, size, min int64) *errors.Validation { if size < min { return errors.TooFewItems(path, in, min) } return nil }
go
func MinItems(path, in string, size, min int64) *errors.Validation { if size < min { return errors.TooFewItems(path, in, min) } return nil }
[ "func", "MinItems", "(", "path", ",", "in", "string", ",", "size", ",", "min", "int64", ")", "*", "errors", ".", "Validation", "{", "if", "size", "<", "min", "{", "return", "errors", ".", "TooFewItems", "(", "path", ",", "in", ",", "min", ")", "\n"...
// MinItems validates that there are at least n items in a slice
[ "MinItems", "validates", "that", "there", "are", "at", "least", "n", "items", "in", "a", "slice" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L60-L65
137,847
go-openapi/validate
values.go
MaxItems
func MaxItems(path, in string, size, max int64) *errors.Validation { if size > max { return errors.TooManyItems(path, in, max) } return nil }
go
func MaxItems(path, in string, size, max int64) *errors.Validation { if size > max { return errors.TooManyItems(path, in, max) } return nil }
[ "func", "MaxItems", "(", "path", ",", "in", "string", ",", "size", ",", "max", "int64", ")", "*", "errors", ".", "Validation", "{", "if", "size", ">", "max", "{", "return", "errors", ".", "TooManyItems", "(", "path", ",", "in", ",", "max", ")", "\n...
// MaxItems validates that there are at most n items in a slice
[ "MaxItems", "validates", "that", "there", "are", "at", "most", "n", "items", "in", "a", "slice" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L68-L73
137,848
go-openapi/validate
values.go
UniqueItems
func UniqueItems(path, in string, data interface{}) *errors.Validation { val := reflect.ValueOf(data) if val.Kind() != reflect.Slice { return nil } var unique []interface{} for i := 0; i < val.Len(); i++ { v := val.Index(i).Interface() for _, u := range unique { if reflect.DeepEqual(v, u) { return err...
go
func UniqueItems(path, in string, data interface{}) *errors.Validation { val := reflect.ValueOf(data) if val.Kind() != reflect.Slice { return nil } var unique []interface{} for i := 0; i < val.Len(); i++ { v := val.Index(i).Interface() for _, u := range unique { if reflect.DeepEqual(v, u) { return err...
[ "func", "UniqueItems", "(", "path", ",", "in", "string", ",", "data", "interface", "{", "}", ")", "*", "errors", ".", "Validation", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "data", ")", "\n", "if", "val", ".", "Kind", "(", ")", "!=", "refl...
// UniqueItems validates that the provided slice has unique elements
[ "UniqueItems", "validates", "that", "the", "provided", "slice", "has", "unique", "elements" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L76-L92
137,849
go-openapi/validate
values.go
MinLength
func MinLength(path, in, data string, minLength int64) *errors.Validation { strLen := int64(utf8.RuneCount([]byte(data))) if strLen < minLength { return errors.TooShort(path, in, minLength) } return nil }
go
func MinLength(path, in, data string, minLength int64) *errors.Validation { strLen := int64(utf8.RuneCount([]byte(data))) if strLen < minLength { return errors.TooShort(path, in, minLength) } return nil }
[ "func", "MinLength", "(", "path", ",", "in", ",", "data", "string", ",", "minLength", "int64", ")", "*", "errors", ".", "Validation", "{", "strLen", ":=", "int64", "(", "utf8", ".", "RuneCount", "(", "[", "]", "byte", "(", "data", ")", ")", ")", "\...
// MinLength validates a string for minimum length
[ "MinLength", "validates", "a", "string", "for", "minimum", "length" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L95-L101
137,850
go-openapi/validate
values.go
MaxLength
func MaxLength(path, in, data string, maxLength int64) *errors.Validation { strLen := int64(utf8.RuneCount([]byte(data))) if strLen > maxLength { return errors.TooLong(path, in, maxLength) } return nil }
go
func MaxLength(path, in, data string, maxLength int64) *errors.Validation { strLen := int64(utf8.RuneCount([]byte(data))) if strLen > maxLength { return errors.TooLong(path, in, maxLength) } return nil }
[ "func", "MaxLength", "(", "path", ",", "in", ",", "data", "string", ",", "maxLength", "int64", ")", "*", "errors", ".", "Validation", "{", "strLen", ":=", "int64", "(", "utf8", ".", "RuneCount", "(", "[", "]", "byte", "(", "data", ")", ")", ")", "\...
// MaxLength validates a string for maximum length
[ "MaxLength", "validates", "a", "string", "for", "maximum", "length" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L104-L110
137,851
go-openapi/validate
values.go
Required
func Required(path, in string, data interface{}) *errors.Validation { val := reflect.ValueOf(data) if val.IsValid() { if reflect.DeepEqual(reflect.Zero(val.Type()).Interface(), val.Interface()) { return errors.Required(path, in) } return nil } return errors.Required(path, in) }
go
func Required(path, in string, data interface{}) *errors.Validation { val := reflect.ValueOf(data) if val.IsValid() { if reflect.DeepEqual(reflect.Zero(val.Type()).Interface(), val.Interface()) { return errors.Required(path, in) } return nil } return errors.Required(path, in) }
[ "func", "Required", "(", "path", ",", "in", "string", ",", "data", "interface", "{", "}", ")", "*", "errors", ".", "Validation", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "data", ")", "\n", "if", "val", ".", "IsValid", "(", ")", "{", "if", ...
// Required validates an interface for requiredness
[ "Required", "validates", "an", "interface", "for", "requiredness" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L113-L122
137,852
go-openapi/validate
values.go
RequiredString
func RequiredString(path, in, data string) *errors.Validation { if data == "" { return errors.Required(path, in) } return nil }
go
func RequiredString(path, in, data string) *errors.Validation { if data == "" { return errors.Required(path, in) } return nil }
[ "func", "RequiredString", "(", "path", ",", "in", ",", "data", "string", ")", "*", "errors", ".", "Validation", "{", "if", "data", "==", "\"", "\"", "{", "return", "errors", ".", "Required", "(", "path", ",", "in", ")", "\n", "}", "\n", "return", "...
// RequiredString validates a string for requiredness
[ "RequiredString", "validates", "a", "string", "for", "requiredness" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L125-L130
137,853
go-openapi/validate
values.go
RequiredNumber
func RequiredNumber(path, in string, data float64) *errors.Validation { if data == 0 { return errors.Required(path, in) } return nil }
go
func RequiredNumber(path, in string, data float64) *errors.Validation { if data == 0 { return errors.Required(path, in) } return nil }
[ "func", "RequiredNumber", "(", "path", ",", "in", "string", ",", "data", "float64", ")", "*", "errors", ".", "Validation", "{", "if", "data", "==", "0", "{", "return", "errors", ".", "Required", "(", "path", ",", "in", ")", "\n", "}", "\n", "return",...
// RequiredNumber validates a number for requiredness
[ "RequiredNumber", "validates", "a", "number", "for", "requiredness" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L133-L138
137,854
go-openapi/validate
values.go
Pattern
func Pattern(path, in, data, pattern string) *errors.Validation { re, err := compileRegexp(pattern) if err != nil { return errors.FailedPattern(path, in, fmt.Sprintf("%s, but pattern is invalid: %s", pattern, err.Error())) } if !re.MatchString(data) { return errors.FailedPattern(path, in, pattern) } return ni...
go
func Pattern(path, in, data, pattern string) *errors.Validation { re, err := compileRegexp(pattern) if err != nil { return errors.FailedPattern(path, in, fmt.Sprintf("%s, but pattern is invalid: %s", pattern, err.Error())) } if !re.MatchString(data) { return errors.FailedPattern(path, in, pattern) } return ni...
[ "func", "Pattern", "(", "path", ",", "in", ",", "data", ",", "pattern", "string", ")", "*", "errors", ".", "Validation", "{", "re", ",", "err", ":=", "compileRegexp", "(", "pattern", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", ...
// Pattern validates a string against a regular expression
[ "Pattern", "validates", "a", "string", "against", "a", "regular", "expression" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L141-L150
137,855
go-openapi/validate
values.go
MaximumInt
func MaximumInt(path, in string, data, max int64, exclusive bool) *errors.Validation { if (!exclusive && data > max) || (exclusive && data >= max) { return errors.ExceedsMaximumInt(path, in, max, exclusive) } return nil }
go
func MaximumInt(path, in string, data, max int64, exclusive bool) *errors.Validation { if (!exclusive && data > max) || (exclusive && data >= max) { return errors.ExceedsMaximumInt(path, in, max, exclusive) } return nil }
[ "func", "MaximumInt", "(", "path", ",", "in", "string", ",", "data", ",", "max", "int64", ",", "exclusive", "bool", ")", "*", "errors", ".", "Validation", "{", "if", "(", "!", "exclusive", "&&", "data", ">", "max", ")", "||", "(", "exclusive", "&&", ...
// MaximumInt validates if a number is smaller than a given maximum
[ "MaximumInt", "validates", "if", "a", "number", "is", "smaller", "than", "a", "given", "maximum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L153-L158
137,856
go-openapi/validate
values.go
MaximumUint
func MaximumUint(path, in string, data, max uint64, exclusive bool) *errors.Validation { if (!exclusive && data > max) || (exclusive && data >= max) { return errors.ExceedsMaximumUint(path, in, max, exclusive) } return nil }
go
func MaximumUint(path, in string, data, max uint64, exclusive bool) *errors.Validation { if (!exclusive && data > max) || (exclusive && data >= max) { return errors.ExceedsMaximumUint(path, in, max, exclusive) } return nil }
[ "func", "MaximumUint", "(", "path", ",", "in", "string", ",", "data", ",", "max", "uint64", ",", "exclusive", "bool", ")", "*", "errors", ".", "Validation", "{", "if", "(", "!", "exclusive", "&&", "data", ">", "max", ")", "||", "(", "exclusive", "&&"...
// MaximumUint validates if a number is smaller than a given maximum
[ "MaximumUint", "validates", "if", "a", "number", "is", "smaller", "than", "a", "given", "maximum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L161-L166
137,857
go-openapi/validate
values.go
Maximum
func Maximum(path, in string, data, max float64, exclusive bool) *errors.Validation { if (!exclusive && data > max) || (exclusive && data >= max) { return errors.ExceedsMaximum(path, in, max, exclusive) } return nil }
go
func Maximum(path, in string, data, max float64, exclusive bool) *errors.Validation { if (!exclusive && data > max) || (exclusive && data >= max) { return errors.ExceedsMaximum(path, in, max, exclusive) } return nil }
[ "func", "Maximum", "(", "path", ",", "in", "string", ",", "data", ",", "max", "float64", ",", "exclusive", "bool", ")", "*", "errors", ".", "Validation", "{", "if", "(", "!", "exclusive", "&&", "data", ">", "max", ")", "||", "(", "exclusive", "&&", ...
// Maximum validates if a number is smaller than a given maximum
[ "Maximum", "validates", "if", "a", "number", "is", "smaller", "than", "a", "given", "maximum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L169-L174
137,858
go-openapi/validate
values.go
Minimum
func Minimum(path, in string, data, min float64, exclusive bool) *errors.Validation { if (!exclusive && data < min) || (exclusive && data <= min) { return errors.ExceedsMinimum(path, in, min, exclusive) } return nil }
go
func Minimum(path, in string, data, min float64, exclusive bool) *errors.Validation { if (!exclusive && data < min) || (exclusive && data <= min) { return errors.ExceedsMinimum(path, in, min, exclusive) } return nil }
[ "func", "Minimum", "(", "path", ",", "in", "string", ",", "data", ",", "min", "float64", ",", "exclusive", "bool", ")", "*", "errors", ".", "Validation", "{", "if", "(", "!", "exclusive", "&&", "data", "<", "min", ")", "||", "(", "exclusive", "&&", ...
// Minimum validates if a number is smaller than a given minimum
[ "Minimum", "validates", "if", "a", "number", "is", "smaller", "than", "a", "given", "minimum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L177-L182
137,859
go-openapi/validate
values.go
MinimumInt
func MinimumInt(path, in string, data, min int64, exclusive bool) *errors.Validation { if (!exclusive && data < min) || (exclusive && data <= min) { return errors.ExceedsMinimumInt(path, in, min, exclusive) } return nil }
go
func MinimumInt(path, in string, data, min int64, exclusive bool) *errors.Validation { if (!exclusive && data < min) || (exclusive && data <= min) { return errors.ExceedsMinimumInt(path, in, min, exclusive) } return nil }
[ "func", "MinimumInt", "(", "path", ",", "in", "string", ",", "data", ",", "min", "int64", ",", "exclusive", "bool", ")", "*", "errors", ".", "Validation", "{", "if", "(", "!", "exclusive", "&&", "data", "<", "min", ")", "||", "(", "exclusive", "&&", ...
// MinimumInt validates if a number is smaller than a given minimum
[ "MinimumInt", "validates", "if", "a", "number", "is", "smaller", "than", "a", "given", "minimum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L185-L190
137,860
go-openapi/validate
values.go
MinimumUint
func MinimumUint(path, in string, data, min uint64, exclusive bool) *errors.Validation { if (!exclusive && data < min) || (exclusive && data <= min) { return errors.ExceedsMinimumUint(path, in, min, exclusive) } return nil }
go
func MinimumUint(path, in string, data, min uint64, exclusive bool) *errors.Validation { if (!exclusive && data < min) || (exclusive && data <= min) { return errors.ExceedsMinimumUint(path, in, min, exclusive) } return nil }
[ "func", "MinimumUint", "(", "path", ",", "in", "string", ",", "data", ",", "min", "uint64", ",", "exclusive", "bool", ")", "*", "errors", ".", "Validation", "{", "if", "(", "!", "exclusive", "&&", "data", "<", "min", ")", "||", "(", "exclusive", "&&"...
// MinimumUint validates if a number is smaller than a given minimum
[ "MinimumUint", "validates", "if", "a", "number", "is", "smaller", "than", "a", "given", "minimum" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L193-L198
137,861
go-openapi/validate
values.go
MultipleOf
func MultipleOf(path, in string, data, factor float64) *errors.Validation { // multipleOf factor must be positive if factor < 0 { return errors.MultipleOfMustBePositive(path, in, factor) } var mult float64 if factor < 1 { mult = 1 / factor * data } else { mult = data / factor } if !swag.IsFloat64AJSONInte...
go
func MultipleOf(path, in string, data, factor float64) *errors.Validation { // multipleOf factor must be positive if factor < 0 { return errors.MultipleOfMustBePositive(path, in, factor) } var mult float64 if factor < 1 { mult = 1 / factor * data } else { mult = data / factor } if !swag.IsFloat64AJSONInte...
[ "func", "MultipleOf", "(", "path", ",", "in", "string", ",", "data", ",", "factor", "float64", ")", "*", "errors", ".", "Validation", "{", "// multipleOf factor must be positive", "if", "factor", "<", "0", "{", "return", "errors", ".", "MultipleOfMustBePositive"...
// MultipleOf validates if the provided number is a multiple of the factor
[ "MultipleOf", "validates", "if", "the", "provided", "number", "is", "a", "multiple", "of", "the", "factor" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L201-L216
137,862
go-openapi/validate
values.go
MultipleOfInt
func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation { // multipleOf factor must be positive if factor < 0 { return errors.MultipleOfMustBePositive(path, in, factor) } mult := data / factor if mult*factor != data { return errors.NotMultipleOf(path, in, factor) } return nil }
go
func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation { // multipleOf factor must be positive if factor < 0 { return errors.MultipleOfMustBePositive(path, in, factor) } mult := data / factor if mult*factor != data { return errors.NotMultipleOf(path, in, factor) } return nil }
[ "func", "MultipleOfInt", "(", "path", ",", "in", "string", ",", "data", "int64", ",", "factor", "int64", ")", "*", "errors", ".", "Validation", "{", "// multipleOf factor must be positive", "if", "factor", "<", "0", "{", "return", "errors", ".", "MultipleOfMus...
// MultipleOfInt validates if the provided integer is a multiple of the factor
[ "MultipleOfInt", "validates", "if", "the", "provided", "integer", "is", "a", "multiple", "of", "the", "factor" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L219-L229
137,863
go-openapi/validate
values.go
MultipleOfUint
func MultipleOfUint(path, in string, data, factor uint64) *errors.Validation { mult := data / factor if mult*factor != data { return errors.NotMultipleOf(path, in, factor) } return nil }
go
func MultipleOfUint(path, in string, data, factor uint64) *errors.Validation { mult := data / factor if mult*factor != data { return errors.NotMultipleOf(path, in, factor) } return nil }
[ "func", "MultipleOfUint", "(", "path", ",", "in", "string", ",", "data", ",", "factor", "uint64", ")", "*", "errors", ".", "Validation", "{", "mult", ":=", "data", "/", "factor", "\n", "if", "mult", "*", "factor", "!=", "data", "{", "return", "errors",...
// MultipleOfUint validates if the provided unsigned integer is a multiple of the factor
[ "MultipleOfUint", "validates", "if", "the", "provided", "unsigned", "integer", "is", "a", "multiple", "of", "the", "factor" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L232-L238
137,864
go-openapi/validate
values.go
FormatOf
func FormatOf(path, in, format, data string, registry strfmt.Registry) *errors.Validation { if registry == nil { registry = strfmt.Default } if ok := registry.ContainsName(format); !ok { return errors.InvalidTypeName(format) } if ok := registry.Validates(format, data); !ok { return errors.InvalidType(path, i...
go
func FormatOf(path, in, format, data string, registry strfmt.Registry) *errors.Validation { if registry == nil { registry = strfmt.Default } if ok := registry.ContainsName(format); !ok { return errors.InvalidTypeName(format) } if ok := registry.Validates(format, data); !ok { return errors.InvalidType(path, i...
[ "func", "FormatOf", "(", "path", ",", "in", ",", "format", ",", "data", "string", ",", "registry", "strfmt", ".", "Registry", ")", "*", "errors", ".", "Validation", "{", "if", "registry", "==", "nil", "{", "registry", "=", "strfmt", ".", "Default", "\n...
// FormatOf validates if a string matches a format in the format registry
[ "FormatOf", "validates", "if", "a", "string", "matches", "a", "format", "in", "the", "format", "registry" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/values.go#L241-L252
137,865
go-openapi/validate
validator.go
NewHeaderValidator
func NewHeaderValidator(name string, header *spec.Header, formats strfmt.Registry) *HeaderValidator { p := &HeaderValidator{name: name, header: header, KnownFormats: formats} p.validators = []valueValidator{ &typeValidator{ Type: spec.StringOrArray([]string{header.Type}), Format: header.Format, In: "...
go
func NewHeaderValidator(name string, header *spec.Header, formats strfmt.Registry) *HeaderValidator { p := &HeaderValidator{name: name, header: header, KnownFormats: formats} p.validators = []valueValidator{ &typeValidator{ Type: spec.StringOrArray([]string{header.Type}), Format: header.Format, In: "...
[ "func", "NewHeaderValidator", "(", "name", "string", ",", "header", "*", "spec", ".", "Header", ",", "formats", "strfmt", ".", "Registry", ")", "*", "HeaderValidator", "{", "p", ":=", "&", "HeaderValidator", "{", "name", ":", "name", ",", "header", ":", ...
// NewHeaderValidator creates a new header validator object
[ "NewHeaderValidator", "creates", "a", "new", "header", "validator", "object" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/validator.go#L185-L201
137,866
go-openapi/validate
validator.go
NewParamValidator
func NewParamValidator(param *spec.Parameter, formats strfmt.Registry) *ParamValidator { p := &ParamValidator{param: param, KnownFormats: formats} p.validators = []valueValidator{ &typeValidator{ Type: spec.StringOrArray([]string{param.Type}), Format: param.Format, In: param.In, Path: param.Name...
go
func NewParamValidator(param *spec.Parameter, formats strfmt.Registry) *ParamValidator { p := &ParamValidator{param: param, KnownFormats: formats} p.validators = []valueValidator{ &typeValidator{ Type: spec.StringOrArray([]string{param.Type}), Format: param.Format, In: param.In, Path: param.Name...
[ "func", "NewParamValidator", "(", "param", "*", "spec", ".", "Parameter", ",", "formats", "strfmt", ".", "Registry", ")", "*", "ParamValidator", "{", "p", ":=", "&", "ParamValidator", "{", "param", ":", "param", ",", "KnownFormats", ":", "formats", "}", "\...
// NewParamValidator creates a new param validator object
[ "NewParamValidator", "creates", "a", "new", "param", "validator", "object" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/validator.go#L291-L307
137,867
go-openapi/validate
validator.go
Validate
func (p *ParamValidator) Validate(data interface{}) *Result { result := new(Result) tpe := reflect.TypeOf(data) kind := tpe.Kind() // TODO: validate type for _, validator := range p.validators { if validator.Applies(p.param, kind) { if err := validator.Validate(data); err != nil { result.Merge(err) i...
go
func (p *ParamValidator) Validate(data interface{}) *Result { result := new(Result) tpe := reflect.TypeOf(data) kind := tpe.Kind() // TODO: validate type for _, validator := range p.validators { if validator.Applies(p.param, kind) { if err := validator.Validate(data); err != nil { result.Merge(err) i...
[ "func", "(", "p", "*", "ParamValidator", ")", "Validate", "(", "data", "interface", "{", "}", ")", "*", "Result", "{", "result", ":=", "new", "(", "Result", ")", "\n", "tpe", ":=", "reflect", ".", "TypeOf", "(", "data", ")", "\n", "kind", ":=", "tp...
// Validate the data against the description of the parameter
[ "Validate", "the", "data", "against", "the", "description", "of", "the", "parameter" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/validator.go#L310-L327
137,868
go-openapi/validate
post/defaulter.go
ApplyDefaults
func ApplyDefaults(r *validate.Result) { fieldSchemata := r.FieldSchemata() for key, schemata := range fieldSchemata { LookForDefaultingScheme: for _, s := range schemata { if s.Default != nil { if _, found := key.Object()[key.Field()]; !found { key.Object()[key.Field()] = s.Default break LookForD...
go
func ApplyDefaults(r *validate.Result) { fieldSchemata := r.FieldSchemata() for key, schemata := range fieldSchemata { LookForDefaultingScheme: for _, s := range schemata { if s.Default != nil { if _, found := key.Object()[key.Field()]; !found { key.Object()[key.Field()] = s.Default break LookForD...
[ "func", "ApplyDefaults", "(", "r", "*", "validate", ".", "Result", ")", "{", "fieldSchemata", ":=", "r", ".", "FieldSchemata", "(", ")", "\n", "for", "key", ",", "schemata", ":=", "range", "fieldSchemata", "{", "LookForDefaultingScheme", ":", "for", "_", "...
// ApplyDefaults applies defaults to the underlying data of the result. The data must be a JSON // struct as returned by json.Unmarshal.
[ "ApplyDefaults", "applies", "defaults", "to", "the", "underlying", "data", "of", "the", "result", ".", "The", "data", "must", "be", "a", "JSON", "struct", "as", "returned", "by", "json", ".", "Unmarshal", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/post/defaulter.go#L23-L36
137,869
go-openapi/validate
schema.go
NewSchemaValidator
func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry, options ...Option) *SchemaValidator { if schema == nil { return nil } if rootSchema == nil { rootSchema = schema } if schema.ID != "" || schema.Ref.String() != "" || schema.Ref.IsRoot() { err := spec....
go
func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry, options ...Option) *SchemaValidator { if schema == nil { return nil } if rootSchema == nil { rootSchema = schema } if schema.ID != "" || schema.Ref.String() != "" || schema.Ref.IsRoot() { err := spec....
[ "func", "NewSchemaValidator", "(", "schema", "*", "spec", ".", "Schema", ",", "rootSchema", "interface", "{", "}", ",", "root", "string", ",", "formats", "strfmt", ".", "Registry", ",", "options", "...", "Option", ")", "*", "SchemaValidator", "{", "if", "s...
// NewSchemaValidator creates a new schema validator. // // Panics if the provided schema is invalid.
[ "NewSchemaValidator", "creates", "a", "new", "schema", "validator", ".", "Panics", "if", "the", "provided", "schema", "is", "invalid", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/schema.go#L59-L90
137,870
go-openapi/validate
schema.go
Applies
func (s *SchemaValidator) Applies(source interface{}, kind reflect.Kind) bool { _, ok := source.(*spec.Schema) return ok }
go
func (s *SchemaValidator) Applies(source interface{}, kind reflect.Kind) bool { _, ok := source.(*spec.Schema) return ok }
[ "func", "(", "s", "*", "SchemaValidator", ")", "Applies", "(", "source", "interface", "{", "}", ",", "kind", "reflect", ".", "Kind", ")", "bool", "{", "_", ",", "ok", ":=", "source", ".", "(", "*", "spec", ".", "Schema", ")", "\n", "return", "ok", ...
// Applies returns true when this schema validator applies
[ "Applies", "returns", "true", "when", "this", "schema", "validator", "applies" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/schema.go#L98-L101
137,871
go-openapi/validate
schema.go
Validate
func (s *SchemaValidator) Validate(data interface{}) *Result { result := &Result{data: data} if s == nil { return result } if s.Schema != nil { result.addRootObjectSchemata(s.Schema) } if data == nil { result.Merge(s.validators[0].Validate(data)) // type validator result.Merge(s.validators[6].Validate(da...
go
func (s *SchemaValidator) Validate(data interface{}) *Result { result := &Result{data: data} if s == nil { return result } if s.Schema != nil { result.addRootObjectSchemata(s.Schema) } if data == nil { result.Merge(s.validators[0].Validate(data)) // type validator result.Merge(s.validators[6].Validate(da...
[ "func", "(", "s", "*", "SchemaValidator", ")", "Validate", "(", "data", "interface", "{", "}", ")", "*", "Result", "{", "result", ":=", "&", "Result", "{", "data", ":", "data", "}", "\n", "if", "s", "==", "nil", "{", "return", "result", "\n", "}", ...
// Validate validates the data against the schema
[ "Validate", "validates", "the", "data", "against", "the", "schema" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/schema.go#L104-L174
137,872
go-openapi/validate
result.go
NewFieldKey
func NewFieldKey(obj map[string]interface{}, field string) FieldKey { return FieldKey{object: reflect.ValueOf(obj), field: field} }
go
func NewFieldKey(obj map[string]interface{}, field string) FieldKey { return FieldKey{object: reflect.ValueOf(obj), field: field} }
[ "func", "NewFieldKey", "(", "obj", "map", "[", "string", "]", "interface", "{", "}", ",", "field", "string", ")", "FieldKey", "{", "return", "FieldKey", "{", "object", ":", "reflect", ".", "ValueOf", "(", "obj", ")", ",", "field", ":", "field", "}", ...
// NewFieldKey returns a pair of an object and field usable as a key of a map.
[ "NewFieldKey", "returns", "a", "pair", "of", "an", "object", "and", "field", "usable", "as", "a", "key", "of", "a", "map", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L70-L72
137,873
go-openapi/validate
result.go
NewItemKey
func NewItemKey(slice interface{}, i int) ItemKey { return ItemKey{slice: reflect.ValueOf(slice), index: i} }
go
func NewItemKey(slice interface{}, i int) ItemKey { return ItemKey{slice: reflect.ValueOf(slice), index: i} }
[ "func", "NewItemKey", "(", "slice", "interface", "{", "}", ",", "i", "int", ")", "ItemKey", "{", "return", "ItemKey", "{", "slice", ":", "reflect", ".", "ValueOf", "(", "slice", ")", ",", "index", ":", "i", "}", "\n", "}" ]
// NewItemKey returns a pair of a slice and index usable as a key of a map.
[ "NewItemKey", "returns", "a", "pair", "of", "a", "slice", "and", "index", "usable", "as", "a", "key", "of", "a", "map", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L85-L87
137,874
go-openapi/validate
result.go
FieldSchemata
func (r *Result) FieldSchemata() map[FieldKey][]*spec.Schema { if r.cachedFieldSchemta != nil { return r.cachedFieldSchemta } ret := make(map[FieldKey][]*spec.Schema, len(r.fieldSchemata)) for _, fs := range r.fieldSchemata { key := NewFieldKey(fs.obj, fs.field) if fs.schemata.one != nil { ret[key] = appe...
go
func (r *Result) FieldSchemata() map[FieldKey][]*spec.Schema { if r.cachedFieldSchemta != nil { return r.cachedFieldSchemta } ret := make(map[FieldKey][]*spec.Schema, len(r.fieldSchemata)) for _, fs := range r.fieldSchemata { key := NewFieldKey(fs.obj, fs.field) if fs.schemata.one != nil { ret[key] = appe...
[ "func", "(", "r", "*", "Result", ")", "FieldSchemata", "(", ")", "map", "[", "FieldKey", "]", "[", "]", "*", "spec", ".", "Schema", "{", "if", "r", ".", "cachedFieldSchemta", "!=", "nil", "{", "return", "r", ".", "cachedFieldSchemta", "\n", "}", "\n\...
// FieldSchemata returns the schemata which apply to fields in objects.
[ "FieldSchemata", "returns", "the", "schemata", "which", "apply", "to", "fields", "in", "objects", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L135-L151
137,875
go-openapi/validate
result.go
ItemSchemata
func (r *Result) ItemSchemata() map[ItemKey][]*spec.Schema { if r.cachedItemSchemata != nil { return r.cachedItemSchemata } ret := make(map[ItemKey][]*spec.Schema, len(r.itemSchemata)) for _, ss := range r.itemSchemata { key := NewItemKey(ss.slice, ss.index) if ss.schemata.one != nil { ret[key] = append(r...
go
func (r *Result) ItemSchemata() map[ItemKey][]*spec.Schema { if r.cachedItemSchemata != nil { return r.cachedItemSchemata } ret := make(map[ItemKey][]*spec.Schema, len(r.itemSchemata)) for _, ss := range r.itemSchemata { key := NewItemKey(ss.slice, ss.index) if ss.schemata.one != nil { ret[key] = append(r...
[ "func", "(", "r", "*", "Result", ")", "ItemSchemata", "(", ")", "map", "[", "ItemKey", "]", "[", "]", "*", "spec", ".", "Schema", "{", "if", "r", ".", "cachedItemSchemata", "!=", "nil", "{", "return", "r", ".", "cachedItemSchemata", "\n", "}", "\n\n"...
// ItemSchemata returns the schemata which apply to items in slices.
[ "ItemSchemata", "returns", "the", "schemata", "which", "apply", "to", "items", "in", "slices", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L154-L170
137,876
go-openapi/validate
result.go
mergeForField
func (r *Result) mergeForField(obj map[string]interface{}, field string, other *Result) *Result { if other == nil { return r } r.mergeWithoutRootSchemata(other) if other.rootObjectSchemata.Len() > 0 { if r.fieldSchemata == nil { r.fieldSchemata = make([]fieldSchemata, len(obj)) } r.fieldSchemata = appen...
go
func (r *Result) mergeForField(obj map[string]interface{}, field string, other *Result) *Result { if other == nil { return r } r.mergeWithoutRootSchemata(other) if other.rootObjectSchemata.Len() > 0 { if r.fieldSchemata == nil { r.fieldSchemata = make([]fieldSchemata, len(obj)) } r.fieldSchemata = appen...
[ "func", "(", "r", "*", "Result", ")", "mergeForField", "(", "obj", "map", "[", "string", "]", "interface", "{", "}", ",", "field", "string", ",", "other", "*", "Result", ")", "*", "Result", "{", "if", "other", "==", "nil", "{", "return", "r", "\n",...
// mergeForField merges other into r, assigning other's root schemata to the given Object and field name.
[ "mergeForField", "merges", "other", "into", "r", "assigning", "other", "s", "root", "schemata", "to", "the", "given", "Object", "and", "field", "name", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L178-L196
137,877
go-openapi/validate
result.go
mergeForSlice
func (r *Result) mergeForSlice(slice reflect.Value, i int, other *Result) *Result { if other == nil { return r } r.mergeWithoutRootSchemata(other) if other.rootObjectSchemata.Len() > 0 { if r.itemSchemata == nil { r.itemSchemata = make([]itemSchemata, slice.Len()) } r.itemSchemata = append(r.itemSchemat...
go
func (r *Result) mergeForSlice(slice reflect.Value, i int, other *Result) *Result { if other == nil { return r } r.mergeWithoutRootSchemata(other) if other.rootObjectSchemata.Len() > 0 { if r.itemSchemata == nil { r.itemSchemata = make([]itemSchemata, slice.Len()) } r.itemSchemata = append(r.itemSchemat...
[ "func", "(", "r", "*", "Result", ")", "mergeForSlice", "(", "slice", "reflect", ".", "Value", ",", "i", "int", ",", "other", "*", "Result", ")", "*", "Result", "{", "if", "other", "==", "nil", "{", "return", "r", "\n", "}", "\n", "r", ".", "merge...
// mergeForSlice merges other into r, assigning other's root schemata to the given slice and index.
[ "mergeForSlice", "merges", "other", "into", "r", "assigning", "other", "s", "root", "schemata", "to", "the", "given", "slice", "and", "index", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L199-L217
137,878
go-openapi/validate
result.go
addRootObjectSchemata
func (r *Result) addRootObjectSchemata(s *spec.Schema) { r.rootObjectSchemata.Append(schemata{one: s}) }
go
func (r *Result) addRootObjectSchemata(s *spec.Schema) { r.rootObjectSchemata.Append(schemata{one: s}) }
[ "func", "(", "r", "*", "Result", ")", "addRootObjectSchemata", "(", "s", "*", "spec", ".", "Schema", ")", "{", "r", ".", "rootObjectSchemata", ".", "Append", "(", "schemata", "{", "one", ":", "s", "}", ")", "\n", "}" ]
// addRootObjectSchemata adds the given schemata for the root object of the result. // The slice schemata might be reused. I.e. do not modify it after being added to a result.
[ "addRootObjectSchemata", "adds", "the", "given", "schemata", "for", "the", "root", "object", "of", "the", "result", ".", "The", "slice", "schemata", "might", "be", "reused", ".", "I", ".", "e", ".", "do", "not", "modify", "it", "after", "being", "added", ...
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L221-L223
137,879
go-openapi/validate
result.go
addPropertySchemata
func (r *Result) addPropertySchemata(obj map[string]interface{}, fld string, schema *spec.Schema) { if r.fieldSchemata == nil { r.fieldSchemata = make([]fieldSchemata, 0, len(obj)) } r.fieldSchemata = append(r.fieldSchemata, fieldSchemata{obj: obj, field: fld, schemata: schemata{one: schema}}) }
go
func (r *Result) addPropertySchemata(obj map[string]interface{}, fld string, schema *spec.Schema) { if r.fieldSchemata == nil { r.fieldSchemata = make([]fieldSchemata, 0, len(obj)) } r.fieldSchemata = append(r.fieldSchemata, fieldSchemata{obj: obj, field: fld, schemata: schemata{one: schema}}) }
[ "func", "(", "r", "*", "Result", ")", "addPropertySchemata", "(", "obj", "map", "[", "string", "]", "interface", "{", "}", ",", "fld", "string", ",", "schema", "*", "spec", ".", "Schema", ")", "{", "if", "r", ".", "fieldSchemata", "==", "nil", "{", ...
// addPropertySchemata adds the given schemata for the object and field. // The slice schemata might be reused. I.e. do not modify it after being added to a result.
[ "addPropertySchemata", "adds", "the", "given", "schemata", "for", "the", "object", "and", "field", ".", "The", "slice", "schemata", "might", "be", "reused", ".", "I", ".", "e", ".", "do", "not", "modify", "it", "after", "being", "added", "to", "a", "resu...
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L227-L232
137,880
go-openapi/validate
result.go
addSliceSchemata
func (r *Result) addSliceSchemata(slice reflect.Value, i int, schema *spec.Schema) { if r.itemSchemata == nil { r.itemSchemata = make([]itemSchemata, 0, slice.Len()) } r.itemSchemata = append(r.itemSchemata, itemSchemata{slice: slice, index: i, schemata: schemata{one: schema}}) }
go
func (r *Result) addSliceSchemata(slice reflect.Value, i int, schema *spec.Schema) { if r.itemSchemata == nil { r.itemSchemata = make([]itemSchemata, 0, slice.Len()) } r.itemSchemata = append(r.itemSchemata, itemSchemata{slice: slice, index: i, schemata: schemata{one: schema}}) }
[ "func", "(", "r", "*", "Result", ")", "addSliceSchemata", "(", "slice", "reflect", ".", "Value", ",", "i", "int", ",", "schema", "*", "spec", ".", "Schema", ")", "{", "if", "r", ".", "itemSchemata", "==", "nil", "{", "r", ".", "itemSchemata", "=", ...
// addSliceSchemata adds the given schemata for the slice and index. // The slice schemata might be reused. I.e. do not modify it after being added to a result.
[ "addSliceSchemata", "adds", "the", "given", "schemata", "for", "the", "slice", "and", "index", ".", "The", "slice", "schemata", "might", "be", "reused", ".", "I", ".", "e", ".", "do", "not", "modify", "it", "after", "being", "added", "to", "a", "result",...
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L236-L241
137,881
go-openapi/validate
result.go
mergeWithoutRootSchemata
func (r *Result) mergeWithoutRootSchemata(other *Result) { r.resetCaches() r.AddErrors(other.Errors...) r.AddWarnings(other.Warnings...) r.MatchCount += other.MatchCount if other.fieldSchemata != nil { if r.fieldSchemata == nil { r.fieldSchemata = other.fieldSchemata } else { for _, x := range other.fie...
go
func (r *Result) mergeWithoutRootSchemata(other *Result) { r.resetCaches() r.AddErrors(other.Errors...) r.AddWarnings(other.Warnings...) r.MatchCount += other.MatchCount if other.fieldSchemata != nil { if r.fieldSchemata == nil { r.fieldSchemata = other.fieldSchemata } else { for _, x := range other.fie...
[ "func", "(", "r", "*", "Result", ")", "mergeWithoutRootSchemata", "(", "other", "*", "Result", ")", "{", "r", ".", "resetCaches", "(", ")", "\n", "r", ".", "AddErrors", "(", "other", ".", "Errors", "...", ")", "\n", "r", ".", "AddWarnings", "(", "oth...
// mergeWithoutRootSchemata merges other into r, ignoring the rootObject schemata.
[ "mergeWithoutRootSchemata", "merges", "other", "into", "r", "ignoring", "the", "rootObject", "schemata", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L244-L269
137,882
go-openapi/validate
result.go
Append
func (s *schemata) Append(other schemata) { if other.one == nil && len(other.multiple) == 0 { return } if s.one == nil && len(s.multiple) == 0 { *s = other return } if s.one != nil { if other.one != nil { s.multiple = []*spec.Schema{s.one, other.one} } else { t := make([]*spec.Schema, 0, 1+len(oth...
go
func (s *schemata) Append(other schemata) { if other.one == nil && len(other.multiple) == 0 { return } if s.one == nil && len(s.multiple) == 0 { *s = other return } if s.one != nil { if other.one != nil { s.multiple = []*spec.Schema{s.one, other.one} } else { t := make([]*spec.Schema, 0, 1+len(oth...
[ "func", "(", "s", "*", "schemata", ")", "Append", "(", "other", "schemata", ")", "{", "if", "other", ".", "one", "==", "nil", "&&", "len", "(", "other", ".", "multiple", ")", "==", "0", "{", "return", "\n", "}", "\n", "if", "s", ".", "one", "==...
// appendSchemata appends the schemata in other to s. It mutated s in-place.
[ "appendSchemata", "appends", "the", "schemata", "in", "other", "to", "s", ".", "It", "mutated", "s", "in", "-", "place", "." ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/result.go#L455-L484
137,883
go-openapi/validate
example_validator.go
isVisited
func (ex *exampleValidator) isVisited(path string) bool { found := ex.visitedSchemas[path] if !found { // search for overlapping paths frags := strings.Split(path, ".") if len(frags) < 2 { // shortcut exit on smaller paths return found } last := len(frags) - 1 var currentFragStr, parent string for...
go
func (ex *exampleValidator) isVisited(path string) bool { found := ex.visitedSchemas[path] if !found { // search for overlapping paths frags := strings.Split(path, ".") if len(frags) < 2 { // shortcut exit on smaller paths return found } last := len(frags) - 1 var currentFragStr, parent string for...
[ "func", "(", "ex", "*", "exampleValidator", ")", "isVisited", "(", "path", "string", ")", "bool", "{", "found", ":=", "ex", ".", "visitedSchemas", "[", "path", "]", "\n", "if", "!", "found", "{", "// search for overlapping paths", "frags", ":=", "strings", ...
// isVisited tells if a path has already been visited
[ "isVisited", "tells", "if", "a", "path", "has", "already", "been", "visited" ]
3fd099a3cf2ee54e86beee561afe8f1b5bfe769e
https://github.com/go-openapi/validate/blob/3fd099a3cf2ee54e86beee561afe8f1b5bfe769e/example_validator.go#L41-L70
137,884
mcuadros/go-candyjs
base.go
NewContext
func NewContext() *Context { ctx := &Context{Context: duktape.New()} ctx.storage = newStorage() ctx.pushGlobalCandyJSObject() return ctx }
go
func NewContext() *Context { ctx := &Context{Context: duktape.New()} ctx.storage = newStorage() ctx.pushGlobalCandyJSObject() return ctx }
[ "func", "NewContext", "(", ")", "*", "Context", "{", "ctx", ":=", "&", "Context", "{", "Context", ":", "duktape", ".", "New", "(", ")", "}", "\n", "ctx", ".", "storage", "=", "newStorage", "(", ")", "\n", "ctx", ".", "pushGlobalCandyJSObject", "(", "...
// NewContext returns a new Context
[ "NewContext", "returns", "a", "new", "Context" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L20-L26
137,885
mcuadros/go-candyjs
base.go
PushGlobalType
func (ctx *Context) PushGlobalType(name string, s interface{}) int { ctx.PushGlobalObject() cons := ctx.PushType(s) ctx.PutPropString(-2, name) ctx.Pop() return cons }
go
func (ctx *Context) PushGlobalType(name string, s interface{}) int { ctx.PushGlobalObject() cons := ctx.PushType(s) ctx.PutPropString(-2, name) ctx.Pop() return cons }
[ "func", "(", "ctx", "*", "Context", ")", "PushGlobalType", "(", "name", "string", ",", "s", "interface", "{", "}", ")", "int", "{", "ctx", ".", "PushGlobalObject", "(", ")", "\n", "cons", ":=", "ctx", ".", "PushType", "(", "s", ")", "\n", "ctx", "....
// PushGlobalType like PushType but pushed to the global object
[ "PushGlobalType", "like", "PushType", "but", "pushed", "to", "the", "global", "object" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L65-L72
137,886
mcuadros/go-candyjs
base.go
PushType
func (ctx *Context) PushType(s interface{}) int { return ctx.PushGoFunction(func() { value := reflect.New(reflect.TypeOf(s)) ctx.PushProxy(value.Interface()) }) }
go
func (ctx *Context) PushType(s interface{}) int { return ctx.PushGoFunction(func() { value := reflect.New(reflect.TypeOf(s)) ctx.PushProxy(value.Interface()) }) }
[ "func", "(", "ctx", "*", "Context", ")", "PushType", "(", "s", "interface", "{", "}", ")", "int", "{", "return", "ctx", ".", "PushGoFunction", "(", "func", "(", ")", "{", "value", ":=", "reflect", ".", "New", "(", "reflect", ".", "TypeOf", "(", "s"...
// PushType push a constructor for the type of the given value, this constructor // returns an empty instance of the type. The value passed is discarded, only // is used for retrieve the time, instead of require pass a `reflect.Type`.
[ "PushType", "push", "a", "constructor", "for", "the", "type", "of", "the", "given", "value", "this", "constructor", "returns", "an", "empty", "instance", "of", "the", "type", ".", "The", "value", "passed", "is", "discarded", "only", "is", "used", "for", "r...
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L77-L82
137,887
mcuadros/go-candyjs
base.go
PushGlobalProxy
func (ctx *Context) PushGlobalProxy(name string, v interface{}) int { ctx.PushGlobalObject() obj := ctx.PushProxy(v) ctx.PutPropString(-2, name) ctx.Pop() return obj }
go
func (ctx *Context) PushGlobalProxy(name string, v interface{}) int { ctx.PushGlobalObject() obj := ctx.PushProxy(v) ctx.PutPropString(-2, name) ctx.Pop() return obj }
[ "func", "(", "ctx", "*", "Context", ")", "PushGlobalProxy", "(", "name", "string", ",", "v", "interface", "{", "}", ")", "int", "{", "ctx", ".", "PushGlobalObject", "(", ")", "\n", "obj", ":=", "ctx", ".", "PushProxy", "(", "v", ")", "\n", "ctx", "...
// PushGlobalProxy like PushProxy but pushed to the global object
[ "PushGlobalProxy", "like", "PushProxy", "but", "pushed", "to", "the", "global", "object" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L85-L92
137,888
mcuadros/go-candyjs
base.go
PushGlobalStruct
func (ctx *Context) PushGlobalStruct(name string, s interface{}) (int, error) { ctx.PushGlobalObject() obj, err := ctx.PushStruct(s) if err != nil { return -1, err } ctx.PutPropString(-2, name) ctx.Pop() return obj, nil }
go
func (ctx *Context) PushGlobalStruct(name string, s interface{}) (int, error) { ctx.PushGlobalObject() obj, err := ctx.PushStruct(s) if err != nil { return -1, err } ctx.PutPropString(-2, name) ctx.Pop() return obj, nil }
[ "func", "(", "ctx", "*", "Context", ")", "PushGlobalStruct", "(", "name", "string", ",", "s", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "ctx", ".", "PushGlobalObject", "(", ")", "\n", "obj", ",", "err", ":=", "ctx", ".", "Push...
// PushGlobalStruct like PushStruct but pushed to the global object
[ "PushGlobalStruct", "like", "PushStruct", "but", "pushed", "to", "the", "global", "object" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L132-L143
137,889
mcuadros/go-candyjs
base.go
PushStruct
func (ctx *Context) PushStruct(s interface{}) (int, error) { t := reflect.TypeOf(s) v := reflect.ValueOf(s) obj := ctx.PushObject() ctx.pushStructMethods(obj, t, v) if t.Kind() == reflect.Ptr { v = v.Elem() t = v.Type() } return obj, ctx.pushStructFields(obj, t, v) }
go
func (ctx *Context) PushStruct(s interface{}) (int, error) { t := reflect.TypeOf(s) v := reflect.ValueOf(s) obj := ctx.PushObject() ctx.pushStructMethods(obj, t, v) if t.Kind() == reflect.Ptr { v = v.Elem() t = v.Type() } return obj, ctx.pushStructFields(obj, t, v) }
[ "func", "(", "ctx", "*", "Context", ")", "PushStruct", "(", "s", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "s", ")", "\n", "v", ":=", "reflect", ".", "ValueOf", "(", "s", ")", "\n\...
// PushStruct push a object to the stack with the same methods and properties // the pushed object is a copy, any change made on JS is not reflected on the // Go instance.
[ "PushStruct", "push", "a", "object", "to", "the", "stack", "with", "the", "same", "methods", "and", "properties", "the", "pushed", "object", "is", "a", "copy", "any", "change", "made", "on", "JS", "is", "not", "reflected", "on", "the", "Go", "instance", ...
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L148-L161
137,890
mcuadros/go-candyjs
base.go
PushGlobalInterface
func (ctx *Context) PushGlobalInterface(name string, v interface{}) error { return ctx.pushGlobalValue(name, reflect.ValueOf(v)) }
go
func (ctx *Context) PushGlobalInterface(name string, v interface{}) error { return ctx.pushGlobalValue(name, reflect.ValueOf(v)) }
[ "func", "(", "ctx", "*", "Context", ")", "PushGlobalInterface", "(", "name", "string", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "ctx", ".", "pushGlobalValue", "(", "name", ",", "reflect", ".", "ValueOf", "(", "v", ")", ")", "\n", ...
// PushGlobalInterface like PushInterface but pushed to the global object
[ "PushGlobalInterface", "like", "PushInterface", "but", "pushed", "to", "the", "global", "object" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L200-L202
137,891
mcuadros/go-candyjs
base.go
PushGlobalGoFunction
func (ctx *Context) PushGlobalGoFunction(name string, f interface{}) (int, error) { return ctx.Context.PushGlobalGoFunction(name, ctx.wrapFunction(f)) }
go
func (ctx *Context) PushGlobalGoFunction(name string, f interface{}) (int, error) { return ctx.Context.PushGlobalGoFunction(name, ctx.wrapFunction(f)) }
[ "func", "(", "ctx", "*", "Context", ")", "PushGlobalGoFunction", "(", "name", "string", ",", "f", "interface", "{", "}", ")", "(", "int", ",", "error", ")", "{", "return", "ctx", ".", "Context", ".", "PushGlobalGoFunction", "(", "name", ",", "ctx", "."...
// PushGlobalGoFunction like PushGoFunction but pushed to the global object
[ "PushGlobalGoFunction", "like", "PushGoFunction", "but", "pushed", "to", "the", "global", "object" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/base.go#L315-L317
137,892
mcuadros/go-candyjs
package.go
PushGlobalPackage
func (ctx *Context) PushGlobalPackage(pckgName, alias string) error { ctx.PushGlobalObject() err := ctx.pushPackage(pckgName) if err != nil { return err } ctx.PutPropString(-2, alias) ctx.Pop() return nil }
go
func (ctx *Context) PushGlobalPackage(pckgName, alias string) error { ctx.PushGlobalObject() err := ctx.pushPackage(pckgName) if err != nil { return err } ctx.PutPropString(-2, alias) ctx.Pop() return nil }
[ "func", "(", "ctx", "*", "Context", ")", "PushGlobalPackage", "(", "pckgName", ",", "alias", "string", ")", "error", "{", "ctx", ".", "PushGlobalObject", "(", ")", "\n\n", "err", ":=", "ctx", ".", "pushPackage", "(", "pckgName", ")", "\n", "if", "err", ...
// PushGlobalPackage all the functions and types from the given package using // the pre-registered PackagePusher function.
[ "PushGlobalPackage", "all", "the", "functions", "and", "types", "from", "the", "given", "package", "using", "the", "pre", "-", "registered", "PackagePusher", "function", "." ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/package.go#L26-L38
137,893
mcuadros/go-candyjs
cmd/candyjs/cmd_import.go
Execute
func (c *CmdImport) Execute(args []string) error { c.fullPkgName = c.Args.Package fmt.Printf("Processing %q\n", c.Args.Package) objects, err := c.getObjects() if err != nil { return err } c.getCurrentPckgName() return c.render(objects) }
go
func (c *CmdImport) Execute(args []string) error { c.fullPkgName = c.Args.Package fmt.Printf("Processing %q\n", c.Args.Package) objects, err := c.getObjects() if err != nil { return err } c.getCurrentPckgName() return c.render(objects) }
[ "func", "(", "c", "*", "CmdImport", ")", "Execute", "(", "args", "[", "]", "string", ")", "error", "{", "c", ".", "fullPkgName", "=", "c", ".", "Args", ".", "Package", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "c", ".", "Args", "...
// Execute run the CmdImport, follows the go-flags interface
[ "Execute", "run", "the", "CmdImport", "follows", "the", "go", "-", "flags", "interface" ]
d703dfa5153a4276b8a4783d985793595228073d
https://github.com/mcuadros/go-candyjs/blob/d703dfa5153a4276b8a4783d985793595228073d/cmd/candyjs/cmd_import.go#L31-L42
137,894
bhoriuchi/go-bunyan
bunyan/log.go
serialize
func (l *bunyanLog) serialize(key string, value interface{}) interface{} { if fn, ok := l.logger.serializers[key]; ok { return fn(value) } else if isError(value) { return fmt.Sprintf("%v", value) } else { return value } }
go
func (l *bunyanLog) serialize(key string, value interface{}) interface{} { if fn, ok := l.logger.serializers[key]; ok { return fn(value) } else if isError(value) { return fmt.Sprintf("%v", value) } else { return value } }
[ "func", "(", "l", "*", "bunyanLog", ")", "serialize", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "fn", ",", "ok", ":=", "l", ".", "logger", ".", "serializers", "[", "key", "]", ";", "ok", "{"...
// serializes a log field
[ "serializes", "a", "log", "field" ]
8815b5fdce8c649679da0123c957d4b5e4b6f8ca
https://github.com/bhoriuchi/go-bunyan/blob/8815b5fdce8c649679da0123c957d4b5e4b6f8ca/bunyan/log.go#L16-L24
137,895
bhoriuchi/go-bunyan
bunyan/log.go
sprintf
func (l *bunyanLog) sprintf(args []interface{}) string { return fmt.Sprintf(args[0].(string), args[1:]...) }
go
func (l *bunyanLog) sprintf(args []interface{}) string { return fmt.Sprintf(args[0].(string), args[1:]...) }
[ "func", "(", "l", "*", "bunyanLog", ")", "sprintf", "(", "args", "[", "]", "interface", "{", "}", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "args", "[", "0", "]", ".", "(", "string", ")", ",", "args", "[", "1", ":", "]", "...", ...
// prints a formatted string using the arguments provided
[ "prints", "a", "formatted", "string", "using", "the", "arguments", "provided" ]
8815b5fdce8c649679da0123c957d4b5e4b6f8ca
https://github.com/bhoriuchi/go-bunyan/blob/8815b5fdce8c649679da0123c957d4b5e4b6f8ca/bunyan/log.go#L27-L29
137,896
bhoriuchi/go-bunyan
bunyan/log.go
writeStream
func (l *bunyanLog) writeStream(stream Stream, data []byte) error { stream.Stream.Write(data) return nil }
go
func (l *bunyanLog) writeStream(stream Stream, data []byte) error { stream.Stream.Write(data) return nil }
[ "func", "(", "l", "*", "bunyanLog", ")", "writeStream", "(", "stream", "Stream", ",", "data", "[", "]", "byte", ")", "error", "{", "stream", ".", "Stream", ".", "Write", "(", "data", ")", "\n", "return", "nil", "\n", "}" ]
// writes the data to a stream that implements io.Writer
[ "writes", "the", "data", "to", "a", "stream", "that", "implements", "io", ".", "Writer" ]
8815b5fdce8c649679da0123c957d4b5e4b6f8ca
https://github.com/bhoriuchi/go-bunyan/blob/8815b5fdce8c649679da0123c957d4b5e4b6f8ca/bunyan/log.go#L104-L107
137,897
bhoriuchi/go-bunyan
bunyan/log.go
writeFile
func (l *bunyanLog) writeFile(stream Stream, data []byte) error { if f, err := os.OpenFile(stream.Path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err != nil { log.Printf("[bunyan] error: %v", err) } else if _, err := f.Write(data); err != nil { log.Printf("[bunyan] error: %v", err) } else if err := f.Close(); ...
go
func (l *bunyanLog) writeFile(stream Stream, data []byte) error { if f, err := os.OpenFile(stream.Path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err != nil { log.Printf("[bunyan] error: %v", err) } else if _, err := f.Write(data); err != nil { log.Printf("[bunyan] error: %v", err) } else if err := f.Close(); ...
[ "func", "(", "l", "*", "bunyanLog", ")", "writeFile", "(", "stream", "Stream", ",", "data", "[", "]", "byte", ")", "error", "{", "if", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "stream", ".", "Path", ",", "os", ".", "O_APPEND", "|", "os"...
// writes the data to a log file
[ "writes", "the", "data", "to", "a", "log", "file" ]
8815b5fdce8c649679da0123c957d4b5e4b6f8ca
https://github.com/bhoriuchi/go-bunyan/blob/8815b5fdce8c649679da0123c957d4b5e4b6f8ca/bunyan/log.go#L110-L119
137,898
bhoriuchi/go-bunyan
bunyan/logger.go
AddStream
func (l *Logger) AddStream(stream Stream) error { if err := stream.init(l.config); err != nil { return err } l.streams = append(l.streams, stream) return nil }
go
func (l *Logger) AddStream(stream Stream) error { if err := stream.init(l.config); err != nil { return err } l.streams = append(l.streams, stream) return nil }
[ "func", "(", "l", "*", "Logger", ")", "AddStream", "(", "stream", "Stream", ")", "error", "{", "if", "err", ":=", "stream", ".", "init", "(", "l", ".", "config", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "l", ".", "st...
// AddStream dynamically adds a stream to the current logger.
[ "AddStream", "dynamically", "adds", "a", "stream", "to", "the", "current", "logger", "." ]
8815b5fdce8c649679da0123c957d4b5e4b6f8ca
https://github.com/bhoriuchi/go-bunyan/blob/8815b5fdce8c649679da0123c957d4b5e4b6f8ca/bunyan/logger.go#L15-L21
137,899
bhoriuchi/go-bunyan
bunyan/logger.go
AddSerializers
func (l *Logger) AddSerializers(serializers map[string]func(value interface{}) interface{}) { for key, value := range serializers { l.serializers[string(key)] = value } }
go
func (l *Logger) AddSerializers(serializers map[string]func(value interface{}) interface{}) { for key, value := range serializers { l.serializers[string(key)] = value } }
[ "func", "(", "l", "*", "Logger", ")", "AddSerializers", "(", "serializers", "map", "[", "string", "]", "func", "(", "value", "interface", "{", "}", ")", "interface", "{", "}", ")", "{", "for", "key", ",", "value", ":=", "range", "serializers", "{", "...
// AddSerializers dynamically adds serializers to the current logger.
[ "AddSerializers", "dynamically", "adds", "serializers", "to", "the", "current", "logger", "." ]
8815b5fdce8c649679da0123c957d4b5e4b6f8ca
https://github.com/bhoriuchi/go-bunyan/blob/8815b5fdce8c649679da0123c957d4b5e4b6f8ca/bunyan/logger.go#L24-L28