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
146,100
dcos/dcos-go
dcos/nodeutil/mesos.go
ContainerIDs
func (t Task) ContainerIDs() (containerIDs []string, err error) { for _, status := range t.Statuses { containerID := status.ContainerStatus.ContainerID.Value if containerID == "" { return nil, ErrContainerIDNotFound } containerIDs = append(containerIDs, containerID) parent := status.ContainerStatus.Conta...
go
func (t Task) ContainerIDs() (containerIDs []string, err error) { for _, status := range t.Statuses { containerID := status.ContainerStatus.ContainerID.Value if containerID == "" { return nil, ErrContainerIDNotFound } containerIDs = append(containerIDs, containerID) parent := status.ContainerStatus.Conta...
[ "func", "(", "t", "Task", ")", "ContainerIDs", "(", ")", "(", "containerIDs", "[", "]", "string", ",", "err", "error", ")", "{", "for", "_", ",", "status", ":=", "range", "t", ".", "Statuses", "{", "containerID", ":=", "status", ".", "ContainerStatus",...
// ContainerIDs returns a slice of container ids , starting with the current, // and then appending the parent container ids.
[ "ContainerIDs", "returns", "a", "slice", "of", "container", "ids", "starting", "with", "the", "current", "and", "then", "appending", "the", "parent", "container", "ids", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/dcos/nodeutil/mesos.go#L66-L85
146,101
dcos/dcos-go
zkstore/connector_new.go
NewConnection
func NewConnection(addrs []string, opts ConnectionOpts) Connector { return &newConnection{ addrs: addrs, opts: opts, } }
go
func NewConnection(addrs []string, opts ConnectionOpts) Connector { return &newConnection{ addrs: addrs, opts: opts, } }
[ "func", "NewConnection", "(", "addrs", "[", "]", "string", ",", "opts", "ConnectionOpts", ")", "Connector", "{", "return", "&", "newConnection", "{", "addrs", ":", "addrs", ",", "opts", ":", "opts", ",", "}", "\n", "}" ]
// NewConnection returns a Connector that creates a new ZK connection
[ "NewConnection", "returns", "a", "Connector", "that", "creates", "a", "new", "ZK", "connection" ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/connector_new.go#L17-L22
146,102
dcos/dcos-go
zkstore/connector_new.go
durationOrDefault
func durationOrDefault(duration time.Duration, defaultDuration time.Duration) time.Duration { if duration != 0 { return duration } return defaultDuration }
go
func durationOrDefault(duration time.Duration, defaultDuration time.Duration) time.Duration { if duration != 0 { return duration } return defaultDuration }
[ "func", "durationOrDefault", "(", "duration", "time", ".", "Duration", ",", "defaultDuration", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "if", "duration", "!=", "0", "{", "return", "duration", "\n", "}", "\n", "return", "defaultDuration", "...
// durationOrDefault returns the first duration unless it is the zero value, // in which case it will return the defaultDuration.
[ "durationOrDefault", "returns", "the", "first", "duration", "unless", "it", "is", "the", "zero", "value", "in", "which", "case", "it", "will", "return", "the", "defaultDuration", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/connector_new.go#L74-L79
146,103
dcos/dcos-go
zkstore/connector_new.go
waitForSession
func waitForSession(zkEvents <-chan zk.Event, timeout time.Duration) error { deadline := time.NewTimer(timeout) defer deadline.Stop() for { select { case e := <-zkEvents: if e.State == zk.StateHasSession { return nil } case <-deadline.C: return errors.New("timed out") } } }
go
func waitForSession(zkEvents <-chan zk.Event, timeout time.Duration) error { deadline := time.NewTimer(timeout) defer deadline.Stop() for { select { case e := <-zkEvents: if e.State == zk.StateHasSession { return nil } case <-deadline.C: return errors.New("timed out") } } }
[ "func", "waitForSession", "(", "zkEvents", "<-", "chan", "zk", ".", "Event", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "deadline", ":=", "time", ".", "NewTimer", "(", "timeout", ")", "\n", "defer", "deadline", ".", "Stop", "(", ")", "...
// waitForSession waits for a session to be established. if it times out // an error will be returned.
[ "waitForSession", "waits", "for", "a", "session", "to", "be", "established", ".", "if", "it", "times", "out", "an", "error", "will", "be", "returned", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/zkstore/connector_new.go#L83-L96
146,104
dcos/dcos-go
exec/exec.go
Read
func (c *CommandExecutor) Read(p []byte) (int, error) { return c.pipe.Read(p) }
go
func (c *CommandExecutor) Read(p []byte) (int, error) { return c.pipe.Read(p) }
[ "func", "(", "c", "*", "CommandExecutor", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "c", ".", "pipe", ".", "Read", "(", "p", ")", "\n", "}" ]
// Read implements the io.Reader. // CommandExecutor will read from stdout and stderr
[ "Read", "implements", "the", "io", ".", "Reader", ".", "CommandExecutor", "will", "read", "from", "stdout", "and", "stderr" ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L47-L49
146,105
dcos/dcos-go
exec/exec.go
Run
func Run(ctx context.Context, command string, arg []string) (*CommandExecutor, error) { if ctx == nil { ctx = context.Background() } if runtime.GOOS == "windows" { // For powershell, if running a script we need to execute it with a -File option // otherwise the return code will get lost if len(arg) == 1 && ...
go
func Run(ctx context.Context, command string, arg []string) (*CommandExecutor, error) { if ctx == nil { ctx = context.Background() } if runtime.GOOS == "windows" { // For powershell, if running a script we need to execute it with a -File option // otherwise the return code will get lost if len(arg) == 1 && ...
[ "func", "Run", "(", "ctx", "context", ".", "Context", ",", "command", "string", ",", "arg", "[", "]", "string", ")", "(", "*", "CommandExecutor", ",", "error", ")", "{", "if", "ctx", "==", "nil", "{", "ctx", "=", "context", ".", "Background", "(", ...
// Run spawns the given command and returns a handle to the running process in the form // of a CommandExecutor.
[ "Run", "spawns", "the", "given", "command", "and", "returns", "a", "handle", "to", "the", "running", "process", "in", "the", "form", "of", "a", "CommandExecutor", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L53-L95
146,106
dcos/dcos-go
exec/exec.go
Command
func Command(command ...string) *exec.Cmd { name, arg := commandParts(command...) return exec.Command(name, arg...) }
go
func Command(command ...string) *exec.Cmd { name, arg := commandParts(command...) return exec.Command(name, arg...) }
[ "func", "Command", "(", "command", "...", "string", ")", "*", "exec", ".", "Cmd", "{", "name", ",", "arg", ":=", "commandParts", "(", "command", "...", ")", "\n", "return", "exec", ".", "Command", "(", "name", ",", "arg", "...", ")", "\n", "}" ]
// Command returns a Cmd from a shell command.
[ "Command", "returns", "a", "Cmd", "from", "a", "shell", "command", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L105-L108
146,107
dcos/dcos-go
exec/exec.go
CommandContext
func CommandContext(ctx context.Context, command ...string) *exec.Cmd { name, arg := commandParts(command...) return exec.CommandContext(ctx, name, arg...) }
go
func CommandContext(ctx context.Context, command ...string) *exec.Cmd { name, arg := commandParts(command...) return exec.CommandContext(ctx, name, arg...) }
[ "func", "CommandContext", "(", "ctx", "context", ".", "Context", ",", "command", "...", "string", ")", "*", "exec", ".", "Cmd", "{", "name", ",", "arg", ":=", "commandParts", "(", "command", "...", ")", "\n", "return", "exec", ".", "CommandContext", "(",...
// CommandContext returns a Cmd with the given context and shell command.
[ "CommandContext", "returns", "a", "Cmd", "with", "the", "given", "context", "and", "shell", "command", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L111-L114
146,108
dcos/dcos-go
exec/exec.go
FullOutput
func FullOutput(c *exec.Cmd) (stdout []byte, stderr []byte, code int, err error) { var outbuf, errbuf bytes.Buffer c.Stdout = &outbuf c.Stderr = &errbuf if runtime.GOOS == "windows" { // For powershell, if running a script we need to execute it with a -File option // otherwise the return code will get lost ...
go
func FullOutput(c *exec.Cmd) (stdout []byte, stderr []byte, code int, err error) { var outbuf, errbuf bytes.Buffer c.Stdout = &outbuf c.Stderr = &errbuf if runtime.GOOS == "windows" { // For powershell, if running a script we need to execute it with a -File option // otherwise the return code will get lost ...
[ "func", "FullOutput", "(", "c", "*", "exec", ".", "Cmd", ")", "(", "stdout", "[", "]", "byte", ",", "stderr", "[", "]", "byte", ",", "code", "int", ",", "err", "error", ")", "{", "var", "outbuf", ",", "errbuf", "bytes", ".", "Buffer", "\n\n", "c"...
// FullOutput runs a command and returns its stdout, stderr, exit code, and error status.
[ "FullOutput", "runs", "a", "command", "and", "returns", "its", "stdout", "stderr", "exit", "code", "and", "error", "status", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L117-L140
146,109
dcos/dcos-go
exec/exec.go
SimpleFullOutput
func SimpleFullOutput(timeout time.Duration, command ...string) (stdout []byte, stderr []byte, code int, err error) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() return FullOutput(CommandContext(ctx, command...)) }
go
func SimpleFullOutput(timeout time.Duration, command ...string) (stdout []byte, stderr []byte, code int, err error) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() return FullOutput(CommandContext(ctx, command...)) }
[ "func", "SimpleFullOutput", "(", "timeout", "time", ".", "Duration", ",", "command", "...", "string", ")", "(", "stdout", "[", "]", "byte", ",", "stderr", "[", "]", "byte", ",", "code", "int", ",", "err", "error", ")", "{", "ctx", ",", "cancel", ":="...
// SimpleFullOutput runs a shell command with a timeout and returns its stdout, stderr, exit code, and error status.
[ "SimpleFullOutput", "runs", "a", "shell", "command", "with", "a", "timeout", "and", "returns", "its", "stdout", "stderr", "exit", "code", "and", "error", "status", "." ]
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L143-L147
146,110
dcos/dcos-go
exec/exec.go
exitCode
func exitCode(e error) (int, error) { if e == nil { return 0, nil } // check if error contains program exit code if exiterr, ok := e.(*exec.ExitError); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { // when a program exceeded timeout it will be terminated // and the code -1 will be set. ...
go
func exitCode(e error) (int, error) { if e == nil { return 0, nil } // check if error contains program exit code if exiterr, ok := e.(*exec.ExitError); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { // when a program exceeded timeout it will be terminated // and the code -1 will be set. ...
[ "func", "exitCode", "(", "e", "error", ")", "(", "int", ",", "error", ")", "{", "if", "e", "==", "nil", "{", "return", "0", ",", "nil", "\n", "}", "\n\n", "// check if error contains program exit code", "if", "exiterr", ",", "ok", ":=", "e", ".", "(", ...
// exitCode takes an error and checks if it's a read error or program had non zero exit code. // The output is the return value and error. The return value must be treated as a real return code value // only if error is nil. If error is not nil, it means it's a real error.
[ "exitCode", "takes", "an", "error", "and", "checks", "if", "it", "s", "a", "read", "error", "or", "program", "had", "non", "zero", "exit", "code", ".", "The", "output", "is", "the", "return", "value", "and", "error", ".", "The", "return", "value", "mus...
3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0
https://github.com/dcos/dcos-go/blob/3b86d9c7fac36be9d16fc1d22e5a5dc54738aac0/exec/exec.go#L152-L169
146,111
rmg/iso4217
constants.go
ByName
func ByName(s string) (int, int) { code := codes[s] return code, minorUnits[code] }
go
func ByName(s string) (int, int) { code := codes[s] return code, minorUnits[code] }
[ "func", "ByName", "(", "s", "string", ")", "(", "int", ",", "int", ")", "{", "code", ":=", "codes", "[", "s", "]", "\n", "return", "code", ",", "minorUnits", "[", "code", "]", "\n", "}" ]
// ByName resolves the given name to the numeric code and the number of minor // unit digits to display for the given currency.
[ "ByName", "resolves", "the", "given", "name", "to", "the", "numeric", "code", "and", "the", "number", "of", "minor", "unit", "digits", "to", "display", "for", "the", "given", "currency", "." ]
cfb0c10f43977b970d9d2659362829a8bb77dfe0
https://github.com/rmg/iso4217/blob/cfb0c10f43977b970d9d2659362829a8bb77dfe0/constants.go#L558-L561
146,112
rainycape/vfs
write.go
WriteZip
func WriteZip(w io.Writer, fs VFS) error { zw := zip.NewWriter(w) err := copyVFS(fs, func(p string, info os.FileInfo, f io.Reader) error { hdr, err := zip.FileInfoHeader(info) if err != nil { return err } hdr.Name = p fw, err := zw.CreateHeader(hdr) if err != nil { return err } _, err = io.Copy(...
go
func WriteZip(w io.Writer, fs VFS) error { zw := zip.NewWriter(w) err := copyVFS(fs, func(p string, info os.FileInfo, f io.Reader) error { hdr, err := zip.FileInfoHeader(info) if err != nil { return err } hdr.Name = p fw, err := zw.CreateHeader(hdr) if err != nil { return err } _, err = io.Copy(...
[ "func", "WriteZip", "(", "w", "io", ".", "Writer", ",", "fs", "VFS", ")", "error", "{", "zw", ":=", "zip", ".", "NewWriter", "(", "w", ")", "\n", "err", ":=", "copyVFS", "(", "fs", ",", "func", "(", "p", "string", ",", "info", "os", ".", "FileI...
// WriteZip writes the given VFS as a zip file to the given io.Writer.
[ "WriteZip", "writes", "the", "given", "VFS", "as", "a", "zip", "file", "to", "the", "given", "io", ".", "Writer", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/write.go#L29-L48
146,113
rainycape/vfs
write.go
WriteTar
func WriteTar(w io.Writer, fs VFS) error { tw := tar.NewWriter(w) err := copyVFS(fs, func(p string, info os.FileInfo, f io.Reader) error { hdr, err := tar.FileInfoHeader(info, "") if err != nil { return err } hdr.Name = p if err := tw.WriteHeader(hdr); err != nil { return err } _, err = io.Copy(tw...
go
func WriteTar(w io.Writer, fs VFS) error { tw := tar.NewWriter(w) err := copyVFS(fs, func(p string, info os.FileInfo, f io.Reader) error { hdr, err := tar.FileInfoHeader(info, "") if err != nil { return err } hdr.Name = p if err := tw.WriteHeader(hdr); err != nil { return err } _, err = io.Copy(tw...
[ "func", "WriteTar", "(", "w", "io", ".", "Writer", ",", "fs", "VFS", ")", "error", "{", "tw", ":=", "tar", ".", "NewWriter", "(", "w", ")", "\n", "err", ":=", "copyVFS", "(", "fs", ",", "func", "(", "p", "string", ",", "info", "os", ".", "FileI...
// WriteTar writes the given VFS as a tar file to the given io.Writer.
[ "WriteTar", "writes", "the", "given", "VFS", "as", "a", "tar", "file", "to", "the", "given", "io", ".", "Writer", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/write.go#L51-L69
146,114
rainycape/vfs
write.go
WriteTarGzip
func WriteTarGzip(w io.Writer, fs VFS) error { gw, err := gzip.NewWriterLevel(w, gzip.BestCompression) if err != nil { return err } if err := WriteTar(gw, fs); err != nil { return err } return gw.Close() }
go
func WriteTarGzip(w io.Writer, fs VFS) error { gw, err := gzip.NewWriterLevel(w, gzip.BestCompression) if err != nil { return err } if err := WriteTar(gw, fs); err != nil { return err } return gw.Close() }
[ "func", "WriteTarGzip", "(", "w", "io", ".", "Writer", ",", "fs", "VFS", ")", "error", "{", "gw", ",", "err", ":=", "gzip", ".", "NewWriterLevel", "(", "w", ",", "gzip", ".", "BestCompression", ")", "\n", "if", "err", "!=", "nil", "{", "return", "e...
// WriteTarGzip writes the given VFS as a tar.gz file to the given io.Writer.
[ "WriteTarGzip", "writes", "the", "given", "VFS", "as", "a", "tar", ".", "gz", "file", "to", "the", "given", "io", ".", "Writer", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/write.go#L72-L81
146,115
rainycape/vfs
file.go
Add
func (d *Dir) Add(name string, entry Entry) error { // TODO: Binary search for ii, v := range d.EntryNames { if v > name { names := make([]string, len(d.EntryNames)+1) copy(names, d.EntryNames[:ii]) names[ii] = name copy(names[ii+1:], d.EntryNames[ii:]) d.EntryNames = names entries := make([]Entr...
go
func (d *Dir) Add(name string, entry Entry) error { // TODO: Binary search for ii, v := range d.EntryNames { if v > name { names := make([]string, len(d.EntryNames)+1) copy(names, d.EntryNames[:ii]) names[ii] = name copy(names[ii+1:], d.EntryNames[ii:]) d.EntryNames = names entries := make([]Entr...
[ "func", "(", "d", "*", "Dir", ")", "Add", "(", "name", "string", ",", "entry", "Entry", ")", "error", "{", "// TODO: Binary search", "for", "ii", ",", "v", ":=", "range", "d", ".", "EntryNames", "{", "if", "v", ">", "name", "{", "names", ":=", "mak...
// Add ads a new entry to the directory. If there's already an // entry ith the same name, an error is returned.
[ "Add", "ads", "a", "new", "entry", "to", "the", "directory", ".", "If", "there", "s", "already", "an", "entry", "ith", "the", "same", "name", "an", "error", "is", "returned", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/file.go#L108-L134
146,116
rainycape/vfs
file.go
Find
func (d *Dir) Find(name string) (Entry, int, error) { for ii, v := range d.EntryNames { if v == name { return d.Entries[ii], ii, nil } } return nil, -1, os.ErrNotExist }
go
func (d *Dir) Find(name string) (Entry, int, error) { for ii, v := range d.EntryNames { if v == name { return d.Entries[ii], ii, nil } } return nil, -1, os.ErrNotExist }
[ "func", "(", "d", "*", "Dir", ")", "Find", "(", "name", "string", ")", "(", "Entry", ",", "int", ",", "error", ")", "{", "for", "ii", ",", "v", ":=", "range", "d", ".", "EntryNames", "{", "if", "v", "==", "name", "{", "return", "d", ".", "Ent...
// Find returns the entry with the given name and its index, // or an error if an entry with that name does not exist in // the directory.
[ "Find", "returns", "the", "entry", "with", "the", "given", "name", "and", "its", "index", "or", "an", "error", "if", "an", "entry", "with", "that", "name", "does", "not", "exist", "in", "the", "directory", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/file.go#L139-L146
146,117
rainycape/vfs
open.go
Tar
func Tar(r io.Reader) (VFS, error) { files := make(map[string]*File) tr := tar.NewReader(r) for { hdr, err := tr.Next() if err != nil { if err == io.EOF { break } return nil, err } if hdr.FileInfo().IsDir() { continue } data, err := ioutil.ReadAll(tr) if err != nil { return nil, err ...
go
func Tar(r io.Reader) (VFS, error) { files := make(map[string]*File) tr := tar.NewReader(r) for { hdr, err := tr.Next() if err != nil { if err == io.EOF { break } return nil, err } if hdr.FileInfo().IsDir() { continue } data, err := ioutil.ReadAll(tr) if err != nil { return nil, err ...
[ "func", "Tar", "(", "r", "io", ".", "Reader", ")", "(", "VFS", ",", "error", ")", "{", "files", ":=", "make", "(", "map", "[", "string", "]", "*", "File", ")", "\n", "tr", ":=", "tar", ".", "NewReader", "(", "r", ")", "\n", "for", "{", "hdr",...
// Tar returns an in-memory VFS initialized with the // contents of the .tar file read from the given io.Reader.
[ "Tar", "returns", "an", "in", "-", "memory", "VFS", "initialized", "with", "the", "contents", "of", "the", ".", "tar", "file", "read", "from", "the", "given", "io", ".", "Reader", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/open.go#L62-L87
146,118
rainycape/vfs
open.go
TarGzip
func TarGzip(r io.Reader) (VFS, error) { zr, err := gzip.NewReader(r) if err != nil { return nil, err } defer zr.Close() return Tar(zr) }
go
func TarGzip(r io.Reader) (VFS, error) { zr, err := gzip.NewReader(r) if err != nil { return nil, err } defer zr.Close() return Tar(zr) }
[ "func", "TarGzip", "(", "r", "io", ".", "Reader", ")", "(", "VFS", ",", "error", ")", "{", "zr", ",", "err", ":=", "gzip", ".", "NewReader", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "de...
// TarGzip returns an in-memory VFS initialized with the // contents of the .tar.gz file read from the given io.Reader.
[ "TarGzip", "returns", "an", "in", "-", "memory", "VFS", "initialized", "with", "the", "contents", "of", "the", ".", "tar", ".", "gz", "file", "read", "from", "the", "given", "io", ".", "Reader", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/open.go#L91-L98
146,119
rainycape/vfs
open.go
TarBzip2
func TarBzip2(r io.Reader) (VFS, error) { bzr := bzip2.NewReader(r) return Tar(bzr) }
go
func TarBzip2(r io.Reader) (VFS, error) { bzr := bzip2.NewReader(r) return Tar(bzr) }
[ "func", "TarBzip2", "(", "r", "io", ".", "Reader", ")", "(", "VFS", ",", "error", ")", "{", "bzr", ":=", "bzip2", ".", "NewReader", "(", "r", ")", "\n", "return", "Tar", "(", "bzr", ")", "\n", "}" ]
// TarBzip2 returns an in-memory VFS initialized with the // contents of then .tar.bz2 file read from the given io.Reader.
[ "TarBzip2", "returns", "an", "in", "-", "memory", "VFS", "initialized", "with", "the", "contents", "of", "then", ".", "tar", ".", "bz2", "file", "read", "from", "the", "given", "io", ".", "Reader", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/open.go#L102-L105
146,120
rainycape/vfs
fs.go
TmpFS
func TmpFS(prefix string) (TemporaryVFS, error) { dir, err := ioutil.TempDir("", prefix) if err != nil { return nil, err } fs, err := newFS(dir) if err != nil { return nil, err } fs.temporary = true return fs, nil }
go
func TmpFS(prefix string) (TemporaryVFS, error) { dir, err := ioutil.TempDir("", prefix) if err != nil { return nil, err } fs, err := newFS(dir) if err != nil { return nil, err } fs.temporary = true return fs, nil }
[ "func", "TmpFS", "(", "prefix", "string", ")", "(", "TemporaryVFS", ",", "error", ")", "{", "dir", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "\"", "\"", ",", "prefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// TmpFS returns a temporary file system with the given prefix and its root // directory name, which might be empty. The temporary file system is created // in the default temporary directory for the operating system. Once you're // done with the temporary filesystem, you might can all its files by calling // its Close...
[ "TmpFS", "returns", "a", "temporary", "file", "system", "with", "the", "given", "prefix", "and", "its", "root", "directory", "name", "which", "might", "be", "empty", ".", "The", "temporary", "file", "system", "is", "created", "in", "the", "default", "tempora...
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/fs.go#L121-L132
146,121
rainycape/vfs
rewriter.go
Rewriter
func Rewriter(fs VFS, rewriter func(oldPath string) (newPath string)) VFS { if rewriter == nil { return fs } return &rewriterFileSystem{fs: fs, rewriter: rewriter} }
go
func Rewriter(fs VFS, rewriter func(oldPath string) (newPath string)) VFS { if rewriter == nil { return fs } return &rewriterFileSystem{fs: fs, rewriter: rewriter} }
[ "func", "Rewriter", "(", "fs", "VFS", ",", "rewriter", "func", "(", "oldPath", "string", ")", "(", "newPath", "string", ")", ")", "VFS", "{", "if", "rewriter", "==", "nil", "{", "return", "fs", "\n", "}", "\n", "return", "&", "rewriterFileSystem", "{",...
// Rewriter returns a file system which uses the provided function // to rewrite paths.
[ "Rewriter", "returns", "a", "file", "system", "which", "uses", "the", "provided", "function", "to", "rewrite", "paths", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/rewriter.go#L51-L56
146,122
rainycape/vfs
mounter.go
Umount
func (m *Mounter) Umount(point string) error { point = path.Clean(point) for ii, v := range m.points { if v.point == point { // Check if we have mount points below this one for _, vv := range m.points[ii:] { if _, ok := hasSubdir(v.point, vv.point); ok { return fmt.Errorf("can't umount %s because %s ...
go
func (m *Mounter) Umount(point string) error { point = path.Clean(point) for ii, v := range m.points { if v.point == point { // Check if we have mount points below this one for _, vv := range m.points[ii:] { if _, ok := hasSubdir(v.point, vv.point); ok { return fmt.Errorf("can't umount %s because %s ...
[ "func", "(", "m", "*", "Mounter", ")", "Umount", "(", "point", "string", ")", "error", "{", "point", "=", "path", ".", "Clean", "(", "point", ")", "\n", "for", "ii", ",", "v", ":=", "range", "m", ".", "points", "{", "if", "v", ".", "point", "==...
// Umount umounts the filesystem from the given mount point. If there are other filesystems // mounted below it or there's no filesystem mounted at that point, an error is returned.
[ "Umount", "umounts", "the", "filesystem", "from", "the", "given", "mount", "point", ".", "If", "there", "are", "other", "filesystems", "mounted", "below", "it", "or", "there", "s", "no", "filesystem", "mounted", "at", "that", "point", "an", "error", "is", ...
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/mounter.go#L78-L93
146,123
rainycape/vfs
util.go
MkdirAll
func MkdirAll(fs VFS, path string, perm os.FileMode) error { cur := "/" if err := makeDir(fs, cur, perm); err != nil { return err } parts := strings.Split(path, "/") for _, v := range parts { cur += v if err := makeDir(fs, cur, perm); err != nil { return err } cur += "/" } return nil }
go
func MkdirAll(fs VFS, path string, perm os.FileMode) error { cur := "/" if err := makeDir(fs, cur, perm); err != nil { return err } parts := strings.Split(path, "/") for _, v := range parts { cur += v if err := makeDir(fs, cur, perm); err != nil { return err } cur += "/" } return nil }
[ "func", "MkdirAll", "(", "fs", "VFS", ",", "path", "string", ",", "perm", "os", ".", "FileMode", ")", "error", "{", "cur", ":=", "\"", "\"", "\n", "if", "err", ":=", "makeDir", "(", "fs", ",", "cur", ",", "perm", ")", ";", "err", "!=", "nil", "...
// MkdirAll makes all directories pointed by the given path, using the same // permissions for all of them. Note that MkdirAll skips directories which // already exists rather than returning an error.
[ "MkdirAll", "makes", "all", "directories", "pointed", "by", "the", "given", "path", "using", "the", "same", "permissions", "for", "all", "of", "them", ".", "Note", "that", "MkdirAll", "skips", "directories", "which", "already", "exists", "rather", "than", "ret...
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/util.go#L85-L99
146,124
rainycape/vfs
util.go
ReadFile
func ReadFile(fs VFS, path string) ([]byte, error) { f, err := fs.Open(path) if err != nil { return nil, err } defer f.Close() return ioutil.ReadAll(f) }
go
func ReadFile(fs VFS, path string) ([]byte, error) { f, err := fs.Open(path) if err != nil { return nil, err } defer f.Close() return ioutil.ReadAll(f) }
[ "func", "ReadFile", "(", "fs", "VFS", ",", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "f", ",", "err", ":=", "fs", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n...
// ReadFile reads the file at the given path from the given fs, returning // either its contents or an error if the file couldn't be read.
[ "ReadFile", "reads", "the", "file", "at", "the", "given", "path", "from", "the", "given", "fs", "returning", "either", "its", "contents", "or", "an", "error", "if", "the", "file", "couldn", "t", "be", "read", "." ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/util.go#L128-L135
146,125
rainycape/vfs
util.go
WriteFile
func WriteFile(fs VFS, path string, data []byte, perm os.FileMode) error { f, err := fs.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, perm) if err != nil { return err } if _, err := f.Write(data); err != nil { f.Close() return err } return f.Close() }
go
func WriteFile(fs VFS, path string, data []byte, perm os.FileMode) error { f, err := fs.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, perm) if err != nil { return err } if _, err := f.Write(data); err != nil { f.Close() return err } return f.Close() }
[ "func", "WriteFile", "(", "fs", "VFS", ",", "path", "string", ",", "data", "[", "]", "byte", ",", "perm", "os", ".", "FileMode", ")", "error", "{", "f", ",", "err", ":=", "fs", ".", "OpenFile", "(", "path", ",", "os", ".", "O_CREATE", "|", "os", ...
// WriteFile writes a file at the given path and fs with the given data and // permissions. If the file already exists, WriteFile truncates it before // writing. If the file can't be created, an error will be returned.
[ "WriteFile", "writes", "a", "file", "at", "the", "given", "path", "and", "fs", "with", "the", "given", "data", "and", "permissions", ".", "If", "the", "file", "already", "exists", "WriteFile", "truncates", "it", "before", "writing", ".", "If", "the", "file...
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/util.go#L140-L150
146,126
rainycape/vfs
util.go
Clone
func Clone(dst VFS, src VFS) error { err := Walk(src, "/", func(fs VFS, path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir() { perm := info.Mode() & os.ModePerm if perm == 0 { perm = 0755 } err := dst.Mkdir(path, info.Mode()|perm) if err != nil && !...
go
func Clone(dst VFS, src VFS) error { err := Walk(src, "/", func(fs VFS, path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir() { perm := info.Mode() & os.ModePerm if perm == 0 { perm = 0755 } err := dst.Mkdir(path, info.Mode()|perm) if err != nil && !...
[ "func", "Clone", "(", "dst", "VFS", ",", "src", "VFS", ")", "error", "{", "err", ":=", "Walk", "(", "src", ",", "\"", "\"", ",", "func", "(", "fs", "VFS", ",", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "err...
// Clone copies all the files from the src VFS to dst. Note that files or directories with // all permissions set to 0 will be set to 0755 for directories and 0644 for files. If you // need more granularity, use Walk directly to clone the file systems.
[ "Clone", "copies", "all", "the", "files", "from", "the", "src", "VFS", "to", "dst", ".", "Note", "that", "files", "or", "directories", "with", "all", "permissions", "set", "to", "0", "will", "be", "set", "to", "0755", "for", "directories", "and", "0644",...
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/util.go#L155-L185
146,127
rainycape/vfs
mem.go
entry
func (fs *memoryFileSystem) entry(path string, followSymlinks bool) (Entry, *Dir, int, error) { path = cleanPath(path) if path == "" || path == "/" || path == "." { return fs.root, nil, 0, nil } if path[0] == '/' { path = path[1:] } dir := fs.root cur := path for { p := strings.IndexByte(cur, '/') name ...
go
func (fs *memoryFileSystem) entry(path string, followSymlinks bool) (Entry, *Dir, int, error) { path = cleanPath(path) if path == "" || path == "/" || path == "." { return fs.root, nil, 0, nil } if path[0] == '/' { path = path[1:] } dir := fs.root cur := path for { p := strings.IndexByte(cur, '/') name ...
[ "func", "(", "fs", "*", "memoryFileSystem", ")", "entry", "(", "path", "string", ",", "followSymlinks", "bool", ")", "(", "Entry", ",", "*", "Dir", ",", "int", ",", "error", ")", "{", "path", "=", "cleanPath", "(", "path", ")", "\n", "if", "path", ...
// entry must always be called with the lock held
[ "entry", "must", "always", "be", "called", "with", "the", "lock", "held" ]
164487ec47b4f3e03930684ba0e85d7cbec8b751
https://github.com/rainycape/vfs/blob/164487ec47b4f3e03930684ba0e85d7cbec8b751/mem.go#L25-L77
146,128
mailhog/storage
mongodb.go
CreateMongoDB
func CreateMongoDB(uri, db, coll string) *MongoDB { log.Printf("Connecting to MongoDB: %s\n", uri) session, err := mgo.Dial(uri) if err != nil { log.Printf("Error connecting to MongoDB: %s", err) return nil } err = session.DB(db).C(coll).EnsureIndexKey("created") if err != nil { log.Printf("Failed creating ...
go
func CreateMongoDB(uri, db, coll string) *MongoDB { log.Printf("Connecting to MongoDB: %s\n", uri) session, err := mgo.Dial(uri) if err != nil { log.Printf("Error connecting to MongoDB: %s", err) return nil } err = session.DB(db).C(coll).EnsureIndexKey("created") if err != nil { log.Printf("Failed creating ...
[ "func", "CreateMongoDB", "(", "uri", ",", "db", ",", "coll", "string", ")", "*", "MongoDB", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "uri", ")", "\n", "session", ",", "err", ":=", "mgo", ".", "Dial", "(", "uri", ")", "\n", "if", ...
// CreateMongoDB creates a MongoDB backed storage backend
[ "CreateMongoDB", "creates", "a", "MongoDB", "backed", "storage", "backend" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/mongodb.go#L17-L33
146,129
mailhog/storage
mongodb.go
Store
func (mongo *MongoDB) Store(m *data.Message) (string, error) { err := mongo.Collection.Insert(m) if err != nil { log.Printf("Error inserting message: %s", err) return "", err } return string(m.ID), nil }
go
func (mongo *MongoDB) Store(m *data.Message) (string, error) { err := mongo.Collection.Insert(m) if err != nil { log.Printf("Error inserting message: %s", err) return "", err } return string(m.ID), nil }
[ "func", "(", "mongo", "*", "MongoDB", ")", "Store", "(", "m", "*", "data", ".", "Message", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "mongo", ".", "Collection", ".", "Insert", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "...
// Store stores a message in MongoDB and returns its storage ID
[ "Store", "stores", "a", "message", "in", "MongoDB", "and", "returns", "its", "storage", "ID" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/mongodb.go#L36-L43
146,130
mailhog/storage
mongodb.go
List
func (mongo *MongoDB) List(start int, limit int) (*data.Messages, error) { messages := &data.Messages{} err := mongo.Collection.Find(bson.M{}).Skip(start).Limit(limit).Sort("-created").Select(bson.M{ "id": 1, "_id": 1, "from": 1, "to": 1, "content.headers": 1...
go
func (mongo *MongoDB) List(start int, limit int) (*data.Messages, error) { messages := &data.Messages{} err := mongo.Collection.Find(bson.M{}).Skip(start).Limit(limit).Sort("-created").Select(bson.M{ "id": 1, "_id": 1, "from": 1, "to": 1, "content.headers": 1...
[ "func", "(", "mongo", "*", "MongoDB", ")", "List", "(", "start", "int", ",", "limit", "int", ")", "(", "*", "data", ".", "Messages", ",", "error", ")", "{", "messages", ":=", "&", "data", ".", "Messages", "{", "}", "\n", "err", ":=", "mongo", "."...
// List returns a list of messages by index
[ "List", "returns", "a", "list", "of", "messages", "by", "index" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/mongodb.go#L82-L99
146,131
mailhog/storage
mongodb.go
DeleteAll
func (mongo *MongoDB) DeleteAll() error { _, err := mongo.Collection.RemoveAll(bson.M{}) return err }
go
func (mongo *MongoDB) DeleteAll() error { _, err := mongo.Collection.RemoveAll(bson.M{}) return err }
[ "func", "(", "mongo", "*", "MongoDB", ")", "DeleteAll", "(", ")", "error", "{", "_", ",", "err", ":=", "mongo", ".", "Collection", ".", "RemoveAll", "(", "bson", ".", "M", "{", "}", ")", "\n", "return", "err", "\n", "}" ]
// DeleteAll deletes all messages stored in MongoDB
[ "DeleteAll", "deletes", "all", "messages", "stored", "in", "MongoDB" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/mongodb.go#L108-L111
146,132
mailhog/storage
mongodb.go
Load
func (mongo *MongoDB) Load(id string) (*data.Message, error) { result := &data.Message{} err := mongo.Collection.Find(bson.M{"id": id}).One(&result) if err != nil { log.Printf("Error loading message: %s", err) return nil, err } return result, nil }
go
func (mongo *MongoDB) Load(id string) (*data.Message, error) { result := &data.Message{} err := mongo.Collection.Find(bson.M{"id": id}).One(&result) if err != nil { log.Printf("Error loading message: %s", err) return nil, err } return result, nil }
[ "func", "(", "mongo", "*", "MongoDB", ")", "Load", "(", "id", "string", ")", "(", "*", "data", ".", "Message", ",", "error", ")", "{", "result", ":=", "&", "data", ".", "Message", "{", "}", "\n", "err", ":=", "mongo", ".", "Collection", ".", "Fin...
// Load loads an individual message by storage ID
[ "Load", "loads", "an", "individual", "message", "by", "storage", "ID" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/mongodb.go#L114-L122
146,133
mailhog/storage
maildir.go
CreateMaildir
func CreateMaildir(path string) *Maildir { if len(path) == 0 { dir, err := ioutil.TempDir("", "mailhog") if err != nil { panic(err) } path = dir } if _, err := os.Stat(path); err != nil { err := os.MkdirAll(path, 0770) if err != nil { panic(err) } } log.Println("Maildir path is", path) return ...
go
func CreateMaildir(path string) *Maildir { if len(path) == 0 { dir, err := ioutil.TempDir("", "mailhog") if err != nil { panic(err) } path = dir } if _, err := os.Stat(path); err != nil { err := os.MkdirAll(path, 0770) if err != nil { panic(err) } } log.Println("Maildir path is", path) return ...
[ "func", "CreateMaildir", "(", "path", "string", ")", "*", "Maildir", "{", "if", "len", "(", "path", ")", "==", "0", "{", "dir", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "...
// CreateMaildir creates a new maildir storage backend
[ "CreateMaildir", "creates", "a", "new", "maildir", "storage", "backend" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/maildir.go#L20-L38
146,134
mailhog/storage
memory.go
CreateInMemory
func CreateInMemory() *InMemory { return &InMemory{ MessageIDIndex: make(map[string]int), Messages: make([]*data.Message, 0), } }
go
func CreateInMemory() *InMemory { return &InMemory{ MessageIDIndex: make(map[string]int), Messages: make([]*data.Message, 0), } }
[ "func", "CreateInMemory", "(", ")", "*", "InMemory", "{", "return", "&", "InMemory", "{", "MessageIDIndex", ":", "make", "(", "map", "[", "string", "]", "int", ")", ",", "Messages", ":", "make", "(", "[", "]", "*", "data", ".", "Message", ",", "0", ...
// CreateInMemory creates a new in memory storage backend
[ "CreateInMemory", "creates", "a", "new", "in", "memory", "storage", "backend" ]
6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa
https://github.com/mailhog/storage/blob/6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa/memory.go#L19-L24
146,135
zbindenren/logrus_mail
mail.go
NewMailHook
func NewMailHook(appname string, host string, port int, from string, to string) (*MailHook, error) { // Connect to the remote SMTP server. c, err := smtp.Dial(host + ":" + strconv.Itoa(port)) if err != nil { return nil, err } // Validate sender and recipient sender, err := mail.ParseAddress(from) if err != ni...
go
func NewMailHook(appname string, host string, port int, from string, to string) (*MailHook, error) { // Connect to the remote SMTP server. c, err := smtp.Dial(host + ":" + strconv.Itoa(port)) if err != nil { return nil, err } // Validate sender and recipient sender, err := mail.ParseAddress(from) if err != ni...
[ "func", "NewMailHook", "(", "appname", "string", ",", "host", "string", ",", "port", "int", ",", "from", "string", ",", "to", "string", ")", "(", "*", "MailHook", ",", "error", ")", "{", "// Connect to the remote SMTP server.", "c", ",", "err", ":=", "smtp...
// NewMailHook creates a hook to be added to an instance of logger.
[ "NewMailHook", "creates", "a", "hook", "to", "be", "added", "to", "an", "instance", "of", "logger", "." ]
14351100bf70956ab9c91c883b1a63809b0d0df7
https://github.com/zbindenren/logrus_mail/blob/14351100bf70956ab9c91c883b1a63809b0d0df7/mail.go#L38-L68
146,136
zbindenren/logrus_mail
mail.go
NewMailAuthHook
func NewMailAuthHook(appname string, host string, port int, from string, to string, username string, password string) (*MailAuthHook, error) { // Check if server listens on that port. conn, err := net.DialTimeout("tcp", host+":"+strconv.Itoa(port), 3*time.Second) if err != nil { return nil, err } defer conn.Clos...
go
func NewMailAuthHook(appname string, host string, port int, from string, to string, username string, password string) (*MailAuthHook, error) { // Check if server listens on that port. conn, err := net.DialTimeout("tcp", host+":"+strconv.Itoa(port), 3*time.Second) if err != nil { return nil, err } defer conn.Clos...
[ "func", "NewMailAuthHook", "(", "appname", "string", ",", "host", "string", ",", "port", "int", ",", "from", "string", ",", "to", "string", ",", "username", "string", ",", "password", "string", ")", "(", "*", "MailAuthHook", ",", "error", ")", "{", "// C...
// NewMailAuthHook creates a hook to be added to an instance of logger.
[ "NewMailAuthHook", "creates", "a", "hook", "to", "be", "added", "to", "an", "instance", "of", "logger", "." ]
14351100bf70956ab9c91c883b1a63809b0d0df7
https://github.com/zbindenren/logrus_mail/blob/14351100bf70956ab9c91c883b1a63809b0d0df7/mail.go#L71-L97
146,137
codeclysm/extract
extractor.go
match
func match(r io.Reader) (io.Reader, types.Type, error) { buffer := make([]byte, 512) n, err := r.Read(buffer) if err != nil && err != io.EOF { return nil, types.Unknown, err } r = io.MultiReader(bytes.NewBuffer(buffer[:n]), r) typ, err := filetype.Match(buffer) return r, typ, err }
go
func match(r io.Reader) (io.Reader, types.Type, error) { buffer := make([]byte, 512) n, err := r.Read(buffer) if err != nil && err != io.EOF { return nil, types.Unknown, err } r = io.MultiReader(bytes.NewBuffer(buffer[:n]), r) typ, err := filetype.Match(buffer) return r, typ, err }
[ "func", "match", "(", "r", "io", ".", "Reader", ")", "(", "io", ".", "Reader", ",", "types", ".", "Type", ",", "error", ")", "{", "buffer", ":=", "make", "(", "[", "]", "byte", ",", "512", ")", "\n\n", "n", ",", "err", ":=", "r", ".", "Read",...
// match reads the first 512 bytes, calls types.Match and returns a reader // for the whole stream
[ "match", "reads", "the", "first", "512", "bytes", "calls", "types", ".", "Match", "and", "returns", "a", "reader", "for", "the", "whole", "stream" ]
cb78af9c8af24b50533f931fa83bdfd4170bf840
https://github.com/codeclysm/extract/blob/cb78af9c8af24b50533f931fa83bdfd4170bf840/extractor.go#L305-L318
146,138
glycerine/go-unsnap-stream
unsnap.go
Dump
func (f *SnappyFile) Dump() { fmt.Printf("EncBuf has length %d and contents:\n%s\n", len(f.EncBuf.Bytes()), string(f.EncBuf.Bytes())) fmt.Printf("DecBuf has length %d and contents:\n%s\n", len(f.DecBuf.Bytes()), string(f.DecBuf.Bytes())) }
go
func (f *SnappyFile) Dump() { fmt.Printf("EncBuf has length %d and contents:\n%s\n", len(f.EncBuf.Bytes()), string(f.EncBuf.Bytes())) fmt.Printf("DecBuf has length %d and contents:\n%s\n", len(f.DecBuf.Bytes()), string(f.DecBuf.Bytes())) }
[ "func", "(", "f", "*", "SnappyFile", ")", "Dump", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\\n", "\"", ",", "len", "(", "f", ".", "EncBuf", ".", "Bytes", "(", ")", ")", ",", "string", "(", "f", ".", "EncBuf", ".", "Bytes", "(",...
// for debugging, show state of buffers
[ "for", "debugging", "show", "state", "of", "buffers" ]
f9677308dec2b35e76737f9713df328ad11b1fea
https://github.com/glycerine/go-unsnap-stream/blob/f9677308dec2b35e76737f9713df328ad11b1fea/unsnap.go#L56-L59
146,139
knq/snaker
snaker.go
CamelToSnake
func CamelToSnake(s string) string { if s == "" { return "" } rs := []rune(s) var r string var lastWasUpper, lastWasLetter, lastWasIsm, isUpper, isLetter bool for i := 0; i < len(rs); { isUpper = unicode.IsUpper(rs[i]) isLetter = unicode.IsLetter(rs[i]) // append _ when last was not upper and not lette...
go
func CamelToSnake(s string) string { if s == "" { return "" } rs := []rune(s) var r string var lastWasUpper, lastWasLetter, lastWasIsm, isUpper, isLetter bool for i := 0; i < len(rs); { isUpper = unicode.IsUpper(rs[i]) isLetter = unicode.IsLetter(rs[i]) // append _ when last was not upper and not lette...
[ "func", "CamelToSnake", "(", "s", "string", ")", "string", "{", "if", "s", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n\n", "rs", ":=", "[", "]", "rune", "(", "s", ")", "\n\n", "var", "r", "string", "\n", "var", "lastWasUpper", ","...
// CamelToSnake converts s to snake_case.
[ "CamelToSnake", "converts", "s", "to", "snake_case", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/snaker.go#L16-L55
146,140
knq/snaker
snaker.go
SnakeToCamel
func SnakeToCamel(s string) string { var r string for _, w := range strings.Split(s, "_") { if w == "" { continue } u := strings.ToUpper(w) if ok := commonInitialisms[u]; ok { r += u } else { r += strings.ToUpper(w[:1]) + strings.ToLower(w[1:]) } } return r }
go
func SnakeToCamel(s string) string { var r string for _, w := range strings.Split(s, "_") { if w == "" { continue } u := strings.ToUpper(w) if ok := commonInitialisms[u]; ok { r += u } else { r += strings.ToUpper(w[:1]) + strings.ToLower(w[1:]) } } return r }
[ "func", "SnakeToCamel", "(", "s", "string", ")", "string", "{", "var", "r", "string", "\n\n", "for", "_", ",", "w", ":=", "range", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", "{", "if", "w", "==", "\"", "\"", "{", "continue", "\n", ...
// SnakeToCamel converts s to CamelCase.
[ "SnakeToCamel", "converts", "s", "to", "CamelCase", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/snaker.go#L63-L80
146,141
knq/snaker
snaker.go
ForceLowerCamelIdentifier
func ForceLowerCamelIdentifier(s string) string { if s == "" { return "" } s = CamelToSnake(s) first := strings.SplitN(s, "_", -1)[0] s = SnakeToCamelIdentifier(s) return strings.ToLower(first) + s[len(first):] }
go
func ForceLowerCamelIdentifier(s string) string { if s == "" { return "" } s = CamelToSnake(s) first := strings.SplitN(s, "_", -1)[0] s = SnakeToCamelIdentifier(s) return strings.ToLower(first) + s[len(first):] }
[ "func", "ForceLowerCamelIdentifier", "(", "s", "string", ")", "string", "{", "if", "s", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n\n", "s", "=", "CamelToSnake", "(", "s", ")", "\n", "first", ":=", "strings", ".", "SplitN", "(", "s", ...
// ForceLowerCamelIdentifier forces the first portion of an identifier to be // lower case.
[ "ForceLowerCamelIdentifier", "forces", "the", "first", "portion", "of", "an", "identifier", "to", "be", "lower", "case", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/snaker.go#L99-L109
146,142
knq/snaker
snaker.go
AddInitialisms
func AddInitialisms(initialisms ...string) error { for _, s := range initialisms { if len(s) < minInitialismLen || len(s) > maxInitialismLen { return fmt.Errorf("%s does not have length between %d and %d", s, minInitialismLen, maxInitialismLen) } commonInitialisms[s] = true } return nil }
go
func AddInitialisms(initialisms ...string) error { for _, s := range initialisms { if len(s) < minInitialismLen || len(s) > maxInitialismLen { return fmt.Errorf("%s does not have length between %d and %d", s, minInitialismLen, maxInitialismLen) } commonInitialisms[s] = true } return nil }
[ "func", "AddInitialisms", "(", "initialisms", "...", "string", ")", "error", "{", "for", "_", ",", "s", ":=", "range", "initialisms", "{", "if", "len", "(", "s", ")", "<", "minInitialismLen", "||", "len", "(", "s", ")", ">", "maxInitialismLen", "{", "r...
// AddInitialisms adds initialisms to the recognized initialisms.
[ "AddInitialisms", "adds", "initialisms", "to", "the", "recognized", "initialisms", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/snaker.go#L112-L121
146,143
knq/snaker
util.go
peekInitialism
func peekInitialism(rs []rune) string { // do no work if len(rs) < minInitialismLen { return "" } // grab at most next maxInitialismLen uppercase characters l := min(len(rs), maxInitialismLen) var z []rune for i := 0; i < l; i++ { if !unicode.IsUpper(rs[i]) { break } z = append(z, rs[i]) } // bail...
go
func peekInitialism(rs []rune) string { // do no work if len(rs) < minInitialismLen { return "" } // grab at most next maxInitialismLen uppercase characters l := min(len(rs), maxInitialismLen) var z []rune for i := 0; i < l; i++ { if !unicode.IsUpper(rs[i]) { break } z = append(z, rs[i]) } // bail...
[ "func", "peekInitialism", "(", "rs", "[", "]", "rune", ")", "string", "{", "// do no work", "if", "len", "(", "rs", ")", "<", "minInitialismLen", "{", "return", "\"", "\"", "\n", "}", "\n\n", "// grab at most next maxInitialismLen uppercase characters", "l", ":=...
// peekInitialism returns the next longest possible initialism in rs.
[ "peekInitialism", "returns", "the", "next", "longest", "possible", "initialism", "in", "rs", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/util.go#L27-L56
146,144
knq/snaker
util.go
replaceBadChars
func replaceBadChars(s string) string { // strip bad characters r := []rune{} for _, ch := range s { if isIdentifierChar(ch) { r = append(r, ch) } else { r = append(r, '_') } } return string(r) }
go
func replaceBadChars(s string) string { // strip bad characters r := []rune{} for _, ch := range s { if isIdentifierChar(ch) { r = append(r, ch) } else { r = append(r, '_') } } return string(r) }
[ "func", "replaceBadChars", "(", "s", "string", ")", "string", "{", "// strip bad characters", "r", ":=", "[", "]", "rune", "{", "}", "\n", "for", "_", ",", "ch", ":=", "range", "s", "{", "if", "isIdentifierChar", "(", "ch", ")", "{", "r", "=", "appen...
// replaceBadChars strips characters and character sequences that are invalid // characters for Go identifiers.
[ "replaceBadChars", "strips", "characters", "and", "character", "sequences", "that", "are", "invalid", "characters", "for", "Go", "identifiers", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/util.go#L68-L80
146,145
knq/snaker
util.go
toIdentifier
func toIdentifier(s string) string { // replace bad chars with _ s = replaceBadChars(strings.TrimSpace(s)) // fix 2 or more __ and remove leading numbers/underscores s = underscoreRE.ReplaceAllString(s, "_") s = leadingRE.ReplaceAllString(s, "_") // remove leading/trailing underscores s = strings.TrimLeft(s, "...
go
func toIdentifier(s string) string { // replace bad chars with _ s = replaceBadChars(strings.TrimSpace(s)) // fix 2 or more __ and remove leading numbers/underscores s = underscoreRE.ReplaceAllString(s, "_") s = leadingRE.ReplaceAllString(s, "_") // remove leading/trailing underscores s = strings.TrimLeft(s, "...
[ "func", "toIdentifier", "(", "s", "string", ")", "string", "{", "// replace bad chars with _", "s", "=", "replaceBadChars", "(", "strings", ".", "TrimSpace", "(", "s", ")", ")", "\n\n", "// fix 2 or more __ and remove leading numbers/underscores", "s", "=", "underscor...
// toIdentifier cleans up a string so that it is usable as an identifier.
[ "toIdentifier", "cleans", "up", "a", "string", "so", "that", "it", "is", "usable", "as", "an", "identifier", "." ]
2bc8a4db468777180ca38d551094b83073bed25f
https://github.com/knq/snaker/blob/2bc8a4db468777180ca38d551094b83073bed25f/util.go#L89-L102
146,146
xo/xoutil
xoutil.go
Scan
func (t *SqTime) Scan(v interface{}) error { switch x := v.(type) { case time.Time: t.Time = x return nil case []byte: return t.parse(string(x)) case string: return t.parse(x) } return fmt.Errorf("cannot convert type %s to time.Time", reflect.TypeOf(v)) }
go
func (t *SqTime) Scan(v interface{}) error { switch x := v.(type) { case time.Time: t.Time = x return nil case []byte: return t.parse(string(x)) case string: return t.parse(x) } return fmt.Errorf("cannot convert type %s to time.Time", reflect.TypeOf(v)) }
[ "func", "(", "t", "*", "SqTime", ")", "Scan", "(", "v", "interface", "{", "}", ")", "error", "{", "switch", "x", ":=", "v", ".", "(", "type", ")", "{", "case", "time", ".", "Time", ":", "t", ".", "Time", "=", "x", "\n", "return", "nil", "\n",...
// Scan satisfies the Scanner interface.
[ "Scan", "satisfies", "the", "Scanner", "interface", "." ]
46189f4026a5a53537a3d5b99092accf968d572b
https://github.com/xo/xoutil/blob/46189f4026a5a53537a3d5b99092accf968d572b/xoutil.go#L27-L40
146,147
xo/xoutil
xoutil.go
parse
func (t *SqTime) parse(s string) error { if s == "" { return nil } for _, f := range sqlite3.SQLiteTimestampFormats { z, err := time.Parse(f, s) if err == nil { t.Time = z return nil } } return errors.New("could not parse time") }
go
func (t *SqTime) parse(s string) error { if s == "" { return nil } for _, f := range sqlite3.SQLiteTimestampFormats { z, err := time.Parse(f, s) if err == nil { t.Time = z return nil } } return errors.New("could not parse time") }
[ "func", "(", "t", "*", "SqTime", ")", "parse", "(", "s", "string", ")", "error", "{", "if", "s", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "for", "_", ",", "f", ":=", "range", "sqlite3", ".", "SQLiteTimestampFormats", "{", "z", "...
// parse attempts to parse string s to t.
[ "parse", "attempts", "to", "parse", "string", "s", "to", "t", "." ]
46189f4026a5a53537a3d5b99092accf968d572b
https://github.com/xo/xoutil/blob/46189f4026a5a53537a3d5b99092accf968d572b/xoutil.go#L43-L57
146,148
mreiferson/go-snappystream
writer.go
NewBufferedWriter
func NewBufferedWriter(w io.Writer) *BufferedWriter { _w := NewWriter(w).(*writer) return &BufferedWriter{ w: _w, bw: bufio.NewWriterSize(_w, MaxBlockSize), } }
go
func NewBufferedWriter(w io.Writer) *BufferedWriter { _w := NewWriter(w).(*writer) return &BufferedWriter{ w: _w, bw: bufio.NewWriterSize(_w, MaxBlockSize), } }
[ "func", "NewBufferedWriter", "(", "w", "io", ".", "Writer", ")", "*", "BufferedWriter", "{", "_w", ":=", "NewWriter", "(", "w", ")", ".", "(", "*", "writer", ")", "\n", "return", "&", "BufferedWriter", "{", "w", ":", "_w", ",", "bw", ":", "bufio", ...
// NewBufferedWriter allocates and returns a BufferedWriter with an internal // buffer of MaxBlockSize bytes. If an error occurs writing a block to w, all // future writes will fail with the same error. After all data has been // written, the client should call the Flush method to guarantee all data has // been forwa...
[ "NewBufferedWriter", "allocates", "and", "returns", "a", "BufferedWriter", "with", "an", "internal", "buffer", "of", "MaxBlockSize", "bytes", ".", "If", "an", "error", "occurs", "writing", "a", "block", "to", "w", "all", "future", "writes", "will", "fail", "wi...
028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
https://github.com/mreiferson/go-snappystream/blob/028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504/writer.go#L38-L44
146,149
mreiferson/go-snappystream
writer.go
Close
func (w *BufferedWriter) Close() error { if w.err != nil { return w.err } w.err = w.bw.Flush() w.w = nil w.bw = nil if w.err != nil { return w.err } w.err = errClosed return nil }
go
func (w *BufferedWriter) Close() error { if w.err != nil { return w.err } w.err = w.bw.Flush() w.w = nil w.bw = nil if w.err != nil { return w.err } w.err = errClosed return nil }
[ "func", "(", "w", "*", "BufferedWriter", ")", "Close", "(", ")", "error", "{", "if", "w", ".", "err", "!=", "nil", "{", "return", "w", ".", "err", "\n", "}", "\n\n", "w", ".", "err", "=", "w", ".", "bw", ".", "Flush", "(", ")", "\n", "w", "...
// Close flushes w's internal buffer and tears down internal data structures. // After a successful call to Close method calls on w return an error. Close // makes no attempt to close the underlying writer.
[ "Close", "flushes", "w", "s", "internal", "buffer", "and", "tears", "down", "internal", "data", "structures", ".", "After", "a", "successful", "call", "to", "Close", "method", "calls", "on", "w", "return", "an", "error", ".", "Close", "makes", "no", "attem...
028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
https://github.com/mreiferson/go-snappystream/blob/028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504/writer.go#L90-L105
146,150
mreiferson/go-snappystream
writer.go
write
func (w *writer) write(p []byte) (int, error) { var err error if len(p) > MaxBlockSize { return 0, errors.New(fmt.Sprintf("block too large %d > %d", len(p), MaxBlockSize)) } w.dst = w.dst[:cap(w.dst)] // Encode does dumb resize w/o context. reslice avoids alloc. w.dst, err = snappy.Encode(w.dst, p) if err != ...
go
func (w *writer) write(p []byte) (int, error) { var err error if len(p) > MaxBlockSize { return 0, errors.New(fmt.Sprintf("block too large %d > %d", len(p), MaxBlockSize)) } w.dst = w.dst[:cap(w.dst)] // Encode does dumb resize w/o context. reslice avoids alloc. w.dst, err = snappy.Encode(w.dst, p) if err != ...
[ "func", "(", "w", "*", "writer", ")", "write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "var", "err", "error", "\n\n", "if", "len", "(", "p", ")", ">", "MaxBlockSize", "{", "return", "0", ",", "errors", ".", "New", ...
// write attempts to encode p as a block and write it to the underlying writer. // The returned int may not equal p's length if compression below // MaxBlockSize-4 could not be achieved.
[ "write", "attempts", "to", "encode", "p", "as", "a", "block", "and", "write", "it", "to", "the", "underlying", "writer", ".", "The", "returned", "int", "may", "not", "equal", "p", "s", "length", "if", "compression", "below", "MaxBlockSize", "-", "4", "co...
028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
https://github.com/mreiferson/go-snappystream/blob/028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504/writer.go#L162-L211
146,151
mreiferson/go-snappystream
reader.go
WriteTo
func (r *reader) WriteTo(w io.Writer) (int64, error) { if r.err != nil { return 0, r.err } n, err := r.buf.WriteTo(w) if err != nil { // r.err doesn't need to be set because a write error occurred and the // stream hasn't been corrupted. return n, err } // pass a bufferFallbackWriter to nextFrame so tha...
go
func (r *reader) WriteTo(w io.Writer) (int64, error) { if r.err != nil { return 0, r.err } n, err := r.buf.WriteTo(w) if err != nil { // r.err doesn't need to be set because a write error occurred and the // stream hasn't been corrupted. return n, err } // pass a bufferFallbackWriter to nextFrame so tha...
[ "func", "(", "r", "*", "reader", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "if", "r", ".", "err", "!=", "nil", "{", "return", "0", ",", "r", ".", "err", "\n", "}", "\n\n", "n", ",", "err", ":=...
// WriteTo implements the io.WriterTo interface used by io.Copy. It writes // decoded data from the underlying reader to w. WriteTo returns the number of // bytes written along with any error encountered.
[ "WriteTo", "implements", "the", "io", ".", "WriterTo", "interface", "used", "by", "io", ".", "Copy", ".", "It", "writes", "decoded", "data", "from", "the", "underlying", "reader", "to", "w", ".", "WriteTo", "returns", "the", "number", "of", "bytes", "writt...
028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
https://github.com/mreiferson/go-snappystream/blob/028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504/reader.go#L63-L101
146,152
mreiferson/go-snappystream
reader.go
Write
func (w *bufferFallbackWriter) Write(b []byte) (int, error) { if w.writerErr != nil { return w.buf.Write(b) } n, err := w.w.Write(b) w.n += int64(n) if err != nil { // begin buffering input. bytes.Buffer does not return errors and so we // do not need complex error handling here. w.writerErr = err w.Writ...
go
func (w *bufferFallbackWriter) Write(b []byte) (int, error) { if w.writerErr != nil { return w.buf.Write(b) } n, err := w.w.Write(b) w.n += int64(n) if err != nil { // begin buffering input. bytes.Buffer does not return errors and so we // do not need complex error handling here. w.writerErr = err w.Writ...
[ "func", "(", "w", "*", "bufferFallbackWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "w", ".", "writerErr", "!=", "nil", "{", "return", "w", ".", "buf", ".", "Write", "(", "b", ")", "\n", "}", ...
// Write attempts to write b to the underlying io.Writer. If the underlying // writer fails or has failed previously unwritten bytes are buffered // internally. Write never returns an error but may panic with // bytes.ErrTooLarge if the buffer grows too large.
[ "Write", "attempts", "to", "write", "b", "to", "the", "underlying", "io", ".", "Writer", ".", "If", "the", "underlying", "writer", "fails", "or", "has", "failed", "previously", "unwritten", "bytes", "are", "buffered", "internally", ".", "Write", "never", "re...
028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
https://github.com/mreiferson/go-snappystream/blob/028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504/reader.go#L123-L137
146,153
mreiferson/go-snappystream
reader.go
noeof
func noeof(n int, err error) (int, error) { if err == io.EOF { return n, io.ErrUnexpectedEOF } return n, err }
go
func noeof(n int, err error) (int, error) { if err == io.EOF { return n, io.ErrUnexpectedEOF } return n, err }
[ "func", "noeof", "(", "n", "int", ",", "err", "error", ")", "(", "int", ",", "error", ")", "{", "if", "err", "==", "io", ".", "EOF", "{", "return", "n", ",", "io", ".", "ErrUnexpectedEOF", "\n", "}", "\n", "return", "n", ",", "err", "\n", "}" ]
// noeof is used after reads in situations where EOF signifies invalid // formatting or corruption.
[ "noeof", "is", "used", "after", "reads", "in", "situations", "where", "EOF", "signifies", "invalid", "formatting", "or", "corruption", "." ]
028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
https://github.com/mreiferson/go-snappystream/blob/028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504/reader.go#L307-L312
146,154
remogatto/prettytest
assertions.go
Equal
func (s *Suite) Equal(exp, act interface{}, messages ...string) *Assertion { actType := reflect.TypeOf(act) expType := reflect.TypeOf(exp) assertion := s.setup(fmt.Sprintf("Expected %v[%s] to be equal to %v[%s]", act, actType, exp, expType), messages) if exp != act { assertion.fail() } return assertion }
go
func (s *Suite) Equal(exp, act interface{}, messages ...string) *Assertion { actType := reflect.TypeOf(act) expType := reflect.TypeOf(exp) assertion := s.setup(fmt.Sprintf("Expected %v[%s] to be equal to %v[%s]", act, actType, exp, expType), messages) if exp != act { assertion.fail() } return assertion }
[ "func", "(", "s", "*", "Suite", ")", "Equal", "(", "exp", ",", "act", "interface", "{", "}", ",", "messages", "...", "string", ")", "*", "Assertion", "{", "actType", ":=", "reflect", ".", "TypeOf", "(", "act", ")", "\n", "expType", ":=", "reflect", ...
// Equal asserts that the expected value equals the actual value.
[ "Equal", "asserts", "that", "the", "expected", "value", "equals", "the", "actual", "value", "." ]
8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80
https://github.com/remogatto/prettytest/blob/8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80/assertions.go#L47-L55
146,155
remogatto/prettytest
assertions.go
Path
func (s *Suite) Path(path string, messages ...string) *Assertion { assertion := s.setup(fmt.Sprintf("Path %s doesn't exist", path), messages) if _, err := os.Stat(path); err != nil { assertion.fail() } return assertion }
go
func (s *Suite) Path(path string, messages ...string) *Assertion { assertion := s.setup(fmt.Sprintf("Path %s doesn't exist", path), messages) if _, err := os.Stat(path); err != nil { assertion.fail() } return assertion }
[ "func", "(", "s", "*", "Suite", ")", "Path", "(", "path", "string", ",", "messages", "...", "string", ")", "*", "Assertion", "{", "assertion", ":=", "s", ".", "setup", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "path", ")", ",", "messages", ...
// Path asserts that the given path exists.
[ "Path", "asserts", "that", "the", "given", "path", "exists", "." ]
8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80
https://github.com/remogatto/prettytest/blob/8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80/assertions.go#L67-L73
146,156
remogatto/prettytest
assertions.go
Nil
func (s *Suite) Nil(value interface{}, messages ...string) *Assertion { assertion := s.setup(fmt.Sprintf("Value %v is not nil", value), messages) if value == nil { return assertion } val := reflect.ValueOf(value) val.Kind() switch v := reflect.ValueOf(value); v.Kind() { case reflect.Chan, reflect.Func, reflect...
go
func (s *Suite) Nil(value interface{}, messages ...string) *Assertion { assertion := s.setup(fmt.Sprintf("Value %v is not nil", value), messages) if value == nil { return assertion } val := reflect.ValueOf(value) val.Kind() switch v := reflect.ValueOf(value); v.Kind() { case reflect.Chan, reflect.Func, reflect...
[ "func", "(", "s", "*", "Suite", ")", "Nil", "(", "value", "interface", "{", "}", ",", "messages", "...", "string", ")", "*", "Assertion", "{", "assertion", ":=", "s", ".", "setup", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "value", ")", "...
// Nil asserts that the value is nil.
[ "Nil", "asserts", "that", "the", "value", "is", "nil", "." ]
8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80
https://github.com/remogatto/prettytest/blob/8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80/assertions.go#L76-L90
146,157
remogatto/prettytest
assertions.go
Error
func (s *Suite) Error(args ...interface{}) { assertion := s.setup("", []string{}) assertion.testFunc.Status = STATUS_FAIL assertion.ErrorMessage = fmt.Sprint(args...) assertion.fail() }
go
func (s *Suite) Error(args ...interface{}) { assertion := s.setup("", []string{}) assertion.testFunc.Status = STATUS_FAIL assertion.ErrorMessage = fmt.Sprint(args...) assertion.fail() }
[ "func", "(", "s", "*", "Suite", ")", "Error", "(", "args", "...", "interface", "{", "}", ")", "{", "assertion", ":=", "s", ".", "setup", "(", "\"", "\"", ",", "[", "]", "string", "{", "}", ")", "\n", "assertion", ".", "testFunc", ".", "Status", ...
// Error logs an error and marks the test function as failed.
[ "Error", "logs", "an", "error", "and", "marks", "the", "test", "function", "as", "failed", "." ]
8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80
https://github.com/remogatto/prettytest/blob/8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80/assertions.go#L93-L98
146,158
abramovic/logrus_influxdb
influxdb.go
newInfluxDBClient
func (hook *InfluxDBHook) newInfluxDBClient(config *Config) (influxdb.Client, error) { protocol := "http" if config.UseHTTPS { protocol = "https" } return influxdb.NewHTTPClient(influxdb.HTTPConfig{ Addr: fmt.Sprintf("%s://%s:%d", protocol, config.Host, config.Port), Username: config.Username, Password:...
go
func (hook *InfluxDBHook) newInfluxDBClient(config *Config) (influxdb.Client, error) { protocol := "http" if config.UseHTTPS { protocol = "https" } return influxdb.NewHTTPClient(influxdb.HTTPConfig{ Addr: fmt.Sprintf("%s://%s:%d", protocol, config.Host, config.Port), Username: config.Username, Password:...
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "newInfluxDBClient", "(", "config", "*", "Config", ")", "(", "influxdb", ".", "Client", ",", "error", ")", "{", "protocol", ":=", "\"", "\"", "\n", "if", "config", ".", "UseHTTPS", "{", "protocol", "=", "\...
// Returns an influxdb client
[ "Returns", "an", "influxdb", "client" ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/influxdb.go#L10-L21
146,159
abramovic/logrus_influxdb
influxdb.go
queryDB
func (hook *InfluxDBHook) queryDB(cmd string) ([]influxdb.Result, error) { response, err := hook.client.Query(influxdb.Query{ Command: cmd, Database: hook.database, }) if err != nil { return nil, err } if response.Error() != nil { return nil, response.Error() } return response.Results, nil }
go
func (hook *InfluxDBHook) queryDB(cmd string) ([]influxdb.Result, error) { response, err := hook.client.Query(influxdb.Query{ Command: cmd, Database: hook.database, }) if err != nil { return nil, err } if response.Error() != nil { return nil, response.Error() } return response.Results, nil }
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "queryDB", "(", "cmd", "string", ")", "(", "[", "]", "influxdb", ".", "Result", ",", "error", ")", "{", "response", ",", "err", ":=", "hook", ".", "client", ".", "Query", "(", "influxdb", ".", "Query", ...
// queryDB convenience function to query the database
[ "queryDB", "convenience", "function", "to", "query", "the", "database" ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/influxdb.go#L38-L50
146,160
abramovic/logrus_influxdb
influxdb.go
databaseExists
func (hook *InfluxDBHook) databaseExists() (err error) { results, err := hook.queryDB("SHOW DATABASES") if err != nil { return err } if results == nil || len(results) == 0 { return fmt.Errorf("Missing results from InfluxDB query response") } if results[0].Series == nil || len(results[0].Series) == 0 { retur...
go
func (hook *InfluxDBHook) databaseExists() (err error) { results, err := hook.queryDB("SHOW DATABASES") if err != nil { return err } if results == nil || len(results) == 0 { return fmt.Errorf("Missing results from InfluxDB query response") } if results[0].Series == nil || len(results[0].Series) == 0 { retur...
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "databaseExists", "(", ")", "(", "err", "error", ")", "{", "results", ",", "err", ":=", "hook", ".", "queryDB", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", ...
// Return back an error if the database does not exist in InfluxDB
[ "Return", "back", "an", "error", "if", "the", "database", "does", "not", "exist", "in", "InfluxDB" ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/influxdb.go#L53-L76
146,161
abramovic/logrus_influxdb
influxdb.go
autocreateDatabase
func (hook *InfluxDBHook) autocreateDatabase() (err error) { err = hook.databaseExists() if err == nil { return nil } _, err = hook.queryDB(fmt.Sprintf("CREATE DATABASE %s", hook.database)) if err != nil { return err } return nil }
go
func (hook *InfluxDBHook) autocreateDatabase() (err error) { err = hook.databaseExists() if err == nil { return nil } _, err = hook.queryDB(fmt.Sprintf("CREATE DATABASE %s", hook.database)) if err != nil { return err } return nil }
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "autocreateDatabase", "(", ")", "(", "err", "error", ")", "{", "err", "=", "hook", ".", "databaseExists", "(", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "_", ",", "err...
// Try to detect if the database exists and if not, automatically create one.
[ "Try", "to", "detect", "if", "the", "database", "exists", "and", "if", "not", "automatically", "create", "one", "." ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/influxdb.go#L79-L89
146,162
abramovic/logrus_influxdb
logrus_influxdb.go
NewInfluxDB
func NewInfluxDB(config *Config, clients ...influxdb.Client) (hook *InfluxDBHook, err error) { if config == nil { config = &Config{} } config.defaults() var client influxdb.Client if len(clients) == 0 { client, err = hook.newInfluxDBClient(config) if err != nil { return nil, fmt.Errorf("NewInfluxDB: Erro...
go
func NewInfluxDB(config *Config, clients ...influxdb.Client) (hook *InfluxDBHook, err error) { if config == nil { config = &Config{} } config.defaults() var client influxdb.Client if len(clients) == 0 { client, err = hook.newInfluxDBClient(config) if err != nil { return nil, fmt.Errorf("NewInfluxDB: Erro...
[ "func", "NewInfluxDB", "(", "config", "*", "Config", ",", "clients", "...", "influxdb", ".", "Client", ")", "(", "hook", "*", "InfluxDBHook", ",", "err", "error", ")", "{", "if", "config", "==", "nil", "{", "config", "=", "&", "Config", "{", "}", "\n...
// NewInfluxDB returns a new InfluxDBHook.
[ "NewInfluxDB", "returns", "a", "new", "InfluxDBHook", "." ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/logrus_influxdb.go#L35-L76
146,163
abramovic/logrus_influxdb
logrus_influxdb.go
Fire
func (hook *InfluxDBHook) Fire(entry *logrus.Entry) (err error) { // If passing a "message" field then it will be overridden by the entry Message entry.Data["message"] = entry.Message measurement := hook.measurement if result, ok := getTag(entry.Data, "measurement"); ok { measurement = result } tags := make(m...
go
func (hook *InfluxDBHook) Fire(entry *logrus.Entry) (err error) { // If passing a "message" field then it will be overridden by the entry Message entry.Data["message"] = entry.Message measurement := hook.measurement if result, ok := getTag(entry.Data, "measurement"); ok { measurement = result } tags := make(m...
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "Fire", "(", "entry", "*", "logrus", ".", "Entry", ")", "(", "err", "error", ")", "{", "// If passing a \"message\" field then it will be overridden by the entry Message", "entry", ".", "Data", "[", "\"", "\"", "]", ...
// Fire adds a new InfluxDB point based off of Logrus entry
[ "Fire", "adds", "a", "new", "InfluxDB", "point", "based", "off", "of", "Logrus", "entry" ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/logrus_influxdb.go#L79-L114
146,164
abramovic/logrus_influxdb
logrus_influxdb.go
writePoints
func (hook *InfluxDBHook) writePoints() (err error) { if hook.batchP == nil { return nil } err = hook.client.Write(hook.batchP) // Note: the InfluxDB client doesn't give us any good way to determine the reason for // a failure (bad syntax, invalid type, failed connection, etc.), so there is no // point in retry...
go
func (hook *InfluxDBHook) writePoints() (err error) { if hook.batchP == nil { return nil } err = hook.client.Write(hook.batchP) // Note: the InfluxDB client doesn't give us any good way to determine the reason for // a failure (bad syntax, invalid type, failed connection, etc.), so there is no // point in retry...
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "writePoints", "(", ")", "(", "err", "error", ")", "{", "if", "hook", ".", "batchP", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "err", "=", "hook", ".", "client", ".", "Write", "(", "hook", ...
// writePoints writes the batched log entries to InfluxDB.
[ "writePoints", "writes", "the", "batched", "log", "entries", "to", "InfluxDB", "." ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/logrus_influxdb.go#L135-L150
146,165
abramovic/logrus_influxdb
logrus_influxdb.go
handleBatch
func (hook *InfluxDBHook) handleBatch() { if hook.batchInterval == 0 || hook.batchCount == 0 { // we don't need to process this if the interval is 0 return } for { time.Sleep(hook.batchInterval) hook.Lock() hook.writePoints() hook.Unlock() } }
go
func (hook *InfluxDBHook) handleBatch() { if hook.batchInterval == 0 || hook.batchCount == 0 { // we don't need to process this if the interval is 0 return } for { time.Sleep(hook.batchInterval) hook.Lock() hook.writePoints() hook.Unlock() } }
[ "func", "(", "hook", "*", "InfluxDBHook", ")", "handleBatch", "(", ")", "{", "if", "hook", ".", "batchInterval", "==", "0", "||", "hook", ".", "batchCount", "==", "0", "{", "// we don't need to process this if the interval is 0", "return", "\n", "}", "\n", "fo...
// we will periodically flush your points to influxdb.
[ "we", "will", "periodically", "flush", "your", "points", "to", "influxdb", "." ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/logrus_influxdb.go#L153-L164
146,166
abramovic/logrus_influxdb
config.go
defaults
func (c *Config) defaults() { if c.Host == "" { c.Host = defaultHost } if c.Port == 0 { c.Port = defaultPort } if c.Timeout == 0 { c.Timeout = 100 * time.Millisecond } if c.Database == "" { c.Database = defaultDatabase } if c.Username == "" { c.Username = os.Getenv("INFLUX_USER") } if c.Password ==...
go
func (c *Config) defaults() { if c.Host == "" { c.Host = defaultHost } if c.Port == 0 { c.Port = defaultPort } if c.Timeout == 0 { c.Timeout = 100 * time.Millisecond } if c.Database == "" { c.Database = defaultDatabase } if c.Username == "" { c.Username = os.Getenv("INFLUX_USER") } if c.Password ==...
[ "func", "(", "c", "*", "Config", ")", "defaults", "(", ")", "{", "if", "c", ".", "Host", "==", "\"", "\"", "{", "c", ".", "Host", "=", "defaultHost", "\n", "}", "\n", "if", "c", ".", "Port", "==", "0", "{", "c", ".", "Port", "=", "defaultPort...
// Set the default configurations
[ "Set", "the", "default", "configurations" ]
8f4523eb7e78339191e8abdd0234c04b65363216
https://github.com/abramovic/logrus_influxdb/blob/8f4523eb7e78339191e8abdd0234c04b65363216/config.go#L32-L66
146,167
remogatto/prettytest
pta/main.go
matches
func matches(s, pattern string) bool { return regexp.MustCompile(pattern).MatchString(s) }
go
func matches(s, pattern string) bool { return regexp.MustCompile(pattern).MatchString(s) }
[ "func", "matches", "(", "s", ",", "pattern", "string", ")", "bool", "{", "return", "regexp", ".", "MustCompile", "(", "pattern", ")", ".", "MatchString", "(", "s", ")", "\n", "}" ]
// Returns whether 's' matches 'pattern'
[ "Returns", "whether", "s", "matches", "pattern" ]
8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80
https://github.com/remogatto/prettytest/blob/8b5d7bfe964e8ebf97cb7b45bb2528f0d7ceef80/pta/main.go#L161-L163
146,168
vito/go-interact
interact/interaction.go
NewInteraction
func NewInteraction(prompt string, choices ...Choice) Interaction { return Interaction{ Input: os.Stdin, Output: os.Stdout, Prompt: prompt, Choices: choices, } }
go
func NewInteraction(prompt string, choices ...Choice) Interaction { return Interaction{ Input: os.Stdin, Output: os.Stdout, Prompt: prompt, Choices: choices, } }
[ "func", "NewInteraction", "(", "prompt", "string", ",", "choices", "...", "Choice", ")", "Interaction", "{", "return", "Interaction", "{", "Input", ":", "os", ".", "Stdin", ",", "Output", ":", "os", ".", "Stdout", ",", "Prompt", ":", "prompt", ",", "Choi...
// NewInteraction constructs an interaction with the given prompt, limited to // the given choices, if any. // // Defaults Input and Output to os.Stdin and os.Stderr, respectively.
[ "NewInteraction", "constructs", "an", "interaction", "with", "the", "given", "prompt", "limited", "to", "the", "given", "choices", "if", "any", ".", "Defaults", "Input", "and", "Output", "to", "os", ".", "Stdin", "and", "os", ".", "Stderr", "respectively", "...
fa338ed9e9ecbb0e9c2e6c7a0160d9fc9b0efbd9
https://github.com/vito/go-interact/blob/fa338ed9e9ecbb0e9c2e6c7a0160d9fc9b0efbd9/interact/interaction.go#L27-L34
146,169
vito/go-interact
interact/terminal/terminal.go
writeWithCRLF
func writeWithCRLF(w io.Writer, buf []byte) (n int, err error) { for len(buf) > 0 { i := bytes.IndexByte(buf, '\n') todo := len(buf) if i >= 0 { todo = i } var nn int nn, err = w.Write(buf[:todo]) n += nn if err != nil { return n, err } buf = buf[todo:] if i >= 0 { if _, err = w.Write(...
go
func writeWithCRLF(w io.Writer, buf []byte) (n int, err error) { for len(buf) > 0 { i := bytes.IndexByte(buf, '\n') todo := len(buf) if i >= 0 { todo = i } var nn int nn, err = w.Write(buf[:todo]) n += nn if err != nil { return n, err } buf = buf[todo:] if i >= 0 { if _, err = w.Write(...
[ "func", "writeWithCRLF", "(", "w", "io", ".", "Writer", ",", "buf", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "for", "len", "(", "buf", ")", ">", "0", "{", "i", ":=", "bytes", ".", "IndexByte", "(", "buf", ",", "'...
// writeWithCRLF writes buf to w but replaces all occurrences of \n with \r\n.
[ "writeWithCRLF", "writes", "buf", "to", "w", "but", "replaces", "all", "occurrences", "of", "\\", "n", "with", "\\", "r", "\\", "n", "." ]
fa338ed9e9ecbb0e9c2e6c7a0160d9fc9b0efbd9
https://github.com/vito/go-interact/blob/fa338ed9e9ecbb0e9c2e6c7a0160d9fc9b0efbd9/interact/terminal/terminal.go#L604-L630
146,170
vito/go-interact
interact/terminal/terminal.go
readPasswordLine
func readPasswordLine(reader io.Reader) ([]byte, error) { var buf [1]byte var ret []byte for { n, err := reader.Read(buf[:]) if n > 0 { switch buf[0] { case '\n': return ret, nil case '\r': // remove \r from passwords on Windows default: ret = append(ret, buf[0]) } continue } i...
go
func readPasswordLine(reader io.Reader) ([]byte, error) { var buf [1]byte var ret []byte for { n, err := reader.Read(buf[:]) if n > 0 { switch buf[0] { case '\n': return ret, nil case '\r': // remove \r from passwords on Windows default: ret = append(ret, buf[0]) } continue } i...
[ "func", "readPasswordLine", "(", "reader", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "[", "1", "]", "byte", "\n", "var", "ret", "[", "]", "byte", "\n\n", "for", "{", "n", ",", "err", ":=", "reader", ...
// readPasswordLine reads from reader until it finds \n or io.EOF. // The slice returned does not include the \n. // readPasswordLine also ignores any \r it finds.
[ "readPasswordLine", "reads", "from", "reader", "until", "it", "finds", "\\", "n", "or", "io", ".", "EOF", ".", "The", "slice", "returned", "does", "not", "include", "the", "\\", "n", ".", "readPasswordLine", "also", "ignores", "any", "\\", "r", "it", "fi...
fa338ed9e9ecbb0e9c2e6c7a0160d9fc9b0efbd9
https://github.com/vito/go-interact/blob/fa338ed9e9ecbb0e9c2e6c7a0160d9fc9b0efbd9/interact/terminal/terminal.go#L934-L958
146,171
golangplus/fmt
fmt.go
Printfln
func Printfln(format string, a ...interface{}) (n int, err error) { return Fprintfln(os.Stdout, format, a...) }
go
func Printfln(format string, a ...interface{}) (n int, err error) { return Fprintfln(os.Stdout, format, a...) }
[ "func", "Printfln", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "Fprintfln", "(", "os", ".", "Stdout", ",", "format", ",", "a", "...", ")", "\n", "}" ]
// Printfln is similar to fmt.Printf but a newline is appended.
[ "Printfln", "is", "similar", "to", "fmt", ".", "Printf", "but", "a", "newline", "is", "appended", "." ]
2a5d6d7d2995baf7d847b7f16ac0179c6888d37b
https://github.com/golangplus/fmt/blob/2a5d6d7d2995baf7d847b7f16ac0179c6888d37b/fmt.go#L10-L12
146,172
golangplus/fmt
fmt.go
Fprintfln
func Fprintfln(w io.Writer, format string, a ...interface{}) (n int, err error) { return fmt.Fprintf(w, format+"\n", a...) }
go
func Fprintfln(w io.Writer, format string, a ...interface{}) (n int, err error) { return fmt.Fprintf(w, format+"\n", a...) }
[ "func", "Fprintfln", "(", "w", "io", ".", "Writer", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "fmt", ".", "Fprintf", "(", "w", ",", "format", "+", "\"", "\\n", ...
// Fprintfln is similar to fmt.Fprintf but a newline is appended.
[ "Fprintfln", "is", "similar", "to", "fmt", ".", "Fprintf", "but", "a", "newline", "is", "appended", "." ]
2a5d6d7d2995baf7d847b7f16ac0179c6888d37b
https://github.com/golangplus/fmt/blob/2a5d6d7d2995baf7d847b7f16ac0179c6888d37b/fmt.go#L15-L17
146,173
golangplus/fmt
fmt.go
Eprint
func Eprint(a ...interface{}) (n int, err error) { return fmt.Fprint(os.Stderr, a...) }
go
func Eprint(a ...interface{}) (n int, err error) { return fmt.Fprint(os.Stderr, a...) }
[ "func", "Eprint", "(", "a", "...", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "fmt", ".", "Fprint", "(", "os", ".", "Stderr", ",", "a", "...", ")", "\n", "}" ]
// Eprint is similar to fmt.Print but output to os.Stderr
[ "Eprint", "is", "similar", "to", "fmt", ".", "Print", "but", "output", "to", "os", ".", "Stderr" ]
2a5d6d7d2995baf7d847b7f16ac0179c6888d37b
https://github.com/golangplus/fmt/blob/2a5d6d7d2995baf7d847b7f16ac0179c6888d37b/fmt.go#L20-L22
146,174
golangplus/fmt
fmt.go
Eprintf
func Eprintf(format string, a ...interface{}) (n int, err error) { return fmt.Fprintf(os.Stderr, format, a...) }
go
func Eprintf(format string, a ...interface{}) (n int, err error) { return fmt.Fprintf(os.Stderr, format, a...) }
[ "func", "Eprintf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "format", ",", "a", "...", ")", "\n", "}" ]
// Eprintf is similar to fmt.Printf but output to os.Stderr
[ "Eprintf", "is", "similar", "to", "fmt", ".", "Printf", "but", "output", "to", "os", ".", "Stderr" ]
2a5d6d7d2995baf7d847b7f16ac0179c6888d37b
https://github.com/golangplus/fmt/blob/2a5d6d7d2995baf7d847b7f16ac0179c6888d37b/fmt.go#L25-L27
146,175
golangplus/fmt
fmt.go
Eprintln
func Eprintln(a ...interface{}) (n int, err error) { return fmt.Fprintln(os.Stderr, a...) }
go
func Eprintln(a ...interface{}) (n int, err error) { return fmt.Fprintln(os.Stderr, a...) }
[ "func", "Eprintln", "(", "a", "...", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "fmt", ".", "Fprintln", "(", "os", ".", "Stderr", ",", "a", "...", ")", "\n", "}" ]
// Eprintln is similar to fmt.Println but output to os.Stderr
[ "Eprintln", "is", "similar", "to", "fmt", ".", "Println", "but", "output", "to", "os", ".", "Stderr" ]
2a5d6d7d2995baf7d847b7f16ac0179c6888d37b
https://github.com/golangplus/fmt/blob/2a5d6d7d2995baf7d847b7f16ac0179c6888d37b/fmt.go#L30-L32
146,176
golangplus/fmt
fmt.go
Eprintfln
func Eprintfln(format string, a ...interface{}) (n int, err error) { return Fprintfln(os.Stderr, format, a...) }
go
func Eprintfln(format string, a ...interface{}) (n int, err error) { return Fprintfln(os.Stderr, format, a...) }
[ "func", "Eprintfln", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "Fprintfln", "(", "os", ".", "Stderr", ",", "format", ",", "a", "...", ")", "\n", "}" ]
// Eprintfln is similar to Printfln but output to os.Stderr
[ "Eprintfln", "is", "similar", "to", "Printfln", "but", "output", "to", "os", ".", "Stderr" ]
2a5d6d7d2995baf7d847b7f16ac0179c6888d37b
https://github.com/golangplus/fmt/blob/2a5d6d7d2995baf7d847b7f16ac0179c6888d37b/fmt.go#L35-L37
146,177
hashicorp/go-gatedio
bytes.go
Bytes
func (b *ByteBuffer) Bytes() []byte { b.Lock() defer b.Unlock() return b.b.Bytes() }
go
func (b *ByteBuffer) Bytes() []byte { b.Lock() defer b.Unlock() return b.b.Bytes() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Bytes", "(", ")", "\n", "}" ]
// Bytes wraps a mutex around the underlying bytes.Buffer function call.
[ "Bytes", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L22-L26
146,178
hashicorp/go-gatedio
bytes.go
Cap
func (b *ByteBuffer) Cap() int { b.Lock() defer b.Unlock() return b.b.Cap() }
go
func (b *ByteBuffer) Cap() int { b.Lock() defer b.Unlock() return b.b.Cap() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Cap", "(", ")", "int", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Cap", "(", ")", "\n", "}" ]
// Cap wraps a mutex around the underlying bytes.Buffer function call.
[ "Cap", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L29-L33
146,179
hashicorp/go-gatedio
bytes.go
Grow
func (b *ByteBuffer) Grow(n int) { b.Lock() defer b.Unlock() b.b.Grow(n) }
go
func (b *ByteBuffer) Grow(n int) { b.Lock() defer b.Unlock() b.b.Grow(n) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Grow", "(", "n", "int", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "b", ".", "b", ".", "Grow", "(", "n", ")", "\n", "}" ]
// Grow wraps a mutex around the underlying bytes.Buffer function call.
[ "Grow", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L36-L40
146,180
hashicorp/go-gatedio
bytes.go
Len
func (b *ByteBuffer) Len() int { b.Lock() defer b.Unlock() return b.b.Len() }
go
func (b *ByteBuffer) Len() int { b.Lock() defer b.Unlock() return b.b.Len() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Len", "(", ")", "int", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Len", "(", ")", "\n", "}" ]
// Len wraps a mutex around the underlying bytes.Buffer function call.
[ "Len", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L43-L47
146,181
hashicorp/go-gatedio
bytes.go
Next
func (b *ByteBuffer) Next(n int) []byte { b.Lock() defer b.Unlock() return b.b.Next(n) }
go
func (b *ByteBuffer) Next(n int) []byte { b.Lock() defer b.Unlock() return b.b.Next(n) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Next", "(", "n", "int", ")", "[", "]", "byte", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Next", "(", "n", ")", "\n", "}" ]
// Next wraps a mutex around the underlying bytes.Buffer function call.
[ "Next", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L50-L54
146,182
hashicorp/go-gatedio
bytes.go
Read
func (b *ByteBuffer) Read(p []byte) (int, error) { b.Lock() defer b.Unlock() return b.b.Read(p) }
go
func (b *ByteBuffer) Read(p []byte) (int, error) { b.Lock() defer b.Unlock() return b.b.Read(p) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Read", "(",...
// Read wraps a mutex around the underlying bytes.Buffer function call.
[ "Read", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L57-L61
146,183
hashicorp/go-gatedio
bytes.go
ReadByte
func (b *ByteBuffer) ReadByte() (byte, error) { b.Lock() defer b.Unlock() return b.b.ReadByte() }
go
func (b *ByteBuffer) ReadByte() (byte, error) { b.Lock() defer b.Unlock() return b.b.ReadByte() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "ReadByte", "(", ")", "(", "byte", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "ReadByte", "(", ")", "\n", "}" ...
// ReadByte wraps a mutex around the underlying bytes.Buffer function call.
[ "ReadByte", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L64-L68
146,184
hashicorp/go-gatedio
bytes.go
ReadBytes
func (b *ByteBuffer) ReadBytes(delim byte) ([]byte, error) { b.Lock() defer b.Unlock() return b.b.ReadBytes(delim) }
go
func (b *ByteBuffer) ReadBytes(delim byte) ([]byte, error) { b.Lock() defer b.Unlock() return b.b.ReadBytes(delim) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "ReadBytes", "(", "delim", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Rea...
// ReadBytes wraps a mutex around the underlying bytes.Buffer function call.
[ "ReadBytes", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L71-L75
146,185
hashicorp/go-gatedio
bytes.go
ReadFrom
func (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error) { b.Lock() defer b.Unlock() return b.b.ReadFrom(r) }
go
func (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error) { b.Lock() defer b.Unlock() return b.b.ReadFrom(r) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "ReadFrom", "(", "r", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Read...
// ReadFrom wraps a mutex around the underlying bytes.Buffer function call.
[ "ReadFrom", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L78-L82
146,186
hashicorp/go-gatedio
bytes.go
ReadRune
func (b *ByteBuffer) ReadRune() (rune, int, error) { b.Lock() defer b.Unlock() return b.b.ReadRune() }
go
func (b *ByteBuffer) ReadRune() (rune, int, error) { b.Lock() defer b.Unlock() return b.b.ReadRune() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "ReadRune", "(", ")", "(", "rune", ",", "int", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "ReadRune", "(", ")"...
// ReadRune wraps a mutex around the underlying bytes.Buffer function call.
[ "ReadRune", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L85-L89
146,187
hashicorp/go-gatedio
bytes.go
ReadString
func (b *ByteBuffer) ReadString(delim byte) (string, error) { b.Lock() defer b.Unlock() return b.b.ReadString(delim) }
go
func (b *ByteBuffer) ReadString(delim byte) (string, error) { b.Lock() defer b.Unlock() return b.b.ReadString(delim) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "ReadString", "(", "delim", "byte", ")", "(", "string", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "ReadString", ...
// ReadString wraps a mutex around the underlying bytes.Buffer function call.
[ "ReadString", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L92-L96
146,188
hashicorp/go-gatedio
bytes.go
Reset
func (b *ByteBuffer) Reset() { b.Lock() defer b.Unlock() b.b.Reset() }
go
func (b *ByteBuffer) Reset() { b.Lock() defer b.Unlock() b.b.Reset() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Reset", "(", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "b", ".", "b", ".", "Reset", "(", ")", "\n", "}" ]
// Reset wraps a mutex around the underlying bytes.Buffer function call.
[ "Reset", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L99-L103
146,189
hashicorp/go-gatedio
bytes.go
String
func (b *ByteBuffer) String() string { b.Lock() defer b.Unlock() return b.b.String() }
go
func (b *ByteBuffer) String() string { b.Lock() defer b.Unlock() return b.b.String() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "String", "(", ")", "string", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "String", "(", ")", "\n", "}" ]
// String wraps a mutex around the underlying bytes.Buffer function call.
[ "String", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L106-L110
146,190
hashicorp/go-gatedio
bytes.go
Truncate
func (b *ByteBuffer) Truncate(n int) { b.Lock() defer b.Unlock() b.b.Truncate(n) }
go
func (b *ByteBuffer) Truncate(n int) { b.Lock() defer b.Unlock() b.b.Truncate(n) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "Truncate", "(", "n", "int", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "b", ".", "b", ".", "Truncate", "(", "n", ")", "\n", "}" ]
// Truncate wraps a mutex around the underlying bytes.Buffer function call.
[ "Truncate", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L113-L117
146,191
hashicorp/go-gatedio
bytes.go
UnreadByte
func (b *ByteBuffer) UnreadByte() error { b.Lock() defer b.Unlock() return b.b.UnreadByte() }
go
func (b *ByteBuffer) UnreadByte() error { b.Lock() defer b.Unlock() return b.b.UnreadByte() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "UnreadByte", "(", ")", "error", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "UnreadByte", "(", ")", "\n", "}" ]
// UnreadByte wraps a mutex around the underlying bytes.Buffer function call.
[ "UnreadByte", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L120-L124
146,192
hashicorp/go-gatedio
bytes.go
UnreadRune
func (b *ByteBuffer) UnreadRune() error { b.Lock() defer b.Unlock() return b.b.UnreadRune() }
go
func (b *ByteBuffer) UnreadRune() error { b.Lock() defer b.Unlock() return b.b.UnreadRune() }
[ "func", "(", "b", "*", "ByteBuffer", ")", "UnreadRune", "(", ")", "error", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "UnreadRune", "(", ")", "\n", "}" ]
// UnreadRune wraps a mutex around the underlying bytes.Buffer function call.
[ "UnreadRune", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L127-L131
146,193
hashicorp/go-gatedio
bytes.go
WriteByte
func (b *ByteBuffer) WriteByte(c byte) error { b.Lock() defer b.Unlock() return b.b.WriteByte(c) }
go
func (b *ByteBuffer) WriteByte(c byte) error { b.Lock() defer b.Unlock() return b.b.WriteByte(c) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "WriteByte", "(", "c", "byte", ")", "error", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "WriteByte", "(", "c", ")", "\n", "}" ]
// WriteByte wraps a mutex around the underlying bytes.Buffer function call.
[ "WriteByte", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L141-L145
146,194
hashicorp/go-gatedio
bytes.go
WriteRune
func (b *ByteBuffer) WriteRune(r rune) (int, error) { b.Lock() defer b.Unlock() return b.b.WriteRune(r) }
go
func (b *ByteBuffer) WriteRune(r rune) (int, error) { b.Lock() defer b.Unlock() return b.b.WriteRune(r) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "WriteRune", "(", "r", "rune", ")", "(", "int", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "WriteRune", "(", "...
// WriteRune wraps a mutex around the underlying bytes.Buffer function call.
[ "WriteRune", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L148-L152
146,195
hashicorp/go-gatedio
bytes.go
WriteString
func (b *ByteBuffer) WriteString(s string) (int, error) { b.Lock() defer b.Unlock() return b.b.WriteString(s) }
go
func (b *ByteBuffer) WriteString(s string) (int, error) { b.Lock() defer b.Unlock() return b.b.WriteString(s) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "WriteString", "(", "s", "string", ")", "(", "int", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "WriteString", "(...
// WriteString wraps a mutex around the underlying bytes.Buffer function call.
[ "WriteString", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L155-L159
146,196
hashicorp/go-gatedio
bytes.go
WriteTo
func (b *ByteBuffer) WriteTo(w io.Writer) (int64, error) { b.Lock() defer b.Unlock() return b.b.WriteTo(w) }
go
func (b *ByteBuffer) WriteTo(w io.Writer) (int64, error) { b.Lock() defer b.Unlock() return b.b.WriteTo(w) }
[ "func", "(", "b", "*", "ByteBuffer", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "b", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "Unlock", "(", ")", "\n", "return", "b", ".", "b", ".", "Write...
// WriteTo wraps a mutex around the underlying bytes.Buffer function call.
[ "WriteTo", "wraps", "a", "mutex", "around", "the", "underlying", "bytes", ".", "Buffer", "function", "call", "." ]
7d66e0012c0c47d5ee698d99703384d405ee594e
https://github.com/hashicorp/go-gatedio/blob/7d66e0012c0c47d5ee698d99703384d405ee594e/bytes.go#L162-L166
146,197
intelsdi-x/snap-plugin-lib-go
examples/snap-plugin-processor-reverse/reverse/reverse.go
Process
func (r RProcessor) Process(mts []plugin.Metric, cfg plugin.Config) ([]plugin.Metric, error) { metrics := []plugin.Metric{} for _, m := range mts { switch m.Data.(type) { case int: m.Data = stringToInt(reverse(intToString(m.Data.(int)))) case int32: i32 := int(m.Data.(int32)) m.Data = stringToInt(rever...
go
func (r RProcessor) Process(mts []plugin.Metric, cfg plugin.Config) ([]plugin.Metric, error) { metrics := []plugin.Metric{} for _, m := range mts { switch m.Data.(type) { case int: m.Data = stringToInt(reverse(intToString(m.Data.(int)))) case int32: i32 := int(m.Data.(int32)) m.Data = stringToInt(rever...
[ "func", "(", "r", "RProcessor", ")", "Process", "(", "mts", "[", "]", "plugin", ".", "Metric", ",", "cfg", "plugin", ".", "Config", ")", "(", "[", "]", "plugin", ".", "Metric", ",", "error", ")", "{", "metrics", ":=", "[", "]", "plugin", ".", "Me...
// Process test process function
[ "Process", "test", "process", "function" ]
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/examples/snap-plugin-processor-reverse/reverse/reverse.go#L32-L55
146,198
intelsdi-x/snap-plugin-lib-go
v1/plugin/config.go
GetString
func (c Config) GetString(key string) (string, error) { var ( strout string val interface{} ok bool ) if val, ok = c[key]; !ok { return strout, ErrConfigNotFound } if strout, ok = val.(string); !ok { return strout, ErrNotAString } return strout, nil }
go
func (c Config) GetString(key string) (string, error) { var ( strout string val interface{} ok bool ) if val, ok = c[key]; !ok { return strout, ErrConfigNotFound } if strout, ok = val.(string); !ok { return strout, ErrNotAString } return strout, nil }
[ "func", "(", "c", "Config", ")", "GetString", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "var", "(", "strout", "string", "\n", "val", "interface", "{", "}", "\n", "ok", "bool", "\n", ")", "\n\n", "if", "val", ",", "ok", "="...
// GetString takes a given key and checks the config for both // that the key exists, and that it is of type string. // Returns an error if either of these is false.
[ "GetString", "takes", "a", "given", "key", "and", "checks", "the", "config", "for", "both", "that", "the", "key", "exists", "and", "that", "it", "is", "of", "type", "string", ".", "Returns", "an", "error", "if", "either", "of", "these", "is", "false", ...
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/config.go#L34-L48
146,199
intelsdi-x/snap-plugin-lib-go
v1/plugin/config.go
GetBool
func (c Config) GetBool(key string) (bool, error) { var ( bout bool val interface{} ok bool ) if val, ok = c[key]; !ok { return bout, ErrConfigNotFound } if bout, ok = val.(bool); !ok { return bout, ErrNotABool } return bout, nil }
go
func (c Config) GetBool(key string) (bool, error) { var ( bout bool val interface{} ok bool ) if val, ok = c[key]; !ok { return bout, ErrConfigNotFound } if bout, ok = val.(bool); !ok { return bout, ErrNotABool } return bout, nil }
[ "func", "(", "c", "Config", ")", "GetBool", "(", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "var", "(", "bout", "bool", "\n", "val", "interface", "{", "}", "\n", "ok", "bool", "\n", ")", "\n\n", "if", "val", ",", "ok", "=", "c",...
// GetBool takes a given key and checks the config for both // that the key exists, and that it is of type bool. // Returns an error if either of these is false.
[ "GetBool", "takes", "a", "given", "key", "and", "checks", "the", "config", "for", "both", "that", "the", "key", "exists", "and", "that", "it", "is", "of", "type", "bool", ".", "Returns", "an", "error", "if", "either", "of", "these", "is", "false", "." ...
2f826c76a182b204f8c0d458e7b76d64fca38062
https://github.com/intelsdi-x/snap-plugin-lib-go/blob/2f826c76a182b204f8c0d458e7b76d64fca38062/v1/plugin/config.go#L53-L69