id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c171100 | error)) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.ping(node, callback)
} | |
c171101 | s.getNode(NewAddr(ni.Addr.UDP()), int160FromByteArray(ni.ID), true)
})
} | |
c171102 | response to put in the server's table before
// handing the response back to the caller.
s.mu.Lock()
s.addResponseNodes(m)
s.mu.Unlock()
callback(m, err)
})
} | |
c171103 | {
return
}
ts.NumResponses++
if r := m.R; r != nil {
r.ForAllNodes(func(ni krpc.NodeInfo) {
onAddr(NewAddr(ni.Addr.UDP()))
})
}
})
}
s.mu.Lock()
for _, addr := range initialAddrs {
onAddr(NewAddr(addr.Addr.UDP()))
}
s.mu.Unlock()
outstanding.Wait()
return
} | |
c171104 | s.mu.Unlock()
return s.numNodes()
} | |
c171105 |
Addr: n.addr.KRPC(),
ID: n.id.AsByteArray(),
})
return true
})
return
} | |
c171106 | s.closed.Set()
s.socket.Close()
} | |
c171107 |
if !n.lastGotResponse.IsZero() && time.Since(n.lastGotQuery) < 15*time.Minute {
return true
}
return false
} | |
c171108 | a.mu.Unlock()
return a.numContacted
} | |
c171109 |
// Function ferries from values to Values until discovery is halted.
go func() {
defer close(a.Peers)
for {
select {
case psv := <-a.values:
select {
case a.Peers <- psv:
case <-a.stop:
return
}
case <-a.stop:
return
}
}
}()
for _, n := range startAddrs {
a.pendContact(n)
}
a.maybeClose()
go a.nodeContactor()
return a, nil
} | |
c171110 | (peerId == nil || !NodeIdSecure(*peerId, to.IP())) {
return
}
a.server.mu.Lock()
defer a.server.mu.Unlock()
a.server.announcePeer(to, a.infoHash, a.announcePort, *token, a.announcePortImplied, nil)
} | |
c171111 | a.mu.Unlock()
a.close()
} | |
c171112 | |= 0x1000 // Version 1
binary.BigEndian.PutUint32(uuid[0:], timeLow)
binary.BigEndian.PutUint16(uuid[4:], timeMid)
binary.BigEndian.PutUint16(uuid[6:], timeHi)
binary.BigEndian.PutUint16(uuid[8:], seq)
copy(uuid[10:], nodeID[:])
return uuid, nil
} | |
c171113 | nodeMu.Lock()
return setNodeInterface(name)
} | |
c171114 |
if nodeID == zeroID {
setNodeInterface("")
}
nid := nodeID
return nid[:]
} | |
c171115 |
}
defer nodeMu.Unlock()
nodeMu.Lock()
copy(nodeID[:], id)
ifname = "user"
return true
} | |
c171116 | uuid[10:])
return node[:]
} | |
c171117 | must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' {
return uuid, errors.New("invalid UUID format")
}
for i, x := range [16]int{
0, 2, 4, 6,
9, 11,
14, 16,
19, 21,
24, 26, 28, 30, 32, 34} {
v, ok := xtob(b[x], b[x+1])
if !ok {
return uuid, errors.New("invalid UUID format")
}
uuid[i] = v
}
return uuid, nil
} | |
c171118 | + s + `): ` + err.Error())
}
return uuid
} | |
c171119 | = uuid.UnmarshalBinary(b)
return uuid, err
} | |
c171120 | panic(err)
}
return uuid
} | |
c171121 | return Microsoft
case (uuid[8] & 0xe0) == 0xe0:
return Future
default:
return Reserved
}
} | |
c171122 | time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
return Time(time)
} | |
c171123 | [36]byte
encodeHex(js[:], uuid)
return js[:], nil
} | |
c171124 |
id, err := ParseBytes(data)
if err == nil {
*uuid = id
}
return err
} | |
c171125 | bytes)", len(data))
}
copy(uuid[:], data)
return nil
} | |
c171126 |
s.list = l
s.setKeys()
err = s.prepareTemplates()
if err != nil {
return 0, "", err
}
return s.innerRun(cursorPos, scroll, ' ')
} | |
c171127 | }
// XXX run through terminal for windows
os.Stdout.Write([]byte(upLine(1) + "\r" + clearLine))
}
p := Prompt{
Label: sa.AddLabel,
Validate: sa.Validate,
IsVimMode: sa.IsVimMode,
Pointer: sa.Pointer,
}
value, err := p.Run()
return SelectedAdd, value, err
} | |
c171128 |
return &ScreenBuf{buf: &bytes.Buffer{}, w: w}
} | |
c171129 | if err != nil {
return err
}
}
s.cursor = 0
s.height = 0
s.reset = false
return nil
} | |
c171130 | n, err = s.buf.Write(line)
if err != nil {
return n, err
}
s.height++
s.cursor++
return n, nil
case s.cursor < s.height:
n, err := s.buf.Write(clearLine)
if err != nil {
return n, err
}
n, err = s.buf.Write(b)
if err != nil {
return n, err
}
n, err = s.buf.Write(moveDown)
if err != nil {
return n, err
}
s.cursor++
return n, nil
default:
return 0, fmt.Errorf("Invalid write cursor position (%d) exceeded line height: %d", s.cursor, s.height)
}
} | |
c171131 |
s.buf.Reset()
for i := 0; i < s.height; i++ {
_, err := s.buf.Write(moveUp)
if err != nil {
return err
}
}
s.cursor = 0
return nil
} | |
c171132 | := ""
s, ok := v.(string)
if !ok || !strings.HasSuffix(s, ResetCode) {
end = ResetCode
}
return fmt.Sprintf("%s%sm%v%s", esc, seq, v, end)
}
} | |
c171133 | reflect.ValueOf(items)
values := make([]*interface{}, slice.Len())
for i := range values {
item := slice.Index(i).Interface()
values[i] = &item
}
return &List{size: size, items: values, scope: values}, nil
} | |
c171134 | l.cursor--
}
if l.start > l.cursor {
l.start = l.cursor
}
} | |
c171135 | = 0
l.start = 0
l.search(term)
} | |
c171136 |
l.start = 0
l.scope = l.items
} | |
c171137 |
l.start = l.cursor
} else {
l.start = i
}
} | |
c171138 | l.start = l.cursor
} else if l.start+l.size <= l.cursor {
l.start = l.cursor - l.size + 1
}
} | |
c171139 | if l.start+l.size <= l.cursor {
l.start = l.cursor - l.size + 1
}
} | |
c171140 | 0
} else {
l.start = start
}
cursor := l.start
if cursor < l.cursor {
l.cursor = cursor
}
} | |
c171141 | start
}
cursor := l.start
if cursor == l.cursor {
l.cursor = len(l.scope) - 1
} else if cursor > l.cursor {
l.cursor = cursor
}
} | |
c171142 | end = max
}
active := NotFound
for i, j := l.start, 0; i < end; i, j = i+1, j+1 {
if l.cursor == i {
active = j
}
result = append(result, *l.scope[i])
}
return result, active
} | |
c171143 | input: []rune(startinginput), erase: eraseDefault}
if eraseDefault {
cur.Start()
} else {
cur.End()
}
return cur
} | |
c171144 |
if c.Position < 0 {
c.Position = 0
}
} | |
c171145 | // does not include i
out = append(out, b...) // add the cursor
out = append(out, a[i+1:]...) // add the rest after i
} else {
b = c.Cursor([]rune{})
out = append(out, a...)
out = append(out, b...)
}
return string(out)
} | |
c171146 | insert the cursor
return format(r, c)
} | |
c171147 | len(c.input))
for i := range r {
r[i] = mask
}
return format(r, c)
} | |
c171148 | = []rune(input)
c.End()
} | |
c171149 | position
c.correctPosition()
} | |
c171150 | = c.Position + shift
c.correctPosition()
} | |
c171151 | = append(a[:i-1], a[i:]...)
}
// now it's pointing to the i+1th element
c.Move(-1)
} | |
c171152 | the default, despite how we set it up. Let
// them.
c.erase = false
c.Move(1)
case KeyBackward:
c.Move(-1)
default:
if c.erase {
c.erase = false
c.Replace("")
c.Update(string(key))
}
}
return []rune(c.Get()), c.Position, true
} | |
c171153 | Issue: issue,
linterNames: []string{issue.Linter},
}
}
}
for _, multi := range issueMap {
issue := multi.Issue
sort.Strings(multi.linterNames)
issue.Linter = strings.Join(multi.linterNames, ", ")
out <- issue
}
close(out)
}()
return out
} | |
c171154 | case *MakeClosure:
return fn.Fn.(*Function)
}
return nil
} | |
c171155 | _ = p.Members[name].(*Function)
return
} | |
c171156 | _ = p.Members[name].(*Global)
return
} | |
c171157 | = p.Members[name].(*NamedConst)
return
} | |
c171158 | (t *Type) {
t, _ = p.Members[name].(*Type)
return
} | |
c171159 | path = filepath.Join(user.HomeDir, "go")
}
return path
} | |
c171160 | existingpath {
return paths
}
}
return append(paths, path)
} | |
c171161 | := findVendoredLinters()
if vendorRoot == "" {
kingpin.Fatalf("could not find vendored linters in GOPATH=%q", getGoPath())
}
debug("found vendored linters at %s, updating environment", vendorRoot)
gobin := os.Getenv("GOBIN")
if gobin == "" {
gobin = filepath.Join(gopaths[0], "bin")
}
setEnv("GOBIN", gobin)
// "go install" panics when one GOPATH element is beneath another, so set
// GOPATH to the vendor root
setEnv("GOPATH", vendorRoot)
debugPrintEnv()
} | |
c171162 | return unmarshal(in, out, true)
} | |
c171163 | !out.IsNil() {
out = out.Elem()
}
d.unmarshal(node, out)
if len(d.terrors) > 0 {
return &TypeError{d.terrors}
}
return nil
} | |
c171164 | e.encoder.finish()
return nil
} | |
c171165 | required: required,
token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),
}
simple_key.mark = parser.mark
if !yaml_parser_remove_simple_key(parser) {
return false
}
parser.simple_keys[len(parser.simple_keys)-1] = simple_key
}
return true
} | |
c171166 | {
y := x + a - 1
return y - y%a
} | |
c171167 | underscores
eow = true
n := 1
for i+n+1 < len(runes) && runes[i+n+1] == '_' {
n++
}
// Leave at most one underscore if the underscore is between two digits
if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) {
n--
}
copy(runes[i+1:], runes[i+n+1:])
runes = runes[:len(runes)-n]
} else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) {
// lower->non-lower
eow = true
}
i++
if !eow {
continue
}
// [w,i) is a word.
word := string(runes[w:i])
if u := strings.ToUpper(word); initialisms[u] {
// Keep consistent case, which is lowercase only at the start.
if w == 0 && unicode.IsLower(runes[w]) {
u = strings.ToLower(u)
}
// All the common initialisms are ASCII,
// so we can replace the bytes exactly.
// TODO(dh): this won't be true once we allow custom initialisms
copy(runes[w:], []rune(u))
} else if w > 0 && strings.ToLower(word) == word {
// already all lowercase, and not the first word, so uppercase the first character.
runes[w] = unicode.ToUpper(runes[w])
}
w = i
}
return string(runes)
} | |
c171168 | }
return (&sanity{reporter: reporter}).checkFunction(fn)
} | |
c171169 | fn.WriteTo(os.Stderr)
panic("SanityCheck failed")
}
} | |
c171170 |
return blocks[0]
}
// Slow path:
m := make(map[*BasicBlock]bool)
for _, b := range blocks {
if m[b] {
return b
}
m[b] = true
}
return nil
} | |
c171171 |
if !filepath.IsAbs(path) {
return newIssuePath(resolvedRoot, resolvedPath), nil
}
relPath, err := filepath.Rel(resolvedRoot, resolvedPath)
return newIssuePath(resolvedRoot, relPath), err
} | |
c171172 | linter,
formatTmpl: formatTmpl,
}
err := formatTmpl.Execute(ioutil.Discard, issue)
return issue, err
} | |
c171173 | {
sorted.issues = append(sorted.issues, issue)
}
sort.Sort(sorted)
for _, issue := range sorted.issues {
out <- issue
}
close(out)
}()
return out
} | |
c171174 | b.expr(fn, e.Y)
}
// All edges from e.X to done carry the short-circuit value.
var edges []Value
for range done.Preds {
edges = append(edges, short)
}
// The edge from e.Y to done carries the value of e.Y.
fn.currentBlock = rhs
edges = append(edges, b.expr(fn, e.Y))
emitJump(fn, done)
fn.currentBlock = done
phi := &Phi{Edges: edges, Comment: e.Op.String()}
phi.pos = e.OpPos
phi.typ = t
return done.emit(phi)
} | |
c171175 | subelement extraction (e.g. Index, Field),
// to avoid large copies.
v = b.addr(fn, e, false).load(fn)
} else {
v = b.expr0(fn, e, tv)
}
if fn.debugInfo() {
emitDebugRef(fn, e, v, false)
}
return v
} | |
c171176 | []ast.Stmt) {
for _, s := range list {
b.stmt(fn, s)
}
} | |
c171177 | token.Pos) {
oldv := loc.load(fn)
loc.store(fn, emitArith(fn, op, oldv, emitConv(fn, incr, oldv.Type()), loc.typ(), pos))
} | |
c171178 | == 0:
// e.g. var x, y int
// Locals are implicitly zero-initialized.
for _, id := range spec.Names {
if !isBlankIdent(id) {
lhs := fn.addLocalForIdent(id)
if fn.debugInfo() {
emitDebugRef(fn, id, lhs, true)
}
}
}
default:
// e.g. var x, y = pos()
tuple := b.exprN(fn, spec.Values[0])
for i, id := range spec.Names {
if !isBlankIdent(id) {
fn.addLocalForIdent(id)
lhs := b.addr(fn, id, false) // non-escaping
lhs.store(fn, emitExtract(fn, tuple, i))
}
}
}
} | |
c171179 | kv.Key).(*Const).Int64()
} else {
i++
}
if i > max {
max = i
}
}
return max + 1
} | |
c171180 | by If. Don't forget conversions
// though.
cond := emitCompare(fn, token.EQL, tag, b.expr(fn, cond), cond.Pos())
emitIf(fn, cond, body, nextCond)
fn.currentBlock = nextCond
}
fn.currentBlock = body
fn.targets = &targets{
tail: fn.targets,
_break: done,
_fallthrough: fallthru,
}
b.stmtList(fn, cc.Body)
fn.targets = fn.targets.tail
emitJump(fn, done)
fn.currentBlock = nextCond
}
if dfltBlock != nil {
emitJump(fn, dfltBlock)
fn.currentBlock = dfltBlock
fn.targets = &targets{
tail: fn.targets,
_break: done,
_fallthrough: dfltFallthrough,
}
b.stmtList(fn, *dfltBody)
fn.targets = fn.targets.tail
}
emitJump(fn, done)
fn.currentBlock = done
} | |
c171181 | default_ = cc
continue
}
body := fn.newBasicBlock("typeswitch.body")
var next *BasicBlock
var casetype types.Type
var ti Value // ti, ok := typeassert,ok x <Ti>
for _, cond := range cc.List {
next = fn.newBasicBlock("typeswitch.next")
casetype = fn.Pkg.typeOf(cond)
var condv Value
if casetype == tUntypedNil {
condv = emitCompare(fn, token.EQL, x, nilConst(x.Type()), token.NoPos)
ti = x
} else {
yok := emitTypeTest(fn, x, casetype, cc.Case)
ti = emitExtract(fn, yok, 0)
condv = emitExtract(fn, yok, 1)
}
emitIf(fn, condv, body, next)
fn.currentBlock = next
}
if len(cc.List) != 1 {
ti = x
}
fn.currentBlock = body
b.typeCaseBody(fn, cc, ti, done)
fn.currentBlock = next
}
if default_ != nil {
b.typeCaseBody(fn, default_, x, done)
} else {
emitJump(fn, done)
}
fn.currentBlock = done
} | |
c171182 | label._break = done
label._continue = cont
}
emitJump(fn, loop)
fn.currentBlock = loop
if loop != body {
b.cond(fn, s.Cond, body, done)
fn.currentBlock = body
}
fn.targets = &targets{
tail: fn.targets,
_break: done,
_continue: cont,
}
b.stmt(fn, s.Body)
fn.targets = fn.targets.tail
emitJump(fn, cont)
if s.Post != nil {
fn.currentBlock = cont
b.stmt(fn, s.Post)
emitJump(fn, loop) // back-edge
}
fn.currentBlock = done
} | |
c171183 | panic("Cannot range over: " + rt.String())
}
// Evaluate both LHS expressions before we update either.
var kl, vl lvalue
if tk != nil {
kl = b.addr(fn, s.Key, false) // non-escaping
}
if tv != nil {
vl = b.addr(fn, s.Value, false) // non-escaping
}
if tk != nil {
kl.store(fn, k)
}
if tv != nil {
vl.store(fn, v)
}
if label != nil {
label._break = done
label._continue = loop
}
fn.targets = &targets{
tail: fn.targets,
_break: done,
_continue: loop,
}
b.stmt(fn, s.Body)
fn.targets = fn.targets.tail
emitJump(fn, loop) // back-edge
fn.currentBlock = done
} | |
c171184 | fn.addParamObj(params.At(i))
}
}
return
}
if fn.Prog.mode&LogSource != 0 {
defer logStack("build function %s @ %s", fn, fn.Prog.Fset.Position(fn.pos))()
}
fn.startBody()
fn.createSyntacticParams(recvField, functype)
b.stmt(fn, body)
if cb := fn.currentBlock; cb != nil && (cb == fn.Blocks[0] || cb == fn.Recover || cb.Preds != nil) {
// Control fell off the end of the function's body block.
//
// Block optimizations eliminate the current block, if
// unreachable. It is a builder invariant that
// if this no-arg return is ill-typed for
// fn.Signature.Results, this block must be
// unreachable. The sanity checker checks this.
fn.emit(new(RunDefers))
fn.emit(new(Return))
}
fn.finishBody()
} | |
c171185 | pkg.values[pkg.info.Defs[id]].(*Function)
if decl.Recv == nil && id.Name == "init" {
var v Call
v.Call.Value = fn
v.setType(types.NewTuple())
pkg.init.emit(&v)
}
b.buildFunction(fn)
} | |
c171186 | go func(p *Package) {
p.Build()
wg.Done()
}(p)
}
}
wg.Wait()
} | |
c171187 | }
panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %s",
id.Name, p.Prog.Fset.Position(id.Pos())))
} | |
c171188 | }
panic(fmt.Sprintf("no type for %T @ %s",
e, p.Prog.Fset.Position(e.Pos())))
} | |
c171189 | != e {
p.parser.problem = fmt.Sprintf("expected %s event but got %s", e, p.event.typ)
p.fail()
}
yaml_event_delete(&p.event)
p.event.typ = yaml_NO_EVENT
} | |
c171190 | !yaml_parser_parse(&p.parser, &p.event) {
p.fail()
}
return p.event.typ
} | |
c171191 | }
out = out.Elem()
again = true
}
if out.CanAddr() {
if u, ok := out.Addr().Interface().(Unmarshaler); ok {
good = d.callUnmarshaler(n, u)
return out, true, good
}
}
}
return out, false, false
} | |
c171192 | > -1 {
out = append(out, f[:n])
f = f[n:]
} else {
out = append(out, f)
f = ""
}
}
}
return out, nil
} | |
c171193 |
} else {
if m[prec] != "" {
// Literal precision
v.Precision = Literal(atoi(m[prec]))
} else if m[precStar] != "" {
// Star precision
if m[precIndex] != "" {
v.Precision = Star{atoi(m[precIndex])}
} else {
v.Precision = Star{-1}
}
} else {
// Zero precision
v.Precision = Zero{}
}
}
if m[verb] == "%" {
v.Value = 0
} else if m[verbIndex] != "" {
v.Value = atoi(m[verbIndex])
} else {
v.Value = -1
}
return v, len(m[0]), nil
} | |
c171194 | return true
}
for _, block := range fn.Blocks {
if len(block.Instrs) == 0 {
continue
}
if _, ok := block.Instrs[len(block.Instrs)-1].(*ssa.Return); ok {
return true
}
}
return false
} | |
c171195 | buffer []byte) (n int, err error) {
return parser.input_reader.Read(buffer)
} | |
c171196 | nil {
panic("must set the input source only once")
}
parser.read_handler = yaml_reader_read_handler
parser.input_reader = r
} | |
c171197 | make([]yaml_emitter_state_t, 0, initial_stack_size),
events: make([]yaml_event_t, 0, initial_queue_size),
}
} | |
c171198 | buffer []byte) error {
_, err := emitter.output_writer.Write(buffer)
return err
} | |
c171199 | nil {
panic("must set the output target only once")
}
emitter.write_handler = yaml_writer_write_handler
emitter.output_writer = w
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.