id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
143,000
ivpusic/golog
logger.go
normalizeName
func (l *Logger) normalizeName() { length := len(l.Name) // name is ok as it is if length == maxnamelen || length == curnamelen { return } // name is too short, add some spaces if length < curnamelen { l.normalizeNameLen() return } // name is too long // do best to normalize it var ( normalized st...
go
func (l *Logger) normalizeName() { length := len(l.Name) // name is ok as it is if length == maxnamelen || length == curnamelen { return } // name is too short, add some spaces if length < curnamelen { l.normalizeNameLen() return } // name is too long // do best to normalize it var ( normalized st...
[ "func", "(", "l", "*", "Logger", ")", "normalizeName", "(", ")", "{", "length", ":=", "len", "(", "l", ".", "Name", ")", "\n\n", "// name is ok as it is", "if", "length", "==", "maxnamelen", "||", "length", "==", "curnamelen", "{", "return", "\n", "}", ...
// method will normalize names if they are too big or too short // normal name length if defined by namelen variable
[ "method", "will", "normalize", "names", "if", "they", "are", "too", "big", "or", "too", "short", "normal", "name", "length", "if", "defined", "by", "namelen", "variable" ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L158-L236
143,001
ivpusic/golog
logger.go
normalizeNameLen
func (l *Logger) normalizeNameLen() { length := len(l.Name) missing := curnamelen - length for i := 0; i < missing; i++ { l.Name += " " } }
go
func (l *Logger) normalizeNameLen() { length := len(l.Name) missing := curnamelen - length for i := 0; i < missing; i++ { l.Name += " " } }
[ "func", "(", "l", "*", "Logger", ")", "normalizeNameLen", "(", ")", "{", "length", ":=", "len", "(", "l", ".", "Name", ")", "\n", "missing", ":=", "curnamelen", "-", "length", "\n", "for", "i", ":=", "0", ";", "i", "<", "missing", ";", "i", "++",...
// if name is still to short we will add spaces
[ "if", "name", "is", "still", "to", "short", "we", "will", "add", "spaces" ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L239-L245
143,002
ivpusic/golog
logger.go
Debug
func (l *Logger) Debug(msg interface{}, data ...interface{}) { if l.shouldAppend(DEBUG) { l.makeLog(msg, DEBUG, data) } }
go
func (l *Logger) Debug(msg interface{}, data ...interface{}) { if l.shouldAppend(DEBUG) { l.makeLog(msg, DEBUG, data) } }
[ "func", "(", "l", "*", "Logger", ")", "Debug", "(", "msg", "interface", "{", "}", ",", "data", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "DEBUG", ")", "{", "l", ".", "makeLog", "(", "msg", ",", "DEBUG", ",", "...
// Making log with DEBUG level.
[ "Making", "log", "with", "DEBUG", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L248-L252
143,003
ivpusic/golog
logger.go
Info
func (l *Logger) Info(msg interface{}, data ...interface{}) { if l.shouldAppend(INFO) { l.makeLog(msg, INFO, data) } }
go
func (l *Logger) Info(msg interface{}, data ...interface{}) { if l.shouldAppend(INFO) { l.makeLog(msg, INFO, data) } }
[ "func", "(", "l", "*", "Logger", ")", "Info", "(", "msg", "interface", "{", "}", ",", "data", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "INFO", ")", "{", "l", ".", "makeLog", "(", "msg", ",", "INFO", ",", "dat...
// Making log with INFO level.
[ "Making", "log", "with", "INFO", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L255-L259
143,004
ivpusic/golog
logger.go
Warn
func (l *Logger) Warn(msg interface{}, data ...interface{}) { if l.shouldAppend(WARN) { l.makeLog(msg, WARN, data) } }
go
func (l *Logger) Warn(msg interface{}, data ...interface{}) { if l.shouldAppend(WARN) { l.makeLog(msg, WARN, data) } }
[ "func", "(", "l", "*", "Logger", ")", "Warn", "(", "msg", "interface", "{", "}", ",", "data", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "WARN", ")", "{", "l", ".", "makeLog", "(", "msg", ",", "WARN", ",", "dat...
// Making log with WARN level.
[ "Making", "log", "with", "WARN", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L262-L266
143,005
ivpusic/golog
logger.go
Error
func (l *Logger) Error(msg interface{}, data ...interface{}) { if l.shouldAppend(ERROR) { l.makeLog(msg, ERROR, data) } }
go
func (l *Logger) Error(msg interface{}, data ...interface{}) { if l.shouldAppend(ERROR) { l.makeLog(msg, ERROR, data) } }
[ "func", "(", "l", "*", "Logger", ")", "Error", "(", "msg", "interface", "{", "}", ",", "data", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "ERROR", ")", "{", "l", ".", "makeLog", "(", "msg", ",", "ERROR", ",", "...
// Making log with ERROR level.
[ "Making", "log", "with", "ERROR", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L269-L273
143,006
ivpusic/golog
logger.go
Panic
func (l *Logger) Panic(msg interface{}, data ...interface{}) { if l.shouldAppend(PANIC) { l.makeLog(msg, PANIC, data) panic(msg) } }
go
func (l *Logger) Panic(msg interface{}, data ...interface{}) { if l.shouldAppend(PANIC) { l.makeLog(msg, PANIC, data) panic(msg) } }
[ "func", "(", "l", "*", "Logger", ")", "Panic", "(", "msg", "interface", "{", "}", ",", "data", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "PANIC", ")", "{", "l", ".", "makeLog", "(", "msg", ",", "PANIC", ",", "...
// Making log with PANIC level.
[ "Making", "log", "with", "PANIC", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L276-L281
143,007
ivpusic/golog
logger.go
Debugf
func (l *Logger) Debugf(msg string, params ...interface{}) { if l.shouldAppend(DEBUG) { l.makeLog(fmt.Sprintf(msg, params...), DEBUG, nil) } }
go
func (l *Logger) Debugf(msg string, params ...interface{}) { if l.shouldAppend(DEBUG) { l.makeLog(fmt.Sprintf(msg, params...), DEBUG, nil) } }
[ "func", "(", "l", "*", "Logger", ")", "Debugf", "(", "msg", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "DEBUG", ")", "{", "l", ".", "makeLog", "(", "fmt", ".", "Sprintf", "(", "msg", ",",...
// Making formatted log with DEBUG level.
[ "Making", "formatted", "log", "with", "DEBUG", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L284-L288
143,008
ivpusic/golog
logger.go
Infof
func (l *Logger) Infof(msg string, params ...interface{}) { if l.shouldAppend(INFO) { l.makeLog(fmt.Sprintf(msg, params...), INFO, nil) } }
go
func (l *Logger) Infof(msg string, params ...interface{}) { if l.shouldAppend(INFO) { l.makeLog(fmt.Sprintf(msg, params...), INFO, nil) } }
[ "func", "(", "l", "*", "Logger", ")", "Infof", "(", "msg", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "INFO", ")", "{", "l", ".", "makeLog", "(", "fmt", ".", "Sprintf", "(", "msg", ",", ...
// Making formatted log with INFO level.
[ "Making", "formatted", "log", "with", "INFO", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L291-L295
143,009
ivpusic/golog
logger.go
Warnf
func (l *Logger) Warnf(msg string, params ...interface{}) { if l.shouldAppend(WARN) { l.makeLog(fmt.Sprintf(msg, params...), WARN, nil) } }
go
func (l *Logger) Warnf(msg string, params ...interface{}) { if l.shouldAppend(WARN) { l.makeLog(fmt.Sprintf(msg, params...), WARN, nil) } }
[ "func", "(", "l", "*", "Logger", ")", "Warnf", "(", "msg", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "WARN", ")", "{", "l", ".", "makeLog", "(", "fmt", ".", "Sprintf", "(", "msg", ",", ...
// Making formatted log with WARN level.
[ "Making", "formatted", "log", "with", "WARN", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L298-L302
143,010
ivpusic/golog
logger.go
Errorf
func (l *Logger) Errorf(msg string, params ...interface{}) { if l.shouldAppend(ERROR) { l.makeLog(fmt.Sprintf(msg, params...), ERROR, nil) } }
go
func (l *Logger) Errorf(msg string, params ...interface{}) { if l.shouldAppend(ERROR) { l.makeLog(fmt.Sprintf(msg, params...), ERROR, nil) } }
[ "func", "(", "l", "*", "Logger", ")", "Errorf", "(", "msg", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "ERROR", ")", "{", "l", ".", "makeLog", "(", "fmt", ".", "Sprintf", "(", "msg", ",",...
// Making formatted log with ERROR level.
[ "Making", "formatted", "log", "with", "ERROR", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L305-L309
143,011
ivpusic/golog
logger.go
Panicf
func (l *Logger) Panicf(msg string, params ...interface{}) { if l.shouldAppend(PANIC) { l.makeLog(fmt.Sprintf(msg, params...), PANIC, nil) panic(msg) } }
go
func (l *Logger) Panicf(msg string, params ...interface{}) { if l.shouldAppend(PANIC) { l.makeLog(fmt.Sprintf(msg, params...), PANIC, nil) panic(msg) } }
[ "func", "(", "l", "*", "Logger", ")", "Panicf", "(", "msg", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "shouldAppend", "(", "PANIC", ")", "{", "l", ".", "makeLog", "(", "fmt", ".", "Sprintf", "(", "msg", ",",...
// Making formatted log with PANIC level.
[ "Making", "formatted", "log", "with", "PANIC", "level", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L312-L317
143,012
ivpusic/golog
logger.go
Enable
func (l *Logger) Enable(appender Appender) { l.appenders = append(l.appenders, appender) }
go
func (l *Logger) Enable(appender Appender) { l.appenders = append(l.appenders, appender) }
[ "func", "(", "l", "*", "Logger", ")", "Enable", "(", "appender", "Appender", ")", "{", "l", ".", "appenders", "=", "append", "(", "l", ".", "appenders", ",", "appender", ")", "\n", "}" ]
// When you want to send logs to another appender, // you should create instance of appender and call this method. // Method is expecting appender instance to be passed // to this method. At the end passed appender will receive logs
[ "When", "you", "want", "to", "send", "logs", "to", "another", "appender", "you", "should", "create", "instance", "of", "appender", "and", "call", "this", "method", ".", "Method", "is", "expecting", "appender", "instance", "to", "be", "passed", "to", "this", ...
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L323-L325
143,013
ivpusic/golog
logger.go
Disable
func (l *Logger) Disable(target interface{}) { var id string var appender Appender switch object := target.(type) { case string: id = object case Appender: appender = object default: l.Warn("Error while disabling logger. Cannot cast to target type.") return } for i, app := range l.appenders { // if ...
go
func (l *Logger) Disable(target interface{}) { var id string var appender Appender switch object := target.(type) { case string: id = object case Appender: appender = object default: l.Warn("Error while disabling logger. Cannot cast to target type.") return } for i, app := range l.appenders { // if ...
[ "func", "(", "l", "*", "Logger", ")", "Disable", "(", "target", "interface", "{", "}", ")", "{", "var", "id", "string", "\n", "var", "appender", "Appender", "\n\n", "switch", "object", ":=", "target", ".", "(", "type", ")", "{", "case", "string", ":"...
// If you want to disable logs from some appender you can use this method. // You have to call method either with appender instance, // or you can pass appender Id as argument. // If appender is found, it will be removed from list of appenders of this logger, // and all other further logs won't be received by this appe...
[ "If", "you", "want", "to", "disable", "logs", "from", "some", "appender", "you", "can", "use", "this", "method", ".", "You", "have", "to", "call", "method", "either", "with", "appender", "instance", "or", "you", "can", "pass", "appender", "Id", "as", "ar...
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L332-L361
143,014
ivpusic/golog
logger.go
SetContext
func (l *Logger) SetContext(ctx Ctx) *Logger { l.ctx = ctx return l }
go
func (l *Logger) SetContext(ctx Ctx) *Logger { l.ctx = ctx return l }
[ "func", "(", "l", "*", "Logger", ")", "SetContext", "(", "ctx", "Ctx", ")", "*", "Logger", "{", "l", ".", "ctx", "=", "ctx", "\n", "return", "l", "\n", "}" ]
// Will set context to current logger. // Later appenders will be able to extract context from Log instance.
[ "Will", "set", "context", "to", "current", "logger", ".", "Later", "appenders", "will", "be", "able", "to", "extract", "context", "from", "Log", "instance", "." ]
28640bee649fa9f065ca537ae68d244fd79845d4
https://github.com/ivpusic/golog/blob/28640bee649fa9f065ca537ae68d244fd79845d4/logger.go#L365-L368
143,015
maraino/go-mock
mock.go
Verify
func (m *Mock) Verify() (bool, error) { for i, f := range m.Functions { switch f.countCheck { case TIMES: if f.count != f.times[1] { return false, fmt.Errorf("Function #%d %s executed %d times, expected: %d", i+1, f.Name, f.count, f.times[1]) } case AT_LEAST: if f.count < f.times[1] { return fal...
go
func (m *Mock) Verify() (bool, error) { for i, f := range m.Functions { switch f.countCheck { case TIMES: if f.count != f.times[1] { return false, fmt.Errorf("Function #%d %s executed %d times, expected: %d", i+1, f.Name, f.count, f.times[1]) } case AT_LEAST: if f.count < f.times[1] { return fal...
[ "func", "(", "m", "*", "Mock", ")", "Verify", "(", ")", "(", "bool", ",", "error", ")", "{", "for", "i", ",", "f", ":=", "range", "m", ".", "Functions", "{", "switch", "f", ".", "countCheck", "{", "case", "TIMES", ":", "if", "f", ".", "count", ...
// Verify verifies the restrictions set in the stubbing.
[ "Verify", "verifies", "the", "restrictions", "set", "in", "the", "stubbing", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L183-L205
143,016
maraino/go-mock
mock.go
VerifyMocks
func VerifyMocks(mocks ...HasVerify) (bool, error) { for _, m := range mocks { if ok, err := m.Verify(); !ok { return ok, err } } return true, nil }
go
func VerifyMocks(mocks ...HasVerify) (bool, error) { for _, m := range mocks { if ok, err := m.Verify(); !ok { return ok, err } } return true, nil }
[ "func", "VerifyMocks", "(", "mocks", "...", "HasVerify", ")", "(", "bool", ",", "error", ")", "{", "for", "_", ",", "m", ":=", "range", "mocks", "{", "if", "ok", ",", "err", ":=", "m", ".", "Verify", "(", ")", ";", "!", "ok", "{", "return", "ok...
// VerifyMocks verifies a list of mocks, and returns the first error, if any.
[ "VerifyMocks", "verifies", "a", "list", "of", "mocks", "and", "returns", "the", "first", "error", "if", "any", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L213-L220
143,017
maraino/go-mock
mock.go
AssertVerifyMocks
func AssertVerifyMocks(t HasError, mocks ...HasVerify) { if ok, err := VerifyMocks(mocks...); !ok { t.Error(err) } }
go
func AssertVerifyMocks(t HasError, mocks ...HasVerify) { if ok, err := VerifyMocks(mocks...); !ok { t.Error(err) } }
[ "func", "AssertVerifyMocks", "(", "t", "HasError", ",", "mocks", "...", "HasVerify", ")", "{", "if", "ok", ",", "err", ":=", "VerifyMocks", "(", "mocks", "...", ")", ";", "!", "ok", "{", "t", ".", "Error", "(", "err", ")", "\n", "}", "\n", "}" ]
// Fail the test if any of the mocks fail verification
[ "Fail", "the", "test", "if", "any", "of", "the", "mocks", "fail", "verification" ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L229-L233
143,018
maraino/go-mock
mock.go
Reset
func (m *Mock) Reset() *Mock { defer m.mutex.Unlock() m.mutex.Lock() m.Functions = nil m.order = 0 return m }
go
func (m *Mock) Reset() *Mock { defer m.mutex.Unlock() m.mutex.Lock() m.Functions = nil m.order = 0 return m }
[ "func", "(", "m", "*", "Mock", ")", "Reset", "(", ")", "*", "Mock", "{", "defer", "m", ".", "mutex", ".", "Unlock", "(", ")", "\n", "m", ".", "mutex", ".", "Lock", "(", ")", "\n\n", "m", ".", "Functions", "=", "nil", "\n", "m", ".", "order", ...
// Reset removes all stubs defined.
[ "Reset", "removes", "all", "stubs", "defined", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L236-L243
143,019
maraino/go-mock
mock.go
Timeout
func (f *MockFunction) Timeout(d time.Duration) *MockFunction { f.timeout = d return f }
go
func (f *MockFunction) Timeout(d time.Duration) *MockFunction { f.timeout = d return f }
[ "func", "(", "f", "*", "MockFunction", ")", "Timeout", "(", "d", "time", ".", "Duration", ")", "*", "MockFunction", "{", "f", ".", "timeout", "=", "d", "\n", "return", "f", "\n", "}" ]
// Timeout defines a timeout to sleep before returning the value of a function.
[ "Timeout", "defines", "a", "timeout", "to", "sleep", "before", "returning", "the", "value", "of", "a", "function", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L481-L484
143,020
maraino/go-mock
mock.go
isMaxCountCheck
func (f *MockFunction) isMaxCountCheck() bool { switch f.countCheck { case TIMES: if f.count >= f.times[1] { return true } case AT_LEAST: // At least does not have a maximum return false case AT_MOST: if f.count >= f.times[1] { return true } case BETWEEN: if f.count >= f.times[1] { return tr...
go
func (f *MockFunction) isMaxCountCheck() bool { switch f.countCheck { case TIMES: if f.count >= f.times[1] { return true } case AT_LEAST: // At least does not have a maximum return false case AT_MOST: if f.count >= f.times[1] { return true } case BETWEEN: if f.count >= f.times[1] { return tr...
[ "func", "(", "f", "*", "MockFunction", ")", "isMaxCountCheck", "(", ")", "bool", "{", "switch", "f", ".", "countCheck", "{", "case", "TIMES", ":", "if", "f", ".", "count", ">=", "f", ".", "times", "[", "1", "]", "{", "return", "true", "\n", "}", ...
// Check if the number of times that a function has been called // has reach the top range.
[ "Check", "if", "the", "number", "of", "times", "that", "a", "function", "has", "been", "called", "has", "reach", "the", "top", "range", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L502-L522
143,021
maraino/go-mock
mock.go
Contains
func (r *MockResult) Contains(i int) bool { if len(r.Result) > i { return true } else { return false } }
go
func (r *MockResult) Contains(i int) bool { if len(r.Result) > i { return true } else { return false } }
[ "func", "(", "r", "*", "MockResult", ")", "Contains", "(", "i", "int", ")", "bool", "{", "if", "len", "(", "r", ".", "Result", ")", ">", "i", "{", "return", "true", "\n", "}", "else", "{", "return", "false", "\n", "}", "\n", "}" ]
// Contains returns true if the results have the index i, false otherwise.
[ "Contains", "returns", "true", "if", "the", "results", "have", "the", "index", "i", "false", "otherwise", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L525-L531
143,022
maraino/go-mock
mock.go
Get
func (r *MockResult) Get(i int) interface{} { if r.Contains(i) { return r.Result[i] } else { return nil } }
go
func (r *MockResult) Get(i int) interface{} { if r.Contains(i) { return r.Result[i] } else { return nil } }
[ "func", "(", "r", "*", "MockResult", ")", "Get", "(", "i", "int", ")", "interface", "{", "}", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", "\n", "}", "else", "{", "return", "nil", "\n", "}"...
// Get returns a specific return parameter. // If a result has not been set, it returns nil,
[ "Get", "returns", "a", "specific", "return", "parameter", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "nil" ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L535-L541
143,023
maraino/go-mock
mock.go
GetType
func (r *MockResult) GetType(i int, ii interface{}) interface{} { t := reflect.TypeOf(ii) if t == nil { panic(fmt.Sprintf("Could not get type information for %#v", ii)) } v := reflect.New(t).Elem() if r.Contains(i) { if r.Result[i] != nil { v.Set(reflect.ValueOf(r.Result[i])) } } return v.Interface() }
go
func (r *MockResult) GetType(i int, ii interface{}) interface{} { t := reflect.TypeOf(ii) if t == nil { panic(fmt.Sprintf("Could not get type information for %#v", ii)) } v := reflect.New(t).Elem() if r.Contains(i) { if r.Result[i] != nil { v.Set(reflect.ValueOf(r.Result[i])) } } return v.Interface() }
[ "func", "(", "r", "*", "MockResult", ")", "GetType", "(", "i", "int", ",", "ii", "interface", "{", "}", ")", "interface", "{", "}", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "ii", ")", "\n", "if", "t", "==", "nil", "{", "panic", "(", "fmt"...
// GetType returns a specific return parameter with the same type of // the second argument. A nil version of the type can be casted // without causing a panic.
[ "GetType", "returns", "a", "specific", "return", "parameter", "with", "the", "same", "type", "of", "the", "second", "argument", ".", "A", "nil", "version", "of", "the", "type", "can", "be", "casted", "without", "causing", "a", "panic", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L546-L558
143,024
maraino/go-mock
mock.go
Bool
func (r *MockResult) Bool(i int) bool { if r.Contains(i) { return r.Result[i].(bool) } else { return false } }
go
func (r *MockResult) Bool(i int) bool { if r.Contains(i) { return r.Result[i].(bool) } else { return false } }
[ "func", "(", "r", "*", "MockResult", ")", "Bool", "(", "i", "int", ")", "bool", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "bool", ")", "\n", "}", "else", "{", "return", "false"...
// Bool returns a specific return parameter as a bool. // If a result has not been set, it returns false.
[ "Bool", "returns", "a", "specific", "return", "parameter", "as", "a", "bool", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "false", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L562-L568
143,025
maraino/go-mock
mock.go
Byte
func (r *MockResult) Byte(i int) byte { if r.Contains(i) { return r.Result[i].(byte) } else { return 0 } }
go
func (r *MockResult) Byte(i int) byte { if r.Contains(i) { return r.Result[i].(byte) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Byte", "(", "i", "int", ")", "byte", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "byte", ")", "\n", "}", "else", "{", "return", "0", ...
// Byte returns a specific return parameter as a byte. // If a result has not been set, it returns 0.
[ "Byte", "returns", "a", "specific", "return", "parameter", "as", "a", "byte", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L572-L578
143,026
maraino/go-mock
mock.go
Error
func (r *MockResult) Error(i int) error { if r.Contains(i) && r.Result[i] != nil { return r.Result[i].(error) } else { return nil } }
go
func (r *MockResult) Error(i int) error { if r.Contains(i) && r.Result[i] != nil { return r.Result[i].(error) } else { return nil } }
[ "func", "(", "r", "*", "MockResult", ")", "Error", "(", "i", "int", ")", "error", "{", "if", "r", ".", "Contains", "(", "i", ")", "&&", "r", ".", "Result", "[", "i", "]", "!=", "nil", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "...
// Error returns a specific return parameter as an error. // If a result has not been set, it returns nil.
[ "Error", "returns", "a", "specific", "return", "parameter", "as", "an", "error", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "nil", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L596-L602
143,027
maraino/go-mock
mock.go
Float32
func (r *MockResult) Float32(i int) float32 { if r.Contains(i) { return r.Result[i].(float32) } else { return 0 } }
go
func (r *MockResult) Float32(i int) float32 { if r.Contains(i) { return r.Result[i].(float32) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Float32", "(", "i", "int", ")", "float32", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "float32", ")", "\n", "}", "else", "{", "return", ...
// Float32 returns a specific return parameter as a float32. // If a result has not been set, it returns 0.
[ "Float32", "returns", "a", "specific", "return", "parameter", "as", "a", "float32", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L606-L612
143,028
maraino/go-mock
mock.go
Float64
func (r *MockResult) Float64(i int) float64 { if r.Contains(i) { return r.Result[i].(float64) } else { return 0 } }
go
func (r *MockResult) Float64(i int) float64 { if r.Contains(i) { return r.Result[i].(float64) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Float64", "(", "i", "int", ")", "float64", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "float64", ")", "\n", "}", "else", "{", "return", ...
// Float64 returns a specific return parameter as a float64. // If a result has not been set, it returns 0.
[ "Float64", "returns", "a", "specific", "return", "parameter", "as", "a", "float64", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L616-L622
143,029
maraino/go-mock
mock.go
Int
func (r *MockResult) Int(i int) int { if r.Contains(i) { return r.Result[i].(int) } else { return 0 } }
go
func (r *MockResult) Int(i int) int { if r.Contains(i) { return r.Result[i].(int) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Int", "(", "i", "int", ")", "int", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "int", ")", "\n", "}", "else", "{", "return", "0", "\n...
// Int returns a specific return parameter as an int. // If a result has not been set, it returns 0.
[ "Int", "returns", "a", "specific", "return", "parameter", "as", "an", "int", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L626-L632
143,030
maraino/go-mock
mock.go
Int8
func (r *MockResult) Int8(i int) int8 { if r.Contains(i) { return r.Result[i].(int8) } else { return 0 } }
go
func (r *MockResult) Int8(i int) int8 { if r.Contains(i) { return r.Result[i].(int8) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Int8", "(", "i", "int", ")", "int8", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "int8", ")", "\n", "}", "else", "{", "return", "0", ...
// Int8 returns a specific return parameter as an int8. // If a result has not been set, it returns 0.
[ "Int8", "returns", "a", "specific", "return", "parameter", "as", "an", "int8", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L636-L642
143,031
maraino/go-mock
mock.go
Int16
func (r *MockResult) Int16(i int) int16 { if r.Contains(i) { return r.Result[i].(int16) } else { return 0 } }
go
func (r *MockResult) Int16(i int) int16 { if r.Contains(i) { return r.Result[i].(int16) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Int16", "(", "i", "int", ")", "int16", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "int16", ")", "\n", "}", "else", "{", "return", "0",...
// Int16 returns a specific return parameter as an int16. // If a result has not been set, it returns 0.
[ "Int16", "returns", "a", "specific", "return", "parameter", "as", "an", "int16", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L646-L652
143,032
maraino/go-mock
mock.go
Int32
func (r *MockResult) Int32(i int) int32 { if r.Contains(i) { return r.Result[i].(int32) } else { return 0 } }
go
func (r *MockResult) Int32(i int) int32 { if r.Contains(i) { return r.Result[i].(int32) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Int32", "(", "i", "int", ")", "int32", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "int32", ")", "\n", "}", "else", "{", "return", "0",...
// Int32 returns a specific return parameter as an int32. // If a result has not been set, it returns 0.
[ "Int32", "returns", "a", "specific", "return", "parameter", "as", "an", "int32", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L656-L662
143,033
maraino/go-mock
mock.go
Int64
func (r *MockResult) Int64(i int) int64 { if r.Contains(i) { return r.Result[i].(int64) } else { return 0 } }
go
func (r *MockResult) Int64(i int) int64 { if r.Contains(i) { return r.Result[i].(int64) } else { return 0 } }
[ "func", "(", "r", "*", "MockResult", ")", "Int64", "(", "i", "int", ")", "int64", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "int64", ")", "\n", "}", "else", "{", "return", "0",...
// Int64 returns a specific return parameter as an int64. // If a result has not been set, it returns 0.
[ "Int64", "returns", "a", "specific", "return", "parameter", "as", "an", "int64", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "0", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L666-L672
143,034
maraino/go-mock
mock.go
String
func (r *MockResult) String(i int) string { if r.Contains(i) { return r.Result[i].(string) } else { return "" } }
go
func (r *MockResult) String(i int) string { if r.Contains(i) { return r.Result[i].(string) } else { return "" } }
[ "func", "(", "r", "*", "MockResult", ")", "String", "(", "i", "int", ")", "string", "{", "if", "r", ".", "Contains", "(", "i", ")", "{", "return", "r", ".", "Result", "[", "i", "]", ".", "(", "string", ")", "\n", "}", "else", "{", "return", "...
// String returns a specific return parameter as a string. // If a result has not been set, it returns "".
[ "String", "returns", "a", "specific", "return", "parameter", "as", "a", "string", ".", "If", "a", "result", "has", "not", "been", "set", "it", "returns", "." ]
4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f
https://github.com/maraino/go-mock/blob/4c74c434cd3a9e9a70ed1eeb56646a1d3fac372f/mock.go#L676-L682
143,035
InVisionApp/go-logger
shims/logrus/logrus.go
New
func New(logger *logrus.Logger) log.Logger { if logger == nil { logger = logrus.StandardLogger() } return &shim{logrus.NewEntry(logger)} }
go
func New(logger *logrus.Logger) log.Logger { if logger == nil { logger = logrus.StandardLogger() } return &shim{logrus.NewEntry(logger)} }
[ "func", "New", "(", "logger", "*", "logrus", ".", "Logger", ")", "log", ".", "Logger", "{", "if", "logger", "==", "nil", "{", "logger", "=", "logrus", ".", "StandardLogger", "(", ")", "\n", "}", "\n\n", "return", "&", "shim", "{", "logrus", ".", "N...
// NewLogrus can be used to override the default logger. // Optionally pass in an existing logrus logger or pass in // `nil` to use the default logger.
[ "NewLogrus", "can", "be", "used", "to", "override", "the", "default", "logger", ".", "Optionally", "pass", "in", "an", "existing", "logrus", "logger", "or", "pass", "in", "nil", "to", "use", "the", "default", "logger", "." ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/shims/logrus/logrus.go#L15-L21
143,036
peterhellberg/link
link.go
ParseHeader
func ParseHeader(h http.Header) Group { if headers, found := h["Link"]; found { return Parse(strings.Join(headers, ", ")) } return nil }
go
func ParseHeader(h http.Header) Group { if headers, found := h["Link"]; found { return Parse(strings.Join(headers, ", ")) } return nil }
[ "func", "ParseHeader", "(", "h", "http", ".", "Header", ")", "Group", "{", "if", "headers", ",", "found", ":=", "h", "[", "\"", "\"", "]", ";", "found", "{", "return", "Parse", "(", "strings", ".", "Join", "(", "headers", ",", "\"", "\"", ")", ")...
// ParseHeader retrieves the Link header from the provided http.Header and parses it into a Group
[ "ParseHeader", "retrieves", "the", "Link", "header", "from", "the", "provided", "http", ".", "Header", "and", "parses", "it", "into", "a", "Group" ]
9b91929be50d62b6748357e9cf8359d7a948abd5
https://github.com/peterhellberg/link/blob/9b91929be50d62b6748357e9cf8359d7a948abd5/link.go#L53-L59
143,037
peterhellberg/link
link.go
Parse
func Parse(s string) Group { if s == "" { return nil } s = valueCommaRegexp.ReplaceAllString(s, "$1") group := Group{} for _, l := range commaRegexp.Split(s, -1) { linkMatches := linkRegexp.FindAllStringSubmatch(l, -1) if len(linkMatches) == 0 { return nil } pieces := linkMatches[0] link := &L...
go
func Parse(s string) Group { if s == "" { return nil } s = valueCommaRegexp.ReplaceAllString(s, "$1") group := Group{} for _, l := range commaRegexp.Split(s, -1) { linkMatches := linkRegexp.FindAllStringSubmatch(l, -1) if len(linkMatches) == 0 { return nil } pieces := linkMatches[0] link := &L...
[ "func", "Parse", "(", "s", "string", ")", "Group", "{", "if", "s", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "s", "=", "valueCommaRegexp", ".", "ReplaceAllString", "(", "s", ",", "\"", "\"", ")", "\n\n", "group", ":=", "Group", "{"...
// Parse parses the provided string into a Group
[ "Parse", "parses", "the", "provided", "string", "into", "a", "Group" ]
9b91929be50d62b6748357e9cf8359d7a948abd5
https://github.com/peterhellberg/link/blob/9b91929be50d62b6748357e9cf8359d7a948abd5/link.go#L62-L111
143,038
InVisionApp/go-logger
shims/zerolog/zerolog.go
New
func New(logger *zerolog.Logger) log.Logger { if logger == nil { lg := zerolog.New(os.Stdout).With().Timestamp().Logger() logger = &lg } return &shim{logger: logger} }
go
func New(logger *zerolog.Logger) log.Logger { if logger == nil { lg := zerolog.New(os.Stdout).With().Timestamp().Logger() logger = &lg } return &shim{logger: logger} }
[ "func", "New", "(", "logger", "*", "zerolog", ".", "Logger", ")", "log", ".", "Logger", "{", "if", "logger", "==", "nil", "{", "lg", ":=", "zerolog", ".", "New", "(", "os", ".", "Stdout", ")", ".", "With", "(", ")", ".", "Timestamp", "(", ")", ...
// New can be used to override the default logger. // Optionally pass in an existing zerolog logger or // pass in `nil` to use the default logger
[ "New", "can", "be", "used", "to", "override", "the", "default", "logger", ".", "Optionally", "pass", "in", "an", "existing", "zerolog", "logger", "or", "pass", "in", "nil", "to", "use", "the", "default", "logger" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/shims/zerolog/zerolog.go#L18-L25
143,039
InVisionApp/go-logger
shims/zerolog/zerolog.go
spaceSep
func spaceSep(a []interface{}) []interface{} { aLen := len(a) if aLen <= 1 { return a } // we only allocate enough room to add a single space between // all elements, so len(a) - 1 spaceSlice := make([]interface{}, aLen-1) // add the empty space to the end of the original slice a = append(a, spaceSlice...) ...
go
func spaceSep(a []interface{}) []interface{} { aLen := len(a) if aLen <= 1 { return a } // we only allocate enough room to add a single space between // all elements, so len(a) - 1 spaceSlice := make([]interface{}, aLen-1) // add the empty space to the end of the original slice a = append(a, spaceSlice...) ...
[ "func", "spaceSep", "(", "a", "[", "]", "interface", "{", "}", ")", "[", "]", "interface", "{", "}", "{", "aLen", ":=", "len", "(", "a", ")", "\n", "if", "aLen", "<=", "1", "{", "return", "a", "\n", "}", "\n\n", "// we only allocate enough room to ad...
// this will add a space between all elements in the slice // this func is needed because fmt.Sprint will not separate // inputs by a space in all cases, which makes the resulting // output very hard to read
[ "this", "will", "add", "a", "space", "between", "all", "elements", "in", "the", "slice", "this", "func", "is", "needed", "because", "fmt", ".", "Sprint", "will", "not", "separate", "inputs", "by", "a", "space", "in", "all", "cases", "which", "makes", "th...
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/shims/zerolog/zerolog.go#L31-L51
143,040
InVisionApp/go-logger
shims/zerolog/zerolog.go
WithFields
func (s *shim) WithFields(fields log.Fields) log.Logger { lg := s.logger.With().Fields(fields).Logger() s.logger = &lg return s }
go
func (s *shim) WithFields(fields log.Fields) log.Logger { lg := s.logger.With().Fields(fields).Logger() s.logger = &lg return s }
[ "func", "(", "s", "*", "shim", ")", "WithFields", "(", "fields", "log", ".", "Fields", ")", "log", ".", "Logger", "{", "lg", ":=", "s", ".", "logger", ".", "With", "(", ")", ".", "Fields", "(", "fields", ")", ".", "Logger", "(", ")", "\n", "s",...
// WithFields will return a new logger derived from the original // zerolog logger, with the provided fields added to the log string, // as a key-value pair
[ "WithFields", "will", "return", "a", "new", "logger", "derived", "from", "the", "original", "zerolog", "logger", "with", "the", "provided", "fields", "added", "to", "the", "log", "string", "as", "a", "key", "-", "value", "pair" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/shims/zerolog/zerolog.go#L117-L122
143,041
InVisionApp/go-logger
log.go
WithFields
func (b *simple) WithFields(fields Fields) Logger { cp := &simple{} if b.fields == nil { cp.fields = fields return cp } cp.fields = make(map[string]interface{}, len(b.fields)+len(fields)) for k, v := range b.fields { cp.fields[k] = v } for k, v := range fields { cp.fields[k] = v } return cp }
go
func (b *simple) WithFields(fields Fields) Logger { cp := &simple{} if b.fields == nil { cp.fields = fields return cp } cp.fields = make(map[string]interface{}, len(b.fields)+len(fields)) for k, v := range b.fields { cp.fields[k] = v } for k, v := range fields { cp.fields[k] = v } return cp }
[ "func", "(", "b", "*", "simple", ")", "WithFields", "(", "fields", "Fields", ")", "Logger", "{", "cp", ":=", "&", "simple", "{", "}", "\n\n", "if", "b", ".", "fields", "==", "nil", "{", "cp", ".", "fields", "=", "fields", "\n", "return", "cp", "\...
// WithFields will return a new logger based on the original logger // with the additional supplied fields
[ "WithFields", "will", "return", "a", "new", "logger", "based", "on", "the", "original", "logger", "with", "the", "additional", "supplied", "fields" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/log.go#L54-L72
143,042
InVisionApp/go-logger
log.go
Debug
func (b *simple) Debug(msg ...interface{}) { stdlog.Printf("[DEBUG] %s %s", fmt.Sprint(msg...), pretty(b.fields)) }
go
func (b *simple) Debug(msg ...interface{}) { stdlog.Printf("[DEBUG] %s %s", fmt.Sprint(msg...), pretty(b.fields)) }
[ "func", "(", "b", "*", "simple", ")", "Debug", "(", "msg", "...", "interface", "{", "}", ")", "{", "stdlog", ".", "Printf", "(", "\"", "\"", ",", "fmt", ".", "Sprint", "(", "msg", "...", ")", ",", "pretty", "(", "b", ".", "fields", ")", ")", ...
// Debug log message
[ "Debug", "log", "message" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/log.go#L75-L77
143,043
InVisionApp/go-logger
log.go
Debugln
func (b *simple) Debugln(msg ...interface{}) { a := fmt.Sprintln(msg...) stdlog.Println("[DEBUG]", a[:len(a)-1], pretty(b.fields)) }
go
func (b *simple) Debugln(msg ...interface{}) { a := fmt.Sprintln(msg...) stdlog.Println("[DEBUG]", a[:len(a)-1], pretty(b.fields)) }
[ "func", "(", "b", "*", "simple", ")", "Debugln", "(", "msg", "...", "interface", "{", "}", ")", "{", "a", ":=", "fmt", ".", "Sprintln", "(", "msg", "...", ")", "\n", "stdlog", ".", "Println", "(", "\"", "\"", ",", "a", "[", ":", "len", "(", "...
// Debugln log line message
[ "Debugln", "log", "line", "message" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/log.go#L95-L98
143,044
InVisionApp/go-logger
log.go
Debugf
func (b *simple) Debugf(format string, args ...interface{}) { stdlog.Print(fmt.Sprintf("[DEBUG] "+format, args...), " ", pretty(b.fields)) }
go
func (b *simple) Debugf(format string, args ...interface{}) { stdlog.Print(fmt.Sprintf("[DEBUG] "+format, args...), " ", pretty(b.fields)) }
[ "func", "(", "b", "*", "simple", ")", "Debugf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "stdlog", ".", "Print", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "format", ",", "args", "...", ")", ",", "\"", ...
// Debugf log message with formatting
[ "Debugf", "log", "message", "with", "formatting" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/log.go#L119-L121
143,045
InVisionApp/go-logger
log.go
pretty
func pretty(m map[string]interface{}) string { if len(m) < 1 { return "" } s := "" for k, v := range m { s += fmt.Sprintf("%s=%v ", k, v) } return s[:len(s)-1] }
go
func pretty(m map[string]interface{}) string { if len(m) < 1 { return "" } s := "" for k, v := range m { s += fmt.Sprintf("%s=%v ", k, v) } return s[:len(s)-1] }
[ "func", "pretty", "(", "m", "map", "[", "string", "]", "interface", "{", "}", ")", "string", "{", "if", "len", "(", "m", ")", "<", "1", "{", "return", "\"", "\"", "\n", "}", "\n\n", "s", ":=", "\"", "\"", "\n", "for", "k", ",", "v", ":=", "...
// helper for pretty printing of fields
[ "helper", "for", "pretty", "printing", "of", "fields" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/log.go#L139-L150
143,046
InVisionApp/go-logger
shims/kitlog/kitlog.go
New
func New(logger kitlog.Logger) log.Logger { if logger == nil { logger = kitlog.NewLogfmtLogger(kitlog.NewSyncWriter(os.Stdout)) } return &shim{logger: logger} }
go
func New(logger kitlog.Logger) log.Logger { if logger == nil { logger = kitlog.NewLogfmtLogger(kitlog.NewSyncWriter(os.Stdout)) } return &shim{logger: logger} }
[ "func", "New", "(", "logger", "kitlog", ".", "Logger", ")", "log", ".", "Logger", "{", "if", "logger", "==", "nil", "{", "logger", "=", "kitlog", ".", "NewLogfmtLogger", "(", "kitlog", ".", "NewSyncWriter", "(", "os", ".", "Stdout", ")", ")", "\n", "...
// New can be used to override the default logger. // Optionally pass in an existing kitlog logger or // pass in `nil` to use the default logger.
[ "New", "can", "be", "used", "to", "override", "the", "default", "logger", ".", "Optionally", "pass", "in", "an", "existing", "kitlog", "logger", "or", "pass", "in", "nil", "to", "use", "the", "default", "logger", "." ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/shims/kitlog/kitlog.go#L19-L25
143,047
InVisionApp/go-logger
shims/kitlog/kitlog.go
WithFields
func (s *shim) WithFields(fields log.Fields) log.Logger { var keyvals []interface{} for key, value := range fields { keyvals = append(keyvals, key, value) } return &shim{ logger: kitlog.With(s.logger, keyvals...), } }
go
func (s *shim) WithFields(fields log.Fields) log.Logger { var keyvals []interface{} for key, value := range fields { keyvals = append(keyvals, key, value) } return &shim{ logger: kitlog.With(s.logger, keyvals...), } }
[ "func", "(", "s", "*", "shim", ")", "WithFields", "(", "fields", "log", ".", "Fields", ")", "log", ".", "Logger", "{", "var", "keyvals", "[", "]", "interface", "{", "}", "\n\n", "for", "key", ",", "value", ":=", "range", "fields", "{", "keyvals", "...
// WithFields will return a new logger derived from the original // kitlog logger, with the provided fields added to the log string, // as a key-value pair
[ "WithFields", "will", "return", "a", "new", "logger", "derived", "from", "the", "original", "kitlog", "logger", "with", "the", "provided", "fields", "added", "to", "the", "log", "string", "as", "a", "key", "-", "value", "pair" ]
753dc5832ddec755df724992c1c3b0f7a288e0aa
https://github.com/InVisionApp/go-logger/blob/753dc5832ddec755df724992c1c3b0f7a288e0aa/shims/kitlog/kitlog.go#L104-L114
143,048
jacobsa/oglematchers
has_substr.go
HasSubstr
func HasSubstr(s string) Matcher { return NewMatcher( func(c interface{}) error { return hasSubstr(s, c) }, fmt.Sprintf("has substring \"%s\"", s)) }
go
func HasSubstr(s string) Matcher { return NewMatcher( func(c interface{}) error { return hasSubstr(s, c) }, fmt.Sprintf("has substring \"%s\"", s)) }
[ "func", "HasSubstr", "(", "s", "string", ")", "Matcher", "{", "return", "NewMatcher", "(", "func", "(", "c", "interface", "{", "}", ")", "error", "{", "return", "hasSubstr", "(", "s", ",", "c", ")", "}", ",", "fmt", ".", "Sprintf", "(", "\"", "\\\"...
// HasSubstr returns a matcher that matches strings containing s as a // substring.
[ "HasSubstr", "returns", "a", "matcher", "that", "matches", "strings", "containing", "s", "as", "a", "substring", "." ]
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/has_substr.go#L27-L31
143,049
jacobsa/oglematchers
greater_than.go
GreaterThan
func GreaterThan(x interface{}) Matcher { desc := fmt.Sprintf("greater than %v", x) // Special case: make it clear that strings are strings. if reflect.TypeOf(x).Kind() == reflect.String { desc = fmt.Sprintf("greater than \"%s\"", x) } return transformDescription(Not(LessOrEqual(x)), desc) }
go
func GreaterThan(x interface{}) Matcher { desc := fmt.Sprintf("greater than %v", x) // Special case: make it clear that strings are strings. if reflect.TypeOf(x).Kind() == reflect.String { desc = fmt.Sprintf("greater than \"%s\"", x) } return transformDescription(Not(LessOrEqual(x)), desc) }
[ "func", "GreaterThan", "(", "x", "interface", "{", "}", ")", "Matcher", "{", "desc", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "x", ")", "\n\n", "// Special case: make it clear that strings are strings.", "if", "reflect", ".", "TypeOf", "(", "x", ")...
// GreaterThan returns a matcher that matches integer, floating point, or // strings values v such that v > x. Comparison is not defined between numeric // and string types, but is defined between all integer and floating point // types. // // x must itself be an integer, floating point, or string type; otherwise, // G...
[ "GreaterThan", "returns", "a", "matcher", "that", "matches", "integer", "floating", "point", "or", "strings", "values", "v", "such", "that", "v", ">", "x", ".", "Comparison", "is", "not", "defined", "between", "numeric", "and", "string", "types", "but", "is"...
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/greater_than.go#L30-L39
143,050
jacobsa/oglematchers
less_than.go
LessThan
func LessThan(x interface{}) Matcher { v := reflect.ValueOf(x) kind := v.Kind() switch { case isInteger(v): case isFloat(v): case kind == reflect.String: default: panic(fmt.Sprintf("LessThan: unexpected kind %v", kind)) } return &lessThanMatcher{v} }
go
func LessThan(x interface{}) Matcher { v := reflect.ValueOf(x) kind := v.Kind() switch { case isInteger(v): case isFloat(v): case kind == reflect.String: default: panic(fmt.Sprintf("LessThan: unexpected kind %v", kind)) } return &lessThanMatcher{v} }
[ "func", "LessThan", "(", "x", "interface", "{", "}", ")", "Matcher", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "x", ")", "\n", "kind", ":=", "v", ".", "Kind", "(", ")", "\n\n", "switch", "{", "case", "isInteger", "(", "v", ")", ":", "case",...
// LessThan returns a matcher that matches integer, floating point, or strings // values v such that v < x. Comparison is not defined between numeric and // string types, but is defined between all integer and floating point types. // // x must itself be an integer, floating point, or string type; otherwise, // LessTha...
[ "LessThan", "returns", "a", "matcher", "that", "matches", "integer", "floating", "point", "or", "strings", "values", "v", "such", "that", "v", "<", "x", ".", "Comparison", "is", "not", "defined", "between", "numeric", "and", "string", "types", "but", "is", ...
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/less_than.go#L31-L45
143,051
jacobsa/oglematchers
has_same_type_as.go
HasSameTypeAs
func HasSameTypeAs(p interface{}) Matcher { expected := reflect.TypeOf(p) pred := func(c interface{}) error { actual := reflect.TypeOf(c) if actual != expected { return fmt.Errorf("which has type %v", actual) } return nil } return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) }
go
func HasSameTypeAs(p interface{}) Matcher { expected := reflect.TypeOf(p) pred := func(c interface{}) error { actual := reflect.TypeOf(c) if actual != expected { return fmt.Errorf("which has type %v", actual) } return nil } return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) }
[ "func", "HasSameTypeAs", "(", "p", "interface", "{", "}", ")", "Matcher", "{", "expected", ":=", "reflect", ".", "TypeOf", "(", "p", ")", "\n", "pred", ":=", "func", "(", "c", "interface", "{", "}", ")", "error", "{", "actual", ":=", "reflect", ".", ...
// HasSameTypeAs returns a matcher that matches values with exactly the same // type as the supplied prototype.
[ "HasSameTypeAs", "returns", "a", "matcher", "that", "matches", "values", "with", "exactly", "the", "same", "type", "as", "the", "supplied", "prototype", "." ]
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/has_same_type_as.go#L25-L37
143,052
jacobsa/oglematchers
identical_to.go
isLegalForIdenticalTo
func isLegalForIdenticalTo(t reflect.Type) (bool, error) { // Allow the zero type. if t == nil { return true, nil } // Reference types are always okay; we compare pointers. switch t.Kind() { case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: return true, nil } // Reject other non-comparable type...
go
func isLegalForIdenticalTo(t reflect.Type) (bool, error) { // Allow the zero type. if t == nil { return true, nil } // Reference types are always okay; we compare pointers. switch t.Kind() { case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: return true, nil } // Reject other non-comparable type...
[ "func", "isLegalForIdenticalTo", "(", "t", "reflect", ".", "Type", ")", "(", "bool", ",", "error", ")", "{", "// Allow the zero type.", "if", "t", "==", "nil", "{", "return", "true", ",", "nil", "\n", "}", "\n\n", "// Reference types are always okay; we compare ...
// Should the supplied type be allowed as an argument to IdenticalTo?
[ "Should", "the", "supplied", "type", "be", "allowed", "as", "an", "argument", "to", "IdenticalTo?" ]
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/identical_to.go#L50-L68
143,053
jacobsa/oglematchers
less_or_equal.go
LessOrEqual
func LessOrEqual(x interface{}) Matcher { desc := fmt.Sprintf("less than or equal to %v", x) // Special case: make it clear that strings are strings. if reflect.TypeOf(x).Kind() == reflect.String { desc = fmt.Sprintf("less than or equal to \"%s\"", x) } // Put LessThan last so that its error messages will be u...
go
func LessOrEqual(x interface{}) Matcher { desc := fmt.Sprintf("less than or equal to %v", x) // Special case: make it clear that strings are strings. if reflect.TypeOf(x).Kind() == reflect.String { desc = fmt.Sprintf("less than or equal to \"%s\"", x) } // Put LessThan last so that its error messages will be u...
[ "func", "LessOrEqual", "(", "x", "interface", "{", "}", ")", "Matcher", "{", "desc", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "x", ")", "\n\n", "// Special case: make it clear that strings are strings.", "if", "reflect", ".", "TypeOf", "(", "x", ")...
// LessOrEqual returns a matcher that matches integer, floating point, or // strings values v such that v <= x. Comparison is not defined between numeric // and string types, but is defined between all integer and floating point // types. // // x must itself be an integer, floating point, or string type; otherwise, // ...
[ "LessOrEqual", "returns", "a", "matcher", "that", "matches", "integer", "floating", "point", "or", "strings", "values", "v", "such", "that", "v", "<", "=", "x", ".", "Comparison", "is", "not", "defined", "between", "numeric", "and", "string", "types", "but",...
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/less_or_equal.go#L30-L41
143,054
jacobsa/oglematchers
new_matcher.go
NewMatcher
func NewMatcher( predicate func(interface{}) error, description string) Matcher { return &predicateMatcher{ predicate: predicate, description: description, } }
go
func NewMatcher( predicate func(interface{}) error, description string) Matcher { return &predicateMatcher{ predicate: predicate, description: description, } }
[ "func", "NewMatcher", "(", "predicate", "func", "(", "interface", "{", "}", ")", "error", ",", "description", "string", ")", "Matcher", "{", "return", "&", "predicateMatcher", "{", "predicate", ":", "predicate", ",", "description", ":", "description", ",", "...
// Create a matcher with the given description and predicate function, which // will be invoked to handle calls to Matchers. // // Using this constructor may be a convenience over defining your own type that // implements Matcher if you do not need any logic in your Description method.
[ "Create", "a", "matcher", "with", "the", "given", "description", "and", "predicate", "function", "which", "will", "be", "invoked", "to", "handle", "calls", "to", "Matchers", ".", "Using", "this", "constructor", "may", "be", "a", "convenience", "over", "definin...
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/new_matcher.go#L23-L30
143,055
jacobsa/oglematchers
greater_or_equal.go
GreaterOrEqual
func GreaterOrEqual(x interface{}) Matcher { desc := fmt.Sprintf("greater than or equal to %v", x) // Special case: make it clear that strings are strings. if reflect.TypeOf(x).Kind() == reflect.String { desc = fmt.Sprintf("greater than or equal to \"%s\"", x) } return transformDescription(Not(LessThan(x)), de...
go
func GreaterOrEqual(x interface{}) Matcher { desc := fmt.Sprintf("greater than or equal to %v", x) // Special case: make it clear that strings are strings. if reflect.TypeOf(x).Kind() == reflect.String { desc = fmt.Sprintf("greater than or equal to \"%s\"", x) } return transformDescription(Not(LessThan(x)), de...
[ "func", "GreaterOrEqual", "(", "x", "interface", "{", "}", ")", "Matcher", "{", "desc", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "x", ")", "\n\n", "// Special case: make it clear that strings are strings.", "if", "reflect", ".", "TypeOf", "(", "x", ...
// GreaterOrEqual returns a matcher that matches integer, floating point, or // strings values v such that v >= x. Comparison is not defined between numeric // and string types, but is defined between all integer and floating point // types. // // x must itself be an integer, floating point, or string type; otherwise, ...
[ "GreaterOrEqual", "returns", "a", "matcher", "that", "matches", "integer", "floating", "point", "or", "strings", "values", "v", "such", "that", "v", ">", "=", "x", ".", "Comparison", "is", "not", "defined", "between", "numeric", "and", "string", "types", "bu...
141901ea67cd4769c6800aa7bfdfc558fa22bda5
https://github.com/jacobsa/oglematchers/blob/141901ea67cd4769c6800aa7bfdfc558fa22bda5/greater_or_equal.go#L30-L39
143,056
codahale/blake2
blake2b.go
New
func New(config *Config) hash.Hash { d := &digest{ param: C.blake2b_param{ digest_length: 64, fanout: 1, depth: 1, }, } if config != nil { if config.Size != 0 { d.param.digest_length = C.uint8_t(config.Size) } if len(config.Key) > 0 { // let the C library worry about the exact...
go
func New(config *Config) hash.Hash { d := &digest{ param: C.blake2b_param{ digest_length: 64, fanout: 1, depth: 1, }, } if config != nil { if config.Size != 0 { d.param.digest_length = C.uint8_t(config.Size) } if len(config.Key) > 0 { // let the C library worry about the exact...
[ "func", "New", "(", "config", "*", "Config", ")", "hash", ".", "Hash", "{", "d", ":=", "&", "digest", "{", "param", ":", "C", ".", "blake2b_param", "{", "digest_length", ":", "64", ",", "fanout", ":", "1", ",", "depth", ":", "1", ",", "}", ",", ...
// New returns a new custom BLAKE2b hash. // // If config is nil, uses a 64-byte digest size.
[ "New", "returns", "a", "new", "custom", "BLAKE2b", "hash", ".", "If", "config", "is", "nil", "uses", "a", "64", "-", "byte", "digest", "size", "." ]
8d10d0420cbfbdc9c1164c0c4ad3457a6c3771b9
https://github.com/codahale/blake2/blob/8d10d0420cbfbdc9c1164c0c4ad3457a6c3771b9/blake2b.go#L78-L117
143,057
codahale/blake2
blake2b.go
NewKeyedBlake2B
func NewKeyedBlake2B(key []byte) hash.Hash { return New(&Config{Size: 64, Key: key}) }
go
func NewKeyedBlake2B(key []byte) hash.Hash { return New(&Config{Size: 64, Key: key}) }
[ "func", "NewKeyedBlake2B", "(", "key", "[", "]", "byte", ")", "hash", ".", "Hash", "{", "return", "New", "(", "&", "Config", "{", "Size", ":", "64", ",", "Key", ":", "key", "}", ")", "\n", "}" ]
// NewKeyedBlake2B returns a new 512-bit BLAKE2B hash with the given secret key.
[ "NewKeyedBlake2B", "returns", "a", "new", "512", "-", "bit", "BLAKE2B", "hash", "with", "the", "given", "secret", "key", "." ]
8d10d0420cbfbdc9c1164c0c4ad3457a6c3771b9
https://github.com/codahale/blake2/blob/8d10d0420cbfbdc9c1164c0c4ad3457a6c3771b9/blake2b.go#L125-L127
143,058
jjcollinge/servicefabric
servicefabric.go
NewClient
func NewClient(httpClient *http.Client, endpoint, apiVersion string, tlsConfig *tls.Config) (*Client, error) { if endpoint == "" { return nil, errors.New("endpoint missing for httpClient configuration") } if apiVersion == "" { apiVersion = DefaultAPIVersion } if tlsConfig != nil { tlsConfig.Renegotiation = ...
go
func NewClient(httpClient *http.Client, endpoint, apiVersion string, tlsConfig *tls.Config) (*Client, error) { if endpoint == "" { return nil, errors.New("endpoint missing for httpClient configuration") } if apiVersion == "" { apiVersion = DefaultAPIVersion } if tlsConfig != nil { tlsConfig.Renegotiation = ...
[ "func", "NewClient", "(", "httpClient", "*", "http", ".", "Client", ",", "endpoint", ",", "apiVersion", "string", ",", "tlsConfig", "*", "tls", ".", "Config", ")", "(", "*", "Client", ",", "error", ")", "{", "if", "endpoint", "==", "\"", "\"", "{", "...
// NewClient returns a new provider client that can query the // Service Fabric management API externally or internally
[ "NewClient", "returns", "a", "new", "provider", "client", "that", "can", "query", "the", "Service", "Fabric", "management", "API", "externally", "or", "internally" ]
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L31-L50
143,059
jjcollinge/servicefabric
servicefabric.go
GetApplications
func (c Client) GetApplications() (*ApplicationItemsPage, error) { var aggregateAppItemsPages ApplicationItemsPage var continueToken string for { res, err := c.getHTTP("Applications/", withContinue(continueToken)) if err != nil { return nil, err } var appItemsPage ApplicationItemsPage err = json.Unmars...
go
func (c Client) GetApplications() (*ApplicationItemsPage, error) { var aggregateAppItemsPages ApplicationItemsPage var continueToken string for { res, err := c.getHTTP("Applications/", withContinue(continueToken)) if err != nil { return nil, err } var appItemsPage ApplicationItemsPage err = json.Unmars...
[ "func", "(", "c", "Client", ")", "GetApplications", "(", ")", "(", "*", "ApplicationItemsPage", ",", "error", ")", "{", "var", "aggregateAppItemsPages", "ApplicationItemsPage", "\n", "var", "continueToken", "string", "\n", "for", "{", "res", ",", "err", ":=", ...
// GetApplications returns all the registered applications // within the Service Fabric cluster.
[ "GetApplications", "returns", "all", "the", "registered", "applications", "within", "the", "Service", "Fabric", "cluster", "." ]
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L54-L77
143,060
jjcollinge/servicefabric
servicefabric.go
GetServices
func (c Client) GetServices(appName string) (*ServiceItemsPage, error) { var aggregateServiceItemsPages ServiceItemsPage var continueToken string for { res, err := c.getHTTP("Applications/"+appName+"/$/GetServices", withContinue(continueToken)) if err != nil { return nil, err } var servicesItemsPage Serv...
go
func (c Client) GetServices(appName string) (*ServiceItemsPage, error) { var aggregateServiceItemsPages ServiceItemsPage var continueToken string for { res, err := c.getHTTP("Applications/"+appName+"/$/GetServices", withContinue(continueToken)) if err != nil { return nil, err } var servicesItemsPage Serv...
[ "func", "(", "c", "Client", ")", "GetServices", "(", "appName", "string", ")", "(", "*", "ServiceItemsPage", ",", "error", ")", "{", "var", "aggregateServiceItemsPages", "ServiceItemsPage", "\n", "var", "continueToken", "string", "\n", "for", "{", "res", ",", ...
// GetServices returns all the services associated // with a Service Fabric application.
[ "GetServices", "returns", "all", "the", "services", "associated", "with", "a", "Service", "Fabric", "application", "." ]
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L81-L104
143,061
jjcollinge/servicefabric
servicefabric.go
GetPartitions
func (c Client) GetPartitions(appName, serviceName string) (*PartitionItemsPage, error) { var aggregatePartitionItemsPages PartitionItemsPage var continueToken string for { basePath := "Applications/" + appName + "/$/GetServices/" + serviceName + "/$/GetPartitions/" res, err := c.getHTTP(basePath, withContinue(c...
go
func (c Client) GetPartitions(appName, serviceName string) (*PartitionItemsPage, error) { var aggregatePartitionItemsPages PartitionItemsPage var continueToken string for { basePath := "Applications/" + appName + "/$/GetServices/" + serviceName + "/$/GetPartitions/" res, err := c.getHTTP(basePath, withContinue(c...
[ "func", "(", "c", "Client", ")", "GetPartitions", "(", "appName", ",", "serviceName", "string", ")", "(", "*", "PartitionItemsPage", ",", "error", ")", "{", "var", "aggregatePartitionItemsPages", "PartitionItemsPage", "\n", "var", "continueToken", "string", "\n", ...
// GetPartitions returns all the partitions associated // with a Service Fabric service.
[ "GetPartitions", "returns", "all", "the", "partitions", "associated", "with", "a", "Service", "Fabric", "service", "." ]
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L108-L132
143,062
jjcollinge/servicefabric
servicefabric.go
GetInstances
func (c Client) GetInstances(appName, serviceName, partitionName string) (*InstanceItemsPage, error) { var aggregateInstanceItemsPages InstanceItemsPage var continueToken string for { basePath := "Applications/" + appName + "/$/GetServices/" + serviceName + "/$/GetPartitions/" + partitionName + "/$/GetReplicas" ...
go
func (c Client) GetInstances(appName, serviceName, partitionName string) (*InstanceItemsPage, error) { var aggregateInstanceItemsPages InstanceItemsPage var continueToken string for { basePath := "Applications/" + appName + "/$/GetServices/" + serviceName + "/$/GetPartitions/" + partitionName + "/$/GetReplicas" ...
[ "func", "(", "c", "Client", ")", "GetInstances", "(", "appName", ",", "serviceName", ",", "partitionName", "string", ")", "(", "*", "InstanceItemsPage", ",", "error", ")", "{", "var", "aggregateInstanceItemsPages", "InstanceItemsPage", "\n", "var", "continueToken"...
// GetInstances returns all the instances associated // with a stateless Service Fabric partition.
[ "GetInstances", "returns", "all", "the", "instances", "associated", "with", "a", "stateless", "Service", "Fabric", "partition", "." ]
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L136-L160
143,063
jjcollinge/servicefabric
servicefabric.go
GetReplicas
func (c Client) GetReplicas(appName, serviceName, partitionName string) (*ReplicaItemsPage, error) { var aggregateReplicaItemsPages ReplicaItemsPage var continueToken string for { basePath := "Applications/" + appName + "/$/GetServices/" + serviceName + "/$/GetPartitions/" + partitionName + "/$/GetReplicas" res,...
go
func (c Client) GetReplicas(appName, serviceName, partitionName string) (*ReplicaItemsPage, error) { var aggregateReplicaItemsPages ReplicaItemsPage var continueToken string for { basePath := "Applications/" + appName + "/$/GetServices/" + serviceName + "/$/GetPartitions/" + partitionName + "/$/GetReplicas" res,...
[ "func", "(", "c", "Client", ")", "GetReplicas", "(", "appName", ",", "serviceName", ",", "partitionName", "string", ")", "(", "*", "ReplicaItemsPage", ",", "error", ")", "{", "var", "aggregateReplicaItemsPages", "ReplicaItemsPage", "\n", "var", "continueToken", ...
// GetReplicas returns all the replicas associated // with a stateful Service Fabric partition.
[ "GetReplicas", "returns", "all", "the", "replicas", "associated", "with", "a", "stateful", "Service", "Fabric", "partition", "." ]
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L164-L188
143,064
jjcollinge/servicefabric
servicefabric.go
GetServiceExtension
func (c Client) GetServiceExtension(appType, applicationVersion, serviceTypeName, extensionKey string, response interface{}) error { res, err := c.getHTTP("ApplicationTypes/"+appType+"/$/GetServiceTypes", withParam("ApplicationTypeVersion", applicationVersion)) if err != nil { return fmt.Errorf("error requesting se...
go
func (c Client) GetServiceExtension(appType, applicationVersion, serviceTypeName, extensionKey string, response interface{}) error { res, err := c.getHTTP("ApplicationTypes/"+appType+"/$/GetServiceTypes", withParam("ApplicationTypeVersion", applicationVersion)) if err != nil { return fmt.Errorf("error requesting se...
[ "func", "(", "c", "Client", ")", "GetServiceExtension", "(", "appType", ",", "applicationVersion", ",", "serviceTypeName", ",", "extensionKey", "string", ",", "response", "interface", "{", "}", ")", "error", "{", "res", ",", "err", ":=", "c", ".", "getHTTP",...
// GetServiceExtension returns all the extensions specified // in a Service's manifest file. If the XML schema does not // map to the provided interface, the default type interface will // be returned.
[ "GetServiceExtension", "returns", "all", "the", "extensions", "specified", "in", "a", "Service", "s", "manifest", "file", ".", "If", "the", "XML", "schema", "does", "not", "map", "to", "the", "provided", "interface", "the", "default", "type", "interface", "wil...
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L194-L220
143,065
jjcollinge/servicefabric
servicefabric.go
GetProperties
func (c Client) GetProperties(name string) (bool, map[string]string, error) { nameExists, err := c.nameExists(name) if err != nil { return false, nil, err } if !nameExists { return false, nil, nil } properties := make(map[string]string) var continueToken string for { res, err := c.getHTTP("Names/"+name...
go
func (c Client) GetProperties(name string) (bool, map[string]string, error) { nameExists, err := c.nameExists(name) if err != nil { return false, nil, err } if !nameExists { return false, nil, nil } properties := make(map[string]string) var continueToken string for { res, err := c.getHTTP("Names/"+name...
[ "func", "(", "c", "Client", ")", "GetProperties", "(", "name", "string", ")", "(", "bool", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "nameExists", ",", "err", ":=", "c", ".", "nameExists", "(", "name", ")", "\n", "if", "err"...
// GetProperties uses the Property Manager API to retrieve // string properties from a name as a dictionary // Property name is the path to the properties you would like to list. // for example a serviceID
[ "GetProperties", "uses", "the", "Property", "Manager", "API", "to", "retrieve", "string", "properties", "from", "a", "name", "as", "a", "dictionary", "Property", "name", "is", "the", "path", "to", "the", "properties", "you", "would", "like", "to", "list", "....
8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe
https://github.com/jjcollinge/servicefabric/blob/8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe/servicefabric.go#L246-L285
143,066
cloudflare/backoff
backoff.go
New
func New(max time.Duration, interval time.Duration) *Backoff { if max < 0 || interval < 0 { panic("backoff: max or interval is negative") } b := &Backoff{ maxDuration: max, interval: interval, } b.setup() return b }
go
func New(max time.Duration, interval time.Duration) *Backoff { if max < 0 || interval < 0 { panic("backoff: max or interval is negative") } b := &Backoff{ maxDuration: max, interval: interval, } b.setup() return b }
[ "func", "New", "(", "max", "time", ".", "Duration", ",", "interval", "time", ".", "Duration", ")", "*", "Backoff", "{", "if", "max", "<", "0", "||", "interval", "<", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "b", ":=", "&", "B...
// New creates a new backoff with the specified max duration and // interval. Zero values may be used to use the default values. // // Panics if either max or interval is negative.
[ "New", "creates", "a", "new", "backoff", "with", "the", "specified", "max", "duration", "and", "interval", ".", "Zero", "values", "may", "be", "used", "to", "use", "the", "default", "values", ".", "Panics", "if", "either", "max", "or", "interval", "is", ...
647f3cdfc87a18586e279c97afd6526d01b0d063
https://github.com/cloudflare/backoff/blob/647f3cdfc87a18586e279c97afd6526d01b0d063/backoff.go#L72-L83
143,067
cloudflare/backoff
backoff.go
NewWithoutJitter
func NewWithoutJitter(max time.Duration, interval time.Duration) *Backoff { b := New(max, interval) b.noJitter = true return b }
go
func NewWithoutJitter(max time.Duration, interval time.Duration) *Backoff { b := New(max, interval) b.noJitter = true return b }
[ "func", "NewWithoutJitter", "(", "max", "time", ".", "Duration", ",", "interval", "time", ".", "Duration", ")", "*", "Backoff", "{", "b", ":=", "New", "(", "max", ",", "interval", ")", "\n", "b", ".", "noJitter", "=", "true", "\n", "return", "b", "\n...
// NewWithoutJitter works similarly to New, except that the created // Backoff will not use jitter.
[ "NewWithoutJitter", "works", "similarly", "to", "New", "except", "that", "the", "created", "Backoff", "will", "not", "use", "jitter", "." ]
647f3cdfc87a18586e279c97afd6526d01b0d063
https://github.com/cloudflare/backoff/blob/647f3cdfc87a18586e279c97afd6526d01b0d063/backoff.go#L87-L91
143,068
cloudflare/backoff
backoff.go
Duration
func (b *Backoff) Duration() time.Duration { b.setup() b.decayN() t := b.duration(b.n) if b.n < math.MaxUint64 { b.n++ } if !b.noJitter { prngMu.Lock() t = time.Duration(prng.Int63n(int64(t))) prngMu.Unlock() } return t }
go
func (b *Backoff) Duration() time.Duration { b.setup() b.decayN() t := b.duration(b.n) if b.n < math.MaxUint64 { b.n++ } if !b.noJitter { prngMu.Lock() t = time.Duration(prng.Int63n(int64(t))) prngMu.Unlock() } return t }
[ "func", "(", "b", "*", "Backoff", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "b", ".", "setup", "(", ")", "\n\n", "b", ".", "decayN", "(", ")", "\n\n", "t", ":=", "b", ".", "duration", "(", "b", ".", "n", ")", "\n\n", "if", "b",...
// Duration returns a time.Duration appropriate for the backoff, // incrementing the attempt counter.
[ "Duration", "returns", "a", "time", ".", "Duration", "appropriate", "for", "the", "backoff", "incrementing", "the", "attempt", "counter", "." ]
647f3cdfc87a18586e279c97afd6526d01b0d063
https://github.com/cloudflare/backoff/blob/647f3cdfc87a18586e279c97afd6526d01b0d063/backoff.go#L120-L138
143,069
cloudflare/backoff
backoff.go
duration
func (b *Backoff) duration(n uint64) (t time.Duration) { // Saturate pow pow := time.Duration(math.MaxInt64) if n < 63 { pow = 1 << n } t = b.interval * pow if t/pow != b.interval || t > b.maxDuration { t = b.maxDuration } return }
go
func (b *Backoff) duration(n uint64) (t time.Duration) { // Saturate pow pow := time.Duration(math.MaxInt64) if n < 63 { pow = 1 << n } t = b.interval * pow if t/pow != b.interval || t > b.maxDuration { t = b.maxDuration } return }
[ "func", "(", "b", "*", "Backoff", ")", "duration", "(", "n", "uint64", ")", "(", "t", "time", ".", "Duration", ")", "{", "// Saturate pow", "pow", ":=", "time", ".", "Duration", "(", "math", ".", "MaxInt64", ")", "\n", "if", "n", "<", "63", "{", ...
// requires b to be locked.
[ "requires", "b", "to", "be", "locked", "." ]
647f3cdfc87a18586e279c97afd6526d01b0d063
https://github.com/cloudflare/backoff/blob/647f3cdfc87a18586e279c97afd6526d01b0d063/backoff.go#L141-L154
143,070
cloudflare/backoff
backoff.go
SetDecay
func (b *Backoff) SetDecay(decay time.Duration) { if decay < 0 { panic("backoff: decay < 0") } b.decay = decay }
go
func (b *Backoff) SetDecay(decay time.Duration) { if decay < 0 { panic("backoff: decay < 0") } b.decay = decay }
[ "func", "(", "b", "*", "Backoff", ")", "SetDecay", "(", "decay", "time", ".", "Duration", ")", "{", "if", "decay", "<", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "b", ".", "decay", "=", "decay", "\n", "}" ]
// SetDecay sets the duration after which the try counter will be reset. // Panics if decay is smaller than 0. // // The decay only kicks in if at least the last backoff + decay has elapsed // since the last try.
[ "SetDecay", "sets", "the", "duration", "after", "which", "the", "try", "counter", "will", "be", "reset", ".", "Panics", "if", "decay", "is", "smaller", "than", "0", ".", "The", "decay", "only", "kicks", "in", "if", "at", "least", "the", "last", "backoff"...
647f3cdfc87a18586e279c97afd6526d01b0d063
https://github.com/cloudflare/backoff/blob/647f3cdfc87a18586e279c97afd6526d01b0d063/backoff.go#L169-L175
143,071
cloudflare/backoff
backoff.go
decayN
func (b *Backoff) decayN() { if b.decay == 0 { return } if b.lastTry.IsZero() { b.lastTry = time.Now() return } lastDuration := b.duration(b.n - 1) decayed := time.Since(b.lastTry) > lastDuration+b.decay b.lastTry = time.Now() if !decayed { return } b.n = 0 }
go
func (b *Backoff) decayN() { if b.decay == 0 { return } if b.lastTry.IsZero() { b.lastTry = time.Now() return } lastDuration := b.duration(b.n - 1) decayed := time.Since(b.lastTry) > lastDuration+b.decay b.lastTry = time.Now() if !decayed { return } b.n = 0 }
[ "func", "(", "b", "*", "Backoff", ")", "decayN", "(", ")", "{", "if", "b", ".", "decay", "==", "0", "{", "return", "\n", "}", "\n\n", "if", "b", ".", "lastTry", ".", "IsZero", "(", ")", "{", "b", ".", "lastTry", "=", "time", ".", "Now", "(", ...
// requires b to be locked
[ "requires", "b", "to", "be", "locked" ]
647f3cdfc87a18586e279c97afd6526d01b0d063
https://github.com/cloudflare/backoff/blob/647f3cdfc87a18586e279c97afd6526d01b0d063/backoff.go#L178-L197
143,072
rogpeppe/go-charset
charset/iconv/iconv.go
Translator
func Translator(toCharset, fromCharset string, invalid rune) (charset.Translator, error) { cto, cfrom := C.CString(toCharset), C.CString(fromCharset) cd, err := C.iconv_open(cto, cfrom) C.free(unsafe.Pointer(cfrom)) C.free(unsafe.Pointer(cto)) if cd == C.iconv_open_error { if err == syscall.EINVAL { return ...
go
func Translator(toCharset, fromCharset string, invalid rune) (charset.Translator, error) { cto, cfrom := C.CString(toCharset), C.CString(fromCharset) cd, err := C.iconv_open(cto, cfrom) C.free(unsafe.Pointer(cfrom)) C.free(unsafe.Pointer(cto)) if cd == C.iconv_open_error { if err == syscall.EINVAL { return ...
[ "func", "Translator", "(", "toCharset", ",", "fromCharset", "string", ",", "invalid", "rune", ")", "(", "charset", ".", "Translator", ",", "error", ")", "{", "cto", ",", "cfrom", ":=", "C", ".", "CString", "(", "toCharset", ")", ",", "C", ".", "CString...
// Translator returns a Translator that translates between // the named character sets. When an invalid multibyte // character is found, the bytes in invalid are substituted instead.
[ "Translator", "returns", "a", "Translator", "that", "translates", "between", "the", "named", "character", "sets", ".", "When", "an", "invalid", "multibyte", "character", "is", "found", "the", "bytes", "in", "invalid", "are", "substituted", "instead", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/iconv/iconv.go#L68-L86
143,073
rogpeppe/go-charset
charset/charset.go
NewReader
func NewReader(charset string, r io.Reader) (io.Reader, error) { tr, err := TranslatorFrom(charset) if err != nil { return nil, err } return NewTranslatingReader(r, tr), nil }
go
func NewReader(charset string, r io.Reader) (io.Reader, error) { tr, err := TranslatorFrom(charset) if err != nil { return nil, err } return NewTranslatingReader(r, tr), nil }
[ "func", "NewReader", "(", "charset", "string", ",", "r", "io", ".", "Reader", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "tr", ",", "err", ":=", "TranslatorFrom", "(", "charset", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil"...
// NewReader returns a new Reader that translates from the named // character set to UTF-8 as it reads r.
[ "NewReader", "returns", "a", "new", "Reader", "that", "translates", "from", "the", "named", "character", "set", "to", "UTF", "-", "8", "as", "it", "reads", "r", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L65-L71
143,074
rogpeppe/go-charset
charset/charset.go
NewWriter
func NewWriter(charset string, w io.Writer) (io.WriteCloser, error) { tr, err := TranslatorTo(charset) if err != nil { return nil, err } return NewTranslatingWriter(w, tr), nil }
go
func NewWriter(charset string, w io.Writer) (io.WriteCloser, error) { tr, err := TranslatorTo(charset) if err != nil { return nil, err } return NewTranslatingWriter(w, tr), nil }
[ "func", "NewWriter", "(", "charset", "string", ",", "w", "io", ".", "Writer", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "tr", ",", "err", ":=", "TranslatorTo", "(", "charset", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n...
// NewWriter returns a new WriteCloser writing to w. It converts writes // of UTF-8 text into writes on w of text in the named character set. // The Close is necessary to flush any remaining partially translated // characters to the output.
[ "NewWriter", "returns", "a", "new", "WriteCloser", "writing", "to", "w", ".", "It", "converts", "writes", "of", "UTF", "-", "8", "text", "into", "writes", "on", "w", "of", "text", "in", "the", "named", "character", "set", ".", "The", "Close", "is", "ne...
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L77-L83
143,075
rogpeppe/go-charset
charset/charset.go
Info
func Info(name string) *Charset { for _, f := range factories { if info := f.Info(name); info != nil { return info } } return nil }
go
func Info(name string) *Charset { for _, f := range factories { if info := f.Info(name); info != nil { return info } } return nil }
[ "func", "Info", "(", "name", "string", ")", "*", "Charset", "{", "for", "_", ",", "f", ":=", "range", "factories", "{", "if", "info", ":=", "f", ".", "Info", "(", "name", ")", ";", "info", "!=", "nil", "{", "return", "info", "\n", "}", "\n", "}...
// Info returns information about a character set, or nil // if the character set is not found.
[ "Info", "returns", "information", "about", "a", "character", "set", "or", "nil", "if", "the", "character", "set", "is", "not", "found", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L87-L94
143,076
rogpeppe/go-charset
charset/charset.go
Names
func Names() []string { // TODO eliminate duplicates var names []string for _, f := range factories { names = append(names, f.Names()...) } return names }
go
func Names() []string { // TODO eliminate duplicates var names []string for _, f := range factories { names = append(names, f.Names()...) } return names }
[ "func", "Names", "(", ")", "[", "]", "string", "{", "// TODO eliminate duplicates", "var", "names", "[", "]", "string", "\n", "for", "_", ",", "f", ":=", "range", "factories", "{", "names", "=", "append", "(", "names", ",", "f", ".", "Names", "(", ")...
// Names returns the canonical names of all supported character sets, in alphabetical order.
[ "Names", "returns", "the", "canonical", "names", "of", "all", "supported", "character", "sets", "in", "alphabetical", "order", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L97-L104
143,077
rogpeppe/go-charset
charset/charset.go
TranslatorFrom
func TranslatorFrom(charset string) (Translator, error) { var err error var tr Translator for _, f := range factories { tr, err = f.TranslatorFrom(charset) if err == nil { break } } if tr == nil { return nil, err } return tr, nil }
go
func TranslatorFrom(charset string) (Translator, error) { var err error var tr Translator for _, f := range factories { tr, err = f.TranslatorFrom(charset) if err == nil { break } } if tr == nil { return nil, err } return tr, nil }
[ "func", "TranslatorFrom", "(", "charset", "string", ")", "(", "Translator", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "tr", "Translator", "\n", "for", "_", ",", "f", ":=", "range", "factories", "{", "tr", ",", "err", "=", "f", ".", ...
// TranslatorFrom returns a translator that will translate from // the named character set to UTF-8.
[ "TranslatorFrom", "returns", "a", "translator", "that", "will", "translate", "from", "the", "named", "character", "set", "to", "UTF", "-", "8", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L108-L121
143,078
rogpeppe/go-charset
charset/charset.go
NewTranslatingWriter
func NewTranslatingWriter(w io.Writer, tr Translator) io.WriteCloser { return &translatingWriter{w: w, tr: tr} }
go
func NewTranslatingWriter(w io.Writer, tr Translator) io.WriteCloser { return &translatingWriter{w: w, tr: tr} }
[ "func", "NewTranslatingWriter", "(", "w", "io", ".", "Writer", ",", "tr", "Translator", ")", "io", ".", "WriteCloser", "{", "return", "&", "translatingWriter", "{", "w", ":", "w", ",", "tr", ":", "tr", "}", "\n", "}" ]
// NewTranslatingWriter returns a new WriteCloser writing to w. // It passes the written bytes through the given Translator.
[ "NewTranslatingWriter", "returns", "a", "new", "WriteCloser", "writing", "to", "w", ".", "It", "passes", "the", "written", "bytes", "through", "the", "given", "Translator", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L164-L166
143,079
rogpeppe/go-charset
charset/charset.go
NewTranslatingReader
func NewTranslatingReader(r io.Reader, tr Translator) io.Reader { return &translatingReader{r: r, tr: tr} }
go
func NewTranslatingReader(r io.Reader, tr Translator) io.Reader { return &translatingReader{r: r, tr: tr} }
[ "func", "NewTranslatingReader", "(", "r", "io", ".", "Reader", ",", "tr", "Translator", ")", "io", ".", "Reader", "{", "return", "&", "translatingReader", "{", "r", ":", "r", ",", "tr", ":", "tr", "}", "\n", "}" ]
// NewTranslatingReader returns a new Reader that // translates data using the given Translator as it reads r.
[ "NewTranslatingReader", "returns", "a", "new", "Reader", "that", "translates", "data", "using", "the", "given", "Translator", "as", "it", "reads", "r", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/charset.go#L227-L229
143,080
rogpeppe/go-charset
charset/local.go
readLocalCharsets
func readLocalCharsets() { csdata, err := readFile("charsets.json") if err != nil { fmt.Fprintf(os.Stderr, "charset: cannot open \"charsets.json\": %v\n", err) return } var entries map[string]charsetEntry err = json.Unmarshal(csdata, &entries) if err != nil { fmt.Fprintf(os.Stderr, "charset: cannot decode ...
go
func readLocalCharsets() { csdata, err := readFile("charsets.json") if err != nil { fmt.Fprintf(os.Stderr, "charset: cannot open \"charsets.json\": %v\n", err) return } var entries map[string]charsetEntry err = json.Unmarshal(csdata, &entries) if err != nil { fmt.Fprintf(os.Stderr, "charset: cannot decode ...
[ "func", "readLocalCharsets", "(", ")", "{", "csdata", ",", "err", ":=", "readFile", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\\"", "\\\"", "\\n", "\"", ",", "err", ")...
// readCharsets reads the JSON config file. // It's done once only, when first needed.
[ "readCharsets", "reads", "the", "JSON", "config", "file", ".", "It", "s", "done", "once", "only", "when", "first", "needed", "." ]
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/local.go#L104-L141
143,081
rogpeppe/go-charset
charset/file.go
RegisterDataFile
func RegisterDataFile(name string, open func() (io.ReadCloser, error)) { files[name] = open }
go
func RegisterDataFile(name string, open func() (io.ReadCloser, error)) { files[name] = open }
[ "func", "RegisterDataFile", "(", "name", "string", ",", "open", "func", "(", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", ")", "{", "files", "[", "name", "]", "=", "open", "\n", "}" ]
// RegisterDataFile registers the existence of a given data // file with the given name that may be used by a character-set converter. // It is intended to be used by packages that wish to embed // data in the executable binary, and should not be // used normally.
[ "RegisterDataFile", "registers", "the", "existence", "of", "a", "given", "data", "file", "with", "the", "given", "name", "that", "may", "be", "used", "by", "a", "character", "-", "set", "converter", ".", "It", "is", "intended", "to", "be", "used", "by", ...
2471d30d28b404738b546df7aaa82c45826bc02e
https://github.com/rogpeppe/go-charset/blob/2471d30d28b404738b546df7aaa82c45826bc02e/charset/file.go#L17-L19
143,082
hooklift/iso9660
reader.go
NewReader
func NewReader(rs io.ReadSeeker) (*Reader, error) { // Starts reading from image data area sector := dataAreaSector // Iterates over volume descriptors until it finds the primary volume descriptor // or an error condition. for { offset, err := rs.Seek(int64(sector*sectorSize), os.SEEK_SET) if err != nil { r...
go
func NewReader(rs io.ReadSeeker) (*Reader, error) { // Starts reading from image data area sector := dataAreaSector // Iterates over volume descriptors until it finds the primary volume descriptor // or an error condition. for { offset, err := rs.Seek(int64(sector*sectorSize), os.SEEK_SET) if err != nil { r...
[ "func", "NewReader", "(", "rs", "io", ".", "ReadSeeker", ")", "(", "*", "Reader", ",", "error", ")", "{", "// Starts reading from image data area", "sector", ":=", "dataAreaSector", "\n", "// Iterates over volume descriptors until it finds the primary volume descriptor", "/...
// NewReader creates a new ISO 9660 image reader.
[ "NewReader", "creates", "a", "new", "ISO", "9660", "image", "reader", "." ]
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/reader.go#L67-L106
143,083
hooklift/iso9660
reader.go
Skip
func (r *Reader) Skip(n int) error { var drecord File var len byte var err error for i := 0; i < n; i++ { if len, err = r.unpackDRecord(&drecord); err != nil { return err } r.read += uint32(len) } return nil }
go
func (r *Reader) Skip(n int) error { var drecord File var len byte var err error for i := 0; i < n; i++ { if len, err = r.unpackDRecord(&drecord); err != nil { return err } r.read += uint32(len) } return nil }
[ "func", "(", "r", "*", "Reader", ")", "Skip", "(", "n", "int", ")", "error", "{", "var", "drecord", "File", "\n", "var", "len", "byte", "\n", "var", "err", "error", "\n", "for", "i", ":=", "0", ";", "i", "<", "n", ";", "i", "++", "{", "if", ...
// Skip skips the given number of directory records.
[ "Skip", "skips", "the", "given", "number", "of", "directory", "records", "." ]
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/reader.go#L109-L120
143,084
hooklift/iso9660
reader.go
Next
func (r *Reader) Next() (os.FileInfo, error) { if r.queue.IsEmpty() { return nil, io.EOF } // We only dequeue the directory when it does not contain more children // or when it is empty and there is no children to iterate over. item, err := r.queue.Peek() if err != nil { panic(err) } f := item.(File) if ...
go
func (r *Reader) Next() (os.FileInfo, error) { if r.queue.IsEmpty() { return nil, io.EOF } // We only dequeue the directory when it does not contain more children // or when it is empty and there is no children to iterate over. item, err := r.queue.Peek() if err != nil { panic(err) } f := item.(File) if ...
[ "func", "(", "r", "*", "Reader", ")", "Next", "(", ")", "(", "os", ".", "FileInfo", ",", "error", ")", "{", "if", "r", ".", "queue", ".", "IsEmpty", "(", ")", "{", "return", "nil", ",", "io", ".", "EOF", "\n", "}", "\n\n", "// We only dequeue the...
// Next moves onto the next directory record present in the image. // It does not use the Path Table since the goal is to read everything // from the ISO image.
[ "Next", "moves", "onto", "the", "next", "directory", "record", "present", "in", "the", "image", ".", "It", "does", "not", "use", "the", "Path", "Table", "since", "the", "goal", "is", "to", "read", "everything", "from", "the", "ISO", "image", "." ]
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/reader.go#L125-L203
143,085
hooklift/iso9660
reader.go
unpackDRecord
func (r *Reader) unpackDRecord(f *File) (byte, error) { // Gets the directory record length var len byte if err := binary.Read(r.image, binary.BigEndian, &len); err != nil { return len, ErrCorruptedImage(err) } if len == 0 { return len + 1, io.EOF } // Reads directory record into Go struct var drecord Dir...
go
func (r *Reader) unpackDRecord(f *File) (byte, error) { // Gets the directory record length var len byte if err := binary.Read(r.image, binary.BigEndian, &len); err != nil { return len, ErrCorruptedImage(err) } if len == 0 { return len + 1, io.EOF } // Reads directory record into Go struct var drecord Dir...
[ "func", "(", "r", "*", "Reader", ")", "unpackDRecord", "(", "f", "*", "File", ")", "(", "byte", ",", "error", ")", "{", "// Gets the directory record length", "var", "len", "byte", "\n", "if", "err", ":=", "binary", ".", "Read", "(", "r", ".", "image",...
// unpackDRecord unpacks directory record bits into Go's struct
[ "unpackDRecord", "unpacks", "directory", "record", "bits", "into", "Go", "s", "struct" ]
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/reader.go#L206-L251
143,086
hooklift/iso9660
reader.go
unpackPVD
func (r *Reader) unpackPVD() error { // Unpack first half var pvd1 PrimaryVolumePart1 if err := binary.Read(r.image, binary.BigEndian, &pvd1); err != nil { return ErrCorruptedImage(err) } r.pvd.PrimaryVolumePart1 = pvd1 // Unpack root directory record var drecord File if _, err := r.unpackDRecord(&drecord); ...
go
func (r *Reader) unpackPVD() error { // Unpack first half var pvd1 PrimaryVolumePart1 if err := binary.Read(r.image, binary.BigEndian, &pvd1); err != nil { return ErrCorruptedImage(err) } r.pvd.PrimaryVolumePart1 = pvd1 // Unpack root directory record var drecord File if _, err := r.unpackDRecord(&drecord); ...
[ "func", "(", "r", "*", "Reader", ")", "unpackPVD", "(", ")", "error", "{", "// Unpack first half", "var", "pvd1", "PrimaryVolumePart1", "\n", "if", "err", ":=", "binary", ".", "Read", "(", "r", ".", "image", ",", "binary", ".", "BigEndian", ",", "&", "...
// unpackPVD unpacks Primary Volume Descriptor in three phases. This is // because the root directory record is a variable-length record and Go's binary // package doesn't support unpacking variable-length structs easily.
[ "unpackPVD", "unpacks", "Primary", "Volume", "Descriptor", "in", "three", "phases", ".", "This", "is", "because", "the", "root", "directory", "record", "is", "a", "variable", "-", "length", "record", "and", "Go", "s", "binary", "package", "doesn", "t", "supp...
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/reader.go#L256-L280
143,087
hooklift/iso9660
iso9660.go
Name
func (f *File) Name() string { name := strings.Split(f.fileID, ";")[0] return strings.ToLower(name) }
go
func (f *File) Name() string { name := strings.Split(f.fileID, ";")[0] return strings.ToLower(name) }
[ "func", "(", "f", "*", "File", ")", "Name", "(", ")", "string", "{", "name", ":=", "strings", ".", "Split", "(", "f", ".", "fileID", ",", "\"", "\"", ")", "[", "0", "]", "\n", "return", "strings", ".", "ToLower", "(", "name", ")", "\n", "}" ]
// Name returns the file's name.
[ "Name", "returns", "the", "file", "s", "name", "." ]
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/iso9660.go#L37-L40
143,088
hooklift/iso9660
iso9660.go
Mode
func (f *File) Mode() os.FileMode { if f.IsDir() { return os.FileMode(0740) } return os.FileMode(0640) }
go
func (f *File) Mode() os.FileMode { if f.IsDir() { return os.FileMode(0740) } return os.FileMode(0640) }
[ "func", "(", "f", "*", "File", ")", "Mode", "(", ")", "os", ".", "FileMode", "{", "if", "f", ".", "IsDir", "(", ")", "{", "return", "os", ".", "FileMode", "(", "0740", ")", "\n", "}", "\n", "return", "os", ".", "FileMode", "(", "0640", ")", "...
// Mode returns file's mode and permissions bits. Since we don't yet support // Rock Ridge extensions we cannot extract POSIX permissions and the rest of the // normal metadata. So, right we return 0740 for directories and 0640 for files.
[ "Mode", "returns", "file", "s", "mode", "and", "permissions", "bits", ".", "Since", "we", "don", "t", "yet", "support", "Rock", "Ridge", "extensions", "we", "cannot", "extract", "POSIX", "permissions", "and", "the", "rest", "of", "the", "normal", "metadata",...
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/iso9660.go#L50-L55
143,089
hooklift/iso9660
iso9660.go
Sys
func (f *File) Sys() interface{} { if f.IsDir() { return nil } return io.NewSectionReader(f.image, int64(f.ExtentLocationBE*sectorSize), int64(f.ExtentLengthBE)) }
go
func (f *File) Sys() interface{} { if f.IsDir() { return nil } return io.NewSectionReader(f.image, int64(f.ExtentLocationBE*sectorSize), int64(f.ExtentLengthBE)) }
[ "func", "(", "f", "*", "File", ")", "Sys", "(", ")", "interface", "{", "}", "{", "if", "f", ".", "IsDir", "(", ")", "{", "return", "nil", "\n", "}", "\n\n", "return", "io", ".", "NewSectionReader", "(", "f", ".", "image", ",", "int64", "(", "f"...
// Sys returns io.Reader instance pointing to the file's content if it is not a directory, nil otherwise.
[ "Sys", "returns", "io", ".", "Reader", "instance", "pointing", "to", "the", "file", "s", "content", "if", "it", "is", "not", "a", "directory", "nil", "otherwise", "." ]
92d4952f9f0928c38af519c8680476358d563530
https://github.com/hooklift/iso9660/blob/92d4952f9f0928c38af519c8680476358d563530/iso9660.go#L71-L77
143,090
gojp/kana
trie.go
insert
func (t *Trie) insert(letters, value string) { lettersRune := []rune(letters) // loop through letters in argument word for l, letter := range lettersRune { letterStr := string(letter) // if letter in children if t.children[letterStr] != nil { t = t.children[letterStr] } else { // not found, so add l...
go
func (t *Trie) insert(letters, value string) { lettersRune := []rune(letters) // loop through letters in argument word for l, letter := range lettersRune { letterStr := string(letter) // if letter in children if t.children[letterStr] != nil { t = t.children[letterStr] } else { // not found, so add l...
[ "func", "(", "t", "*", "Trie", ")", "insert", "(", "letters", ",", "value", "string", ")", "{", "lettersRune", ":=", "[", "]", "rune", "(", "letters", ")", "\n\n", "// loop through letters in argument word", "for", "l", ",", "letter", ":=", "range", "lette...
// Insert a value into the trie
[ "Insert", "a", "value", "into", "the", "trie" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/trie.go#L16-L39
143,091
gojp/kana
trie.go
convert
func (t *Trie) convert(origin string) (result string) { root := t originRune := []rune(origin) result = "" for l := 0; l < len(originRune); l++ { t = root foundVal := "" depth := 0 for i := 0; i+l < len(originRune); i++ { letter := string(originRune[l+i]) if t.children[letter] == nil { // not fou...
go
func (t *Trie) convert(origin string) (result string) { root := t originRune := []rune(origin) result = "" for l := 0; l < len(originRune); l++ { t = root foundVal := "" depth := 0 for i := 0; i+l < len(originRune); i++ { letter := string(originRune[l+i]) if t.children[letter] == nil { // not fou...
[ "func", "(", "t", "*", "Trie", ")", "convert", "(", "origin", "string", ")", "(", "result", "string", ")", "{", "root", ":=", "t", "\n", "originRune", ":=", "[", "]", "rune", "(", "origin", ")", "\n", "result", "=", "\"", "\"", "\n\n", "for", "l"...
// Convert a given string to the corresponding values // in the trie. This performed in a greedy fashion, // replacing the longest valid string it can find at any // given point.
[ "Convert", "a", "given", "string", "to", "the", "corresponding", "values", "in", "the", "trie", ".", "This", "performed", "in", "a", "greedy", "fashion", "replacing", "the", "longest", "valid", "string", "it", "can", "find", "at", "any", "given", "point", ...
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/trie.go#L45-L74
143,092
gojp/kana
kana.go
Initialize
func Initialize() { kanaToRomajiTrie = newTrie() romajiToHiraganaTrie = newTrie() romajiToKatakanaTrie = newTrie() tables := []string{HiraganaTable, KatakanaTable} for t, table := range tables { rows := strings.Split(table, "\n") colNames := strings.Split(string(rows[0]), "\t")[1:] for _, row := range rows[...
go
func Initialize() { kanaToRomajiTrie = newTrie() romajiToHiraganaTrie = newTrie() romajiToKatakanaTrie = newTrie() tables := []string{HiraganaTable, KatakanaTable} for t, table := range tables { rows := strings.Split(table, "\n") colNames := strings.Split(string(rows[0]), "\t")[1:] for _, row := range rows[...
[ "func", "Initialize", "(", ")", "{", "kanaToRomajiTrie", "=", "newTrie", "(", ")", "\n", "romajiToHiraganaTrie", "=", "newTrie", "(", ")", "\n", "romajiToKatakanaTrie", "=", "newTrie", "(", ")", "\n\n", "tables", ":=", "[", "]", "string", "{", "HiraganaTable...
// Initialize builds the Hiragana + Katakana trie. // Because there is no overlap between the hiragana and katakana sets, // they both use the same trie without conflict. Nice bonus!
[ "Initialize", "builds", "the", "Hiragana", "+", "Katakana", "trie", ".", "Because", "there", "is", "no", "overlap", "between", "the", "hiragana", "and", "katakana", "sets", "they", "both", "use", "the", "same", "trie", "without", "conflict", ".", "Nice", "bo...
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L24-L53
143,093
gojp/kana
kana.go
KanaToRomaji
func KanaToRomaji(kana string) (romaji string) { // unfortunate hack to deal with double n's romaji = hiraganaRe.ReplaceAllString(kana, "nn$1") romaji = katakanaRe.ReplaceAllString(romaji, "nn$1") romaji = kanaToRomajiTrie.convert(romaji) // do some post-processing for the tsu and stripe characters // maybe a b...
go
func KanaToRomaji(kana string) (romaji string) { // unfortunate hack to deal with double n's romaji = hiraganaRe.ReplaceAllString(kana, "nn$1") romaji = katakanaRe.ReplaceAllString(romaji, "nn$1") romaji = kanaToRomajiTrie.convert(romaji) // do some post-processing for the tsu and stripe characters // maybe a b...
[ "func", "KanaToRomaji", "(", "kana", "string", ")", "(", "romaji", "string", ")", "{", "// unfortunate hack to deal with double n's", "romaji", "=", "hiraganaRe", ".", "ReplaceAllString", "(", "kana", ",", "\"", "\"", ")", "\n", "romaji", "=", "katakanaRe", ".",...
// KanaToRomaji converts a kana string to its romaji form
[ "KanaToRomaji", "converts", "a", "kana", "string", "to", "its", "romaji", "form" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L56-L95
143,094
gojp/kana
kana.go
RomajiToHiragana
func RomajiToHiragana(romaji string) (hiragana string) { romaji = strings.Replace(romaji, "-", "ー", -1) romaji = replaceTsus(romaji, "っ") romaji = replaceNs(romaji, "ん") hiragana = romajiToHiraganaTrie.convert(romaji) return hiragana }
go
func RomajiToHiragana(romaji string) (hiragana string) { romaji = strings.Replace(romaji, "-", "ー", -1) romaji = replaceTsus(romaji, "っ") romaji = replaceNs(romaji, "ん") hiragana = romajiToHiraganaTrie.convert(romaji) return hiragana }
[ "func", "RomajiToHiragana", "(", "romaji", "string", ")", "(", "hiragana", "string", ")", "{", "romaji", "=", "strings", ".", "Replace", "(", "romaji", ",", "\"", "\"", ",", "\"", " ", "-", ")", "", "", "\n", "romaji", "=", "replaceTsus", "(", "romaj...
// RomajiToHiragana converts a romaji string to its hiragana form
[ "RomajiToHiragana", "converts", "a", "romaji", "string", "to", "its", "hiragana", "form" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L110-L116
143,095
gojp/kana
kana.go
RomajiToKatakana
func RomajiToKatakana(romaji string) (katakana string) { romaji = strings.Replace(romaji, "-", "ー", -1) // convert double consonants to little tsus first romaji = replaceTsus(romaji, "ッ") romaji = replaceNs(romaji, "ン") katakana = romajiToKatakanaTrie.convert(romaji) return katakana }
go
func RomajiToKatakana(romaji string) (katakana string) { romaji = strings.Replace(romaji, "-", "ー", -1) // convert double consonants to little tsus first romaji = replaceTsus(romaji, "ッ") romaji = replaceNs(romaji, "ン") katakana = romajiToKatakanaTrie.convert(romaji) return katakana }
[ "func", "RomajiToKatakana", "(", "romaji", "string", ")", "(", "katakana", "string", ")", "{", "romaji", "=", "strings", ".", "Replace", "(", "romaji", ",", "\"", "\"", ",", "\"", " ", "-", ")", "", "", "\n", "// convert double consonants to little tsus firs...
// RomajiToKatakana converts a romaji string to its katakana form
[ "RomajiToKatakana", "converts", "a", "romaji", "string", "to", "its", "katakana", "form" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L119-L126
143,096
gojp/kana
kana.go
IsLatin
func IsLatin(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Latin, unicode.ASCII_Hex_Digit, unicode.White_Space, unicode.Hyphen}) }
go
func IsLatin(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Latin, unicode.ASCII_Hex_Digit, unicode.White_Space, unicode.Hyphen}) }
[ "func", "IsLatin", "(", "s", "string", ")", "bool", "{", "return", "isChar", "(", "s", ",", "[", "]", "*", "unicode", ".", "RangeTable", "{", "unicode", ".", "Latin", ",", "unicode", ".", "ASCII_Hex_Digit", ",", "unicode", ".", "White_Space", ",", "uni...
// IsLatin returns true if the string contains only Latin characters
[ "IsLatin", "returns", "true", "if", "the", "string", "contains", "only", "Latin", "characters" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L139-L141
143,097
gojp/kana
kana.go
IsKana
func IsKana(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Hiragana, unicode.Katakana, unicode.Hyphen, unicode.Diacritic}) }
go
func IsKana(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Hiragana, unicode.Katakana, unicode.Hyphen, unicode.Diacritic}) }
[ "func", "IsKana", "(", "s", "string", ")", "bool", "{", "return", "isChar", "(", "s", ",", "[", "]", "*", "unicode", ".", "RangeTable", "{", "unicode", ".", "Hiragana", ",", "unicode", ".", "Katakana", ",", "unicode", ".", "Hyphen", ",", "unicode", "...
// IsKana returns true if the string contains only kana
[ "IsKana", "returns", "true", "if", "the", "string", "contains", "only", "kana" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L144-L146
143,098
gojp/kana
kana.go
IsHiragana
func IsHiragana(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Hiragana, unicode.Hyphen, unicode.Diacritic}) }
go
func IsHiragana(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Hiragana, unicode.Hyphen, unicode.Diacritic}) }
[ "func", "IsHiragana", "(", "s", "string", ")", "bool", "{", "return", "isChar", "(", "s", ",", "[", "]", "*", "unicode", ".", "RangeTable", "{", "unicode", ".", "Hiragana", ",", "unicode", ".", "Hyphen", ",", "unicode", ".", "Diacritic", "}", ")", "\...
// IsHiragana returns true if the string contains only hiragana
[ "IsHiragana", "returns", "true", "if", "the", "string", "contains", "only", "hiragana" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L149-L151
143,099
gojp/kana
kana.go
IsKatakana
func IsKatakana(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Katakana, unicode.Hyphen, unicode.Diacritic}) }
go
func IsKatakana(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Katakana, unicode.Hyphen, unicode.Diacritic}) }
[ "func", "IsKatakana", "(", "s", "string", ")", "bool", "{", "return", "isChar", "(", "s", ",", "[", "]", "*", "unicode", ".", "RangeTable", "{", "unicode", ".", "Katakana", ",", "unicode", ".", "Hyphen", ",", "unicode", ".", "Diacritic", "}", ")", "\...
// IsKatakana returns true if the string contains only katakana
[ "IsKatakana", "returns", "true", "if", "the", "string", "contains", "only", "katakana" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L154-L156