id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c19500
n.sendChanRefCount[ptr] cnt++ n.sendChanRefCount[ptr] = cnt }
c19501
to close a nonexistant channel, see what happens... } cnt-- n.sendChanRefCount[ptr] = cnt return cnt == 0 }
c19502
if !ok { return reflect.ValueOf(nil), fmt.Errorf("Inport not found: '%s'", name) } return pName.channel, nil }
c19503
if !ok { return reflect.ValueOf(nil), fmt.Errorf("Outport not found: '%s'", name) } return pName.channel, nil }
c19504
g.getInPort(procPort) } else { // Is a proc channel, err = n.getProcPort(procName, procPort, reflect.RecvDir) } } else { return fmt.Errorf("Could not map inport: process '%s' not found", procName) } if err == nil { n.inPorts[name] = port{proc: procName, port: procPort, channel: channel} } return err...
c19505
processName, port: portName}) return nil } return fmt.Errorf("AddIIP error: could not find '%s.%s'", processName, portName) }
c19506
= iip{}, n.iips[len(n.iips)-1], n.iips[:len(n.iips)-1] return nil } } return fmt.Errorf("RemoveIIP error: could not find IIP for '%s.%s'", processName, portName) }
c19507
!= nil { return err } // Make a channel of an appropriate type chanType := reflect.ChanOf(reflect.BothDir, recvPort.Type().Elem()) channel = reflect.MakeChan(chanType, n.conf.BufferSize) recvPort.Set(channel) found = true shouldClose = true } if found { // Send data to the port go...
c19508
make([]connection, 0, conf.Capacity), sendChanRefCount: make(map[uintptr]uint, conf.Capacity), sendChanMutex: new(sync.Mutex), iips: make([]iip, 0, conf.Capacity), } }
c19509
n.Add(name, NewDefaultGraph()) }
c19510
err != nil { return err } return n.Add(processName, proc) }
c19511
does not exist", processName) } delete(n.procs, processName) return nil }
c19512
&Accounting{Symbol:symbol,Precision:precision} ac.init() ac.isInitialized = true return ac }
c19513
Format: format, FormatNegative: formatNegative, FormatZero: formatZero, } ac.isInitialized = true return ac }
c19514
} formattedNumber := FormatNumberInt(value, accounting.Precision, accounting.Thousand, accounting.Decimal) return accounting.formatMoneyString(formattedNumber) }
c19515
:= FormatNumberDecimal(value, accounting.Precision, accounting.Thousand, accounting.Decimal) return accounting.formatMoneyString(formattedNumber) }
c19516
} result = fmt.Sprintf("%d%s", x, result) if minus { result = "-" + result } if precision > 0 { result += decimalStr + strings.Repeat("0", precision) } return result }
c19517
formatNumberString(fmt.Sprintf(fmt.Sprintf("%%.%df", precision), x), precision, thousand, decimalStr) }
c19518
return formatNumberString(x.StringFixed(int32(precision)), precision, thousand, decimalStr) }
c19519
"prometheus_host", "0.0.0.0", "Prometheus metrics hostname") command.PersistentFlags().IntVar(&service.PrometheusConfig.Port, "prometheus_port", 9000, "Prometheus metrics port") return command }
c19520
service.Config.Address()) return createGrpcServer().Serve(service.ServiceListener) }
c19521
defer cancel() if err := service.PrometheusServer.Shutdown(ctx); err != nil { logrus.Infof("Timeout during shutdown of metrics server. Error: %v", err) } }
c19522
return strings.Replace(strcase.ToSnake(p.Name), "-", "_", -1) }
c19523
{ return fmt.Sprintf("%s:%d", c.Host, c.Port) }
c19524
grpc_recovery.UnaryServerInterceptor(), }, StreamInts: []grpc.StreamServerInterceptor{ grpc_prometheus.StreamServerInterceptor, grpc_recovery.StreamServerInterceptor(), }, } }
c19525
= n AddUnaryInterceptor(otgrpc.OpenTracingServerInterceptor( fromenv.Tracer(n))) }
c19526
{ service.UnaryInts = append(service.UnaryInts, unint) }
c19527
{ service.StreamInts = append(service.StreamInts, sint) }
c19528
port = val } if service.Registry != nil { url, err := service.Registry.Get(name) if err != nil { fmt.Printf("lile: error contacting registry for service %s. err: %s \n", name, err.Error()) } return url } return fmt.Sprintf("%s:%s", host, port) }
c19529
pairs = append(pairs, key, value) } } if strings.HasPrefix(strings.ToLower(key), "x-") { for _, value := range values { pairs = append(pairs, key, value) } } } } ctx = metadata.AppendToOutgoingContext(ctx, pairs...) return invoker(ctx, method, req, resp, cc, opts...) } }
c19530
to determine current working directory: %v", err) } return wd }
c19531
m[k] = v } env = make([]string, 0, len(m)) for k, v := range m { env = append(env, fmt.Sprintf("%s=%s", k, v)) } return env }
c19532
// queue all dependant actions. var results []chan error for _, dep := range a.Deps { results = append(results, execute(seen, dep)) } wg.Add(1) go func() { defer wg.Done() // wait for dependant actions for _, r := range results { if err := get(r); err != nil { result <- err return ...
c19533
err := NewContext(projectroot, gb.GcToolchain()) if err != nil { return errors.Wrap(err, "unable to construct context") } defer ctx.Destroy() ctx.Debug("args: %v", args) return cmd.Run(ctx, args) }
c19534
proj := gb.NewProject(root) ctx, err := gb.NewContext(proj, options...) if err != nil { return nil, err } ctx.Debug("project root %q", proj.Projectdir()) return ctx, err }
c19535
:= untar(tmpdir, r); err != nil { os.RemoveAll(tmpdir) return err } if err := os.Rename(tmpdir, dest); err != nil { os.RemoveAll(tmpdir) return err } return nil }
c19536
!= nil { fmt.Printf("could not load all packages: %v\n", err) } out = append(out, pkgs...) continue } out = append(out, a) } return out }
c19537
filepath.SkipDir } name := filepath.ToSlash(path[len(src):]) if pattern == "std" && strings.Contains(name, ".") { return filepath.SkipDir } if !treeCanMatch(name) { return filepath.SkipDir } if match(name) { pkgs = append(pkgs, name) } return nil }) return pkgs, err }
c19538
{ return nil, err } // step 2. build this package build, err := Compile(pkg, deps...) if err != nil { return nil, err } if build == nil { panic("build action was nil") // shouldn't happen } // record the final action as the action that represents // building this package. targets[pkg.ImportPath] = b...
c19539
runtime/cgo which is // only visible after cgo file generation. // TODO(dfc) what about pkg.Main && pkg.CgoFiles > 0 ?? extra = append(extra, "runtime/cgo") } if pkg.TestScope { extra = append(extra, "regexp") if version.Version > 1.7 { // since Go 1.8 tests have additional implicit dependencies extr...
c19540
return fmt.Errorf("GOOS cannot be blank") } c.gotargetos = goos return nil } }
c19541
return fmt.Errorf("GOARCH cannot be blank") } c.gotargetarch = goarch return nil } }
c19542
*Context) error { c.buildtags = append(c.buildtags, tags...) return nil } }
c19543
func(c *Context) error { c.gcflags = append(c.gcflags, flags...) return nil } }
c19544
func(c *Context) error { c.ldflags = append(c.ldflags, flags...) return nil } }
c19545
Tags("race")(c) Gcflags("-race")(c) Ldflags("-race")(c) return nil }
c19546
ctx.gotargetarch bc.CgoEnabled = cgoEnabled(ctx.gohostos, ctx.gohostarch, ctx.gotargetos, ctx.gotargetarch) bc.ReleaseTags = releaseTags bc.BuildTags = ctx.buildtags i, err := buildImporter(&bc, &ctx) if err != nil { return nil, err } ctx.importer = i // C and unsafe are fake packages synthesised by the c...
c19547
return nil, err } pkg.NotStale = !pkg.isStale() return pkg, nil }
c19548
filepath.Join(c.Project.Pkgdir(), c.ctxString()) }
c19549
== "." || path == ".." || strings.HasPrefix(path, "./") || strings.HasPrefix(path, "../") { return nil, errors.Errorf("import %q: relative import not supported", path) } return c.loadPackage(nil, path) }
c19550
return nil, err } // update the import path as the import may have been discovered via vendoring. p.Imports[i] = pkg.ImportPath stale = stale || !pkg.NotStale } pkg, err := c.newPackage(p) if err != nil { return nil, errors.Wrapf(err, "loadPackage(%q)", path) } pkg.Main = pkg.Name == "main" pkg.NotSt...
c19551
work directory: %v", c.workdir) return os.RemoveAll(c.workdir) }
c19552
c.buildtags...) return strings.Join(v, "-") }
c19553
signalsToIgnore...) go func() { <-sig close(interrupted) }() }
c19554
if debugCopypath { fmt.Printf("skipping symlink: %v\n", path) } return nil } dst := filepath.Join(dst, path[len(src):]) return Copyfile(dst, path) }) if err != nil { // if there was an error during copying, remove the partial copy. RemoveAll(dst) } return err }
c19555
{ return errors.Wrapf(err, "copyfile: create(%q)", dst) } defer w.Close() if debugCopyfile { fmt.Printf("copyfile(dst: %v, src: %v)\n", dst, src) } _, err = io.Copy(w, r) return err }
c19556
var buf bytes.Buffer err := runOut(&buf, pkg.Dir, nil, gcc[0], append(gcc[1:], args...)...) if err != nil { fmt.Fprintf(os.Stderr, "# %s\n", pkg.ImportPath) io.Copy(os.Stderr, &buf) } pkg.Record(gcc[0], time.Since(t0)) return err }
c19557
var buf bytes.Buffer err := runOut(&buf, pkg.Dir, nil, cmd[0], append(cmd[1:], args...)...) if err != nil { fmt.Fprintf(os.Stderr, "# %s\n", pkg.ImportPath) io.Copy(os.Stderr, &buf) } pkg.Record("gccld", time.Since(t0)) return err }
c19558
!= nil { return nil } args = append(args, libgcc) } t0 := time.Now() var buf bytes.Buffer err := runOut(&buf, dir, nil, cmd[0], append(cmd[1:], args...)...) if err != nil { fmt.Fprintf(os.Stderr, "# %s\n", pkg.ImportPath) io.Copy(os.Stderr, &buf) } pkg.Record("gcc3", time.Since(t0)) return err }
c19559
err := runOut(&buf, ".", nil, cmd[0], args...) return strings.TrimSpace(buf.String()), err }
c19560
v = def } return strings.Fields(v) }
c19561
cxxflags = stringList(envList("CGO_CXXFLAGS", defaults), p.CgoCXXFLAGS) ldflags = stringList(envList("CGO_LDFLAGS", defaults), p.CgoLDFLAGS) return }
c19562
p.CgoPkgConfig...) out.Reset() err = runOut(&out, p.Dir, nil, "pkg-config", args...) if err != nil { return nil, nil, err } ldflags := strings.Fields(out.String()) return cflags, ldflags, nil }
c19563
"CGO_CFLAGS=" + strings.Join(quoteFlags(cflags), " "), "CGO_LDFLAGS=" + strings.Join(quoteFlags(ldflags), " "), } var buf bytes.Buffer err := runOut(&buf, pkg.Dir, cgoenv, cgo, args...) if err != nil { fmt.Fprintf(os.Stderr, "# %s\n", pkg.ImportPath) io.Copy(os.Stderr, &buf) } return err }
c19564
return errors.Errorf("unsuppored Go version: %v", runtime.Version()) } var buf bytes.Buffer err := runOut(&buf, pkg.Dir, nil, cgo, args...) if err != nil { fmt.Fprintf(os.Stderr, "# %s\n", pkg.ImportPath) io.Copy(os.Stderr, &buf) } return err }
c19565
filepath.Join(pkg.Workdir(), pkg.pkgname(), "_cgo") }
c19566
{ return ccompilerCmd(pkg, "CC", defaultCC, objdir) }
c19567
{ return ccompilerCmd(pkg, "CXX", defaultCXX, objdir) }
c19568
for multithreading with pthread library. switch pkg.gotargetos { case "windows": a = append(a, "-mthreads") default: a = append(a, "-pthread") } if strings.Contains(a[0], "clang") { // disable ASCII art in clang errors, if possible a = append(a, "-fno-caret-diagnostics") // clang is too smart about com...
c19569
:= envList(envvar, defcmd) return compiler[0] }
c19570
path[:len(path)-len(filepath.Ext(path))] }
c19571
if tag, ok := kv["tag"]; ok { root := filepath.Join(cachePath(), hash(prefix, tag)) dest := filepath.Join(root, "src", filepath.FromSlash(prefix)) fi, err := os.Stat(dest) if err == nil { if !fi.IsDir() { return nil, errors.Errorf("%s is not a directory", dest) } } if err != nil { ...
c19572
could not locate dependant package %q ", p.Name, i) } pkg.Imports = append(pkg.Imports, dep) } return pkg, nil }
c19573
+ len(p.SFiles) + len(p.SysoFiles) + len(p.SwigFiles) + len(p.SwigCXXFiles) if p.Goroot { switch p.ImportPath { case "bytes", "internal/poll", "net", "os", "runtime/pprof", "sync", "syscall", "time": extFiles++ } } return extFiles == 0 }
c19574
pkg.ctxString() } else if len(pkg.buildtags) > 0 { target += "-" + strings.Join(pkg.buildtags, "-") } if pkg.gotargetos == "windows" { target += ".exe" } return target }
c19575
{ return filepath.Join(pkg.Workdir(), pkg.objname()) }
c19576
standard lib return filepath.Join(runtime.GOROOT(), "pkg", pkg.gotargetos+"_"+pkg.gotargetarch+"_race", importpath) case pkg.Goroot: // standard lib return filepath.Join(runtime.GOROOT(), "pkg", pkg.gotargetos+"_"+pkg.gotargetarch, importpath) default: return filepath.Join(pkg.Pkgdir(), importpath) } }
c19577
p.ImportPath == "unsafe" { continue // ignore stale imports of synthetic packages } if olderThan(p.pkgpath()) { pkg.debug("%s is older than %s", pkg.pkgpath(), p.pkgpath()) return true } } // if the main package is up to date but _newer_ than the binary (which // could have been removed), then consi...
c19578
} } for k := range b { if !a[k] { r[k] = true } } return r }
c19579
return nil, errors.Wrapf(err, "ParseFile") } defer r.Close() return Parse(r) }
c19580
mesg.WriteString("\n ") } fmt.Fprintf(&mesg, "%s()\n at %s:%d", lastFn, frame.File, frame.Line) } } lastFn = frame.Function if !more { break } } // At least one net/http frame found if mesg.Len() > 0 { break } netHTTPEnd = true // retry ...
c19581
routeKey, []string) { m.mu.RLock() defer m.mu.RUnlock() return m.responders[key], key, nil }
c19582
else { sm = sm[1:] } return regInfo.responder, routeKey{ Method: key.Method, URL: regInfo.origRx, }, sm } } } return nil, key, nil }
c19583
m.noResponder = responder m.mu.Unlock() }
c19584
:= m.totalCallCount m.mu.RUnlock() return count }
c19585
Responder { return r.times("Times", n, fn...) }
c19586
{ numbers64 = append(numbers64, int64(id)) } return h.EncodeInt64(numbers64) }
c19587
for _, id := range result64 { result = append(result, int(id)) } return result, nil }
c19588
buffer = append(buffer, alphabet...) consistentShuffleInPlace(alphabet, buffer[:len(alphabet)]) number, err := unhash(subHash, alphabet) if err != nil { return nil, err } result = append(result, number) } } sanityCheck, _ := h.EncodeInt64(result) if sanityCheck != hash { return result, fmt....
c19589
return err } *cs = CharsetID(u) return nil } var s string if err := json.Unmarshal(p, &s); err != nil { return err } u, err := strconv.ParseUint(s, 16, 16) if err != nil { return err } *cs = CharsetID(u) return nil }
c19590
return err } *lng = LangID(u) return nil } var s string if err := json.Unmarshal(p, &s); err != nil { return err } u, err := strconv.ParseUint(s, 16, 16) if err != nil { return err } *lng = LangID(u) return nil }
c19591
= []byte{} // Build strings vi.Children = buildStringFileInfo(v) // Build translation vi.Children2 = buildVarFileInfo(v.VarFileInfo) // Calculate the total size vi.WLength += 6 + uint16(soFar) + vi.WValueLength + vi.Children.WLength + vi.Children2.WLength v.Structure = vi }
c19592
return fmt.Sprintf("%d.%d.%d.%d", f.Major, f.Minor, f.Patch, f.Build) }
c19593
return err } defer manifest.Close() id := <-newID coff.AddResource(rtManifest, id, manifest) } // If icon is enabled if vi.IconPath != "" { if err := addIcon(coff, vi.IconPath, newID); err != nil { return err } } coff.Freeze() // Write to file return writeCoff(coff, filename) }
c19594
ioutil.WriteFile(filename, vi.Buffer.Bytes(), 0655) }
c19595
} s := &State{ schema: schema, } return s, nil }
c19596
content type") ctx.Error("Invalid content type", 400) return } ctx.Logger.Info("processing request") if _, err := ctx.Encode(s.schema.Exec(ctx.ToContext(), req.Query, req.OperationName, req.Variables)); err != nil { ctx.SetStatusCode(415) } ctx.Logger.Info("processing request done") }
c19597
bind: ln.Addr().String(), srv: srv, }) app.runningServersMu.Unlock() if err = srv.Serve(ln); err != nil { app.internalLog.Errorf("ListenAndServe failed: %s", err) } return err }
c19598
return UDP, nil case Custom: return Custom, nil default: return ServiceType(typeName), ErrServiceTypeNotFound } }
c19599
case string: r.NotFound(func(ctx *Context) { ctx.HTML() ctx.SendFile(v) }) default: r.NotFound(r.determineHandler(v)) } return r }