id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
21,900
golang/mock
sample/concurrent/mock/concurrent_mock.go
NewMockMath
func NewMockMath(ctrl *gomock.Controller) *MockMath { mock := &MockMath{ctrl: ctrl} mock.recorder = &MockMathMockRecorder{mock} return mock }
go
func NewMockMath(ctrl *gomock.Controller) *MockMath { mock := &MockMath{ctrl: ctrl} mock.recorder = &MockMathMockRecorder{mock} return mock }
[ "func", "NewMockMath", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockMath", "{", "mock", ":=", "&", "MockMath", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockMathMockRecorder", "{", "mock", "}", "\n", "ret...
// NewMockMath creates a new mock instance
[ "NewMockMath", "creates", "a", "new", "mock", "instance" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/concurrent/mock/concurrent_mock.go#L24-L28
21,901
golang/mock
sample/concurrent/mock/concurrent_mock.go
Sum
func (m *MockMath) Sum(arg0, arg1 int) int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Sum", arg0, arg1) ret0, _ := ret[0].(int) return ret0 }
go
func (m *MockMath) Sum(arg0, arg1 int) int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Sum", arg0, arg1) ret0, _ := ret[0].(int) return ret0 }
[ "func", "(", "m", "*", "MockMath", ")", "Sum", "(", "arg0", ",", "arg1", "int", ")", "int", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ...
// Sum mocks base method
[ "Sum", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/concurrent/mock/concurrent_mock.go#L36-L41
21,902
golang/mock
sample/concurrent/mock/concurrent_mock.go
Sum
func (mr *MockMathMockRecorder) Sum(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sum", reflect.TypeOf((*MockMath)(nil).Sum), arg0, arg1) }
go
func (mr *MockMathMockRecorder) Sum(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sum", reflect.TypeOf((*MockMath)(nil).Sum), arg0, arg1) }
[ "func", "(", "mr", "*", "MockMathMockRecorder", ")", "Sum", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "return", "mr", ".", "mock...
// Sum indicates an expected call of Sum
[ "Sum", "indicates", "an", "expected", "call", "of", "Sum" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/concurrent/mock/concurrent_mock.go#L44-L47
21,903
golang/mock
mockgen/reflect.go
run
func run(program string) (*model.Package, error) { f, err := ioutil.TempFile("", "") if err != nil { return nil, err } filename := f.Name() defer os.Remove(filename) if err := f.Close(); err != nil { return nil, err } // Run the program. cmd := exec.Command(program, "-output", filename) cmd.Stdout = os....
go
func run(program string) (*model.Package, error) { f, err := ioutil.TempFile("", "") if err != nil { return nil, err } filename := f.Name() defer os.Remove(filename) if err := f.Close(); err != nil { return nil, err } // Run the program. cmd := exec.Command(program, "-output", filename) cmd.Stdout = os....
[ "func", "run", "(", "program", "string", ")", "(", "*", "model", ".", "Package", ",", "error", ")", "{", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ni...
// run the given program and parse the output as a model.Package.
[ "run", "the", "given", "program", "and", "parse", "the", "output", "as", "a", "model", ".", "Package", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/reflect.go#L54-L90
21,904
golang/mock
mockgen/reflect.go
runInDir
func runInDir(program []byte, dir string) (*model.Package, error) { // We use TempDir instead of TempFile so we can control the filename. tmpDir, err := ioutil.TempDir(dir, "gomock_reflect_") if err != nil { return nil, err } defer func() { if err := os.RemoveAll(tmpDir); err != nil { log.Printf("failed to ...
go
func runInDir(program []byte, dir string) (*model.Package, error) { // We use TempDir instead of TempFile so we can control the filename. tmpDir, err := ioutil.TempDir(dir, "gomock_reflect_") if err != nil { return nil, err } defer func() { if err := os.RemoveAll(tmpDir); err != nil { log.Printf("failed to ...
[ "func", "runInDir", "(", "program", "[", "]", "byte", ",", "dir", "string", ")", "(", "*", "model", ".", "Package", ",", "error", ")", "{", "// We use TempDir instead of TempFile so we can control the filename.", "tmpDir", ",", "err", ":=", "ioutil", ".", "TempD...
// runInDir writes the given program into the given dir, runs it there, and // parses the output as a model.Package.
[ "runInDir", "writes", "the", "given", "program", "into", "the", "given", "dir", "runs", "it", "there", "and", "parses", "the", "output", "as", "a", "model", ".", "Package", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/reflect.go#L94-L132
21,905
golang/mock
sample/user.go
Remember
func Remember(index Index, keys []string, values []interface{}) { for i, k := range keys { index.Put(k, values[i]) } err := index.NillableRet() if err != nil { log.Fatalf("Woah! %v", err) } if len(keys) > 0 && keys[0] == "a" { index.Ellip("%d", 0, 1, 1, 2, 3) index.Ellip("%d", 1, 3, 6, 10, 15) index.Ell...
go
func Remember(index Index, keys []string, values []interface{}) { for i, k := range keys { index.Put(k, values[i]) } err := index.NillableRet() if err != nil { log.Fatalf("Woah! %v", err) } if len(keys) > 0 && keys[0] == "a" { index.Ellip("%d", 0, 1, 1, 2, 3) index.Ellip("%d", 1, 3, 6, 10, 15) index.Ell...
[ "func", "Remember", "(", "index", "Index", ",", "keys", "[", "]", "string", ",", "values", "[", "]", "interface", "{", "}", ")", "{", "for", "i", ",", "k", ":=", "range", "keys", "{", "index", ".", "Put", "(", "k", ",", "values", "[", "i", "]",...
// A function that we will test that uses the above interface. // It takes a list of keys and values, and puts them in the index.
[ "A", "function", "that", "we", "will", "test", "that", "uses", "the", "above", "interface", ".", "It", "takes", "a", "list", "of", "keys", "and", "values", "and", "puts", "them", "in", "the", "index", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/user.go#L95-L108
21,906
golang/mock
gomock/call.go
MinTimes
func (c *Call) MinTimes(n int) *Call { c.minCalls = n if c.maxCalls == 1 { c.maxCalls = 1e8 } return c }
go
func (c *Call) MinTimes(n int) *Call { c.minCalls = n if c.maxCalls == 1 { c.maxCalls = 1e8 } return c }
[ "func", "(", "c", "*", "Call", ")", "MinTimes", "(", "n", "int", ")", "*", "Call", "{", "c", ".", "minCalls", "=", "n", "\n", "if", "c", ".", "maxCalls", "==", "1", "{", "c", ".", "maxCalls", "=", "1e8", "\n", "}", "\n", "return", "c", "\n", ...
// MinTimes requires the call to occur at least n times. If AnyTimes or MaxTimes have not been called, MinTimes also // sets the maximum number of calls to infinity.
[ "MinTimes", "requires", "the", "call", "to", "occur", "at", "least", "n", "times", ".", "If", "AnyTimes", "or", "MaxTimes", "have", "not", "been", "called", "MinTimes", "also", "sets", "the", "maximum", "number", "of", "calls", "to", "infinity", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L87-L93
21,907
golang/mock
gomock/call.go
MaxTimes
func (c *Call) MaxTimes(n int) *Call { c.maxCalls = n if c.minCalls == 1 { c.minCalls = 0 } return c }
go
func (c *Call) MaxTimes(n int) *Call { c.maxCalls = n if c.minCalls == 1 { c.minCalls = 0 } return c }
[ "func", "(", "c", "*", "Call", ")", "MaxTimes", "(", "n", "int", ")", "*", "Call", "{", "c", ".", "maxCalls", "=", "n", "\n", "if", "c", ".", "minCalls", "==", "1", "{", "c", ".", "minCalls", "=", "0", "\n", "}", "\n", "return", "c", "\n", ...
// MaxTimes limits the number of calls to n times. If AnyTimes or MinTimes have not been called, MaxTimes also // sets the minimum number of calls to 0.
[ "MaxTimes", "limits", "the", "number", "of", "calls", "to", "n", "times", ".", "If", "AnyTimes", "or", "MinTimes", "have", "not", "been", "called", "MaxTimes", "also", "sets", "the", "minimum", "number", "of", "calls", "to", "0", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L97-L103
21,908
golang/mock
gomock/call.go
Return
func (c *Call) Return(rets ...interface{}) *Call { c.t.Helper() mt := c.methodType if len(rets) != mt.NumOut() { c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d [%s]", c.receiver, c.method, len(rets), mt.NumOut(), c.origin) } for i, ret := range rets { if got, want := reflect.Typ...
go
func (c *Call) Return(rets ...interface{}) *Call { c.t.Helper() mt := c.methodType if len(rets) != mt.NumOut() { c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d [%s]", c.receiver, c.method, len(rets), mt.NumOut(), c.origin) } for i, ret := range rets { if got, want := reflect.Typ...
[ "func", "(", "c", "*", "Call", ")", "Return", "(", "rets", "...", "interface", "{", "}", ")", "*", "Call", "{", "c", ".", "t", ".", "Helper", "(", ")", "\n\n", "mt", ":=", "c", ".", "methodType", "\n", "if", "len", "(", "rets", ")", "!=", "mt...
// Return declares the values to be returned by the mocked function call.
[ "Return", "declares", "the", "values", "to", "be", "returned", "by", "the", "mocked", "function", "call", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L159-L196
21,909
golang/mock
gomock/call.go
Times
func (c *Call) Times(n int) *Call { c.minCalls, c.maxCalls = n, n return c }
go
func (c *Call) Times(n int) *Call { c.minCalls, c.maxCalls = n, n return c }
[ "func", "(", "c", "*", "Call", ")", "Times", "(", "n", "int", ")", "*", "Call", "{", "c", ".", "minCalls", ",", "c", ".", "maxCalls", "=", "n", ",", "n", "\n", "return", "c", "\n", "}" ]
// Times declares the exact number of times a function call is expected to be executed.
[ "Times", "declares", "the", "exact", "number", "of", "times", "a", "function", "call", "is", "expected", "to", "be", "executed", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L199-L202
21,910
golang/mock
gomock/call.go
SetArg
func (c *Call) SetArg(n int, value interface{}) *Call { c.t.Helper() mt := c.methodType // TODO: This will break on variadic methods. // We will need to check those at invocation time. if n < 0 || n >= mt.NumIn() { c.t.Fatalf("SetArg(%d, ...) called for a method with %d args [%s]", n, mt.NumIn(), c.origin) ...
go
func (c *Call) SetArg(n int, value interface{}) *Call { c.t.Helper() mt := c.methodType // TODO: This will break on variadic methods. // We will need to check those at invocation time. if n < 0 || n >= mt.NumIn() { c.t.Fatalf("SetArg(%d, ...) called for a method with %d args [%s]", n, mt.NumIn(), c.origin) ...
[ "func", "(", "c", "*", "Call", ")", "SetArg", "(", "n", "int", ",", "value", "interface", "{", "}", ")", "*", "Call", "{", "c", ".", "t", ".", "Helper", "(", ")", "\n\n", "mt", ":=", "c", ".", "methodType", "\n", "// TODO: This will break on variadic...
// SetArg declares an action that will set the nth argument's value, // indirected through a pointer. Or, in the case of a slice, SetArg // will copy value's elements into the nth argument.
[ "SetArg", "declares", "an", "action", "that", "will", "set", "the", "nth", "argument", "s", "value", "indirected", "through", "a", "pointer", ".", "Or", "in", "the", "case", "of", "a", "slice", "SetArg", "will", "copy", "value", "s", "elements", "into", ...
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L207-L247
21,911
golang/mock
gomock/call.go
isPreReq
func (c *Call) isPreReq(other *Call) bool { for _, preReq := range c.preReqs { if other == preReq || preReq.isPreReq(other) { return true } } return false }
go
func (c *Call) isPreReq(other *Call) bool { for _, preReq := range c.preReqs { if other == preReq || preReq.isPreReq(other) { return true } } return false }
[ "func", "(", "c", "*", "Call", ")", "isPreReq", "(", "other", "*", "Call", ")", "bool", "{", "for", "_", ",", "preReq", ":=", "range", "c", ".", "preReqs", "{", "if", "other", "==", "preReq", "||", "preReq", ".", "isPreReq", "(", "other", ")", "{...
// isPreReq returns true if other is a direct or indirect prerequisite to c.
[ "isPreReq", "returns", "true", "if", "other", "is", "a", "direct", "or", "indirect", "prerequisite", "to", "c", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L250-L257
21,912
golang/mock
gomock/call.go
After
func (c *Call) After(preReq *Call) *Call { c.t.Helper() if c == preReq { c.t.Fatalf("A call isn't allowed to be its own prerequisite") } if preReq.isPreReq(c) { c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq) } c.preReqs = append(c.preReqs, preReq) return c }
go
func (c *Call) After(preReq *Call) *Call { c.t.Helper() if c == preReq { c.t.Fatalf("A call isn't allowed to be its own prerequisite") } if preReq.isPreReq(c) { c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq) } c.preReqs = append(c.preReqs, preReq) return c }
[ "func", "(", "c", "*", "Call", ")", "After", "(", "preReq", "*", "Call", ")", "*", "Call", "{", "c", ".", "t", ".", "Helper", "(", ")", "\n\n", "if", "c", "==", "preReq", "{", "c", ".", "t", ".", "Fatalf", "(", "\"", "\"", ")", "\n", "}", ...
// After declares that the call may only match after preReq has been exhausted.
[ "After", "declares", "that", "the", "call", "may", "only", "match", "after", "preReq", "has", "been", "exhausted", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L260-L272
21,913
golang/mock
gomock/call.go
dropPrereqs
func (c *Call) dropPrereqs() (preReqs []*Call) { preReqs = c.preReqs c.preReqs = nil return }
go
func (c *Call) dropPrereqs() (preReqs []*Call) { preReqs = c.preReqs c.preReqs = nil return }
[ "func", "(", "c", "*", "Call", ")", "dropPrereqs", "(", ")", "(", "preReqs", "[", "]", "*", "Call", ")", "{", "preReqs", "=", "c", ".", "preReqs", "\n", "c", ".", "preReqs", "=", "nil", "\n", "return", "\n", "}" ]
// dropPrereqs tells the expected Call to not re-check prerequisite calls any // longer, and to return its current set.
[ "dropPrereqs", "tells", "the", "expected", "Call", "to", "not", "re", "-", "check", "prerequisite", "calls", "any", "longer", "and", "to", "return", "its", "current", "set", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L393-L397
21,914
golang/mock
gomock/call.go
InOrder
func InOrder(calls ...*Call) { for i := 1; i < len(calls); i++ { calls[i].After(calls[i-1]) } }
go
func InOrder(calls ...*Call) { for i := 1; i < len(calls); i++ { calls[i].After(calls[i-1]) } }
[ "func", "InOrder", "(", "calls", "...", "*", "Call", ")", "{", "for", "i", ":=", "1", ";", "i", "<", "len", "(", "calls", ")", ";", "i", "++", "{", "calls", "[", "i", "]", ".", "After", "(", "calls", "[", "i", "-", "1", "]", ")", "\n", "}...
// InOrder declares that the given calls should occur in order.
[ "InOrder", "declares", "that", "the", "given", "calls", "should", "occur", "in", "order", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/call.go#L405-L409
21,915
golang/mock
mockgen/mockgen.go
sanitize
func sanitize(s string) string { t := "" for _, r := range s { if t == "" { if unicode.IsLetter(r) || r == '_' { t += string(r) continue } } else { if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { t += string(r) continue } } t += "_" } if t == "_" { t = "x" } return...
go
func sanitize(s string) string { t := "" for _, r := range s { if t == "" { if unicode.IsLetter(r) || r == '_' { t += string(r) continue } } else { if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { t += string(r) continue } } t += "_" } if t == "_" { t = "x" } return...
[ "func", "sanitize", "(", "s", "string", ")", "string", "{", "t", ":=", "\"", "\"", "\n", "for", "_", ",", "r", ":=", "range", "s", "{", "if", "t", "==", "\"", "\"", "{", "if", "unicode", ".", "IsLetter", "(", "r", ")", "||", "r", "==", "'_'",...
// sanitize cleans up a string to make a suitable package name.
[ "sanitize", "cleans", "up", "a", "string", "to", "make", "a", "suitable", "package", "name", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/mockgen.go#L215-L235
21,916
golang/mock
mockgen/mockgen.go
mockName
func (g *generator) mockName(typeName string) string { if mockName, ok := g.mockNames[typeName]; ok { return mockName } return "Mock" + typeName }
go
func (g *generator) mockName(typeName string) string { if mockName, ok := g.mockNames[typeName]; ok { return mockName } return "Mock" + typeName }
[ "func", "(", "g", "*", "generator", ")", "mockName", "(", "typeName", "string", ")", "string", "{", "if", "mockName", ",", "ok", ":=", "g", ".", "mockNames", "[", "typeName", "]", ";", "ok", "{", "return", "mockName", "\n", "}", "\n\n", "return", "\"...
// The name of the mock type to use for the given interface identifier.
[ "The", "name", "of", "the", "mock", "type", "to", "use", "for", "the", "given", "interface", "identifier", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/mockgen.go#L330-L336
21,917
golang/mock
mockgen/mockgen.go
GenerateMockMethod
func (g *generator) GenerateMockMethod(mockType string, m *model.Method, pkgOverride string) error { argNames := g.getArgNames(m) argTypes := g.getArgTypes(m, pkgOverride) argString := makeArgString(argNames, argTypes) rets := make([]string, len(m.Out)) for i, p := range m.Out { rets[i] = p.Type.String(g.packag...
go
func (g *generator) GenerateMockMethod(mockType string, m *model.Method, pkgOverride string) error { argNames := g.getArgNames(m) argTypes := g.getArgTypes(m, pkgOverride) argString := makeArgString(argNames, argTypes) rets := make([]string, len(m.Out)) for i, p := range m.Out { rets[i] = p.Type.String(g.packag...
[ "func", "(", "g", "*", "generator", ")", "GenerateMockMethod", "(", "mockType", "string", ",", "m", "*", "model", ".", "Method", ",", "pkgOverride", "string", ")", "error", "{", "argNames", ":=", "g", ".", "getArgNames", "(", "m", ")", "\n", "argTypes", ...
// GenerateMockMethod generates a mock method implementation. // If non-empty, pkgOverride is the package in which unqualified types reside.
[ "GenerateMockMethod", "generates", "a", "mock", "method", "implementation", ".", "If", "non", "-", "empty", "pkgOverride", "is", "the", "package", "in", "which", "unqualified", "types", "reside", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/mockgen.go#L411-L474
21,918
golang/mock
mockgen/mockgen.go
Output
func (g *generator) Output() []byte { src, err := format.Source(g.buf.Bytes()) if err != nil { log.Fatalf("Failed to format generated source code: %s\n%s", err, g.buf.String()) } return src }
go
func (g *generator) Output() []byte { src, err := format.Source(g.buf.Bytes()) if err != nil { log.Fatalf("Failed to format generated source code: %s\n%s", err, g.buf.String()) } return src }
[ "func", "(", "g", "*", "generator", ")", "Output", "(", ")", "[", "]", "byte", "{", "src", ",", "err", ":=", "format", ".", "Source", "(", "g", ".", "buf", ".", "Bytes", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf"...
// Output returns the generator's output, formatted in the standard Go style.
[ "Output", "returns", "the", "generator", "s", "output", "formatted", "in", "the", "standard", "Go", "style", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/mockgen.go#L582-L588
21,919
golang/mock
gomock/callset.go
Add
func (cs callSet) Add(call *Call) { key := callSetKey{call.receiver, call.method} m := cs.expected if call.exhausted() { m = cs.exhausted } m[key] = append(m[key], call) }
go
func (cs callSet) Add(call *Call) { key := callSetKey{call.receiver, call.method} m := cs.expected if call.exhausted() { m = cs.exhausted } m[key] = append(m[key], call) }
[ "func", "(", "cs", "callSet", ")", "Add", "(", "call", "*", "Call", ")", "{", "key", ":=", "callSetKey", "{", "call", ".", "receiver", ",", "call", ".", "method", "}", "\n", "m", ":=", "cs", ".", "expected", "\n", "if", "call", ".", "exhausted", ...
// Add adds a new expected call.
[ "Add", "adds", "a", "new", "expected", "call", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/callset.go#L42-L49
21,920
golang/mock
gomock/callset.go
Remove
func (cs callSet) Remove(call *Call) { key := callSetKey{call.receiver, call.method} calls := cs.expected[key] for i, c := range calls { if c == call { // maintain order for remaining calls cs.expected[key] = append(calls[:i], calls[i+1:]...) cs.exhausted[key] = append(cs.exhausted[key], call) break ...
go
func (cs callSet) Remove(call *Call) { key := callSetKey{call.receiver, call.method} calls := cs.expected[key] for i, c := range calls { if c == call { // maintain order for remaining calls cs.expected[key] = append(calls[:i], calls[i+1:]...) cs.exhausted[key] = append(cs.exhausted[key], call) break ...
[ "func", "(", "cs", "callSet", ")", "Remove", "(", "call", "*", "Call", ")", "{", "key", ":=", "callSetKey", "{", "call", ".", "receiver", ",", "call", ".", "method", "}", "\n", "calls", ":=", "cs", ".", "expected", "[", "key", "]", "\n", "for", "...
// Remove removes an expected call.
[ "Remove", "removes", "an", "expected", "call", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/callset.go#L52-L63
21,921
golang/mock
gomock/callset.go
FindMatch
func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) (*Call, error) { key := callSetKey{receiver, method} // Search through the expected calls. expected := cs.expected[key] var callsErrors bytes.Buffer for _, call := range expected { err := call.matches(args) if err != nil { ...
go
func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) (*Call, error) { key := callSetKey{receiver, method} // Search through the expected calls. expected := cs.expected[key] var callsErrors bytes.Buffer for _, call := range expected { err := call.matches(args) if err != nil { ...
[ "func", "(", "cs", "callSet", ")", "FindMatch", "(", "receiver", "interface", "{", "}", ",", "method", "string", ",", "args", "[", "]", "interface", "{", "}", ")", "(", "*", "Call", ",", "error", ")", "{", "key", ":=", "callSetKey", "{", "receiver", ...
// FindMatch searches for a matching call. Returns error with explanation message if no call matched.
[ "FindMatch", "searches", "for", "a", "matching", "call", ".", "Returns", "error", "with", "explanation", "message", "if", "no", "call", "matched", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/callset.go#L66-L95
21,922
golang/mock
gomock/callset.go
Failures
func (cs callSet) Failures() []*Call { failures := make([]*Call, 0, len(cs.expected)) for _, calls := range cs.expected { for _, call := range calls { if !call.satisfied() { failures = append(failures, call) } } } return failures }
go
func (cs callSet) Failures() []*Call { failures := make([]*Call, 0, len(cs.expected)) for _, calls := range cs.expected { for _, call := range calls { if !call.satisfied() { failures = append(failures, call) } } } return failures }
[ "func", "(", "cs", "callSet", ")", "Failures", "(", ")", "[", "]", "*", "Call", "{", "failures", ":=", "make", "(", "[", "]", "*", "Call", ",", "0", ",", "len", "(", "cs", ".", "expected", ")", ")", "\n", "for", "_", ",", "calls", ":=", "rang...
// Failures returns the calls that are not satisfied.
[ "Failures", "returns", "the", "calls", "that", "are", "not", "satisfied", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/callset.go#L98-L108
21,923
golang/mock
sample/mock_user/mock_user.go
NewMockIndex
func NewMockIndex(ctrl *gomock.Controller) *MockIndex { mock := &MockIndex{ctrl: ctrl} mock.recorder = &MockIndexMockRecorder{mock} return mock }
go
func NewMockIndex(ctrl *gomock.Controller) *MockIndex { mock := &MockIndex{ctrl: ctrl} mock.recorder = &MockIndexMockRecorder{mock} return mock }
[ "func", "NewMockIndex", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockIndex", "{", "mock", ":=", "&", "MockIndex", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockIndexMockRecorder", "{", "mock", "}", "\n", ...
// NewMockIndex creates a new mock instance
[ "NewMockIndex", "creates", "a", "new", "mock", "instance" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L35-L39
21,924
golang/mock
sample/mock_user/mock_user.go
Anon
func (m *MockIndex) Anon(arg0 string) { m.ctrl.T.Helper() m.ctrl.Call(m, "Anon", arg0) }
go
func (m *MockIndex) Anon(arg0 string) { m.ctrl.T.Helper() m.ctrl.Call(m, "Anon", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "Anon", "(", "arg0", "string", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// Anon mocks base method
[ "Anon", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L47-L50
21,925
golang/mock
sample/mock_user/mock_user.go
Anon
func (mr *MockIndexMockRecorder) Anon(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Anon", reflect.TypeOf((*MockIndex)(nil).Anon), arg0) }
go
func (mr *MockIndexMockRecorder) Anon(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Anon", reflect.TypeOf((*MockIndex)(nil).Anon), arg0) }
[ "func", "(", "mr", "*", "MockIndexMockRecorder", ")", "Anon", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "return", "mr", ".", "mock", ".", "ct...
// Anon indicates an expected call of Anon
[ "Anon", "indicates", "an", "expected", "call", "of", "Anon" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L53-L56
21,926
golang/mock
sample/mock_user/mock_user.go
Chan
func (m *MockIndex) Chan(arg0 chan int, arg1 chan<- hash.Hash) { m.ctrl.T.Helper() m.ctrl.Call(m, "Chan", arg0, arg1) }
go
func (m *MockIndex) Chan(arg0 chan int, arg1 chan<- hash.Hash) { m.ctrl.T.Helper() m.ctrl.Call(m, "Chan", arg0, arg1) }
[ "func", "(", "m", "*", "MockIndex", ")", "Chan", "(", "arg0", "chan", "int", ",", "arg1", "chan", "<-", "hash", ".", "Hash", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", ...
// Chan mocks base method
[ "Chan", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L59-L62
21,927
golang/mock
sample/mock_user/mock_user.go
ConcreteRet
func (m *MockIndex) ConcreteRet() chan<- bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ConcreteRet") ret0, _ := ret[0].(chan<- bool) return ret0 }
go
func (m *MockIndex) ConcreteRet() chan<- bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ConcreteRet") ret0, _ := ret[0].(chan<- bool) return ret0 }
[ "func", "(", "m", "*", "MockIndex", ")", "ConcreteRet", "(", ")", "chan", "<-", "bool", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ...
// ConcreteRet mocks base method
[ "ConcreteRet", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L71-L76
21,928
golang/mock
sample/mock_user/mock_user.go
Ellip
func (mr *MockIndexMockRecorder) Ellip(arg0 interface{}, arg1 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{arg0}, arg1...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ellip", reflect.TypeOf((*MockIndex)(nil).Ellip), varargs...) }
go
func (mr *MockIndexMockRecorder) Ellip(arg0 interface{}, arg1 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{arg0}, arg1...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ellip", reflect.TypeOf((*MockIndex)(nil).Ellip), varargs...) }
[ "func", "(", "mr", "*", "MockIndexMockRecorder", ")", "Ellip", "(", "arg0", "interface", "{", "}", ",", "arg1", "...", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", ...
// Ellip indicates an expected call of Ellip
[ "Ellip", "indicates", "an", "expected", "call", "of", "Ellip" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L95-L99
21,929
golang/mock
sample/mock_user/mock_user.go
EllipOnly
func (m *MockIndex) EllipOnly(arg0 ...string) { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { varargs = append(varargs, a) } m.ctrl.Call(m, "EllipOnly", varargs...) }
go
func (m *MockIndex) EllipOnly(arg0 ...string) { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { varargs = append(varargs, a) } m.ctrl.Call(m, "EllipOnly", varargs...) }
[ "func", "(", "m", "*", "MockIndex", ")", "EllipOnly", "(", "arg0", "...", "string", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "varargs", ":=", "[", "]", "interface", "{", "}", "{", "}", "\n", "for", "_", ",", "a", "...
// EllipOnly mocks base method
[ "EllipOnly", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L102-L109
21,930
golang/mock
sample/mock_user/mock_user.go
ForeignFour
func (m *MockIndex) ForeignFour(arg0 imp4.Imp4) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignFour", arg0) }
go
func (m *MockIndex) ForeignFour(arg0 imp4.Imp4) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignFour", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "ForeignFour", "(", "arg0", "imp4", ".", "Imp4", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", ...
// ForeignFour mocks base method
[ "ForeignFour", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L118-L121
21,931
golang/mock
sample/mock_user/mock_user.go
ForeignOne
func (m *MockIndex) ForeignOne(arg0 imp1.Imp1) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignOne", arg0) }
go
func (m *MockIndex) ForeignOne(arg0 imp1.Imp1) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignOne", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "ForeignOne", "(", "arg0", "imp1", ".", "Imp1", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", ...
// ForeignOne mocks base method
[ "ForeignOne", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L130-L133
21,932
golang/mock
sample/mock_user/mock_user.go
ForeignThree
func (m *MockIndex) ForeignThree(arg0 imp3.Imp3) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignThree", arg0) }
go
func (m *MockIndex) ForeignThree(arg0 imp3.Imp3) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignThree", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "ForeignThree", "(", "arg0", "imp3", ".", "Imp3", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", ...
// ForeignThree mocks base method
[ "ForeignThree", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L142-L145
21,933
golang/mock
sample/mock_user/mock_user.go
ForeignTwo
func (m *MockIndex) ForeignTwo(arg0 imp2.Imp2) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignTwo", arg0) }
go
func (m *MockIndex) ForeignTwo(arg0 imp2.Imp2) { m.ctrl.T.Helper() m.ctrl.Call(m, "ForeignTwo", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "ForeignTwo", "(", "arg0", "imp2", ".", "Imp2", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", ...
// ForeignTwo mocks base method
[ "ForeignTwo", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L154-L157
21,934
golang/mock
sample/mock_user/mock_user.go
Func
func (m *MockIndex) Func(arg0 func(http.Request) (int, bool)) { m.ctrl.T.Helper() m.ctrl.Call(m, "Func", arg0) }
go
func (m *MockIndex) Func(arg0 func(http.Request) (int, bool)) { m.ctrl.T.Helper() m.ctrl.Call(m, "Func", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "Func", "(", "arg0", "func", "(", "http", ".", "Request", ")", "(", "int", ",", "bool", ")", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "...
// Func mocks base method
[ "Func", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L166-L169
21,935
golang/mock
sample/mock_user/mock_user.go
GetTwo
func (m *MockIndex) GetTwo(arg0, arg1 string) (interface{}, interface{}) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetTwo", arg0, arg1) ret0, _ := ret[0].(interface{}) ret1, _ := ret[1].(interface{}) return ret0, ret1 }
go
func (m *MockIndex) GetTwo(arg0, arg1 string) (interface{}, interface{}) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetTwo", arg0, arg1) ret0, _ := ret[0].(interface{}) ret1, _ := ret[1].(interface{}) return ret0, ret1 }
[ "func", "(", "m", "*", "MockIndex", ")", "GetTwo", "(", "arg0", ",", "arg1", "string", ")", "(", "interface", "{", "}", ",", "interface", "{", "}", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "c...
// GetTwo mocks base method
[ "GetTwo", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L192-L198
21,936
golang/mock
sample/mock_user/mock_user.go
Map
func (m *MockIndex) Map(arg0 map[int]hash.Hash) { m.ctrl.T.Helper() m.ctrl.Call(m, "Map", arg0) }
go
func (m *MockIndex) Map(arg0 map[int]hash.Hash) { m.ctrl.T.Helper() m.ctrl.Call(m, "Map", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "Map", "(", "arg0", "map", "[", "int", "]", "hash", ".", "Hash", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", ...
// Map mocks base method
[ "Map", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L207-L210
21,937
golang/mock
sample/mock_user/mock_user.go
NillableRet
func (m *MockIndex) NillableRet() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NillableRet") ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockIndex) NillableRet() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NillableRet") ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockIndex", ")", "NillableRet", "(", ")", "error", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", "...
// NillableRet mocks base method
[ "NillableRet", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L219-L224
21,938
golang/mock
sample/mock_user/mock_user.go
Other
func (m *MockIndex) Other() hash.Hash { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Other") ret0, _ := ret[0].(hash.Hash) return ret0 }
go
func (m *MockIndex) Other() hash.Hash { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Other") ret0, _ := ret[0].(hash.Hash) return ret0 }
[ "func", "(", "m", "*", "MockIndex", ")", "Other", "(", ")", "hash", ".", "Hash", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", ...
// Other mocks base method
[ "Other", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L233-L238
21,939
golang/mock
sample/mock_user/mock_user.go
Ptr
func (m *MockIndex) Ptr(arg0 *int) { m.ctrl.T.Helper() m.ctrl.Call(m, "Ptr", arg0) }
go
func (m *MockIndex) Ptr(arg0 *int) { m.ctrl.T.Helper() m.ctrl.Call(m, "Ptr", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "Ptr", "(", "arg0", "*", "int", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// Ptr mocks base method
[ "Ptr", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L247-L250
21,940
golang/mock
sample/mock_user/mock_user.go
Slice
func (m *MockIndex) Slice(arg0 []int, arg1 []byte) [3]int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Slice", arg0, arg1) ret0, _ := ret[0].([3]int) return ret0 }
go
func (m *MockIndex) Slice(arg0 []int, arg1 []byte) [3]int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Slice", arg0, arg1) ret0, _ := ret[0].([3]int) return ret0 }
[ "func", "(", "m", "*", "MockIndex", ")", "Slice", "(", "arg0", "[", "]", "int", ",", "arg1", "[", "]", "byte", ")", "[", "3", "]", "int", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", ...
// Slice mocks base method
[ "Slice", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L271-L276
21,941
golang/mock
sample/mock_user/mock_user.go
Struct
func (m *MockIndex) Struct(arg0 struct{}) { m.ctrl.T.Helper() m.ctrl.Call(m, "Struct", arg0) }
go
func (m *MockIndex) Struct(arg0 struct{}) { m.ctrl.T.Helper() m.ctrl.Call(m, "Struct", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "Struct", "(", "arg0", "struct", "{", "}", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// Struct mocks base method
[ "Struct", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L285-L288
21,942
golang/mock
sample/mock_user/mock_user.go
StructChan
func (m *MockIndex) StructChan(arg0 chan struct{}) { m.ctrl.T.Helper() m.ctrl.Call(m, "StructChan", arg0) }
go
func (m *MockIndex) StructChan(arg0 chan struct{}) { m.ctrl.T.Helper() m.ctrl.Call(m, "StructChan", arg0) }
[ "func", "(", "m", "*", "MockIndex", ")", "StructChan", "(", "arg0", "chan", "struct", "{", "}", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", ...
// StructChan mocks base method
[ "StructChan", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L297-L300
21,943
golang/mock
sample/mock_user/mock_user.go
Summary
func (m *MockIndex) Summary(arg0 *bytes.Buffer, arg1 io.Writer) { m.ctrl.T.Helper() m.ctrl.Call(m, "Summary", arg0, arg1) }
go
func (m *MockIndex) Summary(arg0 *bytes.Buffer, arg1 io.Writer) { m.ctrl.T.Helper() m.ctrl.Call(m, "Summary", arg0, arg1) }
[ "func", "(", "m", "*", "MockIndex", ")", "Summary", "(", "arg0", "*", "bytes", ".", "Buffer", ",", "arg1", "io", ".", "Writer", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",",...
// Summary mocks base method
[ "Summary", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L309-L312
21,944
golang/mock
sample/mock_user/mock_user.go
Templates
func (m *MockIndex) Templates(arg0 template.CSS, arg1 template0.FuncMap) { m.ctrl.T.Helper() m.ctrl.Call(m, "Templates", arg0, arg1) }
go
func (m *MockIndex) Templates(arg0 template.CSS, arg1 template0.FuncMap) { m.ctrl.T.Helper() m.ctrl.Call(m, "Templates", arg0, arg1) }
[ "func", "(", "m", "*", "MockIndex", ")", "Templates", "(", "arg0", "template", ".", "CSS", ",", "arg1", "template0", ".", "FuncMap", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", "...
// Templates mocks base method
[ "Templates", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L321-L324
21,945
golang/mock
sample/mock_user/mock_user.go
NewMockEmbed
func NewMockEmbed(ctrl *gomock.Controller) *MockEmbed { mock := &MockEmbed{ctrl: ctrl} mock.recorder = &MockEmbedMockRecorder{mock} return mock }
go
func NewMockEmbed(ctrl *gomock.Controller) *MockEmbed { mock := &MockEmbed{ctrl: ctrl} mock.recorder = &MockEmbedMockRecorder{mock} return mock }
[ "func", "NewMockEmbed", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockEmbed", "{", "mock", ":=", "&", "MockEmbed", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockEmbedMockRecorder", "{", "mock", "}", "\n", ...
// NewMockEmbed creates a new mock instance
[ "NewMockEmbed", "creates", "a", "new", "mock", "instance" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L344-L348
21,946
golang/mock
sample/mock_user/mock_user.go
ForeignEmbeddedMethod
func (m *MockEmbed) ForeignEmbeddedMethod() *bufio.Reader { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ForeignEmbeddedMethod") ret0, _ := ret[0].(*bufio.Reader) return ret0 }
go
func (m *MockEmbed) ForeignEmbeddedMethod() *bufio.Reader { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ForeignEmbeddedMethod") ret0, _ := ret[0].(*bufio.Reader) return ret0 }
[ "func", "(", "m", "*", "MockEmbed", ")", "ForeignEmbeddedMethod", "(", ")", "*", "bufio", ".", "Reader", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")",...
// ForeignEmbeddedMethod mocks base method
[ "ForeignEmbeddedMethod", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L368-L373
21,947
golang/mock
sample/mock_user/mock_user.go
ForeignEmbeddedMethod
func (mr *MockEmbedMockRecorder) ForeignEmbeddedMethod() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForeignEmbeddedMethod", reflect.TypeOf((*MockEmbed)(nil).ForeignEmbeddedMethod)) }
go
func (mr *MockEmbedMockRecorder) ForeignEmbeddedMethod() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForeignEmbeddedMethod", reflect.TypeOf((*MockEmbed)(nil).ForeignEmbeddedMethod)) }
[ "func", "(", "mr", "*", "MockEmbedMockRecorder", ")", "ForeignEmbeddedMethod", "(", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordC...
// ForeignEmbeddedMethod indicates an expected call of ForeignEmbeddedMethod
[ "ForeignEmbeddedMethod", "indicates", "an", "expected", "call", "of", "ForeignEmbeddedMethod" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L376-L379
21,948
golang/mock
sample/mock_user/mock_user.go
ImplicitPackage
func (m *MockEmbed) ImplicitPackage(arg0 string, arg1 imp1.ImpT, arg2 []imp1.ImpT, arg3 *imp1.ImpT, arg4 chan imp1.ImpT) { m.ctrl.T.Helper() m.ctrl.Call(m, "ImplicitPackage", arg0, arg1, arg2, arg3, arg4) }
go
func (m *MockEmbed) ImplicitPackage(arg0 string, arg1 imp1.ImpT, arg2 []imp1.ImpT, arg3 *imp1.ImpT, arg4 chan imp1.ImpT) { m.ctrl.T.Helper() m.ctrl.Call(m, "ImplicitPackage", arg0, arg1, arg2, arg3, arg4) }
[ "func", "(", "m", "*", "MockEmbed", ")", "ImplicitPackage", "(", "arg0", "string", ",", "arg1", "imp1", ".", "ImpT", ",", "arg2", "[", "]", "imp1", ".", "ImpT", ",", "arg3", "*", "imp1", ".", "ImpT", ",", "arg4", "chan", "imp1", ".", "ImpT", ")", ...
// ImplicitPackage mocks base method
[ "ImplicitPackage", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L382-L385
21,949
golang/mock
sample/mock_user/mock_user.go
ImplicitPackage
func (mr *MockEmbedMockRecorder) ImplicitPackage(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImplicitPackage", reflect.TypeOf((*MockEmbed)(nil).ImplicitPackage), arg0, arg1, arg2, arg3, arg4) }
go
func (mr *MockEmbedMockRecorder) ImplicitPackage(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImplicitPackage", reflect.TypeOf((*MockEmbed)(nil).ImplicitPackage), arg0, arg1, arg2, arg3, arg4) }
[ "func", "(", "mr", "*", "MockEmbedMockRecorder", ")", "ImplicitPackage", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "H...
// ImplicitPackage indicates an expected call of ImplicitPackage
[ "ImplicitPackage", "indicates", "an", "expected", "call", "of", "ImplicitPackage" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L388-L391
21,950
golang/mock
sample/mock_user/mock_user.go
RegularMethod
func (m *MockEmbed) RegularMethod() { m.ctrl.T.Helper() m.ctrl.Call(m, "RegularMethod") }
go
func (m *MockEmbed) RegularMethod() { m.ctrl.T.Helper() m.ctrl.Call(m, "RegularMethod") }
[ "func", "(", "m", "*", "MockEmbed", ")", "RegularMethod", "(", ")", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "}" ]
// RegularMethod mocks base method
[ "RegularMethod", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L394-L397
21,951
golang/mock
sample/mock_user/mock_user.go
NewMockEmbedded
func NewMockEmbedded(ctrl *gomock.Controller) *MockEmbedded { mock := &MockEmbedded{ctrl: ctrl} mock.recorder = &MockEmbeddedMockRecorder{mock} return mock }
go
func NewMockEmbedded(ctrl *gomock.Controller) *MockEmbedded { mock := &MockEmbedded{ctrl: ctrl} mock.recorder = &MockEmbeddedMockRecorder{mock} return mock }
[ "func", "NewMockEmbedded", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockEmbedded", "{", "mock", ":=", "&", "MockEmbedded", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockEmbeddedMockRecorder", "{", "mock", "}"...
// NewMockEmbedded creates a new mock instance
[ "NewMockEmbedded", "creates", "a", "new", "mock", "instance" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L417-L421
21,952
golang/mock
sample/mock_user/mock_user.go
EmbeddedMethod
func (mr *MockEmbeddedMockRecorder) EmbeddedMethod() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EmbeddedMethod", reflect.TypeOf((*MockEmbedded)(nil).EmbeddedMethod)) }
go
func (mr *MockEmbeddedMockRecorder) EmbeddedMethod() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EmbeddedMethod", reflect.TypeOf((*MockEmbedded)(nil).EmbeddedMethod)) }
[ "func", "(", "mr", "*", "MockEmbeddedMockRecorder", ")", "EmbeddedMethod", "(", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallW...
// EmbeddedMethod indicates an expected call of EmbeddedMethod
[ "EmbeddedMethod", "indicates", "an", "expected", "call", "of", "EmbeddedMethod" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/sample/mock_user/mock_user.go#L435-L438
21,953
golang/mock
gomock/internal/mock_gomock/mock_matcher.go
NewMockMatcher
func NewMockMatcher(ctrl *gomock.Controller) *MockMatcher { mock := &MockMatcher{ctrl: ctrl} mock.recorder = &MockMatcherMockRecorder{mock} return mock }
go
func NewMockMatcher(ctrl *gomock.Controller) *MockMatcher { mock := &MockMatcher{ctrl: ctrl} mock.recorder = &MockMatcherMockRecorder{mock} return mock }
[ "func", "NewMockMatcher", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockMatcher", "{", "mock", ":=", "&", "MockMatcher", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockMatcherMockRecorder", "{", "mock", "}", ...
// NewMockMatcher creates a new mock instance
[ "NewMockMatcher", "creates", "a", "new", "mock", "instance" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/internal/mock_gomock/mock_matcher.go#L24-L28
21,954
golang/mock
gomock/internal/mock_gomock/mock_matcher.go
Matches
func (m *MockMatcher) Matches(arg0 interface{}) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Matches", arg0) ret0, _ := ret[0].(bool) return ret0 }
go
func (m *MockMatcher) Matches(arg0 interface{}) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Matches", arg0) ret0, _ := ret[0].(bool) return ret0 }
[ "func", "(", "m", "*", "MockMatcher", ")", "Matches", "(", "arg0", "interface", "{", "}", ")", "bool", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",",...
// Matches mocks base method
[ "Matches", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/internal/mock_gomock/mock_matcher.go#L36-L41
21,955
golang/mock
gomock/internal/mock_gomock/mock_matcher.go
Matches
func (mr *MockMatcherMockRecorder) Matches(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Matches", reflect.TypeOf((*MockMatcher)(nil).Matches), arg0) }
go
func (mr *MockMatcherMockRecorder) Matches(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Matches", reflect.TypeOf((*MockMatcher)(nil).Matches), arg0) }
[ "func", "(", "mr", "*", "MockMatcherMockRecorder", ")", "Matches", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "mr", ".", "mock", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "return", "mr", ".", "mock", ".", ...
// Matches indicates an expected call of Matches
[ "Matches", "indicates", "an", "expected", "call", "of", "Matches" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/internal/mock_gomock/mock_matcher.go#L44-L47
21,956
golang/mock
gomock/internal/mock_gomock/mock_matcher.go
String
func (m *MockMatcher) String() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "String") ret0, _ := ret[0].(string) return ret0 }
go
func (m *MockMatcher) String() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "String") ret0, _ := ret[0].(string) return ret0 }
[ "func", "(", "m", "*", "MockMatcher", ")", "String", "(", ")", "string", "{", "m", ".", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=...
// String mocks base method
[ "String", "mocks", "base", "method" ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/internal/mock_gomock/mock_matcher.go#L50-L55
21,957
golang/mock
mockgen/parse.go
parseFile
func (p *fileParser) parseFile(importPath string, file *ast.File) (*model.Package, error) { allImports, dotImports := importsOfFile(file) // Don't stomp imports provided by -imports. Those should take precedence. for pkg, path := range allImports { if _, ok := p.imports[pkg]; !ok { p.imports[pkg] = path } } ...
go
func (p *fileParser) parseFile(importPath string, file *ast.File) (*model.Package, error) { allImports, dotImports := importsOfFile(file) // Don't stomp imports provided by -imports. Those should take precedence. for pkg, path := range allImports { if _, ok := p.imports[pkg]; !ok { p.imports[pkg] = path } } ...
[ "func", "(", "p", "*", "fileParser", ")", "parseFile", "(", "importPath", "string", ",", "file", "*", "ast", ".", "File", ")", "(", "*", "model", ".", "Package", ",", "error", ")", "{", "allImports", ",", "dotImports", ":=", "importsOfFile", "(", "file...
// parseFile loads all file imports and auxiliary files import into the // fileParser, parses all file interfaces and returns package model.
[ "parseFile", "loads", "all", "file", "imports", "and", "auxiliary", "files", "import", "into", "the", "fileParser", "parses", "all", "file", "interfaces", "and", "returns", "package", "model", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/parse.go#L161-L193
21,958
golang/mock
mockgen/parse.go
parsePackage
func (p *fileParser) parsePackage(path string) error { var pkgs map[string]*ast.Package if imp, err := build.Import(path, p.srcDir, build.FindOnly); err != nil { return err } else if pkgs, err = parser.ParseDir(p.fileSet, imp.Dir, nil, 0); err != nil { return err } for _, pkg := range pkgs { file := ast.Merg...
go
func (p *fileParser) parsePackage(path string) error { var pkgs map[string]*ast.Package if imp, err := build.Import(path, p.srcDir, build.FindOnly); err != nil { return err } else if pkgs, err = parser.ParseDir(p.fileSet, imp.Dir, nil, 0); err != nil { return err } for _, pkg := range pkgs { file := ast.Merg...
[ "func", "(", "p", "*", "fileParser", ")", "parsePackage", "(", "path", "string", ")", "error", "{", "var", "pkgs", "map", "[", "string", "]", "*", "ast", ".", "Package", "\n", "if", "imp", ",", "err", ":=", "build", ".", "Import", "(", "path", ",",...
// parsePackage loads package specified by path, parses it and populates // corresponding imports and importedInterfaces into the fileParser.
[ "parsePackage", "loads", "package", "specified", "by", "path", "parses", "it", "and", "populates", "corresponding", "imports", "and", "importedInterfaces", "into", "the", "fileParser", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/parse.go#L197-L220
21,959
golang/mock
mockgen/parse.go
importsOfFile
func importsOfFile(file *ast.File) (normalImports map[string]string, dotImports []string) { normalImports = make(map[string]string) dotImports = make([]string, 0) for _, is := range file.Imports { var pkgName string importPath := is.Path.Value[1 : len(is.Path.Value)-1] // remove quotes if is.Name != nil { ...
go
func importsOfFile(file *ast.File) (normalImports map[string]string, dotImports []string) { normalImports = make(map[string]string) dotImports = make([]string, 0) for _, is := range file.Imports { var pkgName string importPath := is.Path.Value[1 : len(is.Path.Value)-1] // remove quotes if is.Name != nil { ...
[ "func", "importsOfFile", "(", "file", "*", "ast", ".", "File", ")", "(", "normalImports", "map", "[", "string", "]", "string", ",", "dotImports", "[", "]", "string", ")", "{", "normalImports", "=", "make", "(", "map", "[", "string", "]", "string", ")",...
// importsOfFile returns a map of package name to import path // of the imports in file.
[ "importsOfFile", "returns", "a", "map", "of", "package", "name", "to", "import", "path", "of", "the", "imports", "in", "file", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/parse.go#L444-L481
21,960
golang/mock
mockgen/parse.go
iterInterfaces
func iterInterfaces(file *ast.File) <-chan namedInterface { ch := make(chan namedInterface) go func() { for _, decl := range file.Decls { gd, ok := decl.(*ast.GenDecl) if !ok || gd.Tok != token.TYPE { continue } for _, spec := range gd.Specs { ts, ok := spec.(*ast.TypeSpec) if !ok { con...
go
func iterInterfaces(file *ast.File) <-chan namedInterface { ch := make(chan namedInterface) go func() { for _, decl := range file.Decls { gd, ok := decl.(*ast.GenDecl) if !ok || gd.Tok != token.TYPE { continue } for _, spec := range gd.Specs { ts, ok := spec.(*ast.TypeSpec) if !ok { con...
[ "func", "iterInterfaces", "(", "file", "*", "ast", ".", "File", ")", "<-", "chan", "namedInterface", "{", "ch", ":=", "make", "(", "chan", "namedInterface", ")", "\n", "go", "func", "(", ")", "{", "for", "_", ",", "decl", ":=", "range", "file", ".", ...
// Create an iterator over all interfaces in file.
[ "Create", "an", "iterator", "over", "all", "interfaces", "in", "file", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/parse.go#L489-L513
21,961
golang/mock
mockgen/parse.go
isVariadic
func isVariadic(f *ast.FuncType) bool { nargs := len(f.Params.List) if nargs == 0 { return false } _, ok := f.Params.List[nargs-1].Type.(*ast.Ellipsis) return ok }
go
func isVariadic(f *ast.FuncType) bool { nargs := len(f.Params.List) if nargs == 0 { return false } _, ok := f.Params.List[nargs-1].Type.(*ast.Ellipsis) return ok }
[ "func", "isVariadic", "(", "f", "*", "ast", ".", "FuncType", ")", "bool", "{", "nargs", ":=", "len", "(", "f", ".", "Params", ".", "List", ")", "\n", "if", "nargs", "==", "0", "{", "return", "false", "\n", "}", "\n", "_", ",", "ok", ":=", "f", ...
// isVariadic returns whether the function is variadic.
[ "isVariadic", "returns", "whether", "the", "function", "is", "variadic", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/parse.go#L516-L523
21,962
golang/mock
gomock/controller.go
NewController
func NewController(t TestReporter) *Controller { h, ok := t.(TestHelper) if !ok { h = nopTestHelper{t} } return &Controller{ T: h, expectedCalls: newCallSet(), } }
go
func NewController(t TestReporter) *Controller { h, ok := t.(TestHelper) if !ok { h = nopTestHelper{t} } return &Controller{ T: h, expectedCalls: newCallSet(), } }
[ "func", "NewController", "(", "t", "TestReporter", ")", "*", "Controller", "{", "h", ",", "ok", ":=", "t", ".", "(", "TestHelper", ")", "\n", "if", "!", "ok", "{", "h", "=", "nopTestHelper", "{", "t", "}", "\n", "}", "\n\n", "return", "&", "Control...
// NewController returns a new Controller. It is the preferred way to create a // Controller.
[ "NewController", "returns", "a", "new", "Controller", ".", "It", "is", "the", "preferred", "way", "to", "create", "a", "Controller", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/controller.go#L118-L128
21,963
golang/mock
gomock/controller.go
WithContext
func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) { h, ok := t.(TestHelper) if !ok { h = nopTestHelper{t} } ctx, cancel := context.WithCancel(ctx) return NewController(&cancelReporter{h, cancel}), ctx }
go
func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) { h, ok := t.(TestHelper) if !ok { h = nopTestHelper{t} } ctx, cancel := context.WithCancel(ctx) return NewController(&cancelReporter{h, cancel}), ctx }
[ "func", "WithContext", "(", "ctx", "context", ".", "Context", ",", "t", "TestReporter", ")", "(", "*", "Controller", ",", "context", ".", "Context", ")", "{", "h", ",", "ok", ":=", "t", ".", "(", "TestHelper", ")", "\n", "if", "!", "ok", "{", "h", ...
// WithContext returns a new Controller and a Context, which is cancelled on any // fatal failure.
[ "WithContext", "returns", "a", "new", "Controller", "and", "a", "Context", "which", "is", "cancelled", "on", "any", "fatal", "failure", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/controller.go#L145-L153
21,964
golang/mock
gomock/controller.go
RecordCall
func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call { ctrl.T.Helper() recv := reflect.ValueOf(receiver) for i := 0; i < recv.Type().NumMethod(); i++ { if recv.Type().Method(i).Name == method { return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).T...
go
func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call { ctrl.T.Helper() recv := reflect.ValueOf(receiver) for i := 0; i < recv.Type().NumMethod(); i++ { if recv.Type().Method(i).Name == method { return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).T...
[ "func", "(", "ctrl", "*", "Controller", ")", "RecordCall", "(", "receiver", "interface", "{", "}", ",", "method", "string", ",", "args", "...", "interface", "{", "}", ")", "*", "Call", "{", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n\n", "recv", ...
// RecordCall is called by a mock. It should not be called by user code.
[ "RecordCall", "is", "called", "by", "a", "mock", ".", "It", "should", "not", "be", "called", "by", "user", "code", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/controller.go#L162-L173
21,965
golang/mock
gomock/controller.go
RecordCallWithMethodType
func (ctrl *Controller) RecordCallWithMethodType(receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call { ctrl.T.Helper() call := newCall(ctrl.T, receiver, method, methodType, args...) ctrl.mu.Lock() defer ctrl.mu.Unlock() ctrl.expectedCalls.Add(call) return call }
go
func (ctrl *Controller) RecordCallWithMethodType(receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call { ctrl.T.Helper() call := newCall(ctrl.T, receiver, method, methodType, args...) ctrl.mu.Lock() defer ctrl.mu.Unlock() ctrl.expectedCalls.Add(call) return call }
[ "func", "(", "ctrl", "*", "Controller", ")", "RecordCallWithMethodType", "(", "receiver", "interface", "{", "}", ",", "method", "string", ",", "methodType", "reflect", ".", "Type", ",", "args", "...", "interface", "{", "}", ")", "*", "Call", "{", "ctrl", ...
// RecordCallWithMethodType is called by a mock. It should not be called by user code.
[ "RecordCallWithMethodType", "is", "called", "by", "a", "mock", ".", "It", "should", "not", "be", "called", "by", "user", "code", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/controller.go#L176-L186
21,966
golang/mock
gomock/controller.go
Call
func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{} { ctrl.T.Helper() // Nest this code so we can use defer to make sure the lock is released. actions := func() []func([]interface{}) []interface{} { ctrl.T.Helper() ctrl.mu.Lock() defer ctrl.mu.Unlock() expec...
go
func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{} { ctrl.T.Helper() // Nest this code so we can use defer to make sure the lock is released. actions := func() []func([]interface{}) []interface{} { ctrl.T.Helper() ctrl.mu.Lock() defer ctrl.mu.Unlock() expec...
[ "func", "(", "ctrl", "*", "Controller", ")", "Call", "(", "receiver", "interface", "{", "}", ",", "method", "string", ",", "args", "...", "interface", "{", "}", ")", "[", "]", "interface", "{", "}", "{", "ctrl", ".", "T", ".", "Helper", "(", ")", ...
// Call is called by a mock. It should not be called by user code.
[ "Call", "is", "called", "by", "a", "mock", ".", "It", "should", "not", "be", "called", "by", "user", "code", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/controller.go#L189-L227
21,967
golang/mock
gomock/controller.go
Finish
func (ctrl *Controller) Finish() { ctrl.T.Helper() ctrl.mu.Lock() defer ctrl.mu.Unlock() if ctrl.finished { ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.") } ctrl.finished = true // If we're currently panicking, probably because this is a deferred call, // pa...
go
func (ctrl *Controller) Finish() { ctrl.T.Helper() ctrl.mu.Lock() defer ctrl.mu.Unlock() if ctrl.finished { ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.") } ctrl.finished = true // If we're currently panicking, probably because this is a deferred call, // pa...
[ "func", "(", "ctrl", "*", "Controller", ")", "Finish", "(", ")", "{", "ctrl", ".", "T", ".", "Helper", "(", ")", "\n\n", "ctrl", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ctrl", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "ctrl", ...
// Finish checks to see if all the methods that were expected to be called // were called. It should be invoked for each Controller. It is not idempotent // and therefore can only be invoked once.
[ "Finish", "checks", "to", "see", "if", "all", "the", "methods", "that", "were", "expected", "to", "be", "called", "were", "called", ".", "It", "should", "be", "invoked", "for", "each", "Controller", ".", "It", "is", "not", "idempotent", "and", "therefore",...
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/gomock/controller.go#L232-L257
21,968
golang/mock
mockgen/model/model.go
Imports
func (pkg *Package) Imports() map[string]bool { im := make(map[string]bool) for _, intf := range pkg.Interfaces { intf.addImports(im) } return im }
go
func (pkg *Package) Imports() map[string]bool { im := make(map[string]bool) for _, intf := range pkg.Interfaces { intf.addImports(im) } return im }
[ "func", "(", "pkg", "*", "Package", ")", "Imports", "(", ")", "map", "[", "string", "]", "bool", "{", "im", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "for", "_", ",", "intf", ":=", "range", "pkg", ".", "Interfaces", "{", ...
// Imports returns the imports needed by the Package as a set of import paths.
[ "Imports", "returns", "the", "imports", "needed", "by", "the", "Package", "as", "a", "set", "of", "import", "paths", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/model/model.go#L44-L50
21,969
golang/mock
mockgen/model/model.go
funcArgsFromType
func funcArgsFromType(t reflect.Type) (in []*Parameter, variadic *Parameter, out []*Parameter, err error) { nin := t.NumIn() if t.IsVariadic() { nin-- } var p *Parameter for i := 0; i < nin; i++ { p, err = parameterFromType(t.In(i)) if err != nil { return } in = append(in, p) } if t.IsVariadic() { ...
go
func funcArgsFromType(t reflect.Type) (in []*Parameter, variadic *Parameter, out []*Parameter, err error) { nin := t.NumIn() if t.IsVariadic() { nin-- } var p *Parameter for i := 0; i < nin; i++ { p, err = parameterFromType(t.In(i)) if err != nil { return } in = append(in, p) } if t.IsVariadic() { ...
[ "func", "funcArgsFromType", "(", "t", "reflect", ".", "Type", ")", "(", "in", "[", "]", "*", "Parameter", ",", "variadic", "*", "Parameter", ",", "out", "[", "]", "*", "Parameter", ",", "err", "error", ")", "{", "nin", ":=", "t", ".", "NumIn", "(",...
// t's Kind must be a reflect.Func.
[ "t", "s", "Kind", "must", "be", "a", "reflect", ".", "Func", "." ]
937870445b8bddd7f05ea90e81c58ebe83681534
https://github.com/golang/mock/blob/937870445b8bddd7f05ea90e81c58ebe83681534/mockgen/model/model.go#L312-L340
21,970
anacrolix/torrent
metainfo/magnet.go
ParseMagnetURI
func ParseMagnetURI(uri string) (m Magnet, err error) { u, err := url.Parse(uri) if err != nil { err = fmt.Errorf("error parsing uri: %s", err) return } if u.Scheme != "magnet" { err = fmt.Errorf("unexpected scheme: %q", u.Scheme) return } xt := u.Query().Get("xt") if !strings.HasPrefix(xt, xtPrefix) { ...
go
func ParseMagnetURI(uri string) (m Magnet, err error) { u, err := url.Parse(uri) if err != nil { err = fmt.Errorf("error parsing uri: %s", err) return } if u.Scheme != "magnet" { err = fmt.Errorf("unexpected scheme: %q", u.Scheme) return } xt := u.Query().Get("xt") if !strings.HasPrefix(xt, xtPrefix) { ...
[ "func", "ParseMagnetURI", "(", "uri", "string", ")", "(", "m", "Magnet", ",", "err", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"...
// ParseMagnetURI parses Magnet-formatted URIs into a Magnet instance
[ "ParseMagnetURI", "parses", "Magnet", "-", "formatted", "URIs", "into", "a", "Magnet", "instance" ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/magnet.go#L35-L77
21,971
anacrolix/torrent
metainfo/metainfo.go
Load
func Load(r io.Reader) (*MetaInfo, error) { var mi MetaInfo d := bencode.NewDecoder(r) err := d.Decode(&mi) if err != nil { return nil, err } return &mi, nil }
go
func Load(r io.Reader) (*MetaInfo, error) { var mi MetaInfo d := bencode.NewDecoder(r) err := d.Decode(&mi) if err != nil { return nil, err } return &mi, nil }
[ "func", "Load", "(", "r", "io", ".", "Reader", ")", "(", "*", "MetaInfo", ",", "error", ")", "{", "var", "mi", "MetaInfo", "\n", "d", ":=", "bencode", ".", "NewDecoder", "(", "r", ")", "\n", "err", ":=", "d", ".", "Decode", "(", "&", "mi", ")",...
// Load a MetaInfo from an io.Reader. Returns a non-nil error in case of // failure.
[ "Load", "a", "MetaInfo", "from", "an", "io", ".", "Reader", ".", "Returns", "a", "non", "-", "nil", "error", "in", "case", "of", "failure", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/metainfo.go#L25-L33
21,972
anacrolix/torrent
metainfo/metainfo.go
LoadFromFile
func LoadFromFile(filename string) (*MetaInfo, error) { f, err := os.Open(filename) if err != nil { return nil, err } defer f.Close() return Load(f) }
go
func LoadFromFile(filename string) (*MetaInfo, error) { f, err := os.Open(filename) if err != nil { return nil, err } defer f.Close() return Load(f) }
[ "func", "LoadFromFile", "(", "filename", "string", ")", "(", "*", "MetaInfo", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n...
// Convenience function for loading a MetaInfo from a file.
[ "Convenience", "function", "for", "loading", "a", "MetaInfo", "from", "a", "file", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/metainfo.go#L36-L43
21,973
anacrolix/torrent
metainfo/metainfo.go
Write
func (mi MetaInfo) Write(w io.Writer) error { return bencode.NewEncoder(w).Encode(mi) }
go
func (mi MetaInfo) Write(w io.Writer) error { return bencode.NewEncoder(w).Encode(mi) }
[ "func", "(", "mi", "MetaInfo", ")", "Write", "(", "w", "io", ".", "Writer", ")", "error", "{", "return", "bencode", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "mi", ")", "\n", "}" ]
// Encode to bencoded form.
[ "Encode", "to", "bencoded", "form", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/metainfo.go#L55-L57
21,974
anacrolix/torrent
metainfo/metainfo.go
SetDefaults
func (mi *MetaInfo) SetDefaults() { mi.Comment = "yoloham" mi.CreatedBy = "github.com/anacrolix/torrent" mi.CreationDate = time.Now().Unix() // mi.Info.PieceLength = 256 * 1024 }
go
func (mi *MetaInfo) SetDefaults() { mi.Comment = "yoloham" mi.CreatedBy = "github.com/anacrolix/torrent" mi.CreationDate = time.Now().Unix() // mi.Info.PieceLength = 256 * 1024 }
[ "func", "(", "mi", "*", "MetaInfo", ")", "SetDefaults", "(", ")", "{", "mi", ".", "Comment", "=", "\"", "\"", "\n", "mi", ".", "CreatedBy", "=", "\"", "\"", "\n", "mi", ".", "CreationDate", "=", "time", ".", "Now", "(", ")", ".", "Unix", "(", "...
// Set good default values in preparation for creating a new MetaInfo file.
[ "Set", "good", "default", "values", "in", "preparation", "for", "creating", "a", "new", "MetaInfo", "file", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/metainfo.go#L60-L65
21,975
anacrolix/torrent
metainfo/metainfo.go
Magnet
func (mi *MetaInfo) Magnet(displayName string, infoHash Hash) (m Magnet) { for t := range mi.UpvertedAnnounceList().DistinctValues() { m.Trackers = append(m.Trackers, t) } m.DisplayName = displayName m.InfoHash = infoHash return }
go
func (mi *MetaInfo) Magnet(displayName string, infoHash Hash) (m Magnet) { for t := range mi.UpvertedAnnounceList().DistinctValues() { m.Trackers = append(m.Trackers, t) } m.DisplayName = displayName m.InfoHash = infoHash return }
[ "func", "(", "mi", "*", "MetaInfo", ")", "Magnet", "(", "displayName", "string", ",", "infoHash", "Hash", ")", "(", "m", "Magnet", ")", "{", "for", "t", ":=", "range", "mi", ".", "UpvertedAnnounceList", "(", ")", ".", "DistinctValues", "(", ")", "{", ...
// Creates a Magnet from a MetaInfo.
[ "Creates", "a", "Magnet", "from", "a", "MetaInfo", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/metainfo.go#L68-L75
21,976
anacrolix/torrent
metainfo/metainfo.go
UpvertedAnnounceList
func (mi *MetaInfo) UpvertedAnnounceList() AnnounceList { if mi.AnnounceList.OverridesAnnounce(mi.Announce) { return mi.AnnounceList } if mi.Announce != "" { return [][]string{[]string{mi.Announce}} } return nil }
go
func (mi *MetaInfo) UpvertedAnnounceList() AnnounceList { if mi.AnnounceList.OverridesAnnounce(mi.Announce) { return mi.AnnounceList } if mi.Announce != "" { return [][]string{[]string{mi.Announce}} } return nil }
[ "func", "(", "mi", "*", "MetaInfo", ")", "UpvertedAnnounceList", "(", ")", "AnnounceList", "{", "if", "mi", ".", "AnnounceList", ".", "OverridesAnnounce", "(", "mi", ".", "Announce", ")", "{", "return", "mi", ".", "AnnounceList", "\n", "}", "\n", "if", "...
// Returns the announce list converted from the old single announce field if // necessary.
[ "Returns", "the", "announce", "list", "converted", "from", "the", "old", "single", "announce", "field", "if", "necessary", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/metainfo/metainfo.go#L79-L87
21,977
anacrolix/torrent
cmd/torrent-pick/main.go
totalBytesEstimate
func totalBytesEstimate(tc *torrent.Client) (ret int64) { var noInfo, hadInfo int64 for _, t := range tc.Torrents() { info := t.Info() if info == nil { noInfo++ continue } ret += info.TotalLength() hadInfo++ } if hadInfo != 0 { // Treat each torrent without info as the average of those with, // ...
go
func totalBytesEstimate(tc *torrent.Client) (ret int64) { var noInfo, hadInfo int64 for _, t := range tc.Torrents() { info := t.Info() if info == nil { noInfo++ continue } ret += info.TotalLength() hadInfo++ } if hadInfo != 0 { // Treat each torrent without info as the average of those with, // ...
[ "func", "totalBytesEstimate", "(", "tc", "*", "torrent", ".", "Client", ")", "(", "ret", "int64", ")", "{", "var", "noInfo", ",", "hadInfo", "int64", "\n", "for", "_", ",", "t", ":=", "range", "tc", ".", "Torrents", "(", ")", "{", "info", ":=", "t"...
// Returns an estimate of the total bytes for all torrents.
[ "Returns", "an", "estimate", "of", "the", "total", "bytes", "for", "all", "torrents", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/cmd/torrent-pick/main.go#L51-L68
21,978
anacrolix/torrent
connection.go
ipv6
func (cn *connection) ipv6() bool { ip := cn.remoteAddr.IP if ip.To4() != nil { return false } return len(ip) == net.IPv6len }
go
func (cn *connection) ipv6() bool { ip := cn.remoteAddr.IP if ip.To4() != nil { return false } return len(ip) == net.IPv6len }
[ "func", "(", "cn", "*", "connection", ")", "ipv6", "(", ")", "bool", "{", "ip", ":=", "cn", ".", "remoteAddr", ".", "IP", "\n", "if", "ip", ".", "To4", "(", ")", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "len", "(", "ip", ...
// Returns true if the connection is over IPv6.
[ "Returns", "true", "if", "the", "connection", "is", "over", "IPv6", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L137-L143
21,979
anacrolix/torrent
connection.go
hasPreferredNetworkOver
func (l *connection) hasPreferredNetworkOver(r *connection) (left, ok bool) { var ml multiLess ml.NextBool(l.isPreferredDirection(), r.isPreferredDirection()) ml.NextBool(!l.utp(), !r.utp()) ml.NextBool(l.ipv6(), r.ipv6()) return ml.FinalOk() }
go
func (l *connection) hasPreferredNetworkOver(r *connection) (left, ok bool) { var ml multiLess ml.NextBool(l.isPreferredDirection(), r.isPreferredDirection()) ml.NextBool(!l.utp(), !r.utp()) ml.NextBool(l.ipv6(), r.ipv6()) return ml.FinalOk() }
[ "func", "(", "l", "*", "connection", ")", "hasPreferredNetworkOver", "(", "r", "*", "connection", ")", "(", "left", ",", "ok", "bool", ")", "{", "var", "ml", "multiLess", "\n", "ml", ".", "NextBool", "(", "l", ".", "isPreferredDirection", "(", ")", ","...
// Returns whether the left connection should be preferred over the right one, // considering only their networking properties. If ok is false, we can't // decide.
[ "Returns", "whether", "the", "left", "connection", "should", "be", "preferred", "over", "the", "right", "one", "considering", "only", "their", "networking", "properties", ".", "If", "ok", "is", "false", "we", "can", "t", "decide", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L154-L160
21,980
anacrolix/torrent
connection.go
bestPeerNumPieces
func (cn *connection) bestPeerNumPieces() pieceIndex { if cn.t.haveInfo() { return cn.t.numPieces() } return cn.peerMinPieces }
go
func (cn *connection) bestPeerNumPieces() pieceIndex { if cn.t.haveInfo() { return cn.t.numPieces() } return cn.peerMinPieces }
[ "func", "(", "cn", "*", "connection", ")", "bestPeerNumPieces", "(", ")", "pieceIndex", "{", "if", "cn", ".", "t", ".", "haveInfo", "(", ")", "{", "return", "cn", ".", "t", ".", "numPieces", "(", ")", "\n", "}", "\n", "return", "cn", ".", "peerMinP...
// The best guess at number of pieces in the torrent for this peer.
[ "The", "best", "guess", "at", "number", "of", "pieces", "in", "the", "torrent", "for", "this", "peer", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L194-L199
21,981
anacrolix/torrent
connection.go
setNumPieces
func (cn *connection) setNumPieces(num pieceIndex) error { cn.peerPieces.RemoveRange(bitmap.BitIndex(num), bitmap.ToEnd) cn.peerPiecesChanged() return nil }
go
func (cn *connection) setNumPieces(num pieceIndex) error { cn.peerPieces.RemoveRange(bitmap.BitIndex(num), bitmap.ToEnd) cn.peerPiecesChanged() return nil }
[ "func", "(", "cn", "*", "connection", ")", "setNumPieces", "(", "num", "pieceIndex", ")", "error", "{", "cn", ".", "peerPieces", ".", "RemoveRange", "(", "bitmap", ".", "BitIndex", "(", "num", ")", ",", "bitmap", ".", "ToEnd", ")", "\n", "cn", ".", "...
// Correct the PeerPieces slice length. Return false if the existing slice is // invalid, such as by receiving badly sized BITFIELD, or invalid HAVE // messages.
[ "Correct", "the", "PeerPieces", "slice", "length", ".", "Return", "false", "if", "the", "existing", "slice", "is", "invalid", "such", "as", "by", "receiving", "badly", "sized", "BITFIELD", "or", "invalid", "HAVE", "messages", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L212-L216
21,982
anacrolix/torrent
connection.go
Post
func (cn *connection) Post(msg pp.Message) { torrent.Add(fmt.Sprintf("messages posted of type %s", msg.Type.String()), 1) // We don't need to track bytes here because a connection.w Writer wrapper // takes care of that (although there's some delay between us recording // the message, and the connection writer flush...
go
func (cn *connection) Post(msg pp.Message) { torrent.Add(fmt.Sprintf("messages posted of type %s", msg.Type.String()), 1) // We don't need to track bytes here because a connection.w Writer wrapper // takes care of that (although there's some delay between us recording // the message, and the connection writer flush...
[ "func", "(", "cn", "*", "connection", ")", "Post", "(", "msg", "pp", ".", "Message", ")", "{", "torrent", ".", "Add", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "msg", ".", "Type", ".", "String", "(", ")", ")", ",", "1", ")", "\n", "//...
// Writes a message into the write buffer.
[ "Writes", "a", "message", "into", "the", "write", "buffer", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L330-L340
21,983
anacrolix/torrent
connection.go
nominalMaxRequests
func (cn *connection) nominalMaxRequests() (ret int) { if cn.t.requestStrategy == 3 { expectingTime := int64(cn.totalExpectingTime()) if expectingTime == 0 { expectingTime = math.MaxInt64 } else { expectingTime *= 2 } return int(clamp( 1, int64(cn.PeerMaxRequests), max( // It makes sense t...
go
func (cn *connection) nominalMaxRequests() (ret int) { if cn.t.requestStrategy == 3 { expectingTime := int64(cn.totalExpectingTime()) if expectingTime == 0 { expectingTime = math.MaxInt64 } else { expectingTime *= 2 } return int(clamp( 1, int64(cn.PeerMaxRequests), max( // It makes sense t...
[ "func", "(", "cn", "*", "connection", ")", "nominalMaxRequests", "(", ")", "(", "ret", "int", ")", "{", "if", "cn", ".", "t", ".", "requestStrategy", "==", "3", "{", "expectingTime", ":=", "int64", "(", "cn", ".", "totalExpectingTime", "(", ")", ")", ...
// The actual value to use as the maximum outbound requests.
[ "The", "actual", "value", "to", "use", "as", "the", "maximum", "outbound", "requests", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L375-L402
21,984
anacrolix/torrent
connection.go
request
func (cn *connection) request(r request, mw messageWriter) bool { if _, ok := cn.requests[r]; ok { panic("chunk already requested") } if !cn.PeerHasPiece(pieceIndex(r.Index)) { panic("requesting piece peer doesn't have") } if _, ok := cn.t.conns[cn]; !ok { panic("requesting but not in active conns") } if c...
go
func (cn *connection) request(r request, mw messageWriter) bool { if _, ok := cn.requests[r]; ok { panic("chunk already requested") } if !cn.PeerHasPiece(pieceIndex(r.Index)) { panic("requesting piece peer doesn't have") } if _, ok := cn.t.conns[cn]; !ok { panic("requesting but not in active conns") } if c...
[ "func", "(", "cn", "*", "connection", ")", "request", "(", "r", "request", ",", "mw", "messageWriter", ")", "bool", "{", "if", "_", ",", "ok", ":=", "cn", ".", "requests", "[", "r", "]", ";", "ok", "{", "panic", "(", "\"", "\"", ")", "\n", "}",...
// Proxies the messageWriter's response.
[ "Proxies", "the", "messageWriter", "s", "response", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L482-L535
21,985
anacrolix/torrent
connection.go
writer
func (cn *connection) writer(keepAliveTimeout time.Duration) { var ( lastWrite time.Time = time.Now() keepAliveTimer *time.Timer ) keepAliveTimer = time.AfterFunc(keepAliveTimeout, func() { cn.mu().Lock() defer cn.mu().Unlock() if time.Since(lastWrite) >= keepAliveTimeout { cn.tickleWriter() } ...
go
func (cn *connection) writer(keepAliveTimeout time.Duration) { var ( lastWrite time.Time = time.Now() keepAliveTimer *time.Timer ) keepAliveTimer = time.AfterFunc(keepAliveTimeout, func() { cn.mu().Lock() defer cn.mu().Unlock() if time.Since(lastWrite) >= keepAliveTimeout { cn.tickleWriter() } ...
[ "func", "(", "cn", "*", "connection", ")", "writer", "(", "keepAliveTimeout", "time", ".", "Duration", ")", "{", "var", "(", "lastWrite", "time", ".", "Time", "=", "time", ".", "Now", "(", ")", "\n", "keepAliveTimer", "*", "time", ".", "Timer", "\n", ...
// Routine that writes to the peer. Some of what to write is buffered by // activity elsewhere in the Client, and some is determined locally when the // connection is writable.
[ "Routine", "that", "writes", "to", "the", "peer", ".", "Some", "of", "what", "to", "write", "is", "buffered", "by", "activity", "elsewhere", "in", "the", "Client", "and", "some", "is", "determined", "locally", "when", "the", "connection", "is", "writable", ...
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L593-L649
21,986
anacrolix/torrent
connection.go
iterBitmapsDistinct
func iterBitmapsDistinct(skip *bitmap.Bitmap, bms ...bitmap.Bitmap) iter.Func { return func(cb iter.Callback) { for _, bm := range bms { if !iter.All(func(i interface{}) bool { skip.Add(i.(int)) return cb(i) }, bitmap.Sub(bm, *skip).Iter) { return } } } }
go
func iterBitmapsDistinct(skip *bitmap.Bitmap, bms ...bitmap.Bitmap) iter.Func { return func(cb iter.Callback) { for _, bm := range bms { if !iter.All(func(i interface{}) bool { skip.Add(i.(int)) return cb(i) }, bitmap.Sub(bm, *skip).Iter) { return } } } }
[ "func", "iterBitmapsDistinct", "(", "skip", "*", "bitmap", ".", "Bitmap", ",", "bms", "...", "bitmap", ".", "Bitmap", ")", "iter", ".", "Func", "{", "return", "func", "(", "cb", "iter", ".", "Callback", ")", "{", "for", "_", ",", "bm", ":=", "range",...
// Emits the indices in the Bitmaps bms in order, never repeating any index. // skip is mutated during execution, and its initial values will never be // emitted.
[ "Emits", "the", "indices", "in", "the", "Bitmaps", "bms", "in", "order", "never", "repeating", "any", "index", ".", "skip", "is", "mutated", "during", "execution", "and", "its", "initial", "values", "will", "never", "be", "emitted", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L684-L695
21,987
anacrolix/torrent
connection.go
shouldRequestWithoutBias
func (cn *connection) shouldRequestWithoutBias() bool { if cn.t.requestStrategy != 2 { return false } if len(cn.t.readers) == 0 { return false } if len(cn.t.conns) == 1 { return true } if cn == cn.t.fastestConn { return true } return false }
go
func (cn *connection) shouldRequestWithoutBias() bool { if cn.t.requestStrategy != 2 { return false } if len(cn.t.readers) == 0 { return false } if len(cn.t.conns) == 1 { return true } if cn == cn.t.fastestConn { return true } return false }
[ "func", "(", "cn", "*", "connection", ")", "shouldRequestWithoutBias", "(", ")", "bool", "{", "if", "cn", ".", "t", ".", "requestStrategy", "!=", "2", "{", "return", "false", "\n", "}", "\n", "if", "len", "(", "cn", ".", "t", ".", "readers", ")", "...
// The connection should download highest priority pieces first, without any // inclination toward avoiding wastage. Generally we might do this if there's // a single connection, or this is the fastest connection, and we have active // readers that signal an ordering preference. It's conceivable that the best // connec...
[ "The", "connection", "should", "download", "highest", "priority", "pieces", "first", "without", "any", "inclination", "toward", "avoiding", "wastage", ".", "Generally", "we", "might", "do", "this", "if", "there", "s", "a", "single", "connection", "or", "this", ...
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L738-L752
21,988
anacrolix/torrent
connection.go
stopRequestingPiece
func (cn *connection) stopRequestingPiece(piece pieceIndex) bool { return cn.pieceRequestOrder.Remove(bitmap.BitIndex(piece)) }
go
func (cn *connection) stopRequestingPiece(piece pieceIndex) bool { return cn.pieceRequestOrder.Remove(bitmap.BitIndex(piece)) }
[ "func", "(", "cn", "*", "connection", ")", "stopRequestingPiece", "(", "piece", "pieceIndex", ")", "bool", "{", "return", "cn", ".", "pieceRequestOrder", ".", "Remove", "(", "bitmap", ".", "BitIndex", "(", "piece", ")", ")", "\n", "}" ]
// check callers updaterequests
[ "check", "callers", "updaterequests" ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L811-L813
21,989
anacrolix/torrent
connection.go
updatePiecePriority
func (cn *connection) updatePiecePriority(piece pieceIndex) bool { tpp := cn.t.piecePriority(piece) if !cn.PeerHasPiece(piece) { tpp = PiecePriorityNone } if tpp == PiecePriorityNone { return cn.stopRequestingPiece(piece) } prio := cn.getPieceInclination()[piece] switch cn.t.requestStrategy { case 1: swit...
go
func (cn *connection) updatePiecePriority(piece pieceIndex) bool { tpp := cn.t.piecePriority(piece) if !cn.PeerHasPiece(piece) { tpp = PiecePriorityNone } if tpp == PiecePriorityNone { return cn.stopRequestingPiece(piece) } prio := cn.getPieceInclination()[piece] switch cn.t.requestStrategy { case 1: swit...
[ "func", "(", "cn", "*", "connection", ")", "updatePiecePriority", "(", "piece", "pieceIndex", ")", "bool", "{", "tpp", ":=", "cn", ".", "t", ".", "piecePriority", "(", "piece", ")", "\n", "if", "!", "cn", ".", "PeerHasPiece", "(", "piece", ")", "{", ...
// This is distinct from Torrent piece priority, which is the user's // preference. Connection piece priority is specific to a connection and is // used to pseudorandomly avoid connections always requesting the same pieces // and thus wasting effort.
[ "This", "is", "distinct", "from", "Torrent", "piece", "priority", "which", "is", "the", "user", "s", "preference", ".", "Connection", "piece", "priority", "is", "specific", "to", "a", "connection", "and", "is", "used", "to", "pseudorandomly", "avoid", "connect...
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L819-L843
21,990
anacrolix/torrent
connection.go
postHandshakeStats
func (cn *connection) postHandshakeStats(f func(*ConnStats)) { t := cn.t f(&t.stats) f(&t.cl.stats) }
go
func (cn *connection) postHandshakeStats(f func(*ConnStats)) { t := cn.t f(&t.stats) f(&t.cl.stats) }
[ "func", "(", "cn", "*", "connection", ")", "postHandshakeStats", "(", "f", "func", "(", "*", "ConnStats", ")", ")", "{", "t", ":=", "cn", ".", "t", "\n", "f", "(", "&", "t", ".", "stats", ")", "\n", "f", "(", "&", "t", ".", "cl", ".", "stats"...
// After handshake, we know what Torrent and Client stats to include for a // connection.
[ "After", "handshake", "we", "know", "what", "Torrent", "and", "Client", "stats", "to", "include", "for", "a", "connection", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L962-L966
21,991
anacrolix/torrent
connection.go
allStats
func (cn *connection) allStats(f func(*ConnStats)) { f(&cn.stats) if cn.reconciledHandshakeStats { cn.postHandshakeStats(f) } }
go
func (cn *connection) allStats(f func(*ConnStats)) { f(&cn.stats) if cn.reconciledHandshakeStats { cn.postHandshakeStats(f) } }
[ "func", "(", "cn", "*", "connection", ")", "allStats", "(", "f", "func", "(", "*", "ConnStats", ")", ")", "{", "f", "(", "&", "cn", ".", "stats", ")", "\n", "if", "cn", ".", "reconciledHandshakeStats", "{", "cn", ".", "postHandshakeStats", "(", "f", ...
// All ConnStats that include this connection. Some objects are not known // until the handshake is complete, after which it's expected to reconcile the // differences.
[ "All", "ConnStats", "that", "include", "this", "connection", ".", "Some", "objects", "are", "not", "known", "until", "the", "handshake", "is", "complete", "after", "which", "it", "s", "expected", "to", "reconcile", "the", "differences", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L971-L976
21,992
anacrolix/torrent
connection.go
useful
func (c *connection) useful() bool { t := c.t if c.closed.IsSet() { return false } if !t.haveInfo() { return c.supportsExtension("ut_metadata") } if t.seeding() && c.PeerInterested { return true } if c.peerHasWantedPieces() { return true } return false }
go
func (c *connection) useful() bool { t := c.t if c.closed.IsSet() { return false } if !t.haveInfo() { return c.supportsExtension("ut_metadata") } if t.seeding() && c.PeerInterested { return true } if c.peerHasWantedPieces() { return true } return false }
[ "func", "(", "c", "*", "connection", ")", "useful", "(", ")", "bool", "{", "t", ":=", "c", ".", "t", "\n", "if", "c", ".", "closed", ".", "IsSet", "(", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "t", ".", "haveInfo", "(", ")", ...
// Returns whether the connection could be useful to us. We're seeding and // they want data, we don't have metainfo and they can provide it, etc.
[ "Returns", "whether", "the", "connection", "could", "be", "useful", "to", "us", ".", "We", "re", "seeding", "and", "they", "want", "data", "we", "don", "t", "have", "metainfo", "and", "they", "can", "provide", "it", "etc", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L988-L1003
21,993
anacrolix/torrent
connection.go
setRW
func (cn *connection) setRW(rw io.ReadWriter) { cn.r = rw cn.w = rw }
go
func (cn *connection) setRW(rw io.ReadWriter) { cn.r = rw cn.w = rw }
[ "func", "(", "cn", "*", "connection", ")", "setRW", "(", "rw", "io", ".", "ReadWriter", ")", "{", "cn", ".", "r", "=", "rw", "\n", "cn", ".", "w", "=", "rw", "\n", "}" ]
// Set both the Reader and Writer for the connection from a single ReadWriter.
[ "Set", "both", "the", "Reader", "and", "Writer", "for", "the", "connection", "from", "a", "single", "ReadWriter", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L1253-L1256
21,994
anacrolix/torrent
connection.go
rw
func (cn *connection) rw() io.ReadWriter { return struct { io.Reader io.Writer }{cn.r, cn.w} }
go
func (cn *connection) rw() io.ReadWriter { return struct { io.Reader io.Writer }{cn.r, cn.w} }
[ "func", "(", "cn", "*", "connection", ")", "rw", "(", ")", "io", ".", "ReadWriter", "{", "return", "struct", "{", "io", ".", "Reader", "\n", "io", ".", "Writer", "\n", "}", "{", "cn", ".", "r", ",", "cn", ".", "w", "}", "\n", "}" ]
// Returns the Reader and Writer as a combined ReadWriter.
[ "Returns", "the", "Reader", "and", "Writer", "as", "a", "combined", "ReadWriter", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L1259-L1264
21,995
anacrolix/torrent
connection.go
upload
func (c *connection) upload(msg func(pp.Message) bool) bool { // Breaking or completing this loop means we don't want to upload to the // peer anymore, and we choke them. another: for c.uploadAllowed() { // We want to upload to the peer. if !c.Unchoke(msg) { return false } for r := range c.PeerRequests { ...
go
func (c *connection) upload(msg func(pp.Message) bool) bool { // Breaking or completing this loop means we don't want to upload to the // peer anymore, and we choke them. another: for c.uploadAllowed() { // We want to upload to the peer. if !c.Unchoke(msg) { return false } for r := range c.PeerRequests { ...
[ "func", "(", "c", "*", "connection", ")", "upload", "(", "msg", "func", "(", "pp", ".", "Message", ")", "bool", ")", "bool", "{", "// Breaking or completing this loop means we don't want to upload to the", "// peer anymore, and we choke them.", "another", ":", "for", ...
// Also handles choking and unchoking of the remote peer.
[ "Also", "handles", "choking", "and", "unchoking", "of", "the", "remote", "peer", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/connection.go#L1400-L1448
21,996
anacrolix/torrent
iplist/iplist.go
Lookup
func (ipl *IPList) Lookup(ip net.IP) (r Range, ok bool) { if ipl == nil { return } // TODO: Perhaps all addresses should be converted to IPv6, if the future // of IP is to always be backwards compatible. But this will cost 4x the // memory for IPv4 addresses? v4 := ip.To4() if v4 != nil { r, ok = ipl.lookup(...
go
func (ipl *IPList) Lookup(ip net.IP) (r Range, ok bool) { if ipl == nil { return } // TODO: Perhaps all addresses should be converted to IPv6, if the future // of IP is to always be backwards compatible. But this will cost 4x the // memory for IPv4 addresses? v4 := ip.To4() if v4 != nil { r, ok = ipl.lookup(...
[ "func", "(", "ipl", "*", "IPList", ")", "Lookup", "(", "ip", "net", ".", "IP", ")", "(", "r", "Range", ",", "ok", "bool", ")", "{", "if", "ipl", "==", "nil", "{", "return", "\n", "}", "\n", "// TODO: Perhaps all addresses should be converted to IPv6, if th...
// Return the range the given IP is in. ok if false if no range is found.
[ "Return", "the", "range", "the", "given", "IP", "is", "in", ".", "ok", "if", "false", "if", "no", "range", "is", "found", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/iplist/iplist.go#L53-L78
21,997
anacrolix/torrent
iplist/iplist.go
lookup
func lookup( first func(i int) net.IP, full func(i int) Range, n int, ip net.IP, ) ( r Range, ok bool, ) { // Find the index of the first range for which the following range exceeds // it. i := sort.Search(n, func(i int) bool { if i+1 >= n { return true } return bytes.Compare(ip, first(i+1)) < 0 }) i...
go
func lookup( first func(i int) net.IP, full func(i int) Range, n int, ip net.IP, ) ( r Range, ok bool, ) { // Find the index of the first range for which the following range exceeds // it. i := sort.Search(n, func(i int) bool { if i+1 >= n { return true } return bytes.Compare(ip, first(i+1)) < 0 }) i...
[ "func", "lookup", "(", "first", "func", "(", "i", "int", ")", "net", ".", "IP", ",", "full", "func", "(", "i", "int", ")", "Range", ",", "n", "int", ",", "ip", "net", ".", "IP", ",", ")", "(", "r", "Range", ",", "ok", "bool", ",", ")", "{",...
// Return a range that contains ip, or nil.
[ "Return", "a", "range", "that", "contains", "ip", "or", "nil", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/iplist/iplist.go#L81-L103
21,998
anacrolix/torrent
iplist/iplist.go
lookup
func (ipl *IPList) lookup(ip net.IP) (Range, bool) { return lookup(func(i int) net.IP { return ipl.ranges[i].First }, func(i int) Range { return ipl.ranges[i] }, len(ipl.ranges), ip) }
go
func (ipl *IPList) lookup(ip net.IP) (Range, bool) { return lookup(func(i int) net.IP { return ipl.ranges[i].First }, func(i int) Range { return ipl.ranges[i] }, len(ipl.ranges), ip) }
[ "func", "(", "ipl", "*", "IPList", ")", "lookup", "(", "ip", "net", ".", "IP", ")", "(", "Range", ",", "bool", ")", "{", "return", "lookup", "(", "func", "(", "i", "int", ")", "net", ".", "IP", "{", "return", "ipl", ".", "ranges", "[", "i", "...
// Return the range the given IP is in. Returns nil if no range is found.
[ "Return", "the", "range", "the", "given", "IP", "is", "in", ".", "Returns", "nil", "if", "no", "range", "is", "found", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/iplist/iplist.go#L106-L112
21,999
anacrolix/torrent
iplist/iplist.go
NewFromReader
func NewFromReader(f io.Reader) (ret *IPList, err error) { var ranges []Range // There's a lot of similar descriptions, so we maintain a pool and reuse // them to reduce memory overhead. uniqStrs := make(map[string]string) scanner := bufio.NewScanner(f) lineNum := 1 for scanner.Scan() { r, ok, lineErr := Parse...
go
func NewFromReader(f io.Reader) (ret *IPList, err error) { var ranges []Range // There's a lot of similar descriptions, so we maintain a pool and reuse // them to reduce memory overhead. uniqStrs := make(map[string]string) scanner := bufio.NewScanner(f) lineNum := 1 for scanner.Scan() { r, ok, lineErr := Parse...
[ "func", "NewFromReader", "(", "f", "io", ".", "Reader", ")", "(", "ret", "*", "IPList", ",", "err", "error", ")", "{", "var", "ranges", "[", "]", "Range", "\n", "// There's a lot of similar descriptions, so we maintain a pool and reuse", "// them to reduce memory over...
// Creates an IPList from a line-delimited P2P Plaintext file.
[ "Creates", "an", "IPList", "from", "a", "line", "-", "delimited", "P2P", "Plaintext", "file", "." ]
d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb
https://github.com/anacrolix/torrent/blob/d2400968fc54c3d8a6482d4ca5ff16cc5e5139cb/iplist/iplist.go#L155-L185