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
147,900
tredoe/term
readline/buffer.go
wordBackward
func (b *buffer) wordBackward() (err error) { for start := false; ; { start, err = b.backward() if start == true || err != nil || b.data[b.pos-1] == 32 { return } } }
go
func (b *buffer) wordBackward() (err error) { for start := false; ; { start, err = b.backward() if start == true || err != nil || b.data[b.pos-1] == 32 { return } } }
[ "func", "(", "b", "*", "buffer", ")", "wordBackward", "(", ")", "(", "err", "error", ")", "{", "for", "start", ":=", "false", ";", ";", "{", "start", ",", "err", "=", "b", ".", "backward", "(", ")", "\n", "if", "start", "==", "true", "||", "err...
// wordBackward moves the cursor one word backward.
[ "wordBackward", "moves", "the", "cursor", "one", "word", "backward", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L258-L265
147,901
tredoe/term
readline/buffer.go
wordForward
func (b *buffer) wordForward() (err error) { for end := false; ; { end, err = b.forward() if end == true || err != nil || b.data[b.pos] == 32 { return } } }
go
func (b *buffer) wordForward() (err error) { for end := false; ; { end, err = b.forward() if end == true || err != nil || b.data[b.pos] == 32 { return } } }
[ "func", "(", "b", "*", "buffer", ")", "wordForward", "(", ")", "(", "err", "error", ")", "{", "for", "end", ":=", "false", ";", ";", "{", "end", ",", "err", "=", "b", ".", "forward", "(", ")", "\n", "if", "end", "==", "true", "||", "err", "!=...
// wordForward moves the cursor one word forward.
[ "wordForward", "moves", "the", "cursor", "one", "word", "forward", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L268-L275
147,902
tredoe/term
readline/buffer.go
deleteChar
func (b *buffer) deleteChar() (err error) { if b.pos == b.size { return } copy(b.data[b.pos:], b.data[b.pos+1:b.size]) b.size-- if lastLine, _ := b.pos2xy(b.size); lastLine == 0 { if _, err = term.Output.Write(DelChar); err != nil { return outputError(err.Error()) } return nil } return b.refresh() }
go
func (b *buffer) deleteChar() (err error) { if b.pos == b.size { return } copy(b.data[b.pos:], b.data[b.pos+1:b.size]) b.size-- if lastLine, _ := b.pos2xy(b.size); lastLine == 0 { if _, err = term.Output.Write(DelChar); err != nil { return outputError(err.Error()) } return nil } return b.refresh() }
[ "func", "(", "b", "*", "buffer", ")", "deleteChar", "(", ")", "(", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "size", "{", "return", "\n", "}", "\n\n", "copy", "(", "b", ".", "data", "[", "b", ".", "pos", ":", "]", ","...
// == Delete // deleteChar deletes the character in cursor.
[ "==", "Delete", "deleteChar", "deletes", "the", "character", "in", "cursor", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L280-L295
147,903
tredoe/term
readline/buffer.go
deleteCharPrev
func (b *buffer) deleteCharPrev() (err error) { if b.pos == b.promptLen { return } copy(b.data[b.pos-1:], b.data[b.pos:b.size]) b.pos-- b.size-- if lastLine, _ := b.pos2xy(b.size); lastLine == 0 { if _, err = term.Output.Write(DelBackspace); err != nil { return outputError(err.Error()) } return nil ...
go
func (b *buffer) deleteCharPrev() (err error) { if b.pos == b.promptLen { return } copy(b.data[b.pos-1:], b.data[b.pos:b.size]) b.pos-- b.size-- if lastLine, _ := b.pos2xy(b.size); lastLine == 0 { if _, err = term.Output.Write(DelBackspace); err != nil { return outputError(err.Error()) } return nil ...
[ "func", "(", "b", "*", "buffer", ")", "deleteCharPrev", "(", ")", "(", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "promptLen", "{", "return", "\n", "}", "\n\n", "copy", "(", "b", ".", "data", "[", "b", ".", "pos", "-", "...
// deleteCharPrev deletes the previous character from cursor.
[ "deleteCharPrev", "deletes", "the", "previous", "character", "from", "cursor", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L298-L314
147,904
tredoe/term
readline/buffer.go
deleteToRight
func (b *buffer) deleteToRight() (err error) { if b.pos == b.size { return } lastLine, _ := b.pos2xy(b.size) posLine, _ := b.pos2xy(b.pos) // To the last line. for ln := posLine; ln < lastLine; ln++ { if _, err = term.Output.Write(CursorDown); err != nil { return outputError(err.Error()) } } // Delet...
go
func (b *buffer) deleteToRight() (err error) { if b.pos == b.size { return } lastLine, _ := b.pos2xy(b.size) posLine, _ := b.pos2xy(b.pos) // To the last line. for ln := posLine; ln < lastLine; ln++ { if _, err = term.Output.Write(CursorDown); err != nil { return outputError(err.Error()) } } // Delet...
[ "func", "(", "b", "*", "buffer", ")", "deleteToRight", "(", ")", "(", "err", "error", ")", "{", "if", "b", ".", "pos", "==", "b", ".", "size", "{", "return", "\n", "}", "\n\n", "lastLine", ",", "_", ":=", "b", ".", "pos2xy", "(", "b", ".", "s...
// deleteToRight deletes from current position until to end of line.
[ "deleteToRight", "deletes", "from", "current", "position", "until", "to", "end", "of", "line", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L317-L343
147,905
tredoe/term
readline/buffer.go
deleteLine
func (b *buffer) deleteLine() error { lines, err := b.end() if err != nil { return err } for lines > 0 { if _, err = term.Output.Write(DelLine_cursorUp); err != nil { return outputError(err.Error()) } lines-- } return nil }
go
func (b *buffer) deleteLine() error { lines, err := b.end() if err != nil { return err } for lines > 0 { if _, err = term.Output.Write(DelLine_cursorUp); err != nil { return outputError(err.Error()) } lines-- } return nil }
[ "func", "(", "b", "*", "buffer", ")", "deleteLine", "(", ")", "error", "{", "lines", ",", "err", ":=", "b", ".", "end", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "for", "lines", ">", "0", "{", "if", "_...
// deleteLine deletes full line.
[ "deleteLine", "deletes", "full", "line", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L346-L359
147,906
tredoe/term
readline/buffer.go
grow
func (b *buffer) grow(n int) { for n > len(b.data) { b.data = b.data[:len(b.data)+BufferLen] } }
go
func (b *buffer) grow(n int) { for n > len(b.data) { b.data = b.data[:len(b.data)+BufferLen] } }
[ "func", "(", "b", "*", "buffer", ")", "grow", "(", "n", "int", ")", "{", "for", "n", ">", "len", "(", "b", ".", "data", ")", "{", "b", ".", "data", "=", "b", ".", "data", "[", ":", "len", "(", "b", ".", "data", ")", "+", "BufferLen", "]",...
// == Utility // grow grows buffer to guarantee space for n more byte.
[ "==", "Utility", "grow", "grows", "buffer", "to", "guarantee", "space", "for", "n", "more", "byte", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L364-L368
147,907
tredoe/term
readline/buffer.go
pos2xy
func (b *buffer) pos2xy(pos int) (line, column int) { if pos < b.columns { return 0, pos } line = pos / b.columns column = pos - (line * b.columns) //- 1 return }
go
func (b *buffer) pos2xy(pos int) (line, column int) { if pos < b.columns { return 0, pos } line = pos / b.columns column = pos - (line * b.columns) //- 1 return }
[ "func", "(", "b", "*", "buffer", ")", "pos2xy", "(", "pos", "int", ")", "(", "line", ",", "column", "int", ")", "{", "if", "pos", "<", "b", ".", "columns", "{", "return", "0", ",", "pos", "\n", "}", "\n\n", "line", "=", "pos", "/", "b", ".", ...
// pos2xy returns the coordinates of a position for a line of size given in // columns.
[ "pos2xy", "returns", "the", "coordinates", "of", "a", "position", "for", "a", "line", "of", "size", "given", "in", "columns", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/buffer.go#L372-L380
147,908
tredoe/term
readline/read.go
NewDefaultLine
func NewDefaultLine(hist *history) (*Line, error) { ter, err := term.New() if err != nil { return nil, err } if err = ter.RawMode(); err != nil { return nil, err } _, col, err := ter.GetSize() if err != nil { return nil, err } buf := newBuffer(len(PS1), col) buf.insertRunes([]rune(PS1)) return &Line...
go
func NewDefaultLine(hist *history) (*Line, error) { ter, err := term.New() if err != nil { return nil, err } if err = ter.RawMode(); err != nil { return nil, err } _, col, err := ter.GetSize() if err != nil { return nil, err } buf := newBuffer(len(PS1), col) buf.insertRunes([]rune(PS1)) return &Line...
[ "func", "NewDefaultLine", "(", "hist", "*", "history", ")", "(", "*", "Line", ",", "error", ")", "{", "ter", ",", "err", ":=", "term", ".", "New", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if"...
// NewDefaultLine returns a line type using the prompt by default, and setting // the terminal to raw mode. // If the history is nil then it is not used.
[ "NewDefaultLine", "returns", "a", "line", "type", "using", "the", "prompt", "by", "default", "and", "setting", "the", "terminal", "to", "raw", "mode", ".", "If", "the", "history", "is", "nil", "then", "it", "is", "not", "used", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/read.go#L53-L81
147,909
tredoe/term
util_unix.go
SupportANSI
func SupportANSI() bool { term := os.Getenv("TERM") if term == "" { return false } for _, v := range shellsWithoutANSI { if v == term { return false } } return true }
go
func SupportANSI() bool { term := os.Getenv("TERM") if term == "" { return false } for _, v := range shellsWithoutANSI { if v == term { return false } } return true }
[ "func", "SupportANSI", "(", ")", "bool", "{", "term", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "term", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "v", ":=", "range", "shellsWithoutANSI", "{", ...
// SupportANSI checks if the terminal supports ANSI escape sequences.
[ "SupportANSI", "checks", "if", "the", "terminal", "supports", "ANSI", "escape", "sequences", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/util_unix.go#L30-L42
147,910
tredoe/term
util_unix.go
ReadPassword
func ReadPassword(password []byte) (n int, err error) { ter, err := New() if err != nil { return 0, err } defer func() { err2 := ter.Restore() if err2 != nil && err == nil { err = err2 } }() if err = ter.RawMode(); err != nil { return 0, err } key := make([]byte, 4) // In-memory representation of...
go
func ReadPassword(password []byte) (n int, err error) { ter, err := New() if err != nil { return 0, err } defer func() { err2 := ter.Restore() if err2 != nil && err == nil { err = err2 } }() if err = ter.RawMode(); err != nil { return 0, err } key := make([]byte, 4) // In-memory representation of...
[ "func", "ReadPassword", "(", "password", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "ter", ",", "err", ":=", "New", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "defer", ...
// ReadPassword reads characters from the input until press Enter or until // fill in the given slice. // // Only reads characters that include letters, marks, numbers, punctuation, // and symbols from Unicode categories L, M, N, P, S, besides of the // ASCII space character. // Ctrl-C interrumpts, and backspace remove...
[ "ReadPassword", "reads", "characters", "from", "the", "input", "until", "press", "Enter", "or", "until", "fill", "in", "the", "given", "slice", ".", "Only", "reads", "characters", "that", "include", "letters", "marks", "numbers", "punctuation", "and", "symbols",...
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/util_unix.go#L73-L143
147,911
tredoe/term
util_unix.go
DetectWinSize
func DetectWinSize() *WinSize { w := &WinSize{ make(chan bool), make(chan bool), make(chan bool), } changeSig := make(chan os.Signal) signal.Notify(changeSig, unix.SIGWINCH) go func() { for { select { case <-changeSig: // Add a pause because it is sent two signals at maximizing a window. ti...
go
func DetectWinSize() *WinSize { w := &WinSize{ make(chan bool), make(chan bool), make(chan bool), } changeSig := make(chan os.Signal) signal.Notify(changeSig, unix.SIGWINCH) go func() { for { select { case <-changeSig: // Add a pause because it is sent two signals at maximizing a window. ti...
[ "func", "DetectWinSize", "(", ")", "*", "WinSize", "{", "w", ":=", "&", "WinSize", "{", "make", "(", "chan", "bool", ")", ",", "make", "(", "chan", "bool", ")", ",", "make", "(", "chan", "bool", ")", ",", "}", "\n\n", "changeSig", ":=", "make", "...
// DetectWinSize caughts a signal named SIGWINCH whenever the window size changes, // being indicated in channel `WinSize.Change`.
[ "DetectWinSize", "caughts", "a", "signal", "named", "SIGWINCH", "whenever", "the", "window", "size", "changes", "being", "indicated", "in", "channel", "WinSize", ".", "Change", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/util_unix.go#L155-L179
147,912
hjfreyer/taglib-go
taglib/taglib.go
Decode
func Decode(r io.ReaderAt, size int64) (GenericTag, error) { magic := make([]byte, 4) if _, err := r.ReadAt(magic, 0); err != nil { return nil, err } if !bytes.Equal(magic[:3], []byte("ID3")) { return nil, errors.New("taglib: format not recognised (not ID3)") } switch magic[3] { case 2: return nil, error...
go
func Decode(r io.ReaderAt, size int64) (GenericTag, error) { magic := make([]byte, 4) if _, err := r.ReadAt(magic, 0); err != nil { return nil, err } if !bytes.Equal(magic[:3], []byte("ID3")) { return nil, errors.New("taglib: format not recognised (not ID3)") } switch magic[3] { case 2: return nil, error...
[ "func", "Decode", "(", "r", "io", ".", "ReaderAt", ",", "size", "int64", ")", "(", "GenericTag", ",", "error", ")", "{", "magic", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "if", "_", ",", "err", ":=", "r", ".", "ReadAt", "(", ...
// Decode reads r and determines which tag format the data is in, if // any, and calls the decoding function for that format. size // indicates the total number of bytes accessible through r.
[ "Decode", "reads", "r", "and", "determines", "which", "tag", "format", "the", "data", "is", "in", "if", "any", "and", "calls", "the", "decoding", "function", "for", "that", "format", ".", "size", "indicates", "the", "total", "number", "of", "bytes", "acces...
0ef8bba9c41b66c12f60ce9833786838d2c2d3d8
https://github.com/hjfreyer/taglib-go/blob/0ef8bba9c41b66c12f60ce9833786838d2c2d3d8/taglib/taglib.go#L55-L75
147,913
tredoe/term
sys/sys_unix.go
GetWinsize
func GetWinsize(fd int, ws *Winsize) (err error) { _, _, e1 := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) if e1 != 0 { err = e1 } return }
go
func GetWinsize(fd int, ws *Winsize) (err error) { _, _, e1 := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) if e1 != 0 { err = e1 } return }
[ "func", "GetWinsize", "(", "fd", "int", ",", "ws", "*", "Winsize", ")", "(", "err", "error", ")", "{", "_", ",", "_", ",", "e1", ":=", "unix", ".", "Syscall", "(", "unix", ".", "SYS_IOCTL", ",", "uintptr", "(", "fd", ")", ",", "uintptr", "(", "...
// GetWinsize gets the winsize struct with the terminal size set by the kernel.
[ "GetWinsize", "gets", "the", "winsize", "struct", "with", "the", "terminal", "size", "set", "by", "the", "kernel", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/sys/sys_unix.go#L52-L59
147,914
tredoe/term
readline/read_unix.go
NewLine
func NewLine(ter *term.Terminal, ps1, ps2 string, lenAnsi int, hist *history) (*Line, error) { if ter.Mode()&term.RawMode == 0 { // the raw mode is not set if err := ter.RawMode(); err != nil { return nil, err } } lenPS1 := len(ps1) - lenAnsi _, col, err := ter.GetSize() if err != nil { return nil, err ...
go
func NewLine(ter *term.Terminal, ps1, ps2 string, lenAnsi int, hist *history) (*Line, error) { if ter.Mode()&term.RawMode == 0 { // the raw mode is not set if err := ter.RawMode(); err != nil { return nil, err } } lenPS1 := len(ps1) - lenAnsi _, col, err := ter.GetSize() if err != nil { return nil, err ...
[ "func", "NewLine", "(", "ter", "*", "term", ".", "Terminal", ",", "ps1", ",", "ps2", "string", ",", "lenAnsi", "int", ",", "hist", "*", "history", ")", "(", "*", "Line", ",", "error", ")", "{", "if", "ter", ".", "Mode", "(", ")", "&", "term", "...
// NewLine returns a line using both prompts ps1 and ps2, and setting the given // terminal to raw mode, if were necessary. // lenAnsi is the length of ANSI codes that the prompt ps1 could have. // If the history is nil then it is not used.
[ "NewLine", "returns", "a", "line", "using", "both", "prompts", "ps1", "and", "ps2", "and", "setting", "the", "given", "terminal", "to", "raw", "mode", "if", "were", "necessary", ".", "lenAnsi", "is", "the", "length", "of", "ANSI", "codes", "that", "the", ...
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/read_unix.go#L30-L57
147,915
tredoe/term
readline/read_unix.go
Prompt
func (ln *Line) Prompt() (err error) { if _, err = term.Output.Write(DelLine_CR); err != nil { return outputError(err.Error()) } if _, err = fmt.Fprint(term.Output, ln.ps1); err != nil { return outputError(err.Error()) } ln.buf.pos, ln.buf.size = ln.lenPS1, ln.lenPS1 return }
go
func (ln *Line) Prompt() (err error) { if _, err = term.Output.Write(DelLine_CR); err != nil { return outputError(err.Error()) } if _, err = fmt.Fprint(term.Output, ln.ps1); err != nil { return outputError(err.Error()) } ln.buf.pos, ln.buf.size = ln.lenPS1, ln.lenPS1 return }
[ "func", "(", "ln", "*", "Line", ")", "Prompt", "(", ")", "(", "err", "error", ")", "{", "if", "_", ",", "err", "=", "term", ".", "Output", ".", "Write", "(", "DelLine_CR", ")", ";", "err", "!=", "nil", "{", "return", "outputError", "(", "err", ...
// Prompt prints the primary prompt.
[ "Prompt", "prints", "the", "primary", "prompt", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/read_unix.go#L60-L70
147,916
tredoe/term
readline/history.go
_baseHistory
func _baseHistory(fname string, size int) (*history, error) { file, err := os.OpenFile(fname, os.O_CREATE|os.O_RDWR, HistoryPerm) if err != nil { return nil, err } h := new(history) h.Cap = size h.filename = fname h.file = file h.li = list.New() return h, nil }
go
func _baseHistory(fname string, size int) (*history, error) { file, err := os.OpenFile(fname, os.O_CREATE|os.O_RDWR, HistoryPerm) if err != nil { return nil, err } h := new(history) h.Cap = size h.filename = fname h.file = file h.li = list.New() return h, nil }
[ "func", "_baseHistory", "(", "fname", "string", ",", "size", "int", ")", "(", "*", "history", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "fname", ",", "os", ".", "O_CREATE", "|", "os", ".", "O_RDWR", ",", "History...
// _baseHistory is the base to create an history file.
[ "_baseHistory", "is", "the", "base", "to", "create", "an", "history", "file", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/history.go#L42-L55
147,917
tredoe/term
readline/history.go
NewHistoryOfSize
func NewHistoryOfSize(filename string, size int) (*history, error) { if size <= 0 { return nil, errors.New("wrong history size: " + strconv.Itoa(size)) } return _baseHistory(filename, size) }
go
func NewHistoryOfSize(filename string, size int) (*history, error) { if size <= 0 { return nil, errors.New("wrong history size: " + strconv.Itoa(size)) } return _baseHistory(filename, size) }
[ "func", "NewHistoryOfSize", "(", "filename", "string", ",", "size", "int", ")", "(", "*", "history", ",", "error", ")", "{", "if", "size", "<=", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", "+", "strconv", ".", "Itoa", "("...
// NewHistoryOfSize creates a new history whose buffer has the specified size, // which must be greater than zero.
[ "NewHistoryOfSize", "creates", "a", "new", "history", "whose", "buffer", "has", "the", "specified", "size", "which", "must", "be", "greater", "than", "zero", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/history.go#L64-L70
147,918
tredoe/term
readline/history.go
Load
func (h *history) Load() { in := bufio.NewReader(h.file) for { line, err := in.ReadString('\n') if err == io.EOF { break } h.li.PushBack(strings.TrimRight(line, "\n")) } h.mark = h.li.Back() // Point to an element. }
go
func (h *history) Load() { in := bufio.NewReader(h.file) for { line, err := in.ReadString('\n') if err == io.EOF { break } h.li.PushBack(strings.TrimRight(line, "\n")) } h.mark = h.li.Back() // Point to an element. }
[ "func", "(", "h", "*", "history", ")", "Load", "(", ")", "{", "in", ":=", "bufio", ".", "NewReader", "(", "h", ".", "file", ")", "\n\n", "for", "{", "line", ",", "err", ":=", "in", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "err", "==", ...
// == Access to file // Load loads the history from the file.
[ "==", "Access", "to", "file", "Load", "loads", "the", "history", "from", "the", "file", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/history.go#L75-L88
147,919
tredoe/term
readline/history.go
_baseNextPrev
func (h *history) _baseNextPrev(c byte) (line []rune, err error) { if h.li.Len() <= 0 { return line, ErrEmptyHist } new := new(list.Element) if c == 'p' { new = h.mark.Prev() } else if c == 'n' { new = h.mark.Next() } else { panic("history._baseNextPrev: wrong character choice") } if new != nil { h....
go
func (h *history) _baseNextPrev(c byte) (line []rune, err error) { if h.li.Len() <= 0 { return line, ErrEmptyHist } new := new(list.Element) if c == 'p' { new = h.mark.Prev() } else if c == 'n' { new = h.mark.Next() } else { panic("history._baseNextPrev: wrong character choice") } if new != nil { h....
[ "func", "(", "h", "*", "history", ")", "_baseNextPrev", "(", "c", "byte", ")", "(", "line", "[", "]", "rune", ",", "err", "error", ")", "{", "if", "h", ".", "li", ".", "Len", "(", ")", "<=", "0", "{", "return", "line", ",", "ErrEmptyHist", "\n"...
// _baseNextPrev is the base to move between lines.
[ "_baseNextPrev", "is", "the", "base", "to", "move", "between", "lines", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/readline/history.go#L155-L176
147,920
tredoe/term
term_unix.go
New
func New() (*Terminal, error) { var t Terminal // Get the actual state if err := sys.Getattr(InputFD, &t.lastState); err != nil { return nil, os.NewSyscallError("sys.Getattr", err) } t.oldState = t.lastState // the actual state is copied to another one t.fd = InputFD return &t, nil }
go
func New() (*Terminal, error) { var t Terminal // Get the actual state if err := sys.Getattr(InputFD, &t.lastState); err != nil { return nil, os.NewSyscallError("sys.Getattr", err) } t.oldState = t.lastState // the actual state is copied to another one t.fd = InputFD return &t, nil }
[ "func", "New", "(", ")", "(", "*", "Terminal", ",", "error", ")", "{", "var", "t", "Terminal", "\n\n", "// Get the actual state", "if", "err", ":=", "sys", ".", "Getattr", "(", "InputFD", ",", "&", "t", ".", "lastState", ")", ";", "err", "!=", "nil",...
// New creates a new terminal interface in the file descriptor InputFD.
[ "New", "creates", "a", "new", "terminal", "interface", "in", "the", "file", "descriptor", "InputFD", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/term_unix.go#L40-L51
147,921
tredoe/term
term_unix.go
Restore
func (t *Terminal) Restore() error { if t.mode != 0 { if err := sys.Setattr(t.fd, sys.TCSANOW, &t.oldState); err != nil { return os.NewSyscallError("sys.Setattr", err) } t.lastState = t.oldState t.mode = 0 } return nil }
go
func (t *Terminal) Restore() error { if t.mode != 0 { if err := sys.Setattr(t.fd, sys.TCSANOW, &t.oldState); err != nil { return os.NewSyscallError("sys.Setattr", err) } t.lastState = t.oldState t.mode = 0 } return nil }
[ "func", "(", "t", "*", "Terminal", ")", "Restore", "(", ")", "error", "{", "if", "t", ".", "mode", "!=", "0", "{", "if", "err", ":=", "sys", ".", "Setattr", "(", "t", ".", "fd", ",", "sys", ".", "TCSANOW", ",", "&", "t", ".", "oldState", ")",...
// Restore restores the original settings for the term.
[ "Restore", "restores", "the", "original", "settings", "for", "the", "term", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/term_unix.go#L66-L75
147,922
tredoe/term
term_unix.go
Restore
func Restore(fd int, st State) error { if err := sys.Setattr(fd, sys.TCSANOW, &st.wrap); err != nil { return os.NewSyscallError("sys.Setattr", err) } return nil }
go
func Restore(fd int, st State) error { if err := sys.Setattr(fd, sys.TCSANOW, &st.wrap); err != nil { return os.NewSyscallError("sys.Setattr", err) } return nil }
[ "func", "Restore", "(", "fd", "int", ",", "st", "State", ")", "error", "{", "if", "err", ":=", "sys", ".", "Setattr", "(", "fd", ",", "sys", ".", "TCSANOW", ",", "&", "st", ".", "wrap", ")", ";", "err", "!=", "nil", "{", "return", "os", ".", ...
// Restore restores the settings from State.
[ "Restore", "restores", "the", "settings", "from", "State", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/term_unix.go#L78-L83
147,923
tredoe/term
term_unix.go
EchoMode
func (t *Terminal) EchoMode(echo bool) error { if !echo { //t.lastState.Lflag &^= (sys.ECHO | sys.ECHOE | sys.ECHOK | sys.ECHONL) t.lastState.Lflag &^= sys.ECHO } else { //t.lastState.Lflag |= (sys.ECHO | sys.ECHOE | sys.ECHOK | sys.ECHONL) t.lastState.Lflag |= sys.ECHO } if err := sys.Setattr(t.fd, sys.TC...
go
func (t *Terminal) EchoMode(echo bool) error { if !echo { //t.lastState.Lflag &^= (sys.ECHO | sys.ECHOE | sys.ECHOK | sys.ECHONL) t.lastState.Lflag &^= sys.ECHO } else { //t.lastState.Lflag |= (sys.ECHO | sys.ECHOE | sys.ECHOK | sys.ECHONL) t.lastState.Lflag |= sys.ECHO } if err := sys.Setattr(t.fd, sys.TC...
[ "func", "(", "t", "*", "Terminal", ")", "EchoMode", "(", "echo", "bool", ")", "error", "{", "if", "!", "echo", "{", "//t.lastState.Lflag &^= (sys.ECHO | sys.ECHOE | sys.ECHOK | sys.ECHONL)", "t", ".", "lastState", ".", "Lflag", "&^=", "sys", ".", "ECHO", "\n", ...
// EchoMode turns the echo mode.
[ "EchoMode", "turns", "the", "echo", "mode", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/term_unix.go#L124-L143
147,924
tredoe/term
term_unix.go
CharMode
func (t *Terminal) CharMode() error { // Disable canonical mode, and set buffer size to 1 byte. t.lastState.Lflag &^= sys.ICANON t.lastState.Cc[sys.VTIME] = 0 t.lastState.Cc[sys.VMIN] = 1 if err := sys.Setattr(t.fd, sys.TCSANOW, &t.lastState); err != nil { return os.NewSyscallError("sys.Setattr", err) } t.mod...
go
func (t *Terminal) CharMode() error { // Disable canonical mode, and set buffer size to 1 byte. t.lastState.Lflag &^= sys.ICANON t.lastState.Cc[sys.VTIME] = 0 t.lastState.Cc[sys.VMIN] = 1 if err := sys.Setattr(t.fd, sys.TCSANOW, &t.lastState); err != nil { return os.NewSyscallError("sys.Setattr", err) } t.mod...
[ "func", "(", "t", "*", "Terminal", ")", "CharMode", "(", ")", "error", "{", "// Disable canonical mode, and set buffer size to 1 byte.", "t", ".", "lastState", ".", "Lflag", "&^=", "sys", ".", "ICANON", "\n", "t", ".", "lastState", ".", "Cc", "[", "sys", "."...
// CharMode sets the terminal to single-character mode.
[ "CharMode", "sets", "the", "terminal", "to", "single", "-", "character", "mode", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/term_unix.go#L146-L157
147,925
tredoe/term
term_unix.go
GetSize
func (t *Terminal) GetSize() (row, column int, err error) { if err = sys.GetWinsize(unix.Stdout, &t.size); err != nil { return } return int(t.size.Row), int(t.size.Col), nil }
go
func (t *Terminal) GetSize() (row, column int, err error) { if err = sys.GetWinsize(unix.Stdout, &t.size); err != nil { return } return int(t.size.Row), int(t.size.Col), nil }
[ "func", "(", "t", "*", "Terminal", ")", "GetSize", "(", ")", "(", "row", ",", "column", "int", ",", "err", "error", ")", "{", "if", "err", "=", "sys", ".", "GetWinsize", "(", "unix", ".", "Stdout", ",", "&", "t", ".", "size", ")", ";", "err", ...
// GetSize returns the size of the term.
[ "GetSize", "returns", "the", "size", "of", "the", "term", "." ]
e551c64f56c0ac0469b4db1b70918e05bfd3ab20
https://github.com/tredoe/term/blob/e551c64f56c0ac0469b4db1b70918e05bfd3ab20/term_unix.go#L180-L185
147,926
aybabtme/uniplot
barchart/barchart.go
XYs
func (p *BarChart) XYs() []*XY { xys := make([]*XY, p.MaxX-p.MinX) for _, xy := range p.xy { slot := xys[xy.X-p.MinX] if slot == nil { slot = &XY{xy.X, xy.Y} } else { slot.Y += xy.Y } } return xys }
go
func (p *BarChart) XYs() []*XY { xys := make([]*XY, p.MaxX-p.MinX) for _, xy := range p.xy { slot := xys[xy.X-p.MinX] if slot == nil { slot = &XY{xy.X, xy.Y} } else { slot.Y += xy.Y } } return xys }
[ "func", "(", "p", "*", "BarChart", ")", "XYs", "(", ")", "[", "]", "*", "XY", "{", "xys", ":=", "make", "(", "[", "]", "*", "XY", ",", "p", ".", "MaxX", "-", "p", ".", "MinX", ")", "\n", "for", "_", ",", "xy", ":=", "range", "p", ".", "...
// XYs aggregates the XY values together in a dense form. // Empty slots between two Xs are left nil to represent // the absence of data.
[ "XYs", "aggregates", "the", "XY", "values", "together", "in", "a", "dense", "form", ".", "Empty", "slots", "between", "two", "Xs", "are", "left", "nil", "to", "represent", "the", "absence", "of", "data", "." ]
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/barchart/barchart.go#L28-L39
147,927
aybabtme/uniplot
barchart/barchart.go
ScaleXYs
func (p *BarChart) ScaleXYs(xWidth int, s ScaleFunc) []XYf { diff := p.MaxX - p.MinX scaleX := float64(diff) / float64(xWidth-1) buckets := make([]XYf, xWidth) for i := range buckets { buckets[i] = XYf{ X: float64(i)*scaleX + float64(p.MinX), Y: nil, ScaledY: nil, } } miny, maxy := flo...
go
func (p *BarChart) ScaleXYs(xWidth int, s ScaleFunc) []XYf { diff := p.MaxX - p.MinX scaleX := float64(diff) / float64(xWidth-1) buckets := make([]XYf, xWidth) for i := range buckets { buckets[i] = XYf{ X: float64(i)*scaleX + float64(p.MinX), Y: nil, ScaledY: nil, } } miny, maxy := flo...
[ "func", "(", "p", "*", "BarChart", ")", "ScaleXYs", "(", "xWidth", "int", ",", "s", "ScaleFunc", ")", "[", "]", "XYf", "{", "diff", ":=", "p", ".", "MaxX", "-", "p", ".", "MinX", "\n", "scaleX", ":=", "float64", "(", "diff", ")", "/", "float64", ...
// ScaleXYs aggregates the XY values together in a dense form. // Empty slots between two Xs are left nil to represent // the absence of data. The values are scaled using s.
[ "ScaleXYs", "aggregates", "the", "XY", "values", "together", "in", "a", "dense", "form", ".", "Empty", "slots", "between", "two", "Xs", "are", "left", "nil", "to", "represent", "the", "absence", "of", "data", ".", "The", "values", "are", "scaled", "using",...
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/barchart/barchart.go#L44-L85
147,928
golang-plus/uuid
internal/version.go
SetVersion
func SetVersion(uuid []byte, version Version) { switch version { case VersionTimeBased: uuid[6] = (uuid[6] | 0x10) & 0x1f case VersionDCESecurity: uuid[6] = (uuid[6] | 0x20) & 0x2f case VersionNameBasedMD5: uuid[6] = (uuid[6] | 0x30) & 0x3f case VersionRandom: uuid[6] = (uuid[6] | 0x40) & 0x4f case Versio...
go
func SetVersion(uuid []byte, version Version) { switch version { case VersionTimeBased: uuid[6] = (uuid[6] | 0x10) & 0x1f case VersionDCESecurity: uuid[6] = (uuid[6] | 0x20) & 0x2f case VersionNameBasedMD5: uuid[6] = (uuid[6] | 0x30) & 0x3f case VersionRandom: uuid[6] = (uuid[6] | 0x40) & 0x4f case Versio...
[ "func", "SetVersion", "(", "uuid", "[", "]", "byte", ",", "version", "Version", ")", "{", "switch", "version", "{", "case", "VersionTimeBased", ":", "uuid", "[", "6", "]", "=", "(", "uuid", "[", "6", "]", "|", "0x10", ")", "&", "0x1f", "\n", "case"...
// SetVersion sets the version for uuid. // This is intended to be called from the New function in packages that implement uuid generating functions.
[ "SetVersion", "sets", "the", "version", "for", "uuid", ".", "This", "is", "intended", "to", "be", "called", "from", "the", "New", "function", "in", "packages", "that", "implement", "uuid", "generating", "functions", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/version.go#L18-L33
147,929
golang-plus/uuid
internal/version.go
GetVersion
func GetVersion(uuid []byte) Version { ver := uuid[6] >> 4 if ver > 0 && ver < 6 { return Version(ver) } return VersionUnknown }
go
func GetVersion(uuid []byte) Version { ver := uuid[6] >> 4 if ver > 0 && ver < 6 { return Version(ver) } return VersionUnknown }
[ "func", "GetVersion", "(", "uuid", "[", "]", "byte", ")", "Version", "{", "ver", ":=", "uuid", "[", "6", "]", ">>", "4", "\n", "if", "ver", ">", "0", "&&", "ver", "<", "6", "{", "return", "Version", "(", "ver", ")", "\n", "}", "\n\n", "return",...
// GetVersion gets the version of uuid.
[ "GetVersion", "gets", "the", "version", "of", "uuid", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/version.go#L36-L43
147,930
golang-plus/uuid
internal/dcesecurity/dcesecurity.go
NewUUID
func NewUUID(domain Domain) ([]byte, error) { uuid, err := timebased.NewUUID() if err != nil { return nil, err } switch domain { case User: uid := os.Getuid() binary.BigEndian.PutUint32(uuid[0:], uint32(uid)) // network byte order case Group: gid := os.Getgid() binary.BigEndian.PutUint32(uuid[0:], uint...
go
func NewUUID(domain Domain) ([]byte, error) { uuid, err := timebased.NewUUID() if err != nil { return nil, err } switch domain { case User: uid := os.Getuid() binary.BigEndian.PutUint32(uuid[0:], uint32(uid)) // network byte order case Group: gid := os.Getgid() binary.BigEndian.PutUint32(uuid[0:], uint...
[ "func", "NewUUID", "(", "domain", "Domain", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "uuid", ",", "err", ":=", "timebased", ".", "NewUUID", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", ...
// NewUUID Generate returns a new DCE security uuid.
[ "NewUUID", "Generate", "returns", "a", "new", "DCE", "security", "uuid", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/dcesecurity/dcesecurity.go#L14-L37
147,931
golang-plus/uuid
parse.go
Parse
func Parse(str string) (UUID, error) { length := len(str) buffer := make([]byte, 16) indexes := []int{} switch length { case 36: if str[8] != '-' || str[13] != '-' || str[18] != '-' || str[23] != '-' { return Nil, errors.Newf("format of UUID string %q is invalid, it should be xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx...
go
func Parse(str string) (UUID, error) { length := len(str) buffer := make([]byte, 16) indexes := []int{} switch length { case 36: if str[8] != '-' || str[13] != '-' || str[18] != '-' || str[23] != '-' { return Nil, errors.Newf("format of UUID string %q is invalid, it should be xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx...
[ "func", "Parse", "(", "str", "string", ")", "(", "UUID", ",", "error", ")", "{", "length", ":=", "len", "(", "str", ")", "\n", "buffer", ":=", "make", "(", "[", "]", "byte", ",", "16", ")", "\n", "indexes", ":=", "[", "]", "int", "{", "}", "\...
// Parse parses the UUID string.
[ "Parse", "parses", "the", "UUID", "string", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/parse.go#L10-L54
147,932
golang-plus/uuid
parse.go
IsValid
func IsValid(uuid string) bool { _, err := Parse(uuid) return err == nil }
go
func IsValid(uuid string) bool { _, err := Parse(uuid) return err == nil }
[ "func", "IsValid", "(", "uuid", "string", ")", "bool", "{", "_", ",", "err", ":=", "Parse", "(", "uuid", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsValid reports whether the passed string is a valid uuid string.
[ "IsValid", "reports", "whether", "the", "passed", "string", "is", "a", "valid", "uuid", "string", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/parse.go#L57-L60
147,933
APTrust/bagins
bag.go
findManifests
func (b *Bag) findManifests() ([]error){ if b.Manifests == nil { b.Manifests = make([]*Manifest, 0) } if len(b.Manifests) == 0 { bagFiles, _ := b.ListFiles() for _, fName := range bagFiles { filePath := filepath.Join(b.pathToFile, fName) payloadManifestPrefix := filepath.Join(b.pathToFile, "manifest-") ...
go
func (b *Bag) findManifests() ([]error){ if b.Manifests == nil { b.Manifests = make([]*Manifest, 0) } if len(b.Manifests) == 0 { bagFiles, _ := b.ListFiles() for _, fName := range bagFiles { filePath := filepath.Join(b.pathToFile, fName) payloadManifestPrefix := filepath.Join(b.pathToFile, "manifest-") ...
[ "func", "(", "b", "*", "Bag", ")", "findManifests", "(", ")", "(", "[", "]", "error", ")", "{", "if", "b", ".", "Manifests", "==", "nil", "{", "b", ".", "Manifests", "=", "make", "(", "[", "]", "*", "Manifest", ",", "0", ")", "\n", "}", "\n",...
// Finds all payload and tag manifests in an existing bag. // This is used by ReadBag, not when creating a bag.
[ "Finds", "all", "payload", "and", "tag", "manifests", "in", "an", "existing", "bag", ".", "This", "is", "used", "by", "ReadBag", "not", "when", "creating", "a", "bag", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/bag.go#L231-L254
147,934
aybabtme/uniplot
spark/io.go
ReaderOut
func ReaderOut(r io.Reader, out *os.File) io.Reader { sprk := Spark(time.Millisecond * 33) sprk.Out = out sprk.Units = Bytes started := false return reader(func(b []byte) (int, error) { if !started { sprk.Start() started = true } n, err := r.Read(b) if err == nil { sprk.Add(float64(n)) } else { ...
go
func ReaderOut(r io.Reader, out *os.File) io.Reader { sprk := Spark(time.Millisecond * 33) sprk.Out = out sprk.Units = Bytes started := false return reader(func(b []byte) (int, error) { if !started { sprk.Start() started = true } n, err := r.Read(b) if err == nil { sprk.Add(float64(n)) } else { ...
[ "func", "ReaderOut", "(", "r", "io", ".", "Reader", ",", "out", "*", "os", ".", "File", ")", "io", ".", "Reader", "{", "sprk", ":=", "Spark", "(", "time", ".", "Millisecond", "*", "33", ")", "\n", "sprk", ".", "Out", "=", "out", "\n", "sprk", "...
// ReaderOut wraps the reads of r with a SparkStream. The stream will // have Bytes units and refresh every 33ms. // // It will stop printing when the reader returns an error.
[ "ReaderOut", "wraps", "the", "reads", "of", "r", "with", "a", "SparkStream", ".", "The", "stream", "will", "have", "Bytes", "units", "and", "refresh", "every", "33ms", ".", "It", "will", "stop", "printing", "when", "the", "reader", "returns", "an", "error"...
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/spark/io.go#L47-L65
147,935
aybabtme/uniplot
spark/io.go
Writer
func Writer(w io.Writer) (io.Writer, func()) { var out = os.Stderr if f, ok := w.(*os.File); ok && f == os.Stderr { out = os.Stdout } sprk := Spark(time.Millisecond * 33) sprk.Units = Bytes sprk.Out = out started := false return writer(func(b []byte) (int, error) { if !started { sprk.Start() started =...
go
func Writer(w io.Writer) (io.Writer, func()) { var out = os.Stderr if f, ok := w.(*os.File); ok && f == os.Stderr { out = os.Stdout } sprk := Spark(time.Millisecond * 33) sprk.Units = Bytes sprk.Out = out started := false return writer(func(b []byte) (int, error) { if !started { sprk.Start() started =...
[ "func", "Writer", "(", "w", "io", ".", "Writer", ")", "(", "io", ".", "Writer", ",", "func", "(", ")", ")", "{", "var", "out", "=", "os", ".", "Stderr", "\n", "if", "f", ",", "ok", ":=", "w", ".", "(", "*", "os", ".", "File", ")", ";", "o...
// Writer wraps the writes to w with a SparkStream. The stream will // have Bytes units and refresh every 33ms. // // It will stop printing when the writer returns an error.
[ "Writer", "wraps", "the", "writes", "to", "w", "with", "a", "SparkStream", ".", "The", "stream", "will", "have", "Bytes", "units", "and", "refresh", "every", "33ms", ".", "It", "will", "stop", "printing", "when", "the", "writer", "returns", "an", "error", ...
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/spark/io.go#L71-L93
147,936
aybabtme/uniplot
spark/io.go
WriteSeeker
func WriteSeeker(ws io.WriteSeeker) (io.WriteSeeker, func()) { var out = os.Stderr if f, ok := ws.(*os.File); ok && f == os.Stderr { out = os.Stdout } sprk := Spark(time.Millisecond * 33) sprk.Units = Bytes sprk.Out = out return writeSeeker{ WriteSeeker: ws, sprk: sprk, started: false, }, spr...
go
func WriteSeeker(ws io.WriteSeeker) (io.WriteSeeker, func()) { var out = os.Stderr if f, ok := ws.(*os.File); ok && f == os.Stderr { out = os.Stdout } sprk := Spark(time.Millisecond * 33) sprk.Units = Bytes sprk.Out = out return writeSeeker{ WriteSeeker: ws, sprk: sprk, started: false, }, spr...
[ "func", "WriteSeeker", "(", "ws", "io", ".", "WriteSeeker", ")", "(", "io", ".", "WriteSeeker", ",", "func", "(", ")", ")", "{", "var", "out", "=", "os", ".", "Stderr", "\n", "if", "f", ",", "ok", ":=", "ws", ".", "(", "*", "os", ".", "File", ...
// WriteSeeker wraps the writes to w with a SparkStream. The stream // will have Bytes units and refresh every 33ms. // // It will stop printing when the writer returns an error.
[ "WriteSeeker", "wraps", "the", "writes", "to", "w", "with", "a", "SparkStream", ".", "The", "stream", "will", "have", "Bytes", "units", "and", "refresh", "every", "33ms", ".", "It", "will", "stop", "printing", "when", "the", "writer", "returns", "an", "err...
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/spark/io.go#L99-L112
147,937
aybabtme/uniplot
spark/spark.go
Spark
func Spark(resolution time.Duration) *SparkStream { return &SparkStream{ Out: os.Stdout, buf: bytes.NewBuffer(nil), queue: queue.New(), res: resolution, tick: time.NewTicker(resolution), } }
go
func Spark(resolution time.Duration) *SparkStream { return &SparkStream{ Out: os.Stdout, buf: bytes.NewBuffer(nil), queue: queue.New(), res: resolution, tick: time.NewTicker(resolution), } }
[ "func", "Spark", "(", "resolution", "time", ".", "Duration", ")", "*", "SparkStream", "{", "return", "&", "SparkStream", "{", "Out", ":", "os", ".", "Stdout", ",", "buf", ":", "bytes", ".", "NewBuffer", "(", "nil", ")", ",", "queue", ":", "queue", "....
// Spark creates a stream of sparklines that will print every lines bucketize // with the given resolution. // // By default, it prints to os.Stdout and is unitless.
[ "Spark", "creates", "a", "stream", "of", "sparklines", "that", "will", "print", "every", "lines", "bucketize", "with", "the", "given", "resolution", ".", "By", "default", "it", "prints", "to", "os", ".", "Stdout", "and", "is", "unitless", "." ]
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/spark/spark.go#L27-L35
147,938
aybabtme/uniplot
spark/spark.go
Add
func (s *SparkStream) Add(v float64) { s.l.Lock() s.cur += v s.l.Unlock() }
go
func (s *SparkStream) Add(v float64) { s.l.Lock() s.cur += v s.l.Unlock() }
[ "func", "(", "s", "*", "SparkStream", ")", "Add", "(", "v", "float64", ")", "{", "s", ".", "l", ".", "Lock", "(", ")", "\n", "s", ".", "cur", "+=", "v", "\n", "s", ".", "l", ".", "Unlock", "(", ")", "\n", "}" ]
// Add puts the value in the current bucket of sparklines. The value // will appear part of the next update of the spark stream.
[ "Add", "puts", "the", "value", "in", "the", "current", "bucket", "of", "sparklines", ".", "The", "value", "will", "appear", "part", "of", "the", "next", "update", "of", "the", "spark", "stream", "." ]
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/spark/spark.go#L75-L79
147,939
APTrust/bagins
manifest.go
NewManifest
func NewManifest(pathToFile string, hashName string, manifestType string) (*Manifest, error) { if manifestType != PayloadManifest && manifestType != TagManifest { return nil, fmt.Errorf("Param manifestType must be either bagins.PayloadManifest " + "or bagins.TagManifest") } if _, err := os.Stat(filepath.Dir(pat...
go
func NewManifest(pathToFile string, hashName string, manifestType string) (*Manifest, error) { if manifestType != PayloadManifest && manifestType != TagManifest { return nil, fmt.Errorf("Param manifestType must be either bagins.PayloadManifest " + "or bagins.TagManifest") } if _, err := os.Stat(filepath.Dir(pat...
[ "func", "NewManifest", "(", "pathToFile", "string", ",", "hashName", "string", ",", "manifestType", "string", ")", "(", "*", "Manifest", ",", "error", ")", "{", "if", "manifestType", "!=", "PayloadManifest", "&&", "manifestType", "!=", "TagManifest", "{", "ret...
// Returns a pointer to a new manifest or returns an error if improperly named.
[ "Returns", "a", "pointer", "to", "a", "new", "manifest", "or", "returns", "an", "error", "if", "improperly", "named", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/manifest.go#L46-L83
147,940
APTrust/bagins
manifest.go
Create
func (m *Manifest) Create() error { if m.Name() == "" { return errors.New("Manifest must have values for basename and algo set to create a file.") } // Create directory if needed. basepath := filepath.Dir(m.name) if err := os.MkdirAll(basepath, 0777); err != nil { return err } // Create the tagfile. fileO...
go
func (m *Manifest) Create() error { if m.Name() == "" { return errors.New("Manifest must have values for basename and algo set to create a file.") } // Create directory if needed. basepath := filepath.Dir(m.name) if err := os.MkdirAll(basepath, 0777); err != nil { return err } // Create the tagfile. fileO...
[ "func", "(", "m", "*", "Manifest", ")", "Create", "(", ")", "error", "{", "if", "m", ".", "Name", "(", ")", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "// Create directory if needed.", "basepath", ...
// Writes key value pairs to a manifest file.
[ "Writes", "key", "value", "pairs", "to", "a", "manifest", "file", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/manifest.go#L144-L170
147,941
APTrust/bagins
manifest.go
ToString
func (m *Manifest) ToString() string { str := "" for fName, ckSum := range m.Data { str += fmt.Sprintf("%s %s\n", ckSum, fName) } return str }
go
func (m *Manifest) ToString() string { str := "" for fName, ckSum := range m.Data { str += fmt.Sprintf("%s %s\n", ckSum, fName) } return str }
[ "func", "(", "m", "*", "Manifest", ")", "ToString", "(", ")", "string", "{", "str", ":=", "\"", "\"", "\n", "for", "fName", ",", "ckSum", ":=", "range", "m", ".", "Data", "{", "str", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "ck...
// Returns the contents of the manifest in the form of a string. // Useful if you don't want to write directly to disk.
[ "Returns", "the", "contents", "of", "the", "manifest", "in", "the", "form", "of", "a", "string", ".", "Useful", "if", "you", "don", "t", "want", "to", "write", "directly", "to", "disk", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/manifest.go#L174-L180
147,942
APTrust/bagins
manifest.go
parseAlgoName
func parseAlgoName(name string) (string, error) { filename := filepath.Base(name) re, err := regexp.Compile(`(^.*\-)(.*)(\.txt$)`) if err != nil { return "", err } matches := re.FindStringSubmatch(filename) if len(matches) < 2 { return "", errors.New("Unable to determine algorithm from filename!") } algo :=...
go
func parseAlgoName(name string) (string, error) { filename := filepath.Base(name) re, err := regexp.Compile(`(^.*\-)(.*)(\.txt$)`) if err != nil { return "", err } matches := re.FindStringSubmatch(filename) if len(matches) < 2 { return "", errors.New("Unable to determine algorithm from filename!") } algo :=...
[ "func", "parseAlgoName", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "filename", ":=", "filepath", ".", "Base", "(", "name", ")", "\n", "re", ",", "err", ":=", "regexp", ".", "Compile", "(", "`(^.*\\-)(.*)(\\.txt$)`", ")", "\n", ...
// Tries to parse the algorithm name from a manifest filename. Returns // an error if unable to do so.
[ "Tries", "to", "parse", "the", "algorithm", "name", "from", "a", "manifest", "filename", ".", "Returns", "an", "error", "if", "unable", "to", "do", "so", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/manifest.go#L201-L213
147,943
APTrust/bagins
manifest.go
parseManifestData
func parseManifestData(file *os.File) (map[string]string, []error) { var errs []error // See regexp examples at http://play.golang.org/p/_msLJ-lBEu // Regex matches these reqs from the bagit spec: "One or // more linear whitespace characters (spaces or tabs) MUST separate // CHECKSUM from FILENAME." as specified h...
go
func parseManifestData(file *os.File) (map[string]string, []error) { var errs []error // See regexp examples at http://play.golang.org/p/_msLJ-lBEu // Regex matches these reqs from the bagit spec: "One or // more linear whitespace characters (spaces or tabs) MUST separate // CHECKSUM from FILENAME." as specified h...
[ "func", "parseManifestData", "(", "file", "*", "os", ".", "File", ")", "(", "map", "[", "string", "]", "string", ",", "[", "]", "error", ")", "{", "var", "errs", "[", "]", "error", "\n", "// See regexp examples at http://play.golang.org/p/_msLJ-lBEu", "// Rege...
// Reads the contents of file and parses checksum and file information in manifest format as // per the bagit specification.
[ "Reads", "the", "contents", "of", "file", "and", "parses", "checksum", "and", "file", "information", "in", "manifest", "format", "as", "per", "the", "bagit", "specification", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/manifest.go#L217-L240
147,944
APTrust/bagins
bagutil/bagutil.go
LookupHash
func LookupHash(algo string) (func() hash.Hash, error) { switch strings.ToLower(algo) { case "md5": return crypto.MD5.New, nil case "sha1": return crypto.SHA1.New, nil case "sha256": return crypto.SHA256.New, nil case "sha512": return crypto.SHA512.New, nil case "sha224": return crypto.SHA224.New, nil ...
go
func LookupHash(algo string) (func() hash.Hash, error) { switch strings.ToLower(algo) { case "md5": return crypto.MD5.New, nil case "sha1": return crypto.SHA1.New, nil case "sha256": return crypto.SHA256.New, nil case "sha512": return crypto.SHA512.New, nil case "sha224": return crypto.SHA224.New, nil ...
[ "func", "LookupHash", "(", "algo", "string", ")", "(", "func", "(", ")", "hash", ".", "Hash", ",", "error", ")", "{", "switch", "strings", ".", "ToLower", "(", "algo", ")", "{", "case", "\"", "\"", ":", "return", "crypto", ".", "MD5", ".", "New", ...
// Returns a new hash function based on a lookup of the algo string // passed to the function. Returns an error if the algo string does not match // any of the available cryto hashes.
[ "Returns", "a", "new", "hash", "function", "based", "on", "a", "lookup", "of", "the", "algo", "string", "passed", "to", "the", "function", ".", "Returns", "an", "error", "if", "the", "algo", "string", "does", "not", "match", "any", "of", "the", "availabl...
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/bagutil/bagutil.go#L52-L71
147,945
spiegel-im-spiegel/gocli
signal/signal.go
Context
func Context(parent context.Context, sig ...os.Signal) context.Context { cctx, cancel := context.WithCancel(parent) go func() { defer cancel() sigCh := make(chan os.Signal, 1) signl.Notify(sigCh, sig...) defer signl.Stop(sigCh) select { case <-cctx.Done(): // cancel event from parent context return ...
go
func Context(parent context.Context, sig ...os.Signal) context.Context { cctx, cancel := context.WithCancel(parent) go func() { defer cancel() sigCh := make(chan os.Signal, 1) signl.Notify(sigCh, sig...) defer signl.Stop(sigCh) select { case <-cctx.Done(): // cancel event from parent context return ...
[ "func", "Context", "(", "parent", "context", ".", "Context", ",", "sig", "...", "os", ".", "Signal", ")", "context", ".", "Context", "{", "cctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "parent", ")", "\n", "go", "func", "(", ")", "{"...
//Context returns context.Context with Cancel
[ "Context", "returns", "context", ".", "Context", "with", "Cancel" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/signal/signal.go#L14-L31
147,946
mailhog/http
server.go
AuthFile
func AuthFile(file string) { users = make(map[string]string) b, err := ioutil.ReadFile(file) if err != nil { log.Fatalf("[HTTP] Error reading auth-file: %s", err) // FIXME - go-log os.Exit(1) } buf := bytes.NewBuffer(b) for { l, err := buf.ReadString('\n') l = strings.TrimSpace(l) if len(l) > 0 { ...
go
func AuthFile(file string) { users = make(map[string]string) b, err := ioutil.ReadFile(file) if err != nil { log.Fatalf("[HTTP] Error reading auth-file: %s", err) // FIXME - go-log os.Exit(1) } buf := bytes.NewBuffer(b) for { l, err := buf.ReadString('\n') l = strings.TrimSpace(l) if len(l) > 0 { ...
[ "func", "AuthFile", "(", "file", "string", ")", "{", "users", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".",...
// AuthFile sets Authorised to a function which validates against file
[ "AuthFile", "sets", "Authorised", "to", "a", "function", "which", "validates", "against", "file" ]
2e653938bf190d0e2fbe4825ce74e5bc149a62f2
https://github.com/mailhog/http/blob/2e653938bf190d0e2fbe4825ce74e5bc149a62f2/server.go#L21-L75
147,947
mailhog/http
server.go
BasicAuthHandler
func BasicAuthHandler(h http.Handler) http.Handler { f := func(w http.ResponseWriter, req *http.Request) { if Authorised == nil { h.ServeHTTP(w, req) return } u, pw, ok := req.BasicAuth() if !ok || !Authorised(u, pw) { w.Header().Set("WWW-Authenticate", "Basic") w.WriteHeader(401) return } ...
go
func BasicAuthHandler(h http.Handler) http.Handler { f := func(w http.ResponseWriter, req *http.Request) { if Authorised == nil { h.ServeHTTP(w, req) return } u, pw, ok := req.BasicAuth() if !ok || !Authorised(u, pw) { w.Header().Set("WWW-Authenticate", "Basic") w.WriteHeader(401) return } ...
[ "func", "BasicAuthHandler", "(", "h", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "f", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "if", "Authorised", "==", "nil", "{", "h", ...
// BasicAuthHandler is middleware to check HTTP Basic Authentication // if an authorisation function is defined.
[ "BasicAuthHandler", "is", "middleware", "to", "check", "HTTP", "Basic", "Authentication", "if", "an", "authorisation", "function", "is", "defined", "." ]
2e653938bf190d0e2fbe4825ce74e5bc149a62f2
https://github.com/mailhog/http/blob/2e653938bf190d0e2fbe4825ce74e5bc149a62f2/server.go#L79-L96
147,948
mailhog/http
server.go
Listen
func Listen(httpBindAddr string, Asset func(string) ([]byte, error), exitCh chan int, registerCallback func(http.Handler)) { log.Info("[HTTP] Binding to address: %s", httpBindAddr) pat := pat.New() registerCallback(pat) //compress := handlers.CompressHandler(pat) auth := BasicAuthHandler(pat) //compress) err :...
go
func Listen(httpBindAddr string, Asset func(string) ([]byte, error), exitCh chan int, registerCallback func(http.Handler)) { log.Info("[HTTP] Binding to address: %s", httpBindAddr) pat := pat.New() registerCallback(pat) //compress := handlers.CompressHandler(pat) auth := BasicAuthHandler(pat) //compress) err :...
[ "func", "Listen", "(", "httpBindAddr", "string", ",", "Asset", "func", "(", "string", ")", "(", "[", "]", "byte", ",", "error", ")", ",", "exitCh", "chan", "int", ",", "registerCallback", "func", "(", "http", ".", "Handler", ")", ")", "{", "log", "."...
// Listen binds to httpBindAddr
[ "Listen", "binds", "to", "httpBindAddr" ]
2e653938bf190d0e2fbe4825ce74e5bc149a62f2
https://github.com/mailhog/http/blob/2e653938bf190d0e2fbe4825ce74e5bc149a62f2/server.go#L99-L112
147,949
Clever/ARCHIVED-oplog-replay
bson/scan.go
NewScanner
func NewScanner(r io.Reader) *Scanner { return &Scanner{ r: r, split: ScanLines, maxTokenSize: MaxScanTokenSize, buf: make([]byte, 4096), // Plausible starting size; needn't be large. } }
go
func NewScanner(r io.Reader) *Scanner { return &Scanner{ r: r, split: ScanLines, maxTokenSize: MaxScanTokenSize, buf: make([]byte, 4096), // Plausible starting size; needn't be large. } }
[ "func", "NewScanner", "(", "r", "io", ".", "Reader", ")", "*", "Scanner", "{", "return", "&", "Scanner", "{", "r", ":", "r", ",", "split", ":", "ScanLines", ",", "maxTokenSize", ":", "MaxScanTokenSize", ",", "buf", ":", "make", "(", "[", "]", "byte",...
// NewScanner returns a new Scanner to read from r. // The split function defaults to ScanLines.
[ "NewScanner", "returns", "a", "new", "Scanner", "to", "read", "from", "r", ".", "The", "split", "function", "defaults", "to", "ScanLines", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L80-L87
147,950
Clever/ARCHIVED-oplog-replay
bson/scan.go
Scan
func (s *Scanner) Scan() bool { // Loop until we have a token. for { // See if we can get a token with what we already have. if s.end > s.start { advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil) if err != nil { s.setErr(err) return false } if !s.advance(advance) { return ...
go
func (s *Scanner) Scan() bool { // Loop until we have a token. for { // See if we can get a token with what we already have. if s.end > s.start { advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil) if err != nil { s.setErr(err) return false } if !s.advance(advance) { return ...
[ "func", "(", "s", "*", "Scanner", ")", "Scan", "(", ")", "bool", "{", "// Loop until we have a token.", "for", "{", "// See if we can get a token with what we already have.", "if", "s", ".", "end", ">", "s", ".", "start", "{", "advance", ",", "token", ",", "er...
// Scan advances the Scanner to the next token, which will then be // available through the Bytes or Text method. It returns false when the // scan stops, either by reaching the end of the input or an error. // After Scan returns false, the Err method will return any error that // occurred during scanning, except that ...
[ "Scan", "advances", "the", "Scanner", "to", "the", "next", "token", "which", "will", "then", "be", "available", "through", "the", "Bytes", "or", "Text", "method", ".", "It", "returns", "false", "when", "the", "scan", "stops", "either", "by", "reaching", "t...
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L116-L187
147,951
Clever/ARCHIVED-oplog-replay
bson/scan.go
advance
func (s *Scanner) advance(n int) bool { if n < 0 { s.setErr(ErrNegativeAdvance) return false } if n > s.end-s.start { s.setErr(ErrAdvanceTooFar) return false } s.start += n return true }
go
func (s *Scanner) advance(n int) bool { if n < 0 { s.setErr(ErrNegativeAdvance) return false } if n > s.end-s.start { s.setErr(ErrAdvanceTooFar) return false } s.start += n return true }
[ "func", "(", "s", "*", "Scanner", ")", "advance", "(", "n", "int", ")", "bool", "{", "if", "n", "<", "0", "{", "s", ".", "setErr", "(", "ErrNegativeAdvance", ")", "\n", "return", "false", "\n", "}", "\n", "if", "n", ">", "s", ".", "end", "-", ...
// advance consumes n bytes of the buffer. It reports whether the advance was legal.
[ "advance", "consumes", "n", "bytes", "of", "the", "buffer", ".", "It", "reports", "whether", "the", "advance", "was", "legal", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L190-L201
147,952
Clever/ARCHIVED-oplog-replay
bson/scan.go
ScanBytes
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } return 1, data[0:1], nil }
go
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } return 1, data[0:1], nil }
[ "func", "ScanBytes", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "advance", "int", ",", "token", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "atEOF", "&&", "len", "(", "data", ")", "==", "0", "{", "return", "0", ",...
// Split functions // ScanBytes is a split function for a Scanner that returns each byte as a token.
[ "Split", "functions", "ScanBytes", "is", "a", "split", "function", "for", "a", "Scanner", "that", "returns", "each", "byte", "as", "a", "token", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L219-L224
147,953
Clever/ARCHIVED-oplog-replay
bson/scan.go
ScanRunes
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } // Fast path 1: ASCII. if data[0] < utf8.RuneSelf { return 1, data[0:1], nil } // Fast path 2: Correct UTF-8 decode without error. _, width := utf8.DecodeRune(data) if width >...
go
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } // Fast path 1: ASCII. if data[0] < utf8.RuneSelf { return 1, data[0:1], nil } // Fast path 2: Correct UTF-8 decode without error. _, width := utf8.DecodeRune(data) if width >...
[ "func", "ScanRunes", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "advance", "int", ",", "token", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "atEOF", "&&", "len", "(", "data", ")", "==", "0", "{", "return", "0", ",...
// ScanRunes is a split function for a Scanner that returns each // UTF-8-encoded rune as a token. The sequence of runes returned is // equivalent to that from a range loop over the input as a string, which // means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd". // Because of the Scan interface, t...
[ "ScanRunes", "is", "a", "split", "function", "for", "a", "Scanner", "that", "returns", "each", "UTF", "-", "8", "-", "encoded", "rune", "as", "a", "token", ".", "The", "sequence", "of", "runes", "returned", "is", "equivalent", "to", "that", "from", "a", ...
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L234-L264
147,954
Clever/ARCHIVED-oplog-replay
bson/scan.go
isSpace
func isSpace(r rune) bool { if r <= '\u00FF' { // Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs. switch r { case ' ', '\t', '\n', '\v', '\f', '\r': return true case '\u0085', '\u00A0': return true } return false } // High-valued ones. if '\u2000' <= r && r <= '\u200a' { ...
go
func isSpace(r rune) bool { if r <= '\u00FF' { // Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs. switch r { case ' ', '\t', '\n', '\v', '\f', '\r': return true case '\u0085', '\u00A0': return true } return false } // High-valued ones. if '\u2000' <= r && r <= '\u200a' { ...
[ "func", "isSpace", "(", "r", "rune", ")", "bool", "{", "if", "r", "<=", "'\\u00FF'", "{", "// Obvious ASCII ones: \\t through \\r plus space. Plus two Latin-1 oddballs.", "switch", "r", "{", "case", "' '", ",", "'\\t'", ",", "'\\n'", ",", "'\\v'", ",", "'\\f'", ...
// isSpace reports whether the character is a Unicode white space character. // We avoid dependency on the unicode package, but check validity of the implementation // in the tests.
[ "isSpace", "reports", "whether", "the", "character", "is", "a", "Unicode", "white", "space", "character", ".", "We", "avoid", "dependency", "on", "the", "unicode", "package", "but", "check", "validity", "of", "the", "implementation", "in", "the", "tests", "." ...
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L299-L319
147,955
Clever/ARCHIVED-oplog-replay
bson/scan.go
ScanWords
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) { // Skip leading spaces. start := 0 for width := 0; start < len(data); start += width { var r rune r, width = utf8.DecodeRune(data[start:]) if !isSpace(r) { break } } if atEOF && len(data) == 0 { return 0, nil, nil } // ...
go
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) { // Skip leading spaces. start := 0 for width := 0; start < len(data); start += width { var r rune r, width = utf8.DecodeRune(data[start:]) if !isSpace(r) { break } } if atEOF && len(data) == 0 { return 0, nil, nil } // ...
[ "func", "ScanWords", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "advance", "int", ",", "token", "[", "]", "byte", ",", "err", "error", ")", "{", "// Skip leading spaces.", "start", ":=", "0", "\n", "for", "width", ":=", "0", ";", ...
// ScanWords is a split function for a Scanner that returns each // space-separated word of text, with surrounding spaces deleted. It will // never return an empty string. The definition of space is set by // unicode.IsSpace.
[ "ScanWords", "is", "a", "split", "function", "for", "a", "Scanner", "that", "returns", "each", "space", "-", "separated", "word", "of", "text", "with", "surrounding", "spaces", "deleted", ".", "It", "will", "never", "return", "an", "empty", "string", ".", ...
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/scan.go#L325-L352
147,956
mastahyeti/certstore
certstore_darwin.go
Certificate
func (i *macIdentity) Certificate() (*x509.Certificate, error) { certRef, err := i.getCertRef() if err != nil { return nil, err } crt, err := exportCertRef(certRef) if err != nil { return nil, err } i.crt = crt return i.crt, nil }
go
func (i *macIdentity) Certificate() (*x509.Certificate, error) { certRef, err := i.getCertRef() if err != nil { return nil, err } crt, err := exportCertRef(certRef) if err != nil { return nil, err } i.crt = crt return i.crt, nil }
[ "func", "(", "i", "*", "macIdentity", ")", "Certificate", "(", ")", "(", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "certRef", ",", "err", ":=", "i", ".", "getCertRef", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// Certificate implements the Identity iterface.
[ "Certificate", "implements", "the", "Identity", "iterface", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L128-L142
147,957
mastahyeti/certstore
certstore_darwin.go
Signer
func (i *macIdentity) Signer() (crypto.Signer, error) { // pre-load the certificate so Public() is less likely to return nil // unexpectedly. if _, err := i.Certificate(); err != nil { return nil, err } return i, nil }
go
func (i *macIdentity) Signer() (crypto.Signer, error) { // pre-load the certificate so Public() is less likely to return nil // unexpectedly. if _, err := i.Certificate(); err != nil { return nil, err } return i, nil }
[ "func", "(", "i", "*", "macIdentity", ")", "Signer", "(", ")", "(", "crypto", ".", "Signer", ",", "error", ")", "{", "// pre-load the certificate so Public() is less likely to return nil", "// unexpectedly.", "if", "_", ",", "err", ":=", "i", ".", "Certificate", ...
// Signer implements the Identity iterface.
[ "Signer", "implements", "the", "Identity", "iterface", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L194-L202
147,958
mastahyeti/certstore
certstore_darwin.go
Public
func (i *macIdentity) Public() crypto.PublicKey { cert, err := i.Certificate() if err != nil { return nil } return cert.PublicKey }
go
func (i *macIdentity) Public() crypto.PublicKey { cert, err := i.Certificate() if err != nil { return nil } return cert.PublicKey }
[ "func", "(", "i", "*", "macIdentity", ")", "Public", "(", ")", "crypto", ".", "PublicKey", "{", "cert", ",", "err", ":=", "i", ".", "Certificate", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "cert", ...
// Public implements the crypto.Signer iterface.
[ "Public", "implements", "the", "crypto", ".", "Signer", "iterface", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L249-L256
147,959
mastahyeti/certstore
certstore_darwin.go
Sign
func (i *macIdentity) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) { hash := opts.HashFunc() if len(digest) != hash.Size() { return nil, errors.New("bad digest for hash") } kref, err := i.getKeyRef() if err != nil { return nil, err } cdigest, err := bytesToCFData(digest) if...
go
func (i *macIdentity) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) { hash := opts.HashFunc() if len(digest) != hash.Size() { return nil, errors.New("bad digest for hash") } kref, err := i.getKeyRef() if err != nil { return nil, err } cdigest, err := bytesToCFData(digest) if...
[ "func", "(", "i", "*", "macIdentity", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "digest", "[", "]", "byte", ",", "opts", "crypto", ".", "SignerOpts", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "hash", ":=", "opts", ".", "HashFu...
// Sign implements the crypto.Signer iterface.
[ "Sign", "implements", "the", "crypto", ".", "Signer", "iterface", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L259-L301
147,960
mastahyeti/certstore
certstore_darwin.go
getAlgo
func (i *macIdentity) getAlgo(hash crypto.Hash) (algo C.SecKeyAlgorithm, err error) { var crt *x509.Certificate if crt, err = i.Certificate(); err != nil { return } switch crt.PublicKey.(type) { case *ecdsa.PublicKey: switch hash { case crypto.SHA1: algo = C.kSecKeyAlgorithmECDSASignatureDigestX962SHA1 ...
go
func (i *macIdentity) getAlgo(hash crypto.Hash) (algo C.SecKeyAlgorithm, err error) { var crt *x509.Certificate if crt, err = i.Certificate(); err != nil { return } switch crt.PublicKey.(type) { case *ecdsa.PublicKey: switch hash { case crypto.SHA1: algo = C.kSecKeyAlgorithmECDSASignatureDigestX962SHA1 ...
[ "func", "(", "i", "*", "macIdentity", ")", "getAlgo", "(", "hash", "crypto", ".", "Hash", ")", "(", "algo", "C", ".", "SecKeyAlgorithm", ",", "err", "error", ")", "{", "var", "crt", "*", "x509", ".", "Certificate", "\n", "if", "crt", ",", "err", "=...
// getAlgo decides which algorithm to use with this key type for the given hash.
[ "getAlgo", "decides", "which", "algorithm", "to", "use", "with", "this", "key", "type", "for", "the", "given", "hash", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L304-L342
147,961
mastahyeti/certstore
certstore_darwin.go
getKeyRef
func (i *macIdentity) getKeyRef() (C.SecKeyRef, error) { if i.kref != nilSecKeyRef { return i.kref, nil } var keyRef C.SecKeyRef if err := osStatusError(C.SecIdentityCopyPrivateKey(i.ref, &keyRef)); err != nil { return nilSecKeyRef, err } i.kref = keyRef return i.kref, nil }
go
func (i *macIdentity) getKeyRef() (C.SecKeyRef, error) { if i.kref != nilSecKeyRef { return i.kref, nil } var keyRef C.SecKeyRef if err := osStatusError(C.SecIdentityCopyPrivateKey(i.ref, &keyRef)); err != nil { return nilSecKeyRef, err } i.kref = keyRef return i.kref, nil }
[ "func", "(", "i", "*", "macIdentity", ")", "getKeyRef", "(", ")", "(", "C", ".", "SecKeyRef", ",", "error", ")", "{", "if", "i", ".", "kref", "!=", "nilSecKeyRef", "{", "return", "i", ".", "kref", ",", "nil", "\n", "}", "\n\n", "var", "keyRef", "...
// getKeyRef gets the SecKeyRef for this identity's pricate key.
[ "getKeyRef", "gets", "the", "SecKeyRef", "for", "this", "identity", "s", "pricate", "key", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L345-L358
147,962
mastahyeti/certstore
certstore_darwin.go
getCertRef
func (i *macIdentity) getCertRef() (C.SecCertificateRef, error) { if i.cref != nilSecCertificateRef { return i.cref, nil } var certRef C.SecCertificateRef if err := osStatusError(C.SecIdentityCopyCertificate(i.ref, &certRef)); err != nil { return nilSecCertificateRef, err } i.cref = certRef return i.cref,...
go
func (i *macIdentity) getCertRef() (C.SecCertificateRef, error) { if i.cref != nilSecCertificateRef { return i.cref, nil } var certRef C.SecCertificateRef if err := osStatusError(C.SecIdentityCopyCertificate(i.ref, &certRef)); err != nil { return nilSecCertificateRef, err } i.cref = certRef return i.cref,...
[ "func", "(", "i", "*", "macIdentity", ")", "getCertRef", "(", ")", "(", "C", ".", "SecCertificateRef", ",", "error", ")", "{", "if", "i", ".", "cref", "!=", "nilSecCertificateRef", "{", "return", "i", ".", "cref", ",", "nil", "\n", "}", "\n\n", "var"...
// getCertRef gets the SecCertificateRef for this identity's certificate.
[ "getCertRef", "gets", "the", "SecCertificateRef", "for", "this", "identity", "s", "certificate", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L361-L374
147,963
mastahyeti/certstore
certstore_darwin.go
stringToCFString
func stringToCFString(gostr string) C.CFStringRef { cstr := C.CString(gostr) defer C.free(unsafe.Pointer(cstr)) return C.CFStringCreateWithCString(nilCFAllocatorRef, cstr, C.kCFStringEncodingUTF8) }
go
func stringToCFString(gostr string) C.CFStringRef { cstr := C.CString(gostr) defer C.free(unsafe.Pointer(cstr)) return C.CFStringCreateWithCString(nilCFAllocatorRef, cstr, C.kCFStringEncodingUTF8) }
[ "func", "stringToCFString", "(", "gostr", "string", ")", "C", ".", "CFStringRef", "{", "cstr", ":=", "C", ".", "CString", "(", "gostr", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n\n", "return", "C",...
// stringToCFString converts a Go string to a CFStringRef.
[ "stringToCFString", "converts", "a", "Go", "string", "to", "a", "CFStringRef", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L394-L399
147,964
mastahyeti/certstore
certstore_darwin.go
cfDataToBytes
func cfDataToBytes(cfdata C.CFDataRef) []byte { nBytes := C.CFDataGetLength(cfdata) bytesPtr := C.CFDataGetBytePtr(cfdata) return C.GoBytes(unsafe.Pointer(bytesPtr), C.int(nBytes)) }
go
func cfDataToBytes(cfdata C.CFDataRef) []byte { nBytes := C.CFDataGetLength(cfdata) bytesPtr := C.CFDataGetBytePtr(cfdata) return C.GoBytes(unsafe.Pointer(bytesPtr), C.int(nBytes)) }
[ "func", "cfDataToBytes", "(", "cfdata", "C", ".", "CFDataRef", ")", "[", "]", "byte", "{", "nBytes", ":=", "C", ".", "CFDataGetLength", "(", "cfdata", ")", "\n", "bytesPtr", ":=", "C", ".", "CFDataGetBytePtr", "(", "cfdata", ")", "\n", "return", "C", "...
// cfDataToBytes converts a CFDataRef to a Go byte slice.
[ "cfDataToBytes", "converts", "a", "CFDataRef", "to", "a", "Go", "byte", "slice", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L419-L423
147,965
mastahyeti/certstore
certstore_darwin.go
bytesToCFData
func bytesToCFData(gobytes []byte) (C.CFDataRef, error) { var ( cptr = (*C.UInt8)(nil) clen = C.CFIndex(len(gobytes)) ) if len(gobytes) > 0 { cptr = (*C.UInt8)(&gobytes[0]) } cdata := C.CFDataCreate(nilCFAllocatorRef, cptr, clen) if cdata == nilCFDataRef { return nilCFDataRef, errors.New("error creatin ...
go
func bytesToCFData(gobytes []byte) (C.CFDataRef, error) { var ( cptr = (*C.UInt8)(nil) clen = C.CFIndex(len(gobytes)) ) if len(gobytes) > 0 { cptr = (*C.UInt8)(&gobytes[0]) } cdata := C.CFDataCreate(nilCFAllocatorRef, cptr, clen) if cdata == nilCFDataRef { return nilCFDataRef, errors.New("error creatin ...
[ "func", "bytesToCFData", "(", "gobytes", "[", "]", "byte", ")", "(", "C", ".", "CFDataRef", ",", "error", ")", "{", "var", "(", "cptr", "=", "(", "*", "C", ".", "UInt8", ")", "(", "nil", ")", "\n", "clen", "=", "C", ".", "CFIndex", "(", "len", ...
// bytesToCFData converts a Go byte slice to a CFDataRef.
[ "bytesToCFData", "converts", "a", "Go", "byte", "slice", "to", "a", "CFDataRef", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L426-L442
147,966
mastahyeti/certstore
certstore_darwin.go
osStatusError
func osStatusError(s C.OSStatus) error { if s == C.errSecSuccess { return nil } return osStatus(s) }
go
func osStatusError(s C.OSStatus) error { if s == C.errSecSuccess { return nil } return osStatus(s) }
[ "func", "osStatusError", "(", "s", "C", ".", "OSStatus", ")", "error", "{", "if", "s", "==", "C", ".", "errSecSuccess", "{", "return", "nil", "\n", "}", "\n\n", "return", "osStatus", "(", "s", ")", "\n", "}" ]
// osStatusError returns an error for an OSStatus unless it is errSecSuccess.
[ "osStatusError", "returns", "an", "error", "for", "an", "OSStatus", "unless", "it", "is", "errSecSuccess", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L452-L458
147,967
mastahyeti/certstore
certstore_darwin.go
cfErrorError
func cfErrorError(cerr C.CFErrorRef) error { if cerr == nilCFErrorRef { return nil } code := int(C.CFErrorGetCode(cerr)) if cdescription := C.CFErrorCopyDescription(cerr); cdescription != nilCFStringRef { defer C.CFRelease(C.CFTypeRef(cdescription)) if cstr := C.CFStringGetCStringPtr(cdescription, C.kCFStr...
go
func cfErrorError(cerr C.CFErrorRef) error { if cerr == nilCFErrorRef { return nil } code := int(C.CFErrorGetCode(cerr)) if cdescription := C.CFErrorCopyDescription(cerr); cdescription != nilCFStringRef { defer C.CFRelease(C.CFTypeRef(cdescription)) if cstr := C.CFStringGetCStringPtr(cdescription, C.kCFStr...
[ "func", "cfErrorError", "(", "cerr", "C", ".", "CFErrorRef", ")", "error", "{", "if", "cerr", "==", "nilCFErrorRef", "{", "return", "nil", "\n", "}", "\n\n", "code", ":=", "int", "(", "C", ".", "CFErrorGetCode", "(", "cerr", ")", ")", "\n\n", "if", "...
// cfErrorError returns an error for a CFErrorRef unless it is nil.
[ "cfErrorError", "returns", "an", "error", "for", "a", "CFErrorRef", "unless", "it", "is", "nil", "." ]
04bdce6d3f6d509bf404d6a2e5b016db14eff232
https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_darwin.go#L466-L485
147,968
akutz/gournal
logrus/gournal_logrus.go
NewWithOptions
func NewWithOptions( out io.Writer, lvl logrus.Level, formatter logrus.Formatter) gournal.Appender { return &appender{&logrus.Logger{Out: out, Level: lvl, Formatter: formatter}} }
go
func NewWithOptions( out io.Writer, lvl logrus.Level, formatter logrus.Formatter) gournal.Appender { return &appender{&logrus.Logger{Out: out, Level: lvl, Formatter: formatter}} }
[ "func", "NewWithOptions", "(", "out", "io", ".", "Writer", ",", "lvl", "logrus", ".", "Level", ",", "formatter", "logrus", ".", "Formatter", ")", "gournal", ".", "Appender", "{", "return", "&", "appender", "{", "&", "logrus", ".", "Logger", "{", "Out", ...
// NewWithOptions returns a logrus logger that implements the Gournal Appender // interface.
[ "NewWithOptions", "returns", "a", "logrus", "logger", "that", "implements", "the", "Gournal", "Appender", "interface", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/logrus/gournal_logrus.go#L25-L31
147,969
akutz/gournal
gournal.go
String
func (level Level) String() string { if level < PanicLevel || level >= levelCount { return lvlValsToStrs[UnknownLevel] } return lvlValsToStrs[level] }
go
func (level Level) String() string { if level < PanicLevel || level >= levelCount { return lvlValsToStrs[UnknownLevel] } return lvlValsToStrs[level] }
[ "func", "(", "level", "Level", ")", "String", "(", ")", "string", "{", "if", "level", "<", "PanicLevel", "||", "level", ">=", "levelCount", "{", "return", "lvlValsToStrs", "[", "UnknownLevel", "]", "\n", "}", "\n", "return", "lvlValsToStrs", "[", "level", ...
// String returns string representation of a Level.
[ "String", "returns", "string", "representation", "of", "a", "Level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L142-L147
147,970
akutz/gournal
gournal.go
ParseLevel
func ParseLevel(lvl string) Level { switch { case strings.EqualFold(lvl, debugLevelStr): return DebugLevel case strings.EqualFold(lvl, infoLevelStr): return InfoLevel case strings.EqualFold(lvl, warnLevelStr), strings.EqualFold(lvl, warningLevelStr): return WarnLevel case strings.EqualFold(lvl, errorLevelS...
go
func ParseLevel(lvl string) Level { switch { case strings.EqualFold(lvl, debugLevelStr): return DebugLevel case strings.EqualFold(lvl, infoLevelStr): return InfoLevel case strings.EqualFold(lvl, warnLevelStr), strings.EqualFold(lvl, warningLevelStr): return WarnLevel case strings.EqualFold(lvl, errorLevelS...
[ "func", "ParseLevel", "(", "lvl", "string", ")", "Level", "{", "switch", "{", "case", "strings", ".", "EqualFold", "(", "lvl", ",", "debugLevelStr", ")", ":", "return", "DebugLevel", "\n", "case", "strings", ".", "EqualFold", "(", "lvl", ",", "infoLevelStr...
// ParseLevel parses a string and returns its constant.
[ "ParseLevel", "parses", "a", "string", "and", "returns", "its", "constant", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L150-L167
147,971
akutz/gournal
gournal.go
Debug
func Debug(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, DebugLevel, nil, msg, args...) }
go
func Debug(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, DebugLevel, nil, msg, args...) }
[ "func", "Debug", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "sendToAppender", "(", "ctx", ",", "DebugLevel", ",", "nil", ",", "msg", ",", "args", "...", ")", "\n", "}" ]
// Debug emits a log entry at the DEBUG level.
[ "Debug", "emits", "a", "log", "entry", "at", "the", "DEBUG", "level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L302-L304
147,972
akutz/gournal
gournal.go
Info
func Info(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, InfoLevel, nil, msg, args...) }
go
func Info(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, InfoLevel, nil, msg, args...) }
[ "func", "Info", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "sendToAppender", "(", "ctx", ",", "InfoLevel", ",", "nil", ",", "msg", ",", "args", "...", ")", "\n", "}" ]
// Info emits a log entry at the INFO level.
[ "Info", "emits", "a", "log", "entry", "at", "the", "INFO", "level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L307-L309
147,973
akutz/gournal
gournal.go
Warn
func Warn(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, WarnLevel, nil, msg, args...) }
go
func Warn(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, WarnLevel, nil, msg, args...) }
[ "func", "Warn", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "sendToAppender", "(", "ctx", ",", "WarnLevel", ",", "nil", ",", "msg", ",", "args", "...", ")", "\n", "}" ]
// Warn emits a log entry at the WARN level.
[ "Warn", "emits", "a", "log", "entry", "at", "the", "WARN", "level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L317-L319
147,974
akutz/gournal
gournal.go
Error
func Error(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, ErrorLevel, nil, msg, args...) }
go
func Error(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, ErrorLevel, nil, msg, args...) }
[ "func", "Error", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "sendToAppender", "(", "ctx", ",", "ErrorLevel", ",", "nil", ",", "msg", ",", "args", "...", ")", "\n", "}" ]
// Error emits a log entry at the ERROR level.
[ "Error", "emits", "a", "log", "entry", "at", "the", "ERROR", "level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L322-L324
147,975
akutz/gournal
gournal.go
Fatal
func Fatal(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, FatalLevel, nil, msg, args...) }
go
func Fatal(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, FatalLevel, nil, msg, args...) }
[ "func", "Fatal", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "sendToAppender", "(", "ctx", ",", "FatalLevel", ",", "nil", ",", "msg", ",", "args", "...", ")", "\n", "}" ]
// Fatal emits a log entry at the FATAL level.
[ "Fatal", "emits", "a", "log", "entry", "at", "the", "FATAL", "level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L327-L329
147,976
akutz/gournal
gournal.go
Panic
func Panic(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, PanicLevel, nil, msg, args...) }
go
func Panic(ctx context.Context, msg string, args ...interface{}) { sendToAppender(ctx, PanicLevel, nil, msg, args...) }
[ "func", "Panic", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "sendToAppender", "(", "ctx", ",", "PanicLevel", ",", "nil", ",", "msg", ",", "args", "...", ")", "\n", "}" ]
// Panic emits a log entry at the PANIC level.
[ "Panic", "emits", "a", "log", "entry", "at", "the", "PANIC", "level", "." ]
f6e56fa29076290418175a5105fd0223c66ad1bc
https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/gournal.go#L332-L334
147,977
APTrust/bagins
tagfile.go
AddField
func (fl *TagFieldList) AddField(field TagField) { fl.fields = append(fl.Fields(), field) }
go
func (fl *TagFieldList) AddField(field TagField) { fl.fields = append(fl.Fields(), field) }
[ "func", "(", "fl", "*", "TagFieldList", ")", "AddField", "(", "field", "TagField", ")", "{", "fl", ".", "fields", "=", "append", "(", "fl", ".", "Fields", "(", ")", ",", "field", ")", "\n", "}" ]
// Adds a Field to the end of the tag field list.
[ "Adds", "a", "Field", "to", "the", "end", "of", "the", "tag", "field", "list", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/tagfile.go#L87-L89
147,978
APTrust/bagins
tagfile.go
validateTagFileName
func validateTagFileName(name string) (err error) { _, err = os.Stat(filepath.Dir(name)) re, _ := regexp.Compile(`.*\.txt`) if !re.MatchString(filepath.Base(name)) { err = errors.New(fmt.Sprint("Tagfiles must end in .txt and contain at least 1 letter. Provided: ", filepath.Base(name))) } return err }
go
func validateTagFileName(name string) (err error) { _, err = os.Stat(filepath.Dir(name)) re, _ := regexp.Compile(`.*\.txt`) if !re.MatchString(filepath.Base(name)) { err = errors.New(fmt.Sprint("Tagfiles must end in .txt and contain at least 1 letter. Provided: ", filepath.Base(name))) } return err }
[ "func", "validateTagFileName", "(", "name", "string", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "os", ".", "Stat", "(", "filepath", ".", "Dir", "(", "name", ")", ")", "\n", "re", ",", "_", ":=", "regexp", ".", "Compile", "(", "`.*...
// Some private convenence methods for manipulating tag files.
[ "Some", "private", "convenence", "methods", "for", "manipulating", "tag", "files", "." ]
5bc94534149810750faf248f6ac948b48cbb2fc5
https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/tagfile.go#L239-L246
147,979
spiegel-im-spiegel/gocli
prompt/prompt.go
New
func New(rw *rwi.RWI, function func(string) (string, error), opts ...OptFunc) *Prompt { p := &Prompt{rw: rw, function: function, scanner: bufio.NewScanner(rw.Reader())} for _, opt := range opts { opt(p) } return p }
go
func New(rw *rwi.RWI, function func(string) (string, error), opts ...OptFunc) *Prompt { p := &Prompt{rw: rw, function: function, scanner: bufio.NewScanner(rw.Reader())} for _, opt := range opts { opt(p) } return p }
[ "func", "New", "(", "rw", "*", "rwi", ".", "RWI", ",", "function", "func", "(", "string", ")", "(", "string", ",", "error", ")", ",", "opts", "...", "OptFunc", ")", "*", "Prompt", "{", "p", ":=", "&", "Prompt", "{", "rw", ":", "rw", ",", "funct...
//New returns new Prompt instance
[ "New", "returns", "new", "Prompt", "instance" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/prompt/prompt.go#L30-L36
147,980
spiegel-im-spiegel/gocli
prompt/prompt.go
IsTerminal
func (p *Prompt) IsTerminal() bool { if file, ok := p.rw.Reader().(*os.File); !ok { return false } else if !isatty.IsTerminal(file.Fd()) && !isatty.IsCygwinTerminal(file.Fd()) { return false } if file, ok := p.rw.Writer().(*os.File); !ok { return false } else if !isatty.IsTerminal(file.Fd()) && !isatty.IsCyg...
go
func (p *Prompt) IsTerminal() bool { if file, ok := p.rw.Reader().(*os.File); !ok { return false } else if !isatty.IsTerminal(file.Fd()) && !isatty.IsCygwinTerminal(file.Fd()) { return false } if file, ok := p.rw.Writer().(*os.File); !ok { return false } else if !isatty.IsTerminal(file.Fd()) && !isatty.IsCyg...
[ "func", "(", "p", "*", "Prompt", ")", "IsTerminal", "(", ")", "bool", "{", "if", "file", ",", "ok", ":=", "p", ".", "rw", ".", "Reader", "(", ")", ".", "(", "*", "os", ".", "File", ")", ";", "!", "ok", "{", "return", "false", "\n", "}", "el...
//IsTerminal returns true if running in terminal
[ "IsTerminal", "returns", "true", "if", "running", "in", "terminal" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/prompt/prompt.go#L53-L65
147,981
spiegel-im-spiegel/gocli
prompt/prompt.go
Run
func (p *Prompt) Run() error { if p == nil { return ErrTerminate } if len(p.headerMsg) > 0 { if err := p.rw.Outputln(p.headerMsg); err != nil { return err } } for { s, ok := p.get() if !ok { break } if res, err := p.function(s); err != nil { _ = p.rw.Outputln(res) if !errors.Is(err, ErrT...
go
func (p *Prompt) Run() error { if p == nil { return ErrTerminate } if len(p.headerMsg) > 0 { if err := p.rw.Outputln(p.headerMsg); err != nil { return err } } for { s, ok := p.get() if !ok { break } if res, err := p.function(s); err != nil { _ = p.rw.Outputln(res) if !errors.Is(err, ErrT...
[ "func", "(", "p", "*", "Prompt", ")", "Run", "(", ")", "error", "{", "if", "p", "==", "nil", "{", "return", "ErrTerminate", "\n", "}", "\n", "if", "len", "(", "p", ".", "headerMsg", ")", ">", "0", "{", "if", "err", ":=", "p", ".", "rw", ".", ...
//Run function starts interactive mode.
[ "Run", "function", "starts", "interactive", "mode", "." ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/prompt/prompt.go#L68-L98
147,982
Clever/ARCHIVED-oplog-replay
ratecontroller/relative/relative.go
New
func New(speed float64) ratecontroller.Controller { if speed == -1 || speed == 0 { speed = math.Inf(1) } return &relativeRateController{speedMultiplier: speed, startTime: time.Now()} }
go
func New(speed float64) ratecontroller.Controller { if speed == -1 || speed == 0 { speed = math.Inf(1) } return &relativeRateController{speedMultiplier: speed, startTime: time.Now()} }
[ "func", "New", "(", "speed", "float64", ")", "ratecontroller", ".", "Controller", "{", "if", "speed", "==", "-", "1", "||", "speed", "==", "0", "{", "speed", "=", "math", ".", "Inf", "(", "1", ")", "\n", "}", "\n", "return", "&", "relativeRateControl...
// New returns a rate controller that the plays the oplog at a speed that's a // multiple of the original oplog speed.
[ "New", "returns", "a", "rate", "controller", "that", "the", "plays", "the", "oplog", "at", "a", "speed", "that", "s", "a", "multiple", "of", "the", "original", "oplog", "speed", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/ratecontroller/relative/relative.go#L35-L40
147,983
golang-plus/uuid
uuid.go
Equal
func (u UUID) Equal(another UUID) bool { return bytes.EqualFold(u[:], another[:]) }
go
func (u UUID) Equal(another UUID) bool { return bytes.EqualFold(u[:], another[:]) }
[ "func", "(", "u", "UUID", ")", "Equal", "(", "another", "UUID", ")", "bool", "{", "return", "bytes", ".", "EqualFold", "(", "u", "[", ":", "]", ",", "another", "[", ":", "]", ")", "\n", "}" ]
// Equal returns true if current uuid equal to passed uuid.
[ "Equal", "returns", "true", "if", "current", "uuid", "equal", "to", "passed", "uuid", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/uuid.go#L29-L31
147,984
golang-plus/uuid
uuid.go
Format
func (u UUID) Format(style Style) string { switch style { case StyleWithoutDash: return fmt.Sprintf("%x", u[:]) //case StyleStandard: default: return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", u[:4], u[4:6], u[6:8], u[8:10], u[10:]) } }
go
func (u UUID) Format(style Style) string { switch style { case StyleWithoutDash: return fmt.Sprintf("%x", u[:]) //case StyleStandard: default: return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", u[:4], u[4:6], u[6:8], u[8:10], u[10:]) } }
[ "func", "(", "u", "UUID", ")", "Format", "(", "style", "Style", ")", "string", "{", "switch", "style", "{", "case", "StyleWithoutDash", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "u", "[", ":", "]", ")", "\n", "//case StyleStandard:", ...
// Format returns the formatted string of UUID.
[ "Format", "returns", "the", "formatted", "string", "of", "UUID", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/uuid.go#L34-L42
147,985
golang-plus/uuid
internal/namebased/md5/md5.go
NewUUID
func NewUUID(namespace, name string) ([]byte, error) { hash := md5.New() _, err := hash.Write([]byte(namespace)) if err != nil { return nil, errors.Wrapf(err, "could not compute hash value for namespace %q", namespace) } _, err = hash.Write([]byte(name)) if err != nil { return nil, errors.Wrapf(err, "could no...
go
func NewUUID(namespace, name string) ([]byte, error) { hash := md5.New() _, err := hash.Write([]byte(namespace)) if err != nil { return nil, errors.Wrapf(err, "could not compute hash value for namespace %q", namespace) } _, err = hash.Write([]byte(name)) if err != nil { return nil, errors.Wrapf(err, "could no...
[ "func", "NewUUID", "(", "namespace", ",", "name", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "hash", ":=", "md5", ".", "New", "(", ")", "\n", "_", ",", "err", ":=", "hash", ".", "Write", "(", "[", "]", "byte", "(", "namespace...
// NewUUID returns a new name-based uses SHA-1 hashing uuid.
[ "NewUUID", "returns", "a", "new", "name", "-", "based", "uses", "SHA", "-", "1", "hashing", "uuid", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/namebased/md5/md5.go#L12-L34
147,986
aybabtme/uniplot
histogram/utils.go
Fprintf
func Fprintf(w io.Writer, h Histogram, s ScaleFunc, f FormatFunc) error { return fprintf(w, h, s, f) }
go
func Fprintf(w io.Writer, h Histogram, s ScaleFunc, f FormatFunc) error { return fprintf(w, h, s, f) }
[ "func", "Fprintf", "(", "w", "io", ".", "Writer", ",", "h", "Histogram", ",", "s", "ScaleFunc", ",", "f", "FormatFunc", ")", "error", "{", "return", "fprintf", "(", "w", ",", "h", ",", "s", ",", "f", ")", "\n", "}" ]
// Fprintf is the same as Fprint, but applies f to the axis labels.
[ "Fprintf", "is", "the", "same", "as", "Fprint", "but", "applies", "f", "to", "the", "axis", "labels", "." ]
039c559e5e7e0512b313109b11266bf6fe2db223
https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/histogram/utils.go#L51-L53
147,987
spiegel-im-spiegel/gocli
rwi/rwi.go
New
func New(opts ...OptFunc) *RWI { c := &RWI{reader: ioutil.NopCloser(bytes.NewReader(nil)), writer: ioutil.Discard, errorWriter: ioutil.Discard} for _, opt := range opts { opt(c) } return c }
go
func New(opts ...OptFunc) *RWI { c := &RWI{reader: ioutil.NopCloser(bytes.NewReader(nil)), writer: ioutil.Discard, errorWriter: ioutil.Discard} for _, opt := range opts { opt(c) } return c }
[ "func", "New", "(", "opts", "...", "OptFunc", ")", "*", "RWI", "{", "c", ":=", "&", "RWI", "{", "reader", ":", "ioutil", ".", "NopCloser", "(", "bytes", ".", "NewReader", "(", "nil", ")", ")", ",", "writer", ":", "ioutil", ".", "Discard", ",", "e...
// New returns a new RWI instance
[ "New", "returns", "a", "new", "RWI", "instance" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/rwi/rwi.go#L25-L31
147,988
spiegel-im-spiegel/gocli
rwi/rwi.go
WithReader
func WithReader(r io.Reader) OptFunc { return func(c *RWI) { if r != nil { c.reader = r } } }
go
func WithReader(r io.Reader) OptFunc { return func(c *RWI) { if r != nil { c.reader = r } } }
[ "func", "WithReader", "(", "r", "io", ".", "Reader", ")", "OptFunc", "{", "return", "func", "(", "c", "*", "RWI", ")", "{", "if", "r", "!=", "nil", "{", "c", ".", "reader", "=", "r", "\n", "}", "\n", "}", "\n", "}" ]
//WithReader returns function for setting Reader
[ "WithReader", "returns", "function", "for", "setting", "Reader" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/rwi/rwi.go#L34-L40
147,989
spiegel-im-spiegel/gocli
rwi/rwi.go
WriteFrom
func (c *RWI) WriteFrom(r io.Reader) error { _, err := io.Copy(c.writer, r) return err }
go
func (c *RWI) WriteFrom(r io.Reader) error { _, err := io.Copy(c.writer, r) return err }
[ "func", "(", "c", "*", "RWI", ")", "WriteFrom", "(", "r", "io", ".", "Reader", ")", "error", "{", "_", ",", "err", ":=", "io", ".", "Copy", "(", "c", ".", "writer", ",", "r", ")", "\n", "return", "err", "\n", "}" ]
//WriteFrom copy from io.Reader to RWI.writer
[ "WriteFrom", "copy", "from", "io", ".", "Reader", "to", "RWI", ".", "writer" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/rwi/rwi.go#L91-L94
147,990
spiegel-im-spiegel/gocli
rwi/rwi.go
WriteErrFrom
func (c *RWI) WriteErrFrom(r io.Reader) error { _, err := io.Copy(c.errorWriter, r) return err }
go
func (c *RWI) WriteErrFrom(r io.Reader) error { _, err := io.Copy(c.errorWriter, r) return err }
[ "func", "(", "c", "*", "RWI", ")", "WriteErrFrom", "(", "r", "io", ".", "Reader", ")", "error", "{", "_", ",", "err", ":=", "io", ".", "Copy", "(", "c", ".", "errorWriter", ",", "r", ")", "\n", "return", "err", "\n", "}" ]
//WriteErrFrom copy from io.Reader to RWI.errorWriter
[ "WriteErrFrom", "copy", "from", "io", ".", "Reader", "to", "RWI", ".", "errorWriter" ]
3e939b56b665677023383e8a22a9f15079c80a43
https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/rwi/rwi.go#L112-L115
147,991
Clever/ARCHIVED-oplog-replay
cmd/oplog-replay/main.go
readerWithRetry
func readerWithRetry(path string) (io.Reader, error) { backoffObj := backoff.ExponentialBackOff{ InitialInterval: 5 * time.Second, RandomizationFactor: backoff.DefaultRandomizationFactor, Multiplier: 2, MaxInterval: 30 * time.Second, MaxElapsedTime: 2 * time.Minute, Clock: ...
go
func readerWithRetry(path string) (io.Reader, error) { backoffObj := backoff.ExponentialBackOff{ InitialInterval: 5 * time.Second, RandomizationFactor: backoff.DefaultRandomizationFactor, Multiplier: 2, MaxInterval: 30 * time.Second, MaxElapsedTime: 2 * time.Minute, Clock: ...
[ "func", "readerWithRetry", "(", "path", "string", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "backoffObj", ":=", "backoff", ".", "ExponentialBackOff", "{", "InitialInterval", ":", "5", "*", "time", ".", "Second", ",", "RandomizationFactor", ":", ...
// readerWithRetry gets a reader from the path, retrying if necessary.
[ "readerWithRetry", "gets", "a", "reader", "from", "the", "path", "retrying", "if", "necessary", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/cmd/oplog-replay/main.go#L40-L61
147,992
Clever/ARCHIVED-oplog-replay
replay/replay.go
NewFailedOperationError
func NewFailedOperationError(op map[string]interface{}) *FailedOperationError { return &FailedOperationError{ op: op, msg: fmt.Sprintf("Operation %v failed", op), } }
go
func NewFailedOperationError(op map[string]interface{}) *FailedOperationError { return &FailedOperationError{ op: op, msg: fmt.Sprintf("Operation %v failed", op), } }
[ "func", "NewFailedOperationError", "(", "op", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "FailedOperationError", "{", "return", "&", "FailedOperationError", "{", "op", ":", "op", ",", "msg", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", "...
// NewFailedOperationError creates and returns a FailedOperationsError for the given op.
[ "NewFailedOperationError", "creates", "and", "returns", "a", "FailedOperationsError", "for", "the", "given", "op", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L25-L30
147,993
Clever/ARCHIVED-oplog-replay
replay/replay.go
parseBSON
func parseBSON(done <-chan struct{}, r io.Reader) (<-chan map[string]interface{}, <-chan error) { c := make(chan map[string]interface{}) errc := make(chan error, 1) go func() { defer close(c) scanner := bsonScanner.New(r) scan: for scanner.Scan() { op := map[string]interface{}{} if err := bson.Unmarsha...
go
func parseBSON(done <-chan struct{}, r io.Reader) (<-chan map[string]interface{}, <-chan error) { c := make(chan map[string]interface{}) errc := make(chan error, 1) go func() { defer close(c) scanner := bsonScanner.New(r) scan: for scanner.Scan() { op := map[string]interface{}{} if err := bson.Unmarsha...
[ "func", "parseBSON", "(", "done", "<-", "chan", "struct", "{", "}", ",", "r", "io", ".", "Reader", ")", "(", "<-", "chan", "map", "[", "string", "]", "interface", "{", "}", ",", "<-", "chan", "error", ")", "{", "c", ":=", "make", "(", "chan", "...
// ParseBSON parses the bson from the Reader interface. It returns a channel that the caller can use // to retrieve the parsed BSON ops, and a channel for parse errors.
[ "ParseBSON", "parses", "the", "bson", "from", "the", "Reader", "interface", ".", "It", "returns", "a", "channel", "that", "the", "caller", "can", "use", "to", "retrieve", "the", "parsed", "BSON", "ops", "and", "a", "channel", "for", "parse", "errors", "." ...
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L34-L61
147,994
Clever/ARCHIVED-oplog-replay
replay/replay.go
controlRate
func controlRate(done <-chan struct{}, ops <-chan map[string]interface{}, controller ratecontroller.Controller) <-chan map[string]interface{} { // The choice of 20 for the maximum number of operations to apply at once is fairly arbitrary c := make(chan map[string]interface{}, 20) go func() { defer close(c) for...
go
func controlRate(done <-chan struct{}, ops <-chan map[string]interface{}, controller ratecontroller.Controller) <-chan map[string]interface{} { // The choice of 20 for the maximum number of operations to apply at once is fairly arbitrary c := make(chan map[string]interface{}, 20) go func() { defer close(c) for...
[ "func", "controlRate", "(", "done", "<-", "chan", "struct", "{", "}", ",", "ops", "<-", "chan", "map", "[", "string", "]", "interface", "{", "}", ",", "controller", "ratecontroller", ".", "Controller", ")", "<-", "chan", "map", "[", "string", "]", "int...
// controlRate takes operations on an input channel puts them into the returned output // channel at a rate dictated by the passed in rate controller.
[ "controlRate", "takes", "operations", "on", "an", "input", "channel", "puts", "them", "into", "the", "returned", "output", "channel", "at", "a", "rate", "dictated", "by", "the", "passed", "in", "rate", "controller", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L65-L84
147,995
Clever/ARCHIVED-oplog-replay
replay/replay.go
batchOps
func batchOps(done <-chan struct{}, ops <-chan map[string]interface{}) <-chan []interface{} { c := make(chan []interface{}) go func() { defer close(c) // In a loop grab as many elements as you can before you would block (the default case) // Only place non-empty batches into the output channel. elements := m...
go
func batchOps(done <-chan struct{}, ops <-chan map[string]interface{}) <-chan []interface{} { c := make(chan []interface{}) go func() { defer close(c) // In a loop grab as many elements as you can before you would block (the default case) // Only place non-empty batches into the output channel. elements := m...
[ "func", "batchOps", "(", "done", "<-", "chan", "struct", "{", "}", ",", "ops", "<-", "chan", "map", "[", "string", "]", "interface", "{", "}", ")", "<-", "chan", "[", "]", "interface", "{", "}", "{", "c", ":=", "make", "(", "chan", "[", "]", "i...
// batchOps takes an input buffered channel and returns a channel which will contain batched // ops. The maximum batch size is the size of the buffered input channel.
[ "batchOps", "takes", "an", "input", "buffered", "channel", "and", "returns", "a", "channel", "which", "will", "contain", "batched", "ops", ".", "The", "maximum", "batch", "size", "is", "the", "size", "of", "the", "buffered", "input", "channel", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L88-L127
147,996
Clever/ARCHIVED-oplog-replay
replay/replay.go
oplogReplay
func oplogReplay(batches <-chan []interface{}, applyOps func([]interface{}) error) error { for batch := range batches { if err := applyOps(batch); err != nil { return err } } return nil }
go
func oplogReplay(batches <-chan []interface{}, applyOps func([]interface{}) error) error { for batch := range batches { if err := applyOps(batch); err != nil { return err } } return nil }
[ "func", "oplogReplay", "(", "batches", "<-", "chan", "[", "]", "interface", "{", "}", ",", "applyOps", "func", "(", "[", "]", "interface", "{", "}", ")", "error", ")", "error", "{", "for", "batch", ":=", "range", "batches", "{", "if", "err", ":=", ...
// oplogReplay takes in a channel of batched operations and applys them using the // supplied function. Returns an error if the apply operation fails.
[ "oplogReplay", "takes", "in", "a", "channel", "of", "batched", "operations", "and", "applys", "them", "using", "the", "supplied", "function", ".", "Returns", "an", "error", "if", "the", "apply", "operation", "fails", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L131-L138
147,997
Clever/ARCHIVED-oplog-replay
replay/replay.go
getApplyOpsFunc
func getApplyOpsFunc(session *mgo.Session, alwaysUpsert bool) func([]interface{}) error { return func(ops []interface{}) error { var result map[string]interface{} if err := session.Run(bson.D{{"applyOps", ops}, {"alwaysUpsert", alwaysUpsert}}, &result); err != nil { return err } // We have to inspect the re...
go
func getApplyOpsFunc(session *mgo.Session, alwaysUpsert bool) func([]interface{}) error { return func(ops []interface{}) error { var result map[string]interface{} if err := session.Run(bson.D{{"applyOps", ops}, {"alwaysUpsert", alwaysUpsert}}, &result); err != nil { return err } // We have to inspect the re...
[ "func", "getApplyOpsFunc", "(", "session", "*", "mgo", ".", "Session", ",", "alwaysUpsert", "bool", ")", "func", "(", "[", "]", "interface", "{", "}", ")", "error", "{", "return", "func", "(", "ops", "[", "]", "interface", "{", "}", ")", "error", "{"...
// getApplyOpsFunc returns the applyOps function. It's separated out for unit testing
[ "getApplyOpsFunc", "returns", "the", "applyOps", "function", ".", "It", "s", "separated", "out", "for", "unit", "testing" ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L141-L172
147,998
Clever/ARCHIVED-oplog-replay
replay/replay.go
ReplayOplog
func ReplayOplog(r io.Reader, controller ratecontroller.Controller, alwaysUpsert bool, host string) error { done := make(chan struct{}) defer close(done) session, err := mgo.Dial(host) if err != nil { return err } defer session.Close() log.Println("Parsing BSON...") ops, parseErrors := parseBSON(done, r) t...
go
func ReplayOplog(r io.Reader, controller ratecontroller.Controller, alwaysUpsert bool, host string) error { done := make(chan struct{}) defer close(done) session, err := mgo.Dial(host) if err != nil { return err } defer session.Close() log.Println("Parsing BSON...") ops, parseErrors := parseBSON(done, r) t...
[ "func", "ReplayOplog", "(", "r", "io", ".", "Reader", ",", "controller", "ratecontroller", ".", "Controller", ",", "alwaysUpsert", "bool", ",", "host", "string", ")", "error", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "defer"...
// ReplayOplog replays an oplog onto the specified host. If there are any errors this function // terminates and returns the error immediately.
[ "ReplayOplog", "replays", "an", "oplog", "onto", "the", "specified", "host", ".", "If", "there", "are", "any", "errors", "this", "function", "terminates", "and", "returns", "the", "error", "immediately", "." ]
486adac430d066719165dc1b164da60356497b40
https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/replay/replay.go#L176-L201
147,999
golang-plus/uuid
version.go
String
func (v Version) String() string { switch v { case VersionTimeBased: return "Version 1: Time-Based" case VersionDCESecurity: return "Version 2: DCE Security With Embedded POSIX UIDs" case VersionNameBasedMD5: return "Version 3: Name-Based (MD5)" case VersionRandom: return "Version 4: Randomly OR Pseudo-Ran...
go
func (v Version) String() string { switch v { case VersionTimeBased: return "Version 1: Time-Based" case VersionDCESecurity: return "Version 2: DCE Security With Embedded POSIX UIDs" case VersionNameBasedMD5: return "Version 3: Name-Based (MD5)" case VersionRandom: return "Version 4: Randomly OR Pseudo-Ran...
[ "func", "(", "v", "Version", ")", "String", "(", ")", "string", "{", "switch", "v", "{", "case", "VersionTimeBased", ":", "return", "\"", "\"", "\n", "case", "VersionDCESecurity", ":", "return", "\"", "\"", "\n", "case", "VersionNameBasedMD5", ":", "return...
// String returns English description of Version.
[ "String", "returns", "English", "description", "of", "Version", "." ]
abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe
https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/version.go#L36-L51