id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
138,900
denormal/go-gitignore
lexer.go
comment
func (l *lexer) comment() ([]rune, Error) { _comment := make([]rune, 0) // read until we reach end of line or end of file // - as we are in a comment, we ignore escape characters for { _next, _err := l.read() if _err != nil { return _comment, _err } // read until we have end of line or end of file s...
go
func (l *lexer) comment() ([]rune, Error) { _comment := make([]rune, 0) // read until we reach end of line or end of file // - as we are in a comment, we ignore escape characters for { _next, _err := l.read() if _err != nil { return _comment, _err } // read until we have end of line or end of file s...
[ "func", "(", "l", "*", "lexer", ")", "comment", "(", ")", "(", "[", "]", "rune", ",", "Error", ")", "{", "_comment", ":=", "make", "(", "[", "]", "rune", ",", "0", ")", "\n\n", "// read until we reach end of line or end of file", "//\t\t- as we are in a comm...
// comment reads all runes until a newline or end of file is reached. An // error is returned if an error is encountered reading from the stream.
[ "comment", "reads", "all", "runes", "until", "a", "newline", "or", "end", "of", "file", "is", "reached", ".", "An", "error", "is", "returned", "if", "an", "error", "is", "encountered", "reading", "from", "the", "stream", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/lexer.go#L237-L263
138,901
denormal/go-gitignore
lexer.go
eol
func (l *lexer) eol() ([]rune, Error) { // read the to the end of the line // - we should only be called here when we encounter an end of line // sequence _line := make([]rune, 0, 1) // loop until there's nothing more to do for { _next, _err := l.read() if _err != nil { return _line, _err } ...
go
func (l *lexer) eol() ([]rune, Error) { // read the to the end of the line // - we should only be called here when we encounter an end of line // sequence _line := make([]rune, 0, 1) // loop until there's nothing more to do for { _next, _err := l.read() if _err != nil { return _line, _err } ...
[ "func", "(", "l", "*", "lexer", ")", "eol", "(", ")", "(", "[", "]", "rune", ",", "Error", ")", "{", "// read the to the end of the line", "// - we should only be called here when we encounter an end of line", "// sequence", "_line", ":=", "make", "(", "["...
// eol returns all runes from the current position to the end of the line. An // error is returned if there is a problem reading from the stream, or if a // carriage return character '\r' is encountered that is not followed by a // newline '\n'.
[ "eol", "returns", "all", "runes", "from", "the", "current", "position", "to", "the", "end", "of", "the", "line", ".", "An", "error", "is", "returned", "if", "there", "is", "a", "problem", "reading", "from", "the", "stream", "or", "if", "a", "carriage", ...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/lexer.go#L299-L336
138,902
denormal/go-gitignore
lexer.go
token
func (l *lexer) token(type_ TokenType, word []rune, e Error) (*Token, Error) { // if we have an error, then we return a BAD token if e != nil { type_ = BAD } // extract the lexer position // - the column is taken from the current column position // minus the length of the consumed "word" _word := ...
go
func (l *lexer) token(type_ TokenType, word []rune, e Error) (*Token, Error) { // if we have an error, then we return a BAD token if e != nil { type_ = BAD } // extract the lexer position // - the column is taken from the current column position // minus the length of the consumed "word" _word := ...
[ "func", "(", "l", "*", "lexer", ")", "token", "(", "type_", "TokenType", ",", "word", "[", "]", "rune", ",", "e", "Error", ")", "(", "*", "Token", ",", "Error", ")", "{", "// if we have an error, then we return a BAD token", "if", "e", "!=", "nil", "{", ...
// token returns a Token instance of the given type_ represented by word runes.
[ "token", "returns", "a", "Token", "instance", "of", "the", "given", "type_", "represented", "by", "word", "runes", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/lexer.go#L434-L455
138,903
denormal/go-gitignore
lexer.go
err
func (l *lexer) err(e error) Error { // do we have an error? if e == nil { return nil } else { return NewError(e, l.Position()) } }
go
func (l *lexer) err(e error) Error { // do we have an error? if e == nil { return nil } else { return NewError(e, l.Position()) } }
[ "func", "(", "l", "*", "lexer", ")", "err", "(", "e", "error", ")", "Error", "{", "// do we have an error?", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "else", "{", "return", "NewError", "(", "e", ",", "l", ".", "Position", "(", ")", ...
// err returns an Error encapsulating the error e and the current Lexer // position.
[ "err", "returns", "an", "Error", "encapsulating", "the", "error", "e", "and", "the", "current", "Lexer", "position", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/lexer.go#L459-L466
138,904
denormal/go-gitignore
parser.go
NewParser
func NewParser(r io.Reader, err func(Error) bool) Parser { return &parser{_lexer: NewLexer(r), _error: err} }
go
func NewParser(r io.Reader, err func(Error) bool) Parser { return &parser{_lexer: NewLexer(r), _error: err} }
[ "func", "NewParser", "(", "r", "io", ".", "Reader", ",", "err", "func", "(", "Error", ")", "bool", ")", "Parser", "{", "return", "&", "parser", "{", "_lexer", ":", "NewLexer", "(", "r", ")", ",", "_error", ":", "err", "}", "\n", "}" ]
// NewParser returns a new Parser instance for the given stream r. // If err is not nil, it will be called for every error encountered during // parsing. Parsing will terminate at the end of the stream, or if err // returns false.
[ "NewParser", "returns", "a", "new", "Parser", "instance", "for", "the", "given", "stream", "r", ".", "If", "err", "is", "not", "nil", "it", "will", "be", "called", "for", "every", "error", "encountered", "during", "parsing", ".", "Parsing", "will", "termin...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L38-L40
138,905
denormal/go-gitignore
parser.go
Parse
func (p *parser) Parse() []Pattern { // keep parsing until there's no more patterns _patterns := make([]Pattern, 0) for { _pattern := p.Next() if _pattern == nil { return _patterns } _patterns = append(_patterns, _pattern) } }
go
func (p *parser) Parse() []Pattern { // keep parsing until there's no more patterns _patterns := make([]Pattern, 0) for { _pattern := p.Next() if _pattern == nil { return _patterns } _patterns = append(_patterns, _pattern) } }
[ "func", "(", "p", "*", "parser", ")", "Parse", "(", ")", "[", "]", "Pattern", "{", "// keep parsing until there's no more patterns", "_patterns", ":=", "make", "(", "[", "]", "Pattern", ",", "0", ")", "\n", "for", "{", "_pattern", ":=", "p", ".", "Next",...
// Parse returns all well-formed .gitignore Patterns contained within the // parser stream. Parsing will terminate at the end of the stream, or if // the parser error handler returns false.
[ "Parse", "returns", "all", "well", "-", "formed", ".", "gitignore", "Patterns", "contained", "within", "the", "parser", "stream", ".", "Parsing", "will", "terminate", "at", "the", "end", "of", "the", "stream", "or", "if", "the", "parser", "error", "handler",...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L45-L55
138,906
denormal/go-gitignore
parser.go
Next
func (p *parser) Next() Pattern { // keep searching until we find the next pattern, or until we // reach the end of the file for { _token, _err := p.next() if _err != nil { if !p.errors(_err) { return nil } // we got an error from the lexer, so skip the remainder // of this line and try again fr...
go
func (p *parser) Next() Pattern { // keep searching until we find the next pattern, or until we // reach the end of the file for { _token, _err := p.next() if _err != nil { if !p.errors(_err) { return nil } // we got an error from the lexer, so skip the remainder // of this line and try again fr...
[ "func", "(", "p", "*", "parser", ")", "Next", "(", ")", "Pattern", "{", "// keep searching until we find the next pattern, or until we", "// reach the end of the file", "for", "{", "_token", ",", "_err", ":=", "p", ".", "next", "(", ")", "\n", "if", "_err", "!="...
// Next returns the next well-formed .gitignore Pattern from the parser stream. // If an error is encountered, and the error handler is either not defined, or // returns true, Next will skip to the end of the current line and attempt to // parse the next Pattern. If the error handler returns false, or the parser // rea...
[ "Next", "returns", "the", "next", "well", "-", "formed", ".", "gitignore", "Pattern", "from", "the", "parser", "stream", ".", "If", "an", "error", "is", "encountered", "and", "the", "error", "handler", "is", "either", "not", "defined", "or", "returns", "tr...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L62-L122
138,907
denormal/go-gitignore
parser.go
Position
func (p *parser) Position() Position { // if we have any previously read tokens, then the token at // the end of the "undo" list (most recently "undone") gives the // position of the parser _length := len(p._undo) if _length != 0 { return p._undo[_length-1].Position } // otherwise, return the position of the ...
go
func (p *parser) Position() Position { // if we have any previously read tokens, then the token at // the end of the "undo" list (most recently "undone") gives the // position of the parser _length := len(p._undo) if _length != 0 { return p._undo[_length-1].Position } // otherwise, return the position of the ...
[ "func", "(", "p", "*", "parser", ")", "Position", "(", ")", "Position", "{", "// if we have any previously read tokens, then the token at", "// the end of the \"undo\" list (most recently \"undone\") gives the", "// position of the parser", "_length", ":=", "len", "(", "p", "."...
// Position returns the current position of the parser in the input stream.
[ "Position", "returns", "the", "current", "position", "of", "the", "parser", "in", "the", "input", "stream", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L125-L136
138,908
denormal/go-gitignore
parser.go
build
func (p *parser) build(t *Token) (Pattern, Error) { // attempt to create a valid pattern switch t.Type { // we have a negated pattern case NEGATION: return p.negation(t) // attempt to build a path specification default: return p.path(t) } }
go
func (p *parser) build(t *Token) (Pattern, Error) { // attempt to create a valid pattern switch t.Type { // we have a negated pattern case NEGATION: return p.negation(t) // attempt to build a path specification default: return p.path(t) } }
[ "func", "(", "p", "*", "parser", ")", "build", "(", "t", "*", "Token", ")", "(", "Pattern", ",", "Error", ")", "{", "// attempt to create a valid pattern", "switch", "t", ".", "Type", "{", "// we have a negated pattern", "case", "NEGATION", ":", "return", "p...
// // private methods // // build attempts to build a well-formed .gitignore Pattern starting from the // given Token t. An Error will be returned if the sequence of tokens returned // by the Lexer does not represent a valid Pattern.
[ "private", "methods", "build", "attempts", "to", "build", "a", "well", "-", "formed", ".", "gitignore", "Pattern", "starting", "from", "the", "given", "Token", "t", ".", "An", "Error", "will", "be", "returned", "if", "the", "sequence", "of", "tokens", "ret...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L145-L156
138,909
denormal/go-gitignore
parser.go
negation
func (p *parser) negation(t *Token) (Pattern, Error) { // a negation appears before a path specification, so // skip the negation token _next, _err := p.next() if _err != nil { return nil, _err } // extract the sequence of tokens for this path _tokens, _err := p.sequence(_next) if _err != nil { return nil,...
go
func (p *parser) negation(t *Token) (Pattern, Error) { // a negation appears before a path specification, so // skip the negation token _next, _err := p.next() if _err != nil { return nil, _err } // extract the sequence of tokens for this path _tokens, _err := p.sequence(_next) if _err != nil { return nil,...
[ "func", "(", "p", "*", "parser", ")", "negation", "(", "t", "*", "Token", ")", "(", "Pattern", ",", "Error", ")", "{", "// a negation appears before a path specification, so", "// skip the negation token", "_next", ",", "_err", ":=", "p", ".", "next", "(", ")"...
// negation attempts to build a well-formed negated .gitignore Pattern starting // from the negation Token t. As with build, negation returns an Error if the // sequence of tokens returned by the Lexer does not represent a valid Pattern.
[ "negation", "attempts", "to", "build", "a", "well", "-", "formed", "negated", ".", "gitignore", "Pattern", "starting", "from", "the", "negation", "Token", "t", ".", "As", "with", "build", "negation", "returns", "an", "Error", "if", "the", "sequence", "of", ...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L161-L180
138,910
denormal/go-gitignore
parser.go
path
func (p *parser) path(t *Token) (Pattern, Error) { // extract the sequence of tokens for this path _tokens, _err := p.sequence(t) if _err != nil { return nil, _err } // remove trailing whitespace tokens _length := len(_tokens) for _length > 0 { // if we have a non-whitespace token, we can stop _length-- ...
go
func (p *parser) path(t *Token) (Pattern, Error) { // extract the sequence of tokens for this path _tokens, _err := p.sequence(t) if _err != nil { return nil, _err } // remove trailing whitespace tokens _length := len(_tokens) for _length > 0 { // if we have a non-whitespace token, we can stop _length-- ...
[ "func", "(", "p", "*", "parser", ")", "path", "(", "t", "*", "Token", ")", "(", "Pattern", ",", "Error", ")", "{", "// extract the sequence of tokens for this path", "_tokens", ",", "_err", ":=", "p", ".", "sequence", "(", "t", ")", "\n", "if", "_err", ...
// path attempts to build a well-formed .gitignore Pattern representing a path // specification, starting with the Token t. If the sequence of tokens returned // by the Lexer does not represent a valid Pattern, path returns an Error. // Trailing whitespace is dropped from the sequence of pattern tokens.
[ "path", "attempts", "to", "build", "a", "well", "-", "formed", ".", "gitignore", "Pattern", "representing", "a", "path", "specification", "starting", "with", "the", "Token", "t", ".", "If", "the", "sequence", "of", "tokens", "returned", "by", "the", "Lexer",...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L186-L208
138,911
denormal/go-gitignore
parser.go
sequence
func (p *parser) sequence(t *Token) ([]*Token, Error) { // extract the sequence of tokens for a valid path // - this excludes the negation token, which is handled as // a special case before sequence() is called switch t.Type { // the path starts with a separator case SEPARATOR: return p.separator(t...
go
func (p *parser) sequence(t *Token) ([]*Token, Error) { // extract the sequence of tokens for a valid path // - this excludes the negation token, which is handled as // a special case before sequence() is called switch t.Type { // the path starts with a separator case SEPARATOR: return p.separator(t...
[ "func", "(", "p", "*", "parser", ")", "sequence", "(", "t", "*", "Token", ")", "(", "[", "]", "*", "Token", ",", "Error", ")", "{", "// extract the sequence of tokens for a valid path", "// - this excludes the negation token, which is handled as", "// a spec...
// sequence attempts to extract a well-formed Token sequence from the Lexer // representing a .gitignore Pattern. sequence returns an Error if the // retrieved sequence of tokens does not represent a valid Pattern.
[ "sequence", "attempts", "to", "extract", "a", "well", "-", "formed", "Token", "sequence", "from", "the", "Lexer", "representing", "a", ".", "gitignore", "Pattern", ".", "sequence", "returns", "an", "Error", "if", "the", "retrieved", "sequence", "of", "tokens",...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L213-L236
138,912
denormal/go-gitignore
parser.go
pattern
func (p *parser) pattern(t *Token) ([]*Token, Error) { // build the list of tokens that may appear after a pattern _tokens := []*Token{t} _token, _err := p.next() if _err != nil { return _tokens, _err } // what tokens are we allowed to have follow a pattern? var _next []*Token switch _token.Type { case SEPA...
go
func (p *parser) pattern(t *Token) ([]*Token, Error) { // build the list of tokens that may appear after a pattern _tokens := []*Token{t} _token, _err := p.next() if _err != nil { return _tokens, _err } // what tokens are we allowed to have follow a pattern? var _next []*Token switch _token.Type { case SEPA...
[ "func", "(", "p", "*", "parser", ")", "pattern", "(", "t", "*", "Token", ")", "(", "[", "]", "*", "Token", ",", "Error", ")", "{", "// build the list of tokens that may appear after a pattern", "_tokens", ":=", "[", "]", "*", "Token", "{", "t", "}", "\n"...
// pattern attempts to retrieve a valid sequence of tokens that may appear // after the path pattern Token t. An Error is returned if the sequence if // tokens is not valid, or if there is an error extracting tokens from the // input stream.
[ "pattern", "attempts", "to", "retrieve", "a", "valid", "sequence", "of", "tokens", "that", "may", "appear", "after", "the", "path", "pattern", "Token", "t", ".", "An", "Error", "is", "returned", "if", "the", "sequence", "if", "tokens", "is", "not", "valid"...
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L324-L355
138,913
denormal/go-gitignore
parser.go
eol
func (p *parser) eol() Error { // are we at the end of the line? _token, _err := p.next() if _err != nil { return _err } // have we encountered whitespace only? switch _token.Type { // if we're at the end of the line or file, we're done case EOL: fallthrough case EOF: p.undo(_token) return nil } //...
go
func (p *parser) eol() Error { // are we at the end of the line? _token, _err := p.next() if _err != nil { return _err } // have we encountered whitespace only? switch _token.Type { // if we're at the end of the line or file, we're done case EOL: fallthrough case EOF: p.undo(_token) return nil } //...
[ "func", "(", "p", "*", "parser", ")", "eol", "(", ")", "Error", "{", "// are we at the end of the line?", "_token", ",", "_err", ":=", "p", ".", "next", "(", ")", "\n", "if", "_err", "!=", "nil", "{", "return", "_err", "\n", "}", "\n\n", "// have we en...
// eol attempts to consume the next Lexer token to read the end of line or end // of file. If a EOL or EOF is not reached , eol will return an error.
[ "eol", "attempts", "to", "consume", "the", "next", "Lexer", "token", "to", "read", "the", "end", "of", "line", "or", "end", "of", "file", ".", "If", "a", "EOL", "or", "EOF", "is", "not", "reached", "eol", "will", "return", "an", "error", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L359-L379
138,914
denormal/go-gitignore
parser.go
next
func (p *parser) next() (*Token, Error) { // do we have any previously read tokens? _length := len(p._undo) if _length > 0 { _token := p._undo[_length-1] p._undo = p._undo[:_length-1] return _token, nil } // otherwise, attempt to retrieve the next token from the lexer return p._lexer.Next() }
go
func (p *parser) next() (*Token, Error) { // do we have any previously read tokens? _length := len(p._undo) if _length > 0 { _token := p._undo[_length-1] p._undo = p._undo[:_length-1] return _token, nil } // otherwise, attempt to retrieve the next token from the lexer return p._lexer.Next() }
[ "func", "(", "p", "*", "parser", ")", "next", "(", ")", "(", "*", "Token", ",", "Error", ")", "{", "// do we have any previously read tokens?", "_length", ":=", "len", "(", "p", ".", "_undo", ")", "\n", "if", "_length", ">", "0", "{", "_token", ":=", ...
// next returns the next token from the Lexer, or an error if there is a // problem reading from the input stream.
[ "next", "returns", "the", "next", "token", "from", "the", "Lexer", "or", "an", "error", "if", "there", "is", "a", "problem", "reading", "from", "the", "input", "stream", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L383-L394
138,915
denormal/go-gitignore
parser.go
skip
func (p *parser) skip() Error { // skip to the next end of line or end of file token for { _token, _err := p.next() if _err != nil { return _err } // if we have an end of line or file token, then we can stop switch _token.Type { case EOL: fallthrough case EOF: return nil } } }
go
func (p *parser) skip() Error { // skip to the next end of line or end of file token for { _token, _err := p.next() if _err != nil { return _err } // if we have an end of line or file token, then we can stop switch _token.Type { case EOL: fallthrough case EOF: return nil } } }
[ "func", "(", "p", "*", "parser", ")", "skip", "(", ")", "Error", "{", "// skip to the next end of line or end of file token", "for", "{", "_token", ",", "_err", ":=", "p", ".", "next", "(", ")", "\n", "if", "_err", "!=", "nil", "{", "return", "_err", "\n...
// skip reads Tokens from the input until the end of line or end of file is // reached. If there is a problem reading tokens, an Error is returned.
[ "skip", "reads", "Tokens", "from", "the", "input", "until", "the", "end", "of", "line", "or", "end", "of", "file", "is", "reached", ".", "If", "there", "is", "a", "problem", "reading", "tokens", "an", "Error", "is", "returned", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L398-L414
138,916
denormal/go-gitignore
parser.go
undo
func (p *parser) undo(t *Token) { // add this token to the list of previously read tokens // - initialise the undo list if required if p._undo == nil { p._undo = make([]*Token, 0, 1) } p._undo = append(p._undo, t) }
go
func (p *parser) undo(t *Token) { // add this token to the list of previously read tokens // - initialise the undo list if required if p._undo == nil { p._undo = make([]*Token, 0, 1) } p._undo = append(p._undo, t) }
[ "func", "(", "p", "*", "parser", ")", "undo", "(", "t", "*", "Token", ")", "{", "// add this token to the list of previously read tokens", "// - initialise the undo list if required", "if", "p", ".", "_undo", "==", "nil", "{", "p", ".", "_undo", "=", "make", ...
// undo returns the given Token t to the parser input stream to be retrieved // again on a subsequent call to next.
[ "undo", "returns", "the", "given", "Token", "t", "to", "the", "parser", "input", "stream", "to", "be", "retrieved", "again", "on", "a", "subsequent", "call", "to", "next", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L418-L425
138,917
denormal/go-gitignore
parser.go
err
func (p *parser) err(e error) Error { // convert the error to include the parser position return NewError(e, p.Position()) }
go
func (p *parser) err(e error) Error { // convert the error to include the parser position return NewError(e, p.Position()) }
[ "func", "(", "p", "*", "parser", ")", "err", "(", "e", "error", ")", "Error", "{", "// convert the error to include the parser position", "return", "NewError", "(", "e", ",", "p", ".", "Position", "(", ")", ")", "\n", "}" ]
// err returns an Error for the error e, capturing the current parser Position.
[ "err", "returns", "an", "Error", "for", "the", "error", "e", "capturing", "the", "current", "parser", "Position", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L428-L431
138,918
denormal/go-gitignore
parser.go
errors
func (p *parser) errors(e Error) bool { // do we have an error handler? if p._error == nil { return true } // pass the error through to the error handler // - if this returns false, parsing will stop return p._error(e) }
go
func (p *parser) errors(e Error) bool { // do we have an error handler? if p._error == nil { return true } // pass the error through to the error handler // - if this returns false, parsing will stop return p._error(e) }
[ "func", "(", "p", "*", "parser", ")", "errors", "(", "e", "Error", ")", "bool", "{", "// do we have an error handler?", "if", "p", ".", "_error", "==", "nil", "{", "return", "true", "\n", "}", "\n\n", "// pass the error through to the error handler", "// - ...
// errors returns the response from the parser error handler to the Error e. If // no error handler has been configured for this parser, errors returns true.
[ "errors", "returns", "the", "response", "from", "the", "parser", "error", "handler", "to", "the", "Error", "e", ".", "If", "no", "error", "handler", "has", "been", "configured", "for", "this", "parser", "errors", "returns", "true", "." ]
ae8ad1d07817b3d3b49cabb21559a3f493a357a3
https://github.com/denormal/go-gitignore/blob/ae8ad1d07817b3d3b49cabb21559a3f493a357a3/parser.go#L435-L444
138,919
foomo/htpasswd
htpasswd.go
Bytes
func (hp HashedPasswords) Bytes() (passwordBytes []byte) { passwordBytes = []byte{} for name, hash := range hp { passwordBytes = append(passwordBytes, []byte(name+PasswordSeparator+hash+LineSeparator)...) } return passwordBytes }
go
func (hp HashedPasswords) Bytes() (passwordBytes []byte) { passwordBytes = []byte{} for name, hash := range hp { passwordBytes = append(passwordBytes, []byte(name+PasswordSeparator+hash+LineSeparator)...) } return passwordBytes }
[ "func", "(", "hp", "HashedPasswords", ")", "Bytes", "(", ")", "(", "passwordBytes", "[", "]", "byte", ")", "{", "passwordBytes", "=", "[", "]", "byte", "{", "}", "\n", "for", "name", ",", "hash", ":=", "range", "hp", "{", "passwordBytes", "=", "appen...
// Bytes bytes representation
[ "Bytes", "bytes", "representation" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L40-L46
138,920
foomo/htpasswd
htpasswd.go
WriteToFile
func (hp HashedPasswords) WriteToFile(file string) error { return ioutil.WriteFile(file, hp.Bytes(), 0644) }
go
func (hp HashedPasswords) WriteToFile(file string) error { return ioutil.WriteFile(file, hp.Bytes(), 0644) }
[ "func", "(", "hp", "HashedPasswords", ")", "WriteToFile", "(", "file", "string", ")", "error", "{", "return", "ioutil", ".", "WriteFile", "(", "file", ",", "hp", ".", "Bytes", "(", ")", ",", "0644", ")", "\n", "}" ]
// WriteToFile put them to a file will be overwritten or created
[ "WriteToFile", "put", "them", "to", "a", "file", "will", "be", "overwritten", "or", "created" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L49-L51
138,921
foomo/htpasswd
htpasswd.go
SetPassword
func (hp HashedPasswords) SetPassword(name, password string, hashAlgorithm HashAlgorithm) (err error) { if len(password) == 0 { return errors.New("passwords must not be empty, if you want to delete a user call RemoveUser") } hash := "" prefix := "" switch hashAlgorithm { case HashBCrypt: hash, err = hashBcryp...
go
func (hp HashedPasswords) SetPassword(name, password string, hashAlgorithm HashAlgorithm) (err error) { if len(password) == 0 { return errors.New("passwords must not be empty, if you want to delete a user call RemoveUser") } hash := "" prefix := "" switch hashAlgorithm { case HashBCrypt: hash, err = hashBcryp...
[ "func", "(", "hp", "HashedPasswords", ")", "SetPassword", "(", "name", ",", "password", "string", ",", "hashAlgorithm", "HashAlgorithm", ")", "(", "err", "error", ")", "{", "if", "len", "(", "password", ")", "==", "0", "{", "return", "errors", ".", "New"...
// SetPassword set a password for a user with a hashing algo
[ "SetPassword", "set", "a", "password", "for", "a", "user", "with", "a", "hashing", "algo" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L54-L72
138,922
foomo/htpasswd
htpasswd.go
ParseHtpasswdFile
func ParseHtpasswdFile(file string) (passwords HashedPasswords, err error) { htpasswdBytes, err := ioutil.ReadFile(file) if err != nil { return } if len(htpasswdBytes) > MaxHtpasswdFilesize { err = errors.New("this file is too large, use a database instead") return } return ParseHtpasswd(htpasswdBytes) }
go
func ParseHtpasswdFile(file string) (passwords HashedPasswords, err error) { htpasswdBytes, err := ioutil.ReadFile(file) if err != nil { return } if len(htpasswdBytes) > MaxHtpasswdFilesize { err = errors.New("this file is too large, use a database instead") return } return ParseHtpasswd(htpasswdBytes) }
[ "func", "ParseHtpasswdFile", "(", "file", "string", ")", "(", "passwords", "HashedPasswords", ",", "err", "error", ")", "{", "htpasswdBytes", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\...
// ParseHtpasswdFile load a htpasswd file
[ "ParseHtpasswdFile", "load", "a", "htpasswd", "file" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L75-L85
138,923
foomo/htpasswd
htpasswd.go
ParseHtpasswd
func ParseHtpasswd(htpasswdBytes []byte) (passwords HashedPasswords, err error) { lines := strings.Split(string(htpasswdBytes), LineSeparator) passwords = make(map[string]string) for lineNumber, line := range lines { // scan lines line = strings.Trim(line, " ") if len(line) == 0 { // skipping empty lines ...
go
func ParseHtpasswd(htpasswdBytes []byte) (passwords HashedPasswords, err error) { lines := strings.Split(string(htpasswdBytes), LineSeparator) passwords = make(map[string]string) for lineNumber, line := range lines { // scan lines line = strings.Trim(line, " ") if len(line) == 0 { // skipping empty lines ...
[ "func", "ParseHtpasswd", "(", "htpasswdBytes", "[", "]", "byte", ")", "(", "passwords", "HashedPasswords", ",", "err", "error", ")", "{", "lines", ":=", "strings", ".", "Split", "(", "string", "(", "htpasswdBytes", ")", ",", "LineSeparator", ")", "\n", "pa...
// ParseHtpasswd parse htpasswd bytes
[ "ParseHtpasswd", "parse", "htpasswd", "bytes" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L88-L114
138,924
foomo/htpasswd
htpasswd.go
SetHtpasswdHash
func SetHtpasswdHash(file, name, hash string) error { passwords, err := ParseHtpasswdFile(file) if err != nil { return err } passwords[name] = hash return passwords.WriteToFile(file) }
go
func SetHtpasswdHash(file, name, hash string) error { passwords, err := ParseHtpasswdFile(file) if err != nil { return err } passwords[name] = hash return passwords.WriteToFile(file) }
[ "func", "SetHtpasswdHash", "(", "file", ",", "name", ",", "hash", "string", ")", "error", "{", "passwords", ",", "err", ":=", "ParseHtpasswdFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "passwords", "["...
// SetHtpasswdHash set password hash for a user
[ "SetHtpasswdHash", "set", "password", "hash", "for", "a", "user" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L117-L124
138,925
foomo/htpasswd
htpasswd.go
RemoveUser
func RemoveUser(file, user string) error { passwords, err := ParseHtpasswdFile(file) if err != nil { return err } _, ok := passwords[user] if !ok { return ErrNotExist } delete(passwords, user) return passwords.WriteToFile(file) }
go
func RemoveUser(file, user string) error { passwords, err := ParseHtpasswdFile(file) if err != nil { return err } _, ok := passwords[user] if !ok { return ErrNotExist } delete(passwords, user) return passwords.WriteToFile(file) }
[ "func", "RemoveUser", "(", "file", ",", "user", "string", ")", "error", "{", "passwords", ",", "err", ":=", "ParseHtpasswdFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "ok", ":=", "passwords...
// RemoveUser remove an existing user from a file, returns an error, if the user does not \ // exist in the file
[ "RemoveUser", "remove", "an", "existing", "user", "from", "a", "file", "returns", "an", "error", "if", "the", "user", "does", "not", "\\", "exist", "in", "the", "file" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L128-L139
138,926
foomo/htpasswd
htpasswd.go
SetPasswordHash
func SetPasswordHash(file, user, hash string) error { if len(hash) == 0 { return errors.New("you might want to rethink your hashing algorithm, it left you with an empty hash") } passwords, err := ParseHtpasswdFile(file) if err != nil { return err } passwords[user] = hash return passwords.WriteToFile(file) }
go
func SetPasswordHash(file, user, hash string) error { if len(hash) == 0 { return errors.New("you might want to rethink your hashing algorithm, it left you with an empty hash") } passwords, err := ParseHtpasswdFile(file) if err != nil { return err } passwords[user] = hash return passwords.WriteToFile(file) }
[ "func", "SetPasswordHash", "(", "file", ",", "user", ",", "hash", "string", ")", "error", "{", "if", "len", "(", "hash", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "passwords", ",", "err", ":=", "P...
// SetPasswordHash directly set a hash for a user in a file
[ "SetPasswordHash", "directly", "set", "a", "hash", "for", "a", "user", "in", "a", "file" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L142-L152
138,927
foomo/htpasswd
htpasswd.go
SetPassword
func SetPassword(file, name, password string, hashAlgorithm HashAlgorithm) error { _, err := os.Stat(file) passwords := HashedPasswords(map[string]string{}) if err == nil { passwords, err = ParseHtpasswdFile(file) if err != nil { return err } } err = passwords.SetPassword(name, password, hashAlgorithm) i...
go
func SetPassword(file, name, password string, hashAlgorithm HashAlgorithm) error { _, err := os.Stat(file) passwords := HashedPasswords(map[string]string{}) if err == nil { passwords, err = ParseHtpasswdFile(file) if err != nil { return err } } err = passwords.SetPassword(name, password, hashAlgorithm) i...
[ "func", "SetPassword", "(", "file", ",", "name", ",", "password", "string", ",", "hashAlgorithm", "HashAlgorithm", ")", "error", "{", "_", ",", "err", ":=", "os", ".", "Stat", "(", "file", ")", "\n", "passwords", ":=", "HashedPasswords", "(", "map", "[",...
// SetPassword set password for a user with a given hashing algorithm
[ "SetPassword", "set", "password", "for", "a", "user", "with", "a", "given", "hashing", "algorithm" ]
cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e
https://github.com/foomo/htpasswd/blob/cb63c4ac0e5029b961b3ac7dcc281ed2a9232e4e/htpasswd.go#L155-L169
138,928
alexbrainman/sspi
schannel/buffer.go
copy
func (ib *inputBuffer) copy(d []byte) int { // TODO: check all call sites, maybe this can be made more efficient return copy(ib.data, d) }
go
func (ib *inputBuffer) copy(d []byte) int { // TODO: check all call sites, maybe this can be made more efficient return copy(ib.data, d) }
[ "func", "(", "ib", "*", "inputBuffer", ")", "copy", "(", "d", "[", "]", "byte", ")", "int", "{", "// TODO: check all call sites, maybe this can be made more efficient", "return", "copy", "(", "ib", ".", "data", ",", "d", ")", "\n", "}" ]
// copy copies data d into buffer ib. copy grows destination if needed.
[ "copy", "copies", "data", "d", "into", "buffer", "ib", ".", "copy", "grows", "destination", "if", "needed", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/schannel/buffer.go#L28-L31
138,929
alexbrainman/sspi
schannel/buffer.go
indexOfSecBuffer
func indexOfSecBuffer(bs []sspi.SecBuffer, buftype uint32) int { for i := range bs { if bs[i].BufferType == buftype { return i } } return -1 }
go
func indexOfSecBuffer(bs []sspi.SecBuffer, buftype uint32) int { for i := range bs { if bs[i].BufferType == buftype { return i } } return -1 }
[ "func", "indexOfSecBuffer", "(", "bs", "[", "]", "sspi", ".", "SecBuffer", ",", "buftype", "uint32", ")", "int", "{", "for", "i", ":=", "range", "bs", "{", "if", "bs", "[", "i", "]", ".", "BufferType", "==", "buftype", "{", "return", "i", "\n", "}"...
// indexOfSecBuffer searches buffers bs for buffer type buftype. // It returns -1 if not found.
[ "indexOfSecBuffer", "searches", "buffers", "bs", "for", "buffer", "type", "buftype", ".", "It", "returns", "-", "1", "if", "not", "found", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/schannel/buffer.go#L71-L78
138,930
alexbrainman/sspi
negotiate/negotiate.go
Release
func (c *ClientContext) Release() error { if c == nil { return nil } return c.sctxt.Release() }
go
func (c *ClientContext) Release() error { if c == nil { return nil } return c.sctxt.Release() }
[ "func", "(", "c", "*", "ClientContext", ")", "Release", "(", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "sctxt", ".", "Release", "(", ")", "\n", "}" ]
// Release free up resources associated with client context c.
[ "Release", "free", "up", "resources", "associated", "with", "client", "context", "c", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L262-L267
138,931
alexbrainman/sspi
negotiate/negotiate.go
Sizes
func (c *ClientContext) Sizes() (uint32, uint32, uint32, uint32, error) { return c.sctxt.Sizes() }
go
func (c *ClientContext) Sizes() (uint32, uint32, uint32, uint32, error) { return c.sctxt.Sizes() }
[ "func", "(", "c", "*", "ClientContext", ")", "Sizes", "(", ")", "(", "uint32", ",", "uint32", ",", "uint32", ",", "uint32", ",", "error", ")", "{", "return", "c", ".", "sctxt", ".", "Sizes", "(", ")", "\n", "}" ]
// Sizes queries the client context for the sizes used in per-message // functions. It returns the maximum token size used in authentication // exchanges, the maximum signature size, the preferred integral size of // messages, the size of any security trailer, and any error.
[ "Sizes", "queries", "the", "client", "context", "for", "the", "sizes", "used", "in", "per", "-", "message", "functions", ".", "It", "returns", "the", "maximum", "token", "size", "used", "in", "authentication", "exchanges", "the", "maximum", "signature", "size"...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L295-L297
138,932
alexbrainman/sspi
negotiate/negotiate.go
MakeSignature
func (c *ClientContext) MakeSignature(msg []byte, qop, seqno uint32) ([]byte, error) { return makeSignature(c.sctxt, msg, qop, seqno) }
go
func (c *ClientContext) MakeSignature(msg []byte, qop, seqno uint32) ([]byte, error) { return makeSignature(c.sctxt, msg, qop, seqno) }
[ "func", "(", "c", "*", "ClientContext", ")", "MakeSignature", "(", "msg", "[", "]", "byte", ",", "qop", ",", "seqno", "uint32", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "makeSignature", "(", "c", ".", "sctxt", ",", "msg", ",", ...
// MakeSignature uses the established client context to create a signature // for the given message using the provided quality of protection flags and // sequence number. It returns the signature token in addition to any error.
[ "MakeSignature", "uses", "the", "established", "client", "context", "to", "create", "a", "signature", "for", "the", "given", "message", "using", "the", "provided", "quality", "of", "protection", "flags", "and", "sequence", "number", ".", "It", "returns", "the", ...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L302-L304
138,933
alexbrainman/sspi
negotiate/negotiate.go
NewServerContext
func NewServerContext(cred *sspi.Credentials, token []byte) (sc *ServerContext, authDone bool, outputToken []byte, err error) { otoken := make([]byte, PackageInfo.MaxToken) c := sspi.NewServerContext(cred, sspi.ASC_REQ_CONNECTION) authDone, n, err2 := updateContext(c, otoken, token, nil) if err2 != nil { return n...
go
func NewServerContext(cred *sspi.Credentials, token []byte) (sc *ServerContext, authDone bool, outputToken []byte, err error) { otoken := make([]byte, PackageInfo.MaxToken) c := sspi.NewServerContext(cred, sspi.ASC_REQ_CONNECTION) authDone, n, err2 := updateContext(c, otoken, token, nil) if err2 != nil { return n...
[ "func", "NewServerContext", "(", "cred", "*", "sspi", ".", "Credentials", ",", "token", "[", "]", "byte", ")", "(", "sc", "*", "ServerContext", ",", "authDone", "bool", ",", "outputToken", "[", "]", "byte", ",", "err", "error", ")", "{", "otoken", ":="...
// NewServerContext creates new server context. It uses server // credentials created by AcquireServerCredentials and token from // the client to start server Negotiate negotiation sequence. // It also returns new token to be sent to the client.
[ "NewServerContext", "creates", "new", "server", "context", ".", "It", "uses", "server", "credentials", "created", "by", "AcquireServerCredentials", "and", "token", "from", "the", "client", "to", "start", "server", "Negotiate", "negotiation", "sequence", ".", "It", ...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L353-L362
138,934
alexbrainman/sspi
negotiate/negotiate.go
Release
func (c *ServerContext) Release() error { if c == nil { return nil } return c.sctxt.Release() }
go
func (c *ServerContext) Release() error { if c == nil { return nil } return c.sctxt.Release() }
[ "func", "(", "c", "*", "ServerContext", ")", "Release", "(", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "sctxt", ".", "Release", "(", ")", "\n", "}" ]
// Release free up resources associated with server context c.
[ "Release", "free", "up", "resources", "associated", "with", "server", "context", "c", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L365-L370
138,935
alexbrainman/sspi
negotiate/negotiate.go
Update
func (c *ServerContext) Update(token []byte) (authCompleted bool, outputToken []byte, err error) { otoken := make([]byte, PackageInfo.MaxToken) authDone, n, err2 := updateContext(c.sctxt, otoken, token, nil) if err2 != nil { return false, nil, err2 } if n == 0 && !authDone { return false, nil, errors.New("nego...
go
func (c *ServerContext) Update(token []byte) (authCompleted bool, outputToken []byte, err error) { otoken := make([]byte, PackageInfo.MaxToken) authDone, n, err2 := updateContext(c.sctxt, otoken, token, nil) if err2 != nil { return false, nil, err2 } if n == 0 && !authDone { return false, nil, errors.New("nego...
[ "func", "(", "c", "*", "ServerContext", ")", "Update", "(", "token", "[", "]", "byte", ")", "(", "authCompleted", "bool", ",", "outputToken", "[", "]", "byte", ",", "err", "error", ")", "{", "otoken", ":=", "make", "(", "[", "]", "byte", ",", "Pack...
// Update advances server part of Negotiate negotiation c. It uses // token received from the client and returns true if server part // of authentication is complete. It also returns new token to be // sent to the client.
[ "Update", "advances", "server", "part", "of", "Negotiate", "negotiation", "c", ".", "It", "uses", "token", "received", "from", "the", "client", "and", "returns", "true", "if", "server", "part", "of", "authentication", "is", "complete", ".", "It", "also", "re...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L381-L392
138,936
alexbrainman/sspi
negotiate/negotiate.go
GetUsername
func (c *ServerContext) GetUsername() (string, error) { var ns _SecPkgContext_NativeNames ret := sspi.QueryContextAttributes(c.sctxt.Handle, _SECPKG_ATTR_NATIVE_NAMES, (*byte)(unsafe.Pointer(&ns))) if ret != sspi.SEC_E_OK { return "", ret } sspi.FreeContextBuffer((*byte)(unsafe.Pointer(ns.ServerName))) defer ss...
go
func (c *ServerContext) GetUsername() (string, error) { var ns _SecPkgContext_NativeNames ret := sspi.QueryContextAttributes(c.sctxt.Handle, _SECPKG_ATTR_NATIVE_NAMES, (*byte)(unsafe.Pointer(&ns))) if ret != sspi.SEC_E_OK { return "", ret } sspi.FreeContextBuffer((*byte)(unsafe.Pointer(ns.ServerName))) defer ss...
[ "func", "(", "c", "*", "ServerContext", ")", "GetUsername", "(", ")", "(", "string", ",", "error", ")", "{", "var", "ns", "_SecPkgContext_NativeNames", "\n", "ret", ":=", "sspi", ".", "QueryContextAttributes", "(", "c", ".", "sctxt", ".", "Handle", ",", ...
// GetUsername returns the username corresponding to the authenticated client
[ "GetUsername", "returns", "the", "username", "corresponding", "to", "the", "authenticated", "client" ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L402-L411
138,937
alexbrainman/sspi
negotiate/negotiate.go
Sizes
func (c *ServerContext) Sizes() (uint32, uint32, uint32, uint32, error) { return c.sctxt.Sizes() }
go
func (c *ServerContext) Sizes() (uint32, uint32, uint32, uint32, error) { return c.sctxt.Sizes() }
[ "func", "(", "c", "*", "ServerContext", ")", "Sizes", "(", ")", "(", "uint32", ",", "uint32", ",", "uint32", ",", "uint32", ",", "error", ")", "{", "return", "c", ".", "sctxt", ".", "Sizes", "(", ")", "\n", "}" ]
// Sizes queries the server context for the sizes used in per-message // functions. It returns the maximum token size used in authentication // exchanges, the maximum signature size, the preferred integral size of // messages, the size of any security trailer, and any error.
[ "Sizes", "queries", "the", "server", "context", "for", "the", "sizes", "used", "in", "per", "-", "message", "functions", ".", "It", "returns", "the", "maximum", "token", "size", "used", "in", "authentication", "exchanges", "the", "maximum", "signature", "size"...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L429-L431
138,938
alexbrainman/sspi
negotiate/negotiate.go
VerifySignature
func (c *ServerContext) VerifySignature(msg, token []byte, seqno uint32) (uint32, error) { return verifySignature(c.sctxt, msg, token, seqno) }
go
func (c *ServerContext) VerifySignature(msg, token []byte, seqno uint32) (uint32, error) { return verifySignature(c.sctxt, msg, token, seqno) }
[ "func", "(", "c", "*", "ServerContext", ")", "VerifySignature", "(", "msg", ",", "token", "[", "]", "byte", ",", "seqno", "uint32", ")", "(", "uint32", ",", "error", ")", "{", "return", "verifySignature", "(", "c", ".", "sctxt", ",", "msg", ",", "tok...
// VerifySignature uses the established server context and signature token // to check that the provided message hasn't been tampered or received out // of sequence. It returns any quality of protection flags and any error // that occurred.
[ "VerifySignature", "uses", "the", "established", "server", "context", "and", "signature", "token", "to", "check", "that", "the", "provided", "message", "hasn", "t", "been", "tampered", "or", "received", "out", "of", "sequence", ".", "It", "returns", "any", "qu...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L444-L446
138,939
alexbrainman/sspi
negotiate/negotiate.go
DecryptMessage
func (c *ServerContext) DecryptMessage(msg []byte, seqno uint32) (uint32, []byte, error) { return decryptMessage(c.sctxt, msg, seqno) }
go
func (c *ServerContext) DecryptMessage(msg []byte, seqno uint32) (uint32, []byte, error) { return decryptMessage(c.sctxt, msg, seqno) }
[ "func", "(", "c", "*", "ServerContext", ")", "DecryptMessage", "(", "msg", "[", "]", "byte", ",", "seqno", "uint32", ")", "(", "uint32", ",", "[", "]", "byte", ",", "error", ")", "{", "return", "decryptMessage", "(", "c", ".", "sctxt", ",", "msg", ...
// DecryptMessage uses the established server context to decrypt a message // using the provided sequence number. // It returns the quality of protection flag and the decrypted message in addition to any error.
[ "DecryptMessage", "uses", "the", "established", "server", "context", "to", "decrypt", "a", "message", "using", "the", "provided", "sequence", "number", ".", "It", "returns", "the", "quality", "of", "protection", "flag", "and", "the", "decrypted", "message", "in"...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/negotiate/negotiate.go#L460-L462
138,940
alexbrainman/sspi
ntlm/ntlm.go
NewClientContext
func NewClientContext(cred *sspi.Credentials) (*ClientContext, []byte, error) { negotiate := make([]byte, PackageInfo.MaxToken) c := sspi.NewClientContext(cred, sspi.ISC_REQ_CONNECTION) authCompleted, n, err := updateContext(c, negotiate, nil) if err != nil { return nil, nil, err } if authCompleted { c.Releas...
go
func NewClientContext(cred *sspi.Credentials) (*ClientContext, []byte, error) { negotiate := make([]byte, PackageInfo.MaxToken) c := sspi.NewClientContext(cred, sspi.ISC_REQ_CONNECTION) authCompleted, n, err := updateContext(c, negotiate, nil) if err != nil { return nil, nil, err } if authCompleted { c.Releas...
[ "func", "NewClientContext", "(", "cred", "*", "sspi", ".", "Credentials", ")", "(", "*", "ClientContext", ",", "[", "]", "byte", ",", "error", ")", "{", "negotiate", ":=", "make", "(", "[", "]", "byte", ",", "PackageInfo", ".", "MaxToken", ")", "\n", ...
// NewClientContext creates new client context. It uses client // credentials cred generated by AcquireCurrentUserCredentials or // AcquireUserCredentials and, if successful, outputs negotiate // message. Negotiate message needs to be sent to the server to // start NTLM negotiation sequence.
[ "NewClientContext", "creates", "new", "client", "context", ".", "It", "uses", "client", "credentials", "cred", "generated", "by", "AcquireCurrentUserCredentials", "or", "AcquireUserCredentials", "and", "if", "successful", "outputs", "negotiate", "message", ".", "Negotia...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/ntlm/ntlm.go#L126-L143
138,941
alexbrainman/sspi
ntlm/ntlm.go
Update
func (c *ClientContext) Update(challenge []byte) ([]byte, error) { authenticate := make([]byte, PackageInfo.MaxToken) authCompleted, n, err := updateContext(c.sctxt, authenticate, challenge) if err != nil { return nil, err } if !authCompleted { return nil, errors.New("ntlm authentication should be completed no...
go
func (c *ClientContext) Update(challenge []byte) ([]byte, error) { authenticate := make([]byte, PackageInfo.MaxToken) authCompleted, n, err := updateContext(c.sctxt, authenticate, challenge) if err != nil { return nil, err } if !authCompleted { return nil, errors.New("ntlm authentication should be completed no...
[ "func", "(", "c", "*", "ClientContext", ")", "Update", "(", "challenge", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "authenticate", ":=", "make", "(", "[", "]", "byte", ",", "PackageInfo", ".", "MaxToken", ")", "\n", "aut...
// Update completes client part of NTLM negotiation c. It uses // challenge message received from the server, and generates // authenticate message to be returned to the server.
[ "Update", "completes", "client", "part", "of", "NTLM", "negotiation", "c", ".", "It", "uses", "challenge", "message", "received", "from", "the", "server", "and", "generates", "authenticate", "message", "to", "be", "returned", "to", "the", "server", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/ntlm/ntlm.go#L161-L175
138,942
alexbrainman/sspi
ntlm/ntlm.go
NewServerContext
func NewServerContext(cred *sspi.Credentials, negotiate []byte) (*ServerContext, []byte, error) { challenge := make([]byte, PackageInfo.MaxToken) c := sspi.NewServerContext(cred, sspi.ASC_REQ_CONNECTION) authCompleted, n, err := updateContext(c, challenge, negotiate) if err != nil { return nil, nil, err } if au...
go
func NewServerContext(cred *sspi.Credentials, negotiate []byte) (*ServerContext, []byte, error) { challenge := make([]byte, PackageInfo.MaxToken) c := sspi.NewServerContext(cred, sspi.ASC_REQ_CONNECTION) authCompleted, n, err := updateContext(c, challenge, negotiate) if err != nil { return nil, nil, err } if au...
[ "func", "NewServerContext", "(", "cred", "*", "sspi", ".", "Credentials", ",", "negotiate", "[", "]", "byte", ")", "(", "*", "ServerContext", ",", "[", "]", "byte", ",", "error", ")", "{", "challenge", ":=", "make", "(", "[", "]", "byte", ",", "Packa...
// NewServerContext creates new server context. It uses server // credentials created by AcquireServerCredentials and client // negotiate message and, if successful, outputs challenge message. // Challenge message needs to be sent to the client to continue // NTLM negotiation sequence.
[ "NewServerContext", "creates", "new", "server", "context", ".", "It", "uses", "server", "credentials", "created", "by", "AcquireServerCredentials", "and", "client", "negotiate", "message", "and", "if", "successful", "outputs", "challenge", "message", ".", "Challenge",...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/ntlm/ntlm.go#L197-L214
138,943
alexbrainman/sspi
ntlm/ntlm.go
Update
func (c *ServerContext) Update(authenticate []byte) error { authCompleted, n, err := updateContext(c.sctxt, nil, authenticate) if err != nil { return err } if !authCompleted { return errors.New("ntlm authentication should be completed now") } if n != 0 { return errors.New("ntlm token should be empty now") ...
go
func (c *ServerContext) Update(authenticate []byte) error { authCompleted, n, err := updateContext(c.sctxt, nil, authenticate) if err != nil { return err } if !authCompleted { return errors.New("ntlm authentication should be completed now") } if n != 0 { return errors.New("ntlm token should be empty now") ...
[ "func", "(", "c", "*", "ServerContext", ")", "Update", "(", "authenticate", "[", "]", "byte", ")", "error", "{", "authCompleted", ",", "n", ",", "err", ":=", "updateContext", "(", "c", ".", "sctxt", ",", "nil", ",", "authenticate", ")", "\n", "if", "...
// Update completes server part of NTLM negotiation c. It uses // authenticate message received from the client.
[ "Update", "completes", "server", "part", "of", "NTLM", "negotiation", "c", ".", "It", "uses", "authenticate", "message", "received", "from", "the", "client", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/ntlm/ntlm.go#L231-L243
138,944
alexbrainman/sspi
sspi.go
AcquireCredentials
func AcquireCredentials(principal string, pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { var principalName *uint16 if principal != "" { var err error principalName, err = syscall.UTF16PtrFromString(principal) if err != nil { return nil, err } } name, err := syscall.UTF16PtrFromSt...
go
func AcquireCredentials(principal string, pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { var principalName *uint16 if principal != "" { var err error principalName, err = syscall.UTF16PtrFromString(principal) if err != nil { return nil, err } } name, err := syscall.UTF16PtrFromSt...
[ "func", "AcquireCredentials", "(", "principal", "string", ",", "pkgname", "string", ",", "creduse", "uint32", ",", "authdata", "*", "byte", ")", "(", "*", "Credentials", ",", "error", ")", "{", "var", "principalName", "*", "uint16", "\n", "if", "principal", ...
// AcquireCredentials calls the windows AcquireCredentialsHandle function and // returns Credentials containing a security handle that can be used for // InitializeSecurityContext or AcceptSecurityContext operations. // As a special case, passing an empty string as the principal parameter will // pass a null string to ...
[ "AcquireCredentials", "calls", "the", "windows", "AcquireCredentialsHandle", "function", "and", "returns", "Credentials", "containing", "a", "security", "handle", "that", "can", "be", "used", "for", "InitializeSecurityContext", "or", "AcceptSecurityContext", "operations", ...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/sspi.go#L59-L78
138,945
alexbrainman/sspi
sspi.go
verifySelectiveFlags
func verifySelectiveFlags(flags, establishedFlags uint32) (valid bool, missing, extra uint32) { missing = flags&establishedFlags ^ flags extra = flags | establishedFlags ^ flags valid = missing == 0 return valid, missing, extra }
go
func verifySelectiveFlags(flags, establishedFlags uint32) (valid bool, missing, extra uint32) { missing = flags&establishedFlags ^ flags extra = flags | establishedFlags ^ flags valid = missing == 0 return valid, missing, extra }
[ "func", "verifySelectiveFlags", "(", "flags", ",", "establishedFlags", "uint32", ")", "(", "valid", "bool", ",", "missing", ",", "extra", "uint32", ")", "{", "missing", "=", "flags", "&", "establishedFlags", "^", "flags", "\n", "extra", "=", "flags", "|", ...
// verifySelectiveFlags determines if all bits requested in flags are set in establishedFlags. // missing represents the bits set in flags that are not set in establishedFlags. // extra represents the bits set in establishedFlags that are not set in flags. // valid is true and missing is zero when establishedFlags has ...
[ "verifySelectiveFlags", "determines", "if", "all", "bits", "requested", "in", "flags", "are", "set", "in", "establishedFlags", ".", "missing", "represents", "the", "bits", "set", "in", "flags", "that", "are", "not", "set", "in", "establishedFlags", ".", "extra",...
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/sspi.go#L211-L216
138,946
alexbrainman/sspi
sspi.go
NewSecBufferDesc
func NewSecBufferDesc(b []SecBuffer) *SecBufferDesc { return &SecBufferDesc{ Version: SECBUFFER_VERSION, BuffersCount: uint32(len(b)), Buffers: &b[0], } }
go
func NewSecBufferDesc(b []SecBuffer) *SecBufferDesc { return &SecBufferDesc{ Version: SECBUFFER_VERSION, BuffersCount: uint32(len(b)), Buffers: &b[0], } }
[ "func", "NewSecBufferDesc", "(", "b", "[", "]", "SecBuffer", ")", "*", "SecBufferDesc", "{", "return", "&", "SecBufferDesc", "{", "Version", ":", "SECBUFFER_VERSION", ",", "BuffersCount", ":", "uint32", "(", "len", "(", "b", ")", ")", ",", "Buffers", ":", ...
// NewSecBufferDesc returns an initialized SecBufferDesc describing the // provided SecBuffer.
[ "NewSecBufferDesc", "returns", "an", "initialized", "SecBufferDesc", "describing", "the", "provided", "SecBuffer", "." ]
e580b900e9f5657daa5473021296289be6da2661
https://github.com/alexbrainman/sspi/blob/e580b900e9f5657daa5473021296289be6da2661/sspi.go#L220-L226
138,947
coreos/go-tcmu
cmd_handler.go
EmulateModeSense
func EmulateModeSense(cmd *SCSICmd, wce bool) (SCSIResponse, error) { pgs := &bytes.Buffer{} outlen := int(cmd.XferLen()) page := cmd.GetCDB(2) if page == 0x3f || page == 0x08 { CachingModePage(pgs, wce) } scsiCmd := cmd.Command() dsp := byte(0x10) // Support DPO/FUA pgdata := pgs.Bytes() var hdr []byte ...
go
func EmulateModeSense(cmd *SCSICmd, wce bool) (SCSIResponse, error) { pgs := &bytes.Buffer{} outlen := int(cmd.XferLen()) page := cmd.GetCDB(2) if page == 0x3f || page == 0x08 { CachingModePage(pgs, wce) } scsiCmd := cmd.Command() dsp := byte(0x10) // Support DPO/FUA pgdata := pgs.Bytes() var hdr []byte ...
[ "func", "EmulateModeSense", "(", "cmd", "*", "SCSICmd", ",", "wce", "bool", ")", "(", "SCSIResponse", ",", "error", ")", "{", "pgs", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "outlen", ":=", "int", "(", "cmd", ".", "XferLen", "(", ")", ")"...
// EmulateModeSense responds to a static Mode Sense command. `wce` enables or diables // the SCSI "Write Cache Enabled" flag.
[ "EmulateModeSense", "responds", "to", "a", "static", "Mode", "Sense", "command", ".", "wce", "enables", "or", "diables", "the", "SCSI", "Write", "Cache", "Enabled", "flag", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/cmd_handler.go#L234-L268
138,948
coreos/go-tcmu
cmd_handler.go
EmulateModeSelect
func EmulateModeSelect(cmd *SCSICmd, wce bool) (SCSIResponse, error) { selectTen := (cmd.GetCDB(0) == scsi.ModeSelect10) page := cmd.GetCDB(2) & 0x3f subpage := cmd.GetCDB(3) allocLen := cmd.XferLen() hdrLen := 4 if selectTen { hdrLen = 8 } inBuf := make([]byte, 512) gotSense := false if allocLen == 0 { ...
go
func EmulateModeSelect(cmd *SCSICmd, wce bool) (SCSIResponse, error) { selectTen := (cmd.GetCDB(0) == scsi.ModeSelect10) page := cmd.GetCDB(2) & 0x3f subpage := cmd.GetCDB(3) allocLen := cmd.XferLen() hdrLen := 4 if selectTen { hdrLen = 8 } inBuf := make([]byte, 512) gotSense := false if allocLen == 0 { ...
[ "func", "EmulateModeSelect", "(", "cmd", "*", "SCSICmd", ",", "wce", "bool", ")", "(", "SCSIResponse", ",", "error", ")", "{", "selectTen", ":=", "(", "cmd", ".", "GetCDB", "(", "0", ")", "==", "scsi", ".", "ModeSelect10", ")", "\n", "page", ":=", "c...
// EmulateModeSelect checks that the only mode selected is the static one returned from // EmulateModeSense. `wce` should match the Write Cache Enabled of the EmulateModeSense call.
[ "EmulateModeSelect", "checks", "that", "the", "only", "mode", "selected", "is", "the", "static", "one", "returned", "from", "EmulateModeSense", ".", "wce", "should", "match", "the", "Write", "Cache", "Enabled", "of", "the", "EmulateModeSense", "call", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/cmd_handler.go#L272-L320
138,949
coreos/go-tcmu
scsi_handler.go
CdbLen
func (c *SCSICmd) CdbLen() int { opcode := c.cdb[0] // See spc-4 4.2.5.1 operation code // if opcode <= 0x1f { return 6 } else if opcode <= 0x5f { return 10 } else if opcode == 0x7f { return int(c.cdb[7]) + 8 } else if opcode >= 0x80 && opcode <= 0x9f { return 16 } else if opcode >= 0xa0 && opcode <= 0x...
go
func (c *SCSICmd) CdbLen() int { opcode := c.cdb[0] // See spc-4 4.2.5.1 operation code // if opcode <= 0x1f { return 6 } else if opcode <= 0x5f { return 10 } else if opcode == 0x7f { return int(c.cdb[7]) + 8 } else if opcode >= 0x80 && opcode <= 0x9f { return 16 } else if opcode >= 0xa0 && opcode <= 0x...
[ "func", "(", "c", "*", "SCSICmd", ")", "CdbLen", "(", ")", "int", "{", "opcode", ":=", "c", ".", "cdb", "[", "0", "]", "\n", "// See spc-4 4.2.5.1 operation code", "//", "if", "opcode", "<=", "0x1f", "{", "return", "6", "\n", "}", "else", "if", "opco...
// CdbLen returns the length of the command, in bytes.
[ "CdbLen", "returns", "the", "length", "of", "the", "command", "in", "bytes", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L36-L52
138,950
coreos/go-tcmu
scsi_handler.go
LBA
func (c *SCSICmd) LBA() uint64 { order := binary.BigEndian switch c.CdbLen() { case 6: val6 := uint8(order.Uint16(c.cdb[2:4])) if val6 == 0 { return 256 } return uint64(val6) case 10: return uint64(order.Uint32(c.cdb[2:6])) case 12: return uint64(order.Uint32(c.cdb[2:6])) case 16: return uint64(...
go
func (c *SCSICmd) LBA() uint64 { order := binary.BigEndian switch c.CdbLen() { case 6: val6 := uint8(order.Uint16(c.cdb[2:4])) if val6 == 0 { return 256 } return uint64(val6) case 10: return uint64(order.Uint32(c.cdb[2:6])) case 12: return uint64(order.Uint32(c.cdb[2:6])) case 16: return uint64(...
[ "func", "(", "c", "*", "SCSICmd", ")", "LBA", "(", ")", "uint64", "{", "order", ":=", "binary", ".", "BigEndian", "\n\n", "switch", "c", ".", "CdbLen", "(", ")", "{", "case", "6", ":", "val6", ":=", "uint8", "(", "order", ".", "Uint16", "(", "c",...
// LBA returns the block address that this command wishes to access.
[ "LBA", "returns", "the", "block", "address", "that", "this", "command", "wishes", "to", "access", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L55-L75
138,951
coreos/go-tcmu
scsi_handler.go
Read
func (c *SCSICmd) Read(b []byte) (n int, err error) { toRead := len(b) boff := 0 for toRead != 0 { if c.vecoffset == len(c.vecs) { return boff, io.EOF } read := copy(b[boff:], c.vecs[c.vecoffset][c.offset:]) boff += read toRead -= read c.offset += read if c.offset == len(c.vecs[c.vecoffset]) { c....
go
func (c *SCSICmd) Read(b []byte) (n int, err error) { toRead := len(b) boff := 0 for toRead != 0 { if c.vecoffset == len(c.vecs) { return boff, io.EOF } read := copy(b[boff:], c.vecs[c.vecoffset][c.offset:]) boff += read toRead -= read c.offset += read if c.offset == len(c.vecs[c.vecoffset]) { c....
[ "func", "(", "c", "*", "SCSICmd", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "toRead", ":=", "len", "(", "b", ")", "\n", "boff", ":=", "0", "\n", "for", "toRead", "!=", "0", "{", "if", "c",...
// Read, for a SCSICmd, is a io.Reader from the data buffer attached to this SCSI command. // If there's data to be written to the virtual device, this is the way to access it.
[ "Read", "for", "a", "SCSICmd", "is", "a", "io", ".", "Reader", "from", "the", "data", "buffer", "attached", "to", "this", "SCSI", "command", ".", "If", "there", "s", "data", "to", "be", "written", "to", "the", "virtual", "device", "this", "is", "the", ...
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L118-L135
138,952
coreos/go-tcmu
scsi_handler.go
Ok
func (c *SCSICmd) Ok() SCSIResponse { return SCSIResponse{ id: c.id, status: scsi.SamStatGood, } }
go
func (c *SCSICmd) Ok() SCSIResponse { return SCSIResponse{ id: c.id, status: scsi.SamStatGood, } }
[ "func", "(", "c", "*", "SCSICmd", ")", "Ok", "(", ")", "SCSIResponse", "{", "return", "SCSIResponse", "{", "id", ":", "c", ".", "id", ",", "status", ":", "scsi", ".", "SamStatGood", ",", "}", "\n", "}" ]
// Ok creates a SCSIResponse to this command with SAM_STAT_GOOD, the common case for commands that succeed.
[ "Ok", "creates", "a", "SCSIResponse", "to", "this", "command", "with", "SAM_STAT_GOOD", "the", "common", "case", "for", "commands", "that", "succeed", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L143-L148
138,953
coreos/go-tcmu
scsi_handler.go
RespondSenseData
func (c *SCSICmd) RespondSenseData(status byte, sense []byte) SCSIResponse { return SCSIResponse{ id: c.id, status: status, senseBuffer: sense, } }
go
func (c *SCSICmd) RespondSenseData(status byte, sense []byte) SCSIResponse { return SCSIResponse{ id: c.id, status: status, senseBuffer: sense, } }
[ "func", "(", "c", "*", "SCSICmd", ")", "RespondSenseData", "(", "status", "byte", ",", "sense", "[", "]", "byte", ")", "SCSIResponse", "{", "return", "SCSIResponse", "{", "id", ":", "c", ".", "id", ",", "status", ":", "status", ",", "senseBuffer", ":",...
// RespondSenseData returns a SCSIResponse with the given status byte set and takes a byte array representing the SCSI sense data to be written.
[ "RespondSenseData", "returns", "a", "SCSIResponse", "with", "the", "given", "status", "byte", "set", "and", "takes", "a", "byte", "array", "representing", "the", "SCSI", "sense", "data", "to", "be", "written", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L164-L170
138,954
coreos/go-tcmu
scsi_handler.go
NotHandled
func (c *SCSICmd) NotHandled() SCSIResponse { buf := make([]byte, tcmuSenseBufferSize) buf[0] = 0x70 /* fixed, current */ buf[2] = 0x5 /* illegal request */ buf[7] = 0xa buf[12] = 0x20 /* ASC: invalid command operation code */ buf[13] = 0x0 /* ASCQ: (none) */ return SCSIResponse{ id: c.id, status...
go
func (c *SCSICmd) NotHandled() SCSIResponse { buf := make([]byte, tcmuSenseBufferSize) buf[0] = 0x70 /* fixed, current */ buf[2] = 0x5 /* illegal request */ buf[7] = 0xa buf[12] = 0x20 /* ASC: invalid command operation code */ buf[13] = 0x0 /* ASCQ: (none) */ return SCSIResponse{ id: c.id, status...
[ "func", "(", "c", "*", "SCSICmd", ")", "NotHandled", "(", ")", "SCSIResponse", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "tcmuSenseBufferSize", ")", "\n", "buf", "[", "0", "]", "=", "0x70", "/* fixed, current */", "\n", "buf", "[", "2", "...
// NotHandled creates a response and sense data that tells the kernel this device does not emulate this command.
[ "NotHandled", "creates", "a", "response", "and", "sense", "data", "that", "tells", "the", "kernel", "this", "device", "does", "not", "emulate", "this", "command", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L173-L186
138,955
coreos/go-tcmu
scsi_handler.go
CheckCondition
func (c *SCSICmd) CheckCondition(key byte, asc uint16) SCSIResponse { buf := make([]byte, tcmuSenseBufferSize) buf[0] = 0x70 /* fixed, current */ buf[2] = key buf[7] = 0xa buf[12] = byte(uint8((asc >> 8) & 0xff)) buf[13] = byte(uint8(asc & 0xff)) return SCSIResponse{ id: c.id, status: scsi.SamS...
go
func (c *SCSICmd) CheckCondition(key byte, asc uint16) SCSIResponse { buf := make([]byte, tcmuSenseBufferSize) buf[0] = 0x70 /* fixed, current */ buf[2] = key buf[7] = 0xa buf[12] = byte(uint8((asc >> 8) & 0xff)) buf[13] = byte(uint8(asc & 0xff)) return SCSIResponse{ id: c.id, status: scsi.SamS...
[ "func", "(", "c", "*", "SCSICmd", ")", "CheckCondition", "(", "key", "byte", ",", "asc", "uint16", ")", "SCSIResponse", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "tcmuSenseBufferSize", ")", "\n", "buf", "[", "0", "]", "=", "0x70", "/* fix...
// CheckCondition returns a response providing extra sense data. Takes a Sense Key and an Additional Sense Code.
[ "CheckCondition", "returns", "a", "response", "providing", "extra", "sense", "data", ".", "Takes", "a", "Sense", "Key", "and", "an", "Additional", "Sense", "Code", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L189-L201
138,956
coreos/go-tcmu
scsi_handler.go
MediumError
func (c *SCSICmd) MediumError() SCSIResponse { return c.CheckCondition(scsi.SenseMediumError, scsi.AscReadError) }
go
func (c *SCSICmd) MediumError() SCSIResponse { return c.CheckCondition(scsi.SenseMediumError, scsi.AscReadError) }
[ "func", "(", "c", "*", "SCSICmd", ")", "MediumError", "(", ")", "SCSIResponse", "{", "return", "c", ".", "CheckCondition", "(", "scsi", ".", "SenseMediumError", ",", "scsi", ".", "AscReadError", ")", "\n", "}" ]
// MediumError is a preset response for a read error condition from the device
[ "MediumError", "is", "a", "preset", "response", "for", "a", "read", "error", "condition", "from", "the", "device" ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L204-L206
138,957
coreos/go-tcmu
scsi_handler.go
IllegalRequest
func (c *SCSICmd) IllegalRequest() SCSIResponse { return c.CheckCondition(scsi.SenseIllegalRequest, scsi.AscInvalidFieldInCdb) }
go
func (c *SCSICmd) IllegalRequest() SCSIResponse { return c.CheckCondition(scsi.SenseIllegalRequest, scsi.AscInvalidFieldInCdb) }
[ "func", "(", "c", "*", "SCSICmd", ")", "IllegalRequest", "(", ")", "SCSIResponse", "{", "return", "c", ".", "CheckCondition", "(", "scsi", ".", "SenseIllegalRequest", ",", "scsi", ".", "AscInvalidFieldInCdb", ")", "\n", "}" ]
// IllegalRequest is a preset response for a request that is malformed or unexpected.
[ "IllegalRequest", "is", "a", "preset", "response", "for", "a", "request", "that", "is", "malformed", "or", "unexpected", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L209-L211
138,958
coreos/go-tcmu
scsi_handler.go
TargetFailure
func (c *SCSICmd) TargetFailure() SCSIResponse { return c.CheckCondition(scsi.SenseHardwareError, scsi.AscInternalTargetFailure) }
go
func (c *SCSICmd) TargetFailure() SCSIResponse { return c.CheckCondition(scsi.SenseHardwareError, scsi.AscInternalTargetFailure) }
[ "func", "(", "c", "*", "SCSICmd", ")", "TargetFailure", "(", ")", "SCSIResponse", "{", "return", "c", ".", "CheckCondition", "(", "scsi", ".", "SenseHardwareError", ",", "scsi", ".", "AscInternalTargetFailure", ")", "\n", "}" ]
// TargetFailure is a preset response for returning a hardware error.
[ "TargetFailure", "is", "a", "preset", "response", "for", "returning", "a", "hardware", "error", "." ]
51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726
https://github.com/coreos/go-tcmu/blob/51bcb4f0f3a2dc05fb66b23069e58ee2ab08c726/scsi_handler.go#L214-L216
138,959
hsanjuan/go-libp2p-http
p2phttp.go
ProtocolOption
func ProtocolOption(p protocol.ID) Option { return func(o *options) { o.Protocol = p } }
go
func ProtocolOption(p protocol.ID) Option { return func(o *options) { o.Protocol = p } }
[ "func", "ProtocolOption", "(", "p", "protocol", ".", "ID", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "Protocol", "=", "p", "\n", "}", "\n", "}" ]
// ProtocolOption sets the Protocol Tag associated to the libp2p roundtripper.
[ "ProtocolOption", "sets", "the", "Protocol", "Tag", "associated", "to", "the", "libp2p", "roundtripper", "." ]
f53827a3f0ba3acaa10f64cc9c425021c8ebfc34
https://github.com/hsanjuan/go-libp2p-http/blob/f53827a3f0ba3acaa10f64cc9c425021c8ebfc34/p2phttp.go#L73-L77
138,960
hsanjuan/go-libp2p-http
p2phttp.go
Close
func (rb *respBody) Close() error { rb.conn.Close() return rb.ReadCloser.Close() }
go
func (rb *respBody) Close() error { rb.conn.Close() return rb.ReadCloser.Close() }
[ "func", "(", "rb", "*", "respBody", ")", "Close", "(", ")", "error", "{", "rb", ".", "conn", ".", "Close", "(", ")", "\n", "return", "rb", ".", "ReadCloser", ".", "Close", "(", ")", "\n", "}" ]
// Closes the response's body and the connection.
[ "Closes", "the", "response", "s", "body", "and", "the", "connection", "." ]
f53827a3f0ba3acaa10f64cc9c425021c8ebfc34
https://github.com/hsanjuan/go-libp2p-http/blob/f53827a3f0ba3acaa10f64cc9c425021c8ebfc34/p2phttp.go#L115-L118
138,961
muesli/crunchy
crunchy.go
NewValidatorWithOpts
func NewValidatorWithOpts(options Options) *Validator { if options.MinLength <= 0 { options.MinLength = 8 } if options.MinDiff <= 0 { options.MinDiff = 5 } if options.MinDist < 0 { options.MinDist = 3 } return &Validator{ options: options, words: make(map[string]struct{}), hashedWords: mak...
go
func NewValidatorWithOpts(options Options) *Validator { if options.MinLength <= 0 { options.MinLength = 8 } if options.MinDiff <= 0 { options.MinDiff = 5 } if options.MinDist < 0 { options.MinDist = 3 } return &Validator{ options: options, words: make(map[string]struct{}), hashedWords: mak...
[ "func", "NewValidatorWithOpts", "(", "options", "Options", ")", "*", "Validator", "{", "if", "options", ".", "MinLength", "<=", "0", "{", "options", ".", "MinLength", "=", "8", "\n", "}", "\n", "if", "options", ".", "MinDiff", "<=", "0", "{", "options", ...
// NewValidatorWithOpts returns a new password validator with custom settings
[ "NewValidatorWithOpts", "returns", "a", "new", "password", "validator", "with", "custom", "settings" ]
ee5032c9b35b57a43c16bfbab8196051a5bcb1d9
https://github.com/muesli/crunchy/blob/ee5032c9b35b57a43c16bfbab8196051a5bcb1d9/crunchy.go#L54-L70
138,962
muesli/crunchy
crunchy.go
Check
func (v *Validator) Check(password string) error { if strings.TrimSpace(password) == "" { return ErrEmpty } if len(password) < v.options.MinLength { return ErrTooShort } if countUniqueChars(password) < v.options.MinDiff { return ErrTooFewChars } // Inspired by cracklib maxrepeat := 3.0 + (0.09 * float64(...
go
func (v *Validator) Check(password string) error { if strings.TrimSpace(password) == "" { return ErrEmpty } if len(password) < v.options.MinLength { return ErrTooShort } if countUniqueChars(password) < v.options.MinDiff { return ErrTooFewChars } // Inspired by cracklib maxrepeat := 3.0 + (0.09 * float64(...
[ "func", "(", "v", "*", "Validator", ")", "Check", "(", "password", "string", ")", "error", "{", "if", "strings", ".", "TrimSpace", "(", "password", ")", "==", "\"", "\"", "{", "return", "ErrEmpty", "\n", "}", "\n", "if", "len", "(", "password", ")", ...
// Check validates a password for common flaws // It returns nil if the password is considered acceptable.
[ "Check", "validates", "a", "password", "for", "common", "flaws", "It", "returns", "nil", "if", "the", "password", "is", "considered", "acceptable", "." ]
ee5032c9b35b57a43c16bfbab8196051a5bcb1d9
https://github.com/muesli/crunchy/blob/ee5032c9b35b57a43c16bfbab8196051a5bcb1d9/crunchy.go#L151-L169
138,963
muesli/crunchy
stringutils.go
countUniqueChars
func countUniqueChars(s string) int { m := make(map[rune]struct{}) for _, c := range s { c = unicode.ToLower(c) if _, ok := m[c]; !ok { m[c] = struct{}{} } } return len(m) }
go
func countUniqueChars(s string) int { m := make(map[rune]struct{}) for _, c := range s { c = unicode.ToLower(c) if _, ok := m[c]; !ok { m[c] = struct{}{} } } return len(m) }
[ "func", "countUniqueChars", "(", "s", "string", ")", "int", "{", "m", ":=", "make", "(", "map", "[", "rune", "]", "struct", "{", "}", ")", "\n\n", "for", "_", ",", "c", ":=", "range", "s", "{", "c", "=", "unicode", ".", "ToLower", "(", "c", ")"...
// countUniqueChars returns the amount of unique runes in a string
[ "countUniqueChars", "returns", "the", "amount", "of", "unique", "runes", "in", "a", "string" ]
ee5032c9b35b57a43c16bfbab8196051a5bcb1d9
https://github.com/muesli/crunchy/blob/ee5032c9b35b57a43c16bfbab8196051a5bcb1d9/stringutils.go#L19-L30
138,964
muesli/crunchy
stringutils.go
reverse
func reverse(s string) string { var rs []rune for len(s) > 0 { r, size := utf8.DecodeLastRuneInString(s) s = s[:len(s)-size] rs = append(rs, r) } return string(rs) }
go
func reverse(s string) string { var rs []rune for len(s) > 0 { r, size := utf8.DecodeLastRuneInString(s) s = s[:len(s)-size] rs = append(rs, r) } return string(rs) }
[ "func", "reverse", "(", "s", "string", ")", "string", "{", "var", "rs", "[", "]", "rune", "\n", "for", "len", "(", "s", ")", ">", "0", "{", "r", ",", "size", ":=", "utf8", ".", "DecodeLastRuneInString", "(", "s", ")", "\n", "s", "=", "s", "[", ...
// reverse returns the reversed form of a string
[ "reverse", "returns", "the", "reversed", "form", "of", "a", "string" ]
ee5032c9b35b57a43c16bfbab8196051a5bcb1d9
https://github.com/muesli/crunchy/blob/ee5032c9b35b57a43c16bfbab8196051a5bcb1d9/stringutils.go#L50-L60
138,965
muesli/crunchy
stringutils.go
hashsum
func hashsum(s string, hasher hash.Hash) string { hasher.Reset() hasher.Write([]byte(s)) return hex.EncodeToString(hasher.Sum(nil)) }
go
func hashsum(s string, hasher hash.Hash) string { hasher.Reset() hasher.Write([]byte(s)) return hex.EncodeToString(hasher.Sum(nil)) }
[ "func", "hashsum", "(", "s", "string", ",", "hasher", "hash", ".", "Hash", ")", "string", "{", "hasher", ".", "Reset", "(", ")", "\n", "hasher", ".", "Write", "(", "[", "]", "byte", "(", "s", ")", ")", "\n", "return", "hex", ".", "EncodeToString", ...
// hashsum returns the hashed sum of a string
[ "hashsum", "returns", "the", "hashed", "sum", "of", "a", "string" ]
ee5032c9b35b57a43c16bfbab8196051a5bcb1d9
https://github.com/muesli/crunchy/blob/ee5032c9b35b57a43c16bfbab8196051a5bcb1d9/stringutils.go#L68-L72
138,966
stampzilla/gozwave
serialrecorder/serialrecorder.go
New
func New(port string, baud int) *serialRecorder { return &serialRecorder{ port: port, baud: baud, Logger: os.Stdout, writeBuffer: make(chan *Row, 100), } }
go
func New(port string, baud int) *serialRecorder { return &serialRecorder{ port: port, baud: baud, Logger: os.Stdout, writeBuffer: make(chan *Row, 100), } }
[ "func", "New", "(", "port", "string", ",", "baud", "int", ")", "*", "serialRecorder", "{", "return", "&", "serialRecorder", "{", "port", ":", "port", ",", "baud", ":", "baud", ",", "Logger", ":", "os", ".", "Stdout", ",", "writeBuffer", ":", "make", ...
// New returns a new serialRecorder that implements PortOpener for serial port that will record and output each write and read to stdout
[ "New", "returns", "a", "new", "serialRecorder", "that", "implements", "PortOpener", "for", "serial", "port", "that", "will", "record", "and", "output", "each", "write", "and", "read", "to", "stdout" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialrecorder/serialrecorder.go#L30-L37
138,967
stampzilla/gozwave
commands/raw.go
Encode
func (r Raw) Encode() []byte { return append([]byte{ 0x13, // SendData // TODO: use functions.SendData somehow without import cycle byte(r.node), // Node id byte(len(r.data) + 1), // Length }, r.data...) }
go
func (r Raw) Encode() []byte { return append([]byte{ 0x13, // SendData // TODO: use functions.SendData somehow without import cycle byte(r.node), // Node id byte(len(r.data) + 1), // Length }, r.data...) }
[ "func", "(", "r", "Raw", ")", "Encode", "(", ")", "[", "]", "byte", "{", "return", "append", "(", "[", "]", "byte", "{", "0x13", ",", "// SendData // TODO: use functions.SendData somehow without import cycle", "byte", "(", "r", ".", "node", ")", ",", "// Nod...
// Encode make sure we implement the Encodable interface
[ "Encode", "make", "sure", "we", "implement", "the", "Encodable", "interface" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/raw.go#L15-L22
138,968
stampzilla/gozwave
serialapi/message.go
Decode
func Decode(data []byte) (length int, msg *Message, err error) { // SOF 0x01 1 Start Of Frame // ACK 0x06 6 Message Ack // NAK 0x15 21 Message NAK // CAN 0x18 24 Cancel - Resend request switch data[0] { case 0x01: // SOF if len(data) < 2 { return 2, nil, nil } length := int(data[1]) if len(data) < len...
go
func Decode(data []byte) (length int, msg *Message, err error) { // SOF 0x01 1 Start Of Frame // ACK 0x06 6 Message Ack // NAK 0x15 21 Message NAK // CAN 0x18 24 Cancel - Resend request switch data[0] { case 0x01: // SOF if len(data) < 2 { return 2, nil, nil } length := int(data[1]) if len(data) < len...
[ "func", "Decode", "(", "data", "[", "]", "byte", ")", "(", "length", "int", ",", "msg", "*", "Message", ",", "err", "error", ")", "{", "// SOF\t0x01\t1\tStart Of Frame", "// ACK\t0x06\t6\tMessage Ack", "// NAK\t0x15\t21\tMessage NAK", "// CAN\t0x18\t24\tCancel - Resend ...
// Decode decodes serialapi raw data
[ "Decode", "decodes", "serialapi", "raw", "data" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/message.go#L36-L70
138,969
stampzilla/gozwave
serialapi/message.go
GenerateChecksum
func GenerateChecksum(data []byte) byte { var offset int ret := data[offset] for i := offset + 1; i < len(data)-1; i++ { // Xor bytes ret ^= data[i] } // Not result ret = (byte)(^ret) return ret }
go
func GenerateChecksum(data []byte) byte { var offset int ret := data[offset] for i := offset + 1; i < len(data)-1; i++ { // Xor bytes ret ^= data[i] } // Not result ret = (byte)(^ret) return ret }
[ "func", "GenerateChecksum", "(", "data", "[", "]", "byte", ")", "byte", "{", "var", "offset", "int", "\n", "ret", ":=", "data", "[", "offset", "]", "\n", "for", "i", ":=", "offset", "+", "1", ";", "i", "<", "len", "(", "data", ")", "-", "1", ";...
// GenerateChecksum calculates the checksum for a serialapi message
[ "GenerateChecksum", "calculates", "the", "checksum", "for", "a", "serialapi", "message" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/message.go#L73-L83
138,970
stampzilla/gozwave
serialapi/message.go
CompileMessage
func CompileMessage(data []byte) []byte { // Compile message msg := append([]byte{0x00, 0x00}, data...) msg = append(msg, 0x00) // Add length msg[0] = byte(len(msg) - 1) // Add checksum msg[len(msg)-1] = GenerateChecksum(msg) // Add header msg = append([]byte{0x01}, msg...) return msg }
go
func CompileMessage(data []byte) []byte { // Compile message msg := append([]byte{0x00, 0x00}, data...) msg = append(msg, 0x00) // Add length msg[0] = byte(len(msg) - 1) // Add checksum msg[len(msg)-1] = GenerateChecksum(msg) // Add header msg = append([]byte{0x01}, msg...) return msg }
[ "func", "CompileMessage", "(", "data", "[", "]", "byte", ")", "[", "]", "byte", "{", "// Compile message", "msg", ":=", "append", "(", "[", "]", "byte", "{", "0x00", ",", "0x00", "}", ",", "data", "...", ")", "\n", "msg", "=", "append", "(", "msg",...
// CompileMessage is used to calculate length and checksum for messages that are going to be sent to the controller
[ "CompileMessage", "is", "used", "to", "calculate", "length", "and", "checksum", "for", "messages", "that", "are", "going", "to", "be", "sent", "to", "the", "controller" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/message.go#L86-L101
138,971
stampzilla/gozwave
serialapi/message.go
NewMessage
func NewMessage(data []byte) (*Message, error) { message := &Message{} message.startByte = data[0] if len(data) <= 1 { return message, nil } message.Length = data[1] message.MessageType = data[2] message.Function = ZWaveFunction(data[3]) var err error switch message.Function { case ApplicationCommandHandle...
go
func NewMessage(data []byte) (*Message, error) { message := &Message{} message.startByte = data[0] if len(data) <= 1 { return message, nil } message.Length = data[1] message.MessageType = data[2] message.Function = ZWaveFunction(data[3]) var err error switch message.Function { case ApplicationCommandHandle...
[ "func", "NewMessage", "(", "data", "[", "]", "byte", ")", "(", "*", "Message", ",", "error", ")", "{", "message", ":=", "&", "Message", "{", "}", "\n", "message", ".", "startByte", "=", "data", "[", "0", "]", "\n", "if", "len", "(", "data", ")", ...
// NewMessage tries to decode a binary message from the controller in to a message struct
[ "NewMessage", "tries", "to", "decode", "a", "binary", "message", "from", "the", "controller", "in", "to", "a", "message", "struct" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/message.go#L104-L162
138,972
stampzilla/gozwave
serialapi/application_command_handler.go
NewApplicationCommandHandler
func NewApplicationCommandHandler(data []byte) (*FuncApplicationCommandHandler, error) { f := &FuncApplicationCommandHandler{} f.Command = commands.ZWaveCommand(data[0]) f.Class = data[1] var err error f.Report, err = reports.New(f.Command, f.Class, data[2:]) if err != nil { return nil, err } if report, ok...
go
func NewApplicationCommandHandler(data []byte) (*FuncApplicationCommandHandler, error) { f := &FuncApplicationCommandHandler{} f.Command = commands.ZWaveCommand(data[0]) f.Class = data[1] var err error f.Report, err = reports.New(f.Command, f.Class, data[2:]) if err != nil { return nil, err } if report, ok...
[ "func", "NewApplicationCommandHandler", "(", "data", "[", "]", "byte", ")", "(", "*", "FuncApplicationCommandHandler", ",", "error", ")", "{", "f", ":=", "&", "FuncApplicationCommandHandler", "{", "}", "\n\n", "f", ".", "Command", "=", "commands", ".", "ZWaveC...
// NewApplicationCommandHandler decodes and creates a funcApplicationCommandHandler. This is the most common message from the controller. Its sent everytime a report are received from the zwave network.
[ "NewApplicationCommandHandler", "decodes", "and", "creates", "a", "funcApplicationCommandHandler", ".", "This", "is", "the", "most", "common", "message", "from", "the", "controller", ".", "Its", "sent", "everytime", "a", "report", "are", "received", "from", "the", ...
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/application_command_handler.go#L17-L34
138,973
stampzilla/gozwave
commands/reports/alarm.go
NewAlarm
func NewAlarm(data []byte) (*Alarm, error) { a := &Alarm{data: data} if len(data) < 2 { return nil, fmt.Errorf("To short, expected at least 2 byte") } a.Type = data[0] a.Level = data[1] if len(data) >= 6 { a.SensorSourceID = data[2] a.Status = data[3] a.SensorType = data[4] a.Event = data[5] } // ...
go
func NewAlarm(data []byte) (*Alarm, error) { a := &Alarm{data: data} if len(data) < 2 { return nil, fmt.Errorf("To short, expected at least 2 byte") } a.Type = data[0] a.Level = data[1] if len(data) >= 6 { a.SensorSourceID = data[2] a.Status = data[3] a.SensorType = data[4] a.Event = data[5] } // ...
[ "func", "NewAlarm", "(", "data", "[", "]", "byte", ")", "(", "*", "Alarm", ",", "error", ")", "{", "a", ":=", "&", "Alarm", "{", "data", ":", "data", "}", "\n\n", "if", "len", "(", "data", ")", "<", "2", "{", "return", "nil", ",", "fmt", ".",...
// NewAlarm creates a new alarm report.
[ "NewAlarm", "creates", "a", "new", "alarm", "report", "." ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/alarm.go#L19-L41
138,974
stampzilla/gozwave
commands/reports/report.go
New
func New(c commands.ZWaveCommand, class byte, data []byte) (Report, error) { switch c { case commands.Alarm: switch class { case 0x05: // Report return NewAlarm(data) } case commands.ManufacturerSpecific: switch class { case 0x05: // Report return NewManufacturerSpecific(data) } case commands.Mult...
go
func New(c commands.ZWaveCommand, class byte, data []byte) (Report, error) { switch c { case commands.Alarm: switch class { case 0x05: // Report return NewAlarm(data) } case commands.ManufacturerSpecific: switch class { case 0x05: // Report return NewManufacturerSpecific(data) } case commands.Mult...
[ "func", "New", "(", "c", "commands", ".", "ZWaveCommand", ",", "class", "byte", ",", "data", "[", "]", "byte", ")", "(", "Report", ",", "error", ")", "{", "switch", "c", "{", "case", "commands", ".", "Alarm", ":", "switch", "class", "{", "case", "0...
// New creates a new report based on command, command class and data
[ "New", "creates", "a", "new", "report", "based", "on", "command", "command", "class", "and", "data" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/report.go#L28-L77
138,975
stampzilla/gozwave
serialapi/get_node_protocolinfo.go
NewGetNodeProtocolInfo
func NewGetNodeProtocolInfo(data []byte) (*FuncGetNodeProtocolInfo, error) { pi := &FuncGetNodeProtocolInfo{} if len(data) < 6 { return nil, fmt.Errorf("wrong length, should be at least 6 bytes got len %d data: %x", len(data), data) } // Capabilities pi.Listening = data[0]&0x80 != 0 pi.Routing = data[0]&0x40 ...
go
func NewGetNodeProtocolInfo(data []byte) (*FuncGetNodeProtocolInfo, error) { pi := &FuncGetNodeProtocolInfo{} if len(data) < 6 { return nil, fmt.Errorf("wrong length, should be at least 6 bytes got len %d data: %x", len(data), data) } // Capabilities pi.Listening = data[0]&0x80 != 0 pi.Routing = data[0]&0x40 ...
[ "func", "NewGetNodeProtocolInfo", "(", "data", "[", "]", "byte", ")", "(", "*", "FuncGetNodeProtocolInfo", ",", "error", ")", "{", "pi", ":=", "&", "FuncGetNodeProtocolInfo", "{", "}", "\n\n", "if", "len", "(", "data", ")", "<", "6", "{", "return", "nil"...
// NewGetNodeProtocolInfo decodes and cretes a funcGetNodeProtocolInfo. It is sent from the controller and contanins all basic information that the controller knows about a node.
[ "NewGetNodeProtocolInfo", "decodes", "and", "cretes", "a", "funcGetNodeProtocolInfo", ".", "It", "is", "sent", "from", "the", "controller", "and", "contanins", "all", "basic", "information", "that", "the", "controller", "knows", "about", "a", "node", "." ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/get_node_protocolinfo.go#L22-L51
138,976
stampzilla/gozwave
commands/reports/manufacturer_specific.go
NewManufacturerSpecific
func NewManufacturerSpecific(data []byte) (*ManufacturerSpecific, error) { if len(data) != 6 { return nil, fmt.Errorf("Failed to decode ManufacturerSpecific: Wrong length") } type aliasCmdManufacturerSpecific struct { Manufacturer uint16 Type uint16 ID uint16 } ms := &aliasCmdManufactur...
go
func NewManufacturerSpecific(data []byte) (*ManufacturerSpecific, error) { if len(data) != 6 { return nil, fmt.Errorf("Failed to decode ManufacturerSpecific: Wrong length") } type aliasCmdManufacturerSpecific struct { Manufacturer uint16 Type uint16 ID uint16 } ms := &aliasCmdManufactur...
[ "func", "NewManufacturerSpecific", "(", "data", "[", "]", "byte", ")", "(", "*", "ManufacturerSpecific", ",", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "6", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", ...
// NewManufacturerSpecific decodes and returns a manufacureSpecific report.
[ "NewManufacturerSpecific", "decodes", "and", "returns", "a", "manufacureSpecific", "report", "." ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/manufacturer_specific.go#L18-L41
138,977
stampzilla/gozwave
database/commandclasses.go
GetMandatoryCommandClasses
func GetMandatoryCommandClasses(generic, specific byte) []*CommandClass { for k, v := range definitions { if k.Generic == generic && k.Specific == specific { return v } } return nil }
go
func GetMandatoryCommandClasses(generic, specific byte) []*CommandClass { for k, v := range definitions { if k.Generic == generic && k.Specific == specific { return v } } return nil }
[ "func", "GetMandatoryCommandClasses", "(", "generic", ",", "specific", "byte", ")", "[", "]", "*", "CommandClass", "{", "for", "k", ",", "v", ":=", "range", "definitions", "{", "if", "k", ".", "Generic", "==", "generic", "&&", "k", ".", "Specific", "==",...
// GetMandatoryCommandClasses generates a list of mandatory commandclasses
[ "GetMandatoryCommandClasses", "generates", "a", "list", "of", "mandatory", "commandclasses" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/database/commandclasses.go#L4-L11
138,978
stampzilla/gozwave
commands/reports/switch_binary.go
NewSwitchBinaryV1
func NewSwitchBinaryV1(data []byte) (*SwitchBinaryV1, error) { if len(data) != 1 { return nil, fmt.Errorf("Wrong length, expected 1 byte got %d", len(data)) } return &SwitchBinaryV1{ CurrentValue: data[0] == 0xFF && data[0] != 0xFE, Valid: data[0] != 0xFE, data: data, }, nil }
go
func NewSwitchBinaryV1(data []byte) (*SwitchBinaryV1, error) { if len(data) != 1 { return nil, fmt.Errorf("Wrong length, expected 1 byte got %d", len(data)) } return &SwitchBinaryV1{ CurrentValue: data[0] == 0xFF && data[0] != 0xFE, Valid: data[0] != 0xFE, data: data, }, nil }
[ "func", "NewSwitchBinaryV1", "(", "data", "[", "]", "byte", ")", "(", "*", "SwitchBinaryV1", ",", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "dat...
// NewSwitchBinaryV1 creates a new SwitchBinary report that contains the switch status from a // zwave node
[ "NewSwitchBinaryV1", "creates", "a", "new", "SwitchBinary", "report", "that", "contains", "the", "switch", "status", "from", "a", "zwave", "node" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/switch_binary.go#L23-L33
138,979
stampzilla/gozwave
commands/reports/switch_binary.go
NewSwitchBinaryV2
func NewSwitchBinaryV2(data []byte) (*SwitchBinaryV2, error) { if len(data) != 3 { return nil, fmt.Errorf("Wrong length, expected 3 byte got %d", len(data)) } return &SwitchBinaryV2{ CurrentValue: data[0] != 0x00, TargetValue: data[1] != 0x00, Duration: commands.Duration(data[2]), data: data,...
go
func NewSwitchBinaryV2(data []byte) (*SwitchBinaryV2, error) { if len(data) != 3 { return nil, fmt.Errorf("Wrong length, expected 3 byte got %d", len(data)) } return &SwitchBinaryV2{ CurrentValue: data[0] != 0x00, TargetValue: data[1] != 0x00, Duration: commands.Duration(data[2]), data: data,...
[ "func", "NewSwitchBinaryV2", "(", "data", "[", "]", "byte", ")", "(", "*", "SwitchBinaryV2", ",", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "3", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "dat...
// NewSwitchBinaryV2 creates a new switchBinary report that contains the switch status from a // zwave node
[ "NewSwitchBinaryV2", "creates", "a", "new", "switchBinary", "report", "that", "contains", "the", "switch", "status", "from", "a", "zwave", "node" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/switch_binary.go#L54-L65
138,980
stampzilla/gozwave
commands/reports/switch_multilevel.go
NewSwitchMultilevelV1
func NewSwitchMultilevelV1(data []byte) (*SwitchMultilevelV1, error) { if len(data) != 1 { return nil, fmt.Errorf("Wrong length, expected 1 byte got %d", len(data)) } return &SwitchMultilevelV1{ CurrentValue: math.Min(float64(data[0]), 100), Valid: data[0] != 0xFE, data: data, }, nil }
go
func NewSwitchMultilevelV1(data []byte) (*SwitchMultilevelV1, error) { if len(data) != 1 { return nil, fmt.Errorf("Wrong length, expected 1 byte got %d", len(data)) } return &SwitchMultilevelV1{ CurrentValue: math.Min(float64(data[0]), 100), Valid: data[0] != 0xFE, data: data, }, nil }
[ "func", "NewSwitchMultilevelV1", "(", "data", "[", "]", "byte", ")", "(", "*", "SwitchMultilevelV1", ",", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "("...
// NewSwitchMultilevelV1 creates a new SwitchMultilevelV1 report from binary data sent from a // zwave node
[ "NewSwitchMultilevelV1", "creates", "a", "new", "SwitchMultilevelV1", "report", "from", "binary", "data", "sent", "from", "a", "zwave", "node" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/switch_multilevel.go#L22-L32
138,981
stampzilla/gozwave
commands/reports/switch_multilevel.go
NewSwitchMultilevelV4
func NewSwitchMultilevelV4(data []byte) (*SwitchMultilevelV4, error) { if len(data) != 3 { return nil, fmt.Errorf("Wrong length, expected 3 byte got %d", len(data)) } return &SwitchMultilevelV4{ CurrentValue: math.Min(float64(data[0]), 100), TargetValue: math.Min(float64(data[1]), 100), Duration: comma...
go
func NewSwitchMultilevelV4(data []byte) (*SwitchMultilevelV4, error) { if len(data) != 3 { return nil, fmt.Errorf("Wrong length, expected 3 byte got %d", len(data)) } return &SwitchMultilevelV4{ CurrentValue: math.Min(float64(data[0]), 100), TargetValue: math.Min(float64(data[1]), 100), Duration: comma...
[ "func", "NewSwitchMultilevelV4", "(", "data", "[", "]", "byte", ")", "(", "*", "SwitchMultilevelV4", ",", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "3", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "("...
// NewSwitchMultilevelV4 creates a new SwitchMultilevelV1 report from binary data sent from a // zwave node
[ "NewSwitchMultilevelV4", "creates", "a", "new", "SwitchMultilevelV1", "report", "from", "binary", "data", "sent", "from", "a", "zwave", "node" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/reports/switch_multilevel.go#L56-L69
138,982
stampzilla/gozwave
commands/duration.go
Duration
func (d Duration) Duration() (time.Duration, error) { switch { case byte(d) == 0x00: return time.Duration(0), nil case byte(d) <= 0x7F: return time.Duration(d) * time.Second, nil case d <= 0xFD: return time.Duration(d-0x7F) * time.Minute, nil } return time.Duration(0), fmt.Errorf("Factory default duration")...
go
func (d Duration) Duration() (time.Duration, error) { switch { case byte(d) == 0x00: return time.Duration(0), nil case byte(d) <= 0x7F: return time.Duration(d) * time.Second, nil case d <= 0xFD: return time.Duration(d-0x7F) * time.Minute, nil } return time.Duration(0), fmt.Errorf("Factory default duration")...
[ "func", "(", "d", "Duration", ")", "Duration", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "switch", "{", "case", "byte", "(", "d", ")", "==", "0x00", ":", "return", "time", ".", "Duration", "(", "0", ")", ",", "nil", "\n", ...
// Duration converts zwave duration type into time.Duration
[ "Duration", "converts", "zwave", "duration", "type", "into", "time", ".", "Duration" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/commands/duration.go#L12-L22
138,983
stampzilla/gozwave
serialapi/discovery_nodes.go
NewDiscoverdNodes
func NewDiscoverdNodes(data []byte) (*DiscoverdNodes, error) { f := &DiscoverdNodes{ data: data, } if len(data) < 6 { return nil, fmt.Errorf("wrong length, should be at least 6 bytes got %d", len(data)) } for index, bits := range data { f.ActiveNodes[index*8+0] = bits&0x01 != 0 f.ActiveNodes[index*8+1] =...
go
func NewDiscoverdNodes(data []byte) (*DiscoverdNodes, error) { f := &DiscoverdNodes{ data: data, } if len(data) < 6 { return nil, fmt.Errorf("wrong length, should be at least 6 bytes got %d", len(data)) } for index, bits := range data { f.ActiveNodes[index*8+0] = bits&0x01 != 0 f.ActiveNodes[index*8+1] =...
[ "func", "NewDiscoverdNodes", "(", "data", "[", "]", "byte", ")", "(", "*", "DiscoverdNodes", ",", "error", ")", "{", "f", ":=", "&", "DiscoverdNodes", "{", "data", ":", "data", ",", "}", "\n\n", "if", "len", "(", "data", ")", "<", "6", "{", "return...
// NewDiscoverdNodes decodes and creates a discoveryNode message. This message is received from the controller and contains a list of all available nodes in the network
[ "NewDiscoverdNodes", "decodes", "and", "creates", "a", "discoveryNode", "message", ".", "This", "message", "is", "received", "from", "the", "controller", "and", "contains", "a", "list", "of", "all", "available", "nodes", "in", "the", "network" ]
576012815e010355bd3374a4f6af2d544ccab079
https://github.com/stampzilla/gozwave/blob/576012815e010355bd3374a4f6af2d544ccab079/serialapi/discovery_nodes.go#L12-L34
138,984
mitchellh/prefixedio
reader.go
NewReader
func NewReader(r io.Reader) (*Reader, error) { if r == nil { return nil, errors.New("Reader must not be nil") } return &Reader{r: r}, nil }
go
func NewReader(r io.Reader) (*Reader, error) { if r == nil { return nil, errors.New("Reader must not be nil") } return &Reader{r: r}, nil }
[ "func", "NewReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Reader", ",", "error", ")", "{", "if", "r", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "Reader", "{",...
// NewReader creates a new Reader with the given io.Reader.
[ "NewReader", "creates", "a", "new", "Reader", "with", "the", "given", "io", ".", "Reader", "." ]
5733675afd5162de652b410d2244d82b00a38a79
https://github.com/mitchellh/prefixedio/blob/5733675afd5162de652b410d2244d82b00a38a79/reader.go#L39-L45
138,985
mitchellh/prefixedio
reader.go
read
func (r *Reader) read() { var err error var lastPrefix string buf := bufio.NewReader(r.r) // Listen for bytes in a goroutine. We do this so that if we're blocking // we can flush the bytes we have after some configured time. There is // probably a way to make this a lot faster but this works for now. byteCh := ...
go
func (r *Reader) read() { var err error var lastPrefix string buf := bufio.NewReader(r.r) // Listen for bytes in a goroutine. We do this so that if we're blocking // we can flush the bytes we have after some configured time. There is // probably a way to make this a lot faster but this works for now. byteCh := ...
[ "func", "(", "r", "*", "Reader", ")", "read", "(", ")", "{", "var", "err", "error", "\n", "var", "lastPrefix", "string", "\n", "buf", ":=", "bufio", ".", "NewReader", "(", "r", ".", "r", ")", "\n\n", "// Listen for bytes in a goroutine. We do this so that if...
// read runs in a goroutine and performs a read on the reader, // dispatching lines to prefixes where necessary.
[ "read", "runs", "in", "a", "goroutine", "and", "performs", "a", "read", "on", "the", "reader", "dispatching", "lines", "to", "prefixes", "where", "necessary", "." ]
5733675afd5162de652b410d2244d82b00a38a79
https://github.com/mitchellh/prefixedio/blob/5733675afd5162de652b410d2244d82b00a38a79/reader.go#L97-L210
138,986
spacemonkeygo/spacelog
setup/setup.go
MustSetupWithFacility
func MustSetupWithFacility(procname string, facility spacelog.SyslogPriority) { err := SetupWithFacility(procname, facility) if err != nil { panic(err) } }
go
func MustSetupWithFacility(procname string, facility spacelog.SyslogPriority) { err := SetupWithFacility(procname, facility) if err != nil { panic(err) } }
[ "func", "MustSetupWithFacility", "(", "procname", "string", ",", "facility", "spacelog", ".", "SyslogPriority", ")", "{", "err", ":=", "SetupWithFacility", "(", "procname", ",", "facility", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", ...
// MustSetupWithFacility is deprecated and will be removed soon. Please // configure facility through the facility flag option.
[ "MustSetupWithFacility", "is", "deprecated", "and", "will", "be", "removed", "soon", ".", "Please", "configure", "facility", "through", "the", "facility", "flag", "option", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/setup/setup.go#L66-L71
138,987
spacemonkeygo/spacelog
setup/setup.go
SetupWithFacility
func SetupWithFacility(procname string, facility spacelog.SyslogPriority) error { config_copy := config config_copy.Facility = int(facility) return spacelog.Setup(procname, config_copy) }
go
func SetupWithFacility(procname string, facility spacelog.SyslogPriority) error { config_copy := config config_copy.Facility = int(facility) return spacelog.Setup(procname, config_copy) }
[ "func", "SetupWithFacility", "(", "procname", "string", ",", "facility", "spacelog", ".", "SyslogPriority", ")", "error", "{", "config_copy", ":=", "config", "\n", "config_copy", ".", "Facility", "=", "int", "(", "facility", ")", "\n", "return", "spacelog", "....
// SetupWithFacility is deprecated and will be removed soon. Please // configure facility through the facility flag option.
[ "SetupWithFacility", "is", "deprecated", "and", "will", "be", "removed", "soon", ".", "Please", "configure", "facility", "through", "the", "facility", "flag", "option", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/setup/setup.go#L75-L80
138,988
spacemonkeygo/spacelog
text.go
NewTextHandler
func NewTextHandler(t *template.Template, output TextOutput) *TextHandler { return &TextHandler{template: t, output: output} }
go
func NewTextHandler(t *template.Template, output TextOutput) *TextHandler { return &TextHandler{template: t, output: output} }
[ "func", "NewTextHandler", "(", "t", "*", "template", ".", "Template", ",", "output", "TextOutput", ")", "*", "TextHandler", "{", "return", "&", "TextHandler", "{", "template", ":", "t", ",", "output", ":", "output", "}", "\n", "}" ]
// NewTextHandler creates a Handler that creates LogEvents, passes them to // the given template, and passes the result to output
[ "NewTextHandler", "creates", "a", "Handler", "that", "creates", "LogEvents", "passes", "them", "to", "the", "given", "template", "and", "passes", "the", "result", "to", "output" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/text.go#L39-L41
138,989
spacemonkeygo/spacelog
text.go
Log
func (h *TextHandler) Log(logger_name string, level LogLevel, msg string, calldepth int) { h.mtx.RLock() output, template := h.output, h.template h.mtx.RUnlock() event := LogEvent{ LoggerName: logger_name, Level: level, Message: strings.TrimRight(msg, "\n\r"), Timestamp: time.Now()} if calldepth ...
go
func (h *TextHandler) Log(logger_name string, level LogLevel, msg string, calldepth int) { h.mtx.RLock() output, template := h.output, h.template h.mtx.RUnlock() event := LogEvent{ LoggerName: logger_name, Level: level, Message: strings.TrimRight(msg, "\n\r"), Timestamp: time.Now()} if calldepth ...
[ "func", "(", "h", "*", "TextHandler", ")", "Log", "(", "logger_name", "string", ",", "level", "LogLevel", ",", "msg", "string", ",", "calldepth", "int", ")", "{", "h", ".", "mtx", ".", "RLock", "(", ")", "\n", "output", ",", "template", ":=", "h", ...
// Log makes a LogEvent, formats it with the configured template, then passes // the output to configured output sink
[ "Log", "makes", "a", "LogEvent", "formats", "it", "with", "the", "configured", "template", "then", "passes", "the", "output", "to", "configured", "output", "sink" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/text.go#L45-L66
138,990
spacemonkeygo/spacelog
text.go
SetTextTemplate
func (h *TextHandler) SetTextTemplate(t *template.Template) { h.mtx.Lock() defer h.mtx.Unlock() h.template = t }
go
func (h *TextHandler) SetTextTemplate(t *template.Template) { h.mtx.Lock() defer h.mtx.Unlock() h.template = t }
[ "func", "(", "h", "*", "TextHandler", ")", "SetTextTemplate", "(", "t", "*", "template", ".", "Template", ")", "{", "h", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "mtx", ".", "Unlock", "(", ")", "\n", "h", ".", "template", "=", ...
// SetTextTemplate changes the TextHandler's text formatting template
[ "SetTextTemplate", "changes", "the", "TextHandler", "s", "text", "formatting", "template" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/text.go#L69-L73
138,991
spacemonkeygo/spacelog
text.go
SetTextOutput
func (h *TextHandler) SetTextOutput(output TextOutput) { h.mtx.Lock() defer h.mtx.Unlock() h.output = output }
go
func (h *TextHandler) SetTextOutput(output TextOutput) { h.mtx.Lock() defer h.mtx.Unlock() h.output = output }
[ "func", "(", "h", "*", "TextHandler", ")", "SetTextOutput", "(", "output", "TextOutput", ")", "{", "h", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "mtx", ".", "Unlock", "(", ")", "\n", "h", ".", "output", "=", "output", "\n", "}"...
// SetTextOutput changes the TextHandler's TextOutput sink
[ "SetTextOutput", "changes", "the", "TextHandler", "s", "TextOutput", "sink" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/text.go#L76-L80
138,992
spacemonkeygo/spacelog
templates.go
ColorizeLevel
func ColorizeLevel(level LogLevel) string { switch level.Match() { case Critical, Error: return TermColors{}.Red() case Warning: return TermColors{}.Magenta() case Notice: return TermColors{}.Yellow() case Info, Debug, Trace: return TermColors{}.Green() } return "" }
go
func ColorizeLevel(level LogLevel) string { switch level.Match() { case Critical, Error: return TermColors{}.Red() case Warning: return TermColors{}.Magenta() case Notice: return TermColors{}.Yellow() case Info, Debug, Trace: return TermColors{}.Green() } return "" }
[ "func", "ColorizeLevel", "(", "level", "LogLevel", ")", "string", "{", "switch", "level", ".", "Match", "(", ")", "{", "case", "Critical", ",", "Error", ":", "return", "TermColors", "{", "}", ".", "Red", "(", ")", "\n", "case", "Warning", ":", "return"...
// ColorizeLevel returns a TermColor byte sequence for the appropriate color // for the level. If you'd like to configure your own color choices, you can // make your own template with its own function map to your own colorize // function.
[ "ColorizeLevel", "returns", "a", "TermColor", "byte", "sequence", "for", "the", "appropriate", "color", "for", "the", "level", ".", "If", "you", "d", "like", "to", "configure", "your", "own", "color", "choices", "you", "can", "make", "your", "own", "template...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/templates.go#L25-L37
138,993
spacemonkeygo/spacelog
event.go
LevelJustified
func (l *LogEvent) LevelJustified() (rv string) { rv = l.Level.String() if len(rv) < 5 { rv += strings.Repeat(" ", 5-len(rv)) } return rv }
go
func (l *LogEvent) LevelJustified() (rv string) { rv = l.Level.String() if len(rv) < 5 { rv += strings.Repeat(" ", 5-len(rv)) } return rv }
[ "func", "(", "l", "*", "LogEvent", ")", "LevelJustified", "(", ")", "(", "rv", "string", ")", "{", "rv", "=", "l", ".", "Level", ".", "String", "(", ")", "\n", "if", "len", "(", "rv", ")", "<", "5", "{", "rv", "+=", "strings", ".", "Repeat", ...
// LevelJustified returns the log level in string form justified so that all // log levels take the same text width.
[ "LevelJustified", "returns", "the", "log", "level", "in", "string", "form", "justified", "so", "that", "all", "log", "levels", "take", "the", "same", "text", "width", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/event.go#L69-L75
138,994
spacemonkeygo/spacelog
level.go
String
func (l LogLevel) String() string { switch l.Match() { case Critical: return "CRIT" case Error: return "ERR" case Warning: return "WARN" case Notice: return "NOTE" case Info: return "INFO" case Debug: return "DEBUG" case Trace: return "TRACE" default: return "UNSET" } }
go
func (l LogLevel) String() string { switch l.Match() { case Critical: return "CRIT" case Error: return "ERR" case Warning: return "WARN" case Notice: return "NOTE" case Info: return "INFO" case Debug: return "DEBUG" case Trace: return "TRACE" default: return "UNSET" } }
[ "func", "(", "l", "LogLevel", ")", "String", "(", ")", "string", "{", "switch", "l", ".", "Match", "(", ")", "{", "case", "Critical", ":", "return", "\"", "\"", "\n", "case", "Error", ":", "return", "\"", "\"", "\n", "case", "Warning", ":", "return...
// String returns the log level name in short form
[ "String", "returns", "the", "log", "level", "name", "in", "short", "form" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/level.go#L40-L59
138,995
spacemonkeygo/spacelog
level.go
LevelFromString
func LevelFromString(str string) (LogLevel, error) { switch strings.ToLower(str) { case "crit", "critical": return Critical, nil case "err", "error": return Error, nil case "warn", "warning": return Warning, nil case "note", "notice": return Notice, nil case "info": return Info, nil case "debug": ret...
go
func LevelFromString(str string) (LogLevel, error) { switch strings.ToLower(str) { case "crit", "critical": return Critical, nil case "err", "error": return Error, nil case "warn", "warning": return Warning, nil case "note", "notice": return Notice, nil case "info": return Info, nil case "debug": ret...
[ "func", "LevelFromString", "(", "str", "string", ")", "(", "LogLevel", ",", "error", ")", "{", "switch", "strings", ".", "ToLower", "(", "str", ")", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "return", "Critical", ",", "nil", "\n", "case", "\"", ...
// LevelFromString will convert a named log level to its corresponding value // type, or error if both the name was unknown and an integer value was unable // to be parsed.
[ "LevelFromString", "will", "convert", "a", "named", "log", "level", "to", "its", "corresponding", "value", "type", "or", "error", "if", "both", "the", "name", "was", "unknown", "and", "an", "integer", "value", "was", "unable", "to", "be", "parsed", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/level.go#L114-L136
138,996
spacemonkeygo/spacelog
setup.go
MustSetup
func MustSetup(procname string, config SetupConfig) { err := Setup(procname, config) if err != nil { panic(err) } }
go
func MustSetup(procname string, config SetupConfig) { err := Setup(procname, config) if err != nil { panic(err) } }
[ "func", "MustSetup", "(", "procname", "string", ",", "config", "SetupConfig", ")", "{", "err", ":=", "Setup", "(", "procname", ",", "config", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}" ]
// MustSetup is the same as Setup, but panics instead of returning an error
[ "MustSetup", "is", "the", "same", "as", "Setup", "but", "panics", "instead", "of", "returning", "an", "error" ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/setup.go#L61-L66
138,997
spacemonkeygo/spacelog
capture.go
CaptureOutputToFile
func CaptureOutputToFile(path string) error { fh, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) if err != nil { return err } defer fh.Close() return CaptureOutputToFd(int(fh.Fd())) }
go
func CaptureOutputToFile(path string) error { fh, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) if err != nil { return err } defer fh.Close() return CaptureOutputToFd(int(fh.Fd())) }
[ "func", "CaptureOutputToFile", "(", "path", "string", ")", "error", "{", "fh", ",", "err", ":=", "os", ".", "OpenFile", "(", "path", ",", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", ",", "0644", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// CaptureOutputToFile opens a filehandle using the given path, then calls // CaptureOutputToFd on the associated filehandle.
[ "CaptureOutputToFile", "opens", "a", "filehandle", "using", "the", "given", "path", "then", "calls", "CaptureOutputToFd", "on", "the", "associated", "filehandle", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/capture.go#L25-L32
138,998
spacemonkeygo/spacelog
capture.go
CaptureOutputToProcess
func CaptureOutputToProcess(command string, args ...string) error { cmd := exec.Command(command, args...) out, err := cmd.StdinPipe() if err != nil { return err } defer out.Close() type fder interface { Fd() uintptr } out_fder, ok := out.(fder) if !ok { return fmt.Errorf("unable to get underlying pipe") ...
go
func CaptureOutputToProcess(command string, args ...string) error { cmd := exec.Command(command, args...) out, err := cmd.StdinPipe() if err != nil { return err } defer out.Close() type fder interface { Fd() uintptr } out_fder, ok := out.(fder) if !ok { return fmt.Errorf("unable to get underlying pipe") ...
[ "func", "CaptureOutputToProcess", "(", "command", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "command", ",", "args", "...", ")", "\n", "out", ",", "err", ":=", "cmd", ".", "StdinPipe", "(", ")",...
// CaptureOutputToProcess starts a process and using CaptureOutputToFd, // redirects stdout and stderr to the subprocess' stdin. // CaptureOutputToProcess expects the subcommand to last the lifetime of the // process, and if the subprocess dies, will panic.
[ "CaptureOutputToProcess", "starts", "a", "process", "and", "using", "CaptureOutputToFd", "redirects", "stdout", "and", "stderr", "to", "the", "subprocess", "stdin", ".", "CaptureOutputToProcess", "expects", "the", "subcommand", "to", "last", "the", "lifetime", "of", ...
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/capture.go#L38-L67
138,999
spacemonkeygo/spacelog
convenience.go
Trace
func (l *Logger) Trace(v ...interface{}) { if l.getLevel() <= Trace { l.getHandler().Log(l.name, Trace, fmt.Sprint(v...), 1) } }
go
func (l *Logger) Trace(v ...interface{}) { if l.getLevel() <= Trace { l.getHandler().Log(l.name, Trace, fmt.Sprint(v...), 1) } }
[ "func", "(", "l", "*", "Logger", ")", "Trace", "(", "v", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "getLevel", "(", ")", "<=", "Trace", "{", "l", ".", "getHandler", "(", ")", ".", "Log", "(", "l", ".", "name", ",", "Trace", ",",...
// Trace logs a collection of values if the logger's level is trace or even // more permissive.
[ "Trace", "logs", "a", "collection", "of", "values", "if", "the", "logger", "s", "level", "is", "trace", "or", "even", "more", "permissive", "." ]
2296661a0572a51438413369004fa931c2641923
https://github.com/spacemonkeygo/spacelog/blob/2296661a0572a51438413369004fa931c2641923/convenience.go#L24-L28