_id
stringlengths 86
170
| text
stringlengths 54
39.3k
|
|---|---|
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/process.go#L112-L162
|
func Core(proc *core.Process) (p *Process, err error) {
// Make sure we have DWARF info.
if _, err := proc.DWARF(); err != nil {
return nil, err
}
// Guard against failures of proc.Read* routines.
/*
defer func() {
e := recover()
if e == nil {
return
}
p = nil
if x, ok := e.(error); ok {
err = x
return
}
panic(e) // Not an error, re-panic it.
}()
*/
p = &Process{
proc: proc,
runtimeMap: map[core.Address]*Type{},
dwarfMap: map[dwarf.Type]*Type{},
}
// Initialize everything that just depends on DWARF.
p.readDWARFTypes()
p.readRuntimeConstants()
p.readGlobals()
// Find runtime globals we care about. Initialize regions for them.
p.rtGlobals = map[string]region{}
for _, g := range p.globals {
if strings.HasPrefix(g.Name, "runtime.") {
p.rtGlobals[g.Name[8:]] = region{p: p, a: g.Addr, typ: g.Type}
}
}
// Read all the data that depend on runtime globals.
p.buildVersion = p.rtGlobals["buildVersion"].String()
p.readModules()
p.readHeap()
p.readGs()
p.readStackVars() // needs to be after readGs.
p.markObjects() // needs to be after readGlobals, readStackVars.
return p, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/target/easyjson.go#L1082-L1086
|
func (v *GetBrowserContextsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget11(&r, v)
return r.Error()
}
|
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/ipblock.go#L40-L45
|
func (c *Client) ListIPBlocks() (*IPBlocks, error) {
url := ipblockColPath() + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty)
ret := &IPBlocks{}
err := c.client.Get(url, ret, http.StatusOK)
return ret, err
}
|
https://github.com/Financial-Times/base-ft-rw-app-go/blob/1ea8a13e1f37b95318cd965796558d932750f407/baseftrwapp/baseftapp.go#L39-L48
|
func RunServer(services map[string]Service, healthHandler func(http.ResponseWriter, *http.Request), port int, serviceName string, env string) {
RunServerWithConf(RWConf{
EnableReqLog: true,
Services: services,
Env: env,
HealthHandler: healthHandler,
Port: port,
ServiceName: serviceName,
})
}
|
https://github.com/geoffgarside/ber/blob/27a1aff36ce64dbe5d93c08cc5f161983134ddc5/ber.go#L322-L324
|
func parseT61String(bytes []byte) (ret string, err error) {
return string(bytes), nil
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps/util.go#L65-L88
|
func InputBranches(input *Input) []*pfs.Branch {
var result []*pfs.Branch
VisitInput(input, func(input *Input) {
if input.Pfs != nil {
result = append(result, &pfs.Branch{
Repo: &pfs.Repo{Name: input.Pfs.Repo},
Name: input.Pfs.Branch,
})
}
if input.Cron != nil {
result = append(result, &pfs.Branch{
Repo: &pfs.Repo{Name: input.Cron.Repo},
Name: "master",
})
}
if input.Git != nil {
result = append(result, &pfs.Branch{
Repo: &pfs.Repo{Name: input.Git.Name},
Name: input.Git.Branch,
})
}
})
return result
}
|
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/routes_client.go#L122-L145
|
func (a *Client) PatchAppsAppRoutesRoute(params *PatchAppsAppRoutesRouteParams) (*PatchAppsAppRoutesRouteOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPatchAppsAppRoutesRouteParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "PatchAppsAppRoutesRoute",
Method: "PATCH",
PathPattern: "/apps/{app}/routes/{route}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &PatchAppsAppRoutesRouteReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*PatchAppsAppRoutesRouteOK), nil
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/crds/client.go#L154-L180
|
func registerResource(config *rest.Config, t Type) error {
c, err := apiextensionsclient.NewForConfig(config)
if err != nil {
return err
}
crd := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: v1.ObjectMeta{
Name: fmt.Sprintf("%s.%s", t.Plural, group),
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: group,
Version: version,
Scope: apiextensionsv1beta1.NamespaceScoped,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Singular: t.Singular,
Plural: t.Plural,
Kind: t.Kind,
ListKind: t.ListKind,
},
},
}
if _, err := c.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd); err != nil && !apierrors.IsAlreadyExists(err) {
return err
}
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L306-L315
|
func (p *GetAllCookiesParams) Do(ctx context.Context) (cookies []*Cookie, err error) {
// execute
var res GetAllCookiesReturns
err = cdp.Execute(ctx, CommandGetAllCookies, nil, &res)
if err != nil {
return nil, err
}
return res.Cookies, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/tracing/types.go#L75-L77
|
func (t *StreamFormat) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L110-L117
|
func (f *FakeClient) IsMember(org, user string) (bool, error) {
for _, m := range f.OrgMembers[org] {
if m == user {
return true, nil
}
}
return false, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/target/easyjson.go#L196-L200
|
func (v *SetDiscoverTargetsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget1(&r, v)
return r.Error()
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L1150-L1158
|
func (u LedgerEntryData) MustOffer() OfferEntry {
val, ok := u.GetOffer()
if !ok {
panic("arm Offer is not set")
}
return val
}
|
https://github.com/mgutz/str/blob/968bf66e3da857419e4f6e71b2d5c9ae95682dc4/funcsAO.go#L290-L295
|
func Left(s string, n int) string {
if n < 0 {
return Right(s, -n)
}
return Substr(s, 0, n)
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/archive/transport.go#L51-L84
|
func ParseReference(refString string) (types.ImageReference, error) {
if refString == "" {
return nil, errors.Errorf("docker-archive reference %s isn't of the form <path>[:<reference>]", refString)
}
parts := strings.SplitN(refString, ":", 2)
path := parts[0]
var destinationRef reference.NamedTagged
// A :tag was specified, which is only necessary for destinations.
if len(parts) == 2 {
ref, err := reference.ParseNormalizedNamed(parts[1])
if err != nil {
return nil, errors.Wrapf(err, "docker-archive parsing reference")
}
ref = reference.TagNameOnly(ref)
if _, isDigest := ref.(reference.Canonical); isDigest {
return nil, errors.Errorf("docker-archive doesn't support digest references: %s", refString)
}
refTagged, isTagged := ref.(reference.NamedTagged)
if !isTagged {
// Really shouldn't be hit...
return nil, errors.Errorf("internal error: reference is not tagged even after reference.TagNameOnly: %s", refString)
}
destinationRef = refTagged
}
return archiveReference{
destinationRef: destinationRef,
path: path,
}, nil
}
|
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcpurgecache/tcpurgecache.go#L148-L156
|
func (purgeCache *PurgeCache) PurgeRequests(provisionerId, workerType, since string) (*OpenPurgeRequestList, error) {
v := url.Values{}
if since != "" {
v.Add("since", since)
}
cd := tcclient.Client(*purgeCache)
responseObject, _, err := (&cd).APICall(nil, "GET", "/purge-cache/"+url.QueryEscape(provisionerId)+"/"+url.QueryEscape(workerType), new(OpenPurgeRequestList), v)
return responseObject.(*OpenPurgeRequestList), err
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/y/watermark.go#L90-L92
|
func (w *WaterMark) Done(index uint64) {
w.markCh <- mark{index: index, done: true}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/debugger.go#L346-L348
|
func (p *PauseParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandPause, nil, nil)
}
|
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step0.go#L9-L16
|
func step0(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("'s'", "'s", "'")
if suffix == "" {
return false
}
w.RemoveLastNRunes(len(suffixRunes))
return true
}
|
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/apps/put_apps_app_parameters.go#L93-L96
|
func (o *PutAppsAppParams) WithApp(app string) *PutAppsAppParams {
o.SetApp(app)
return o
}
|
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L254-L256
|
func (t Templates) Respond(w http.ResponseWriter, name string, data interface{}) {
t.RespondWithStatus(w, name, data, 0)
}
|
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/cmd/utils.go#L47-L140
|
func EnvelopeToMarkdown(w io.Writer, e *enmime.Envelope, name string) error {
md := &markdown{bufio.NewWriter(w)}
md.H1(name)
// Output a sorted list of headers, minus the ones displayed later
md.H2("Header")
if e.Root != nil && e.Root.Header != nil {
keys := make([]string, 0, len(e.Root.Header))
for k := range e.Root.Header {
switch strings.ToLower(k) {
case "from", "to", "cc", "bcc", "reply-to", "subject":
continue
}
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
md.Printf(" %v: %v\n", k, e.GetHeader(k))
}
}
md.Println()
md.H2("Envelope")
for _, hkey := range addressHeaders {
addrlist, err := e.AddressList(hkey)
if err != nil {
if err == mail.ErrHeaderNotPresent {
continue
}
return err
}
md.H3(hkey)
for _, addr := range addrlist {
md.Printf("- %v `<%v>`\n", addr.Name, addr.Address)
}
md.Println()
}
md.H3("Subject")
md.Println(e.GetHeader("Subject"))
md.Println()
md.H2("Body Text")
md.Println(e.Text)
md.Println()
md.H2("Body HTML")
md.Println(e.HTML)
md.Println()
md.H2("Attachment List")
for _, a := range e.Attachments {
md.Printf("- %v (%v)\n", a.FileName, a.ContentType)
if a.ContentID != "" {
md.Printf(" Content-ID: %s\n", a.ContentID)
}
}
md.Println()
md.H2("Inline List")
for _, a := range e.Inlines {
md.Printf("- %v (%v)\n", a.FileName, a.ContentType)
if a.ContentID != "" {
md.Printf(" Content-ID: %s\n", a.ContentID)
}
}
md.Println()
md.H2("Other Part List")
for _, a := range e.OtherParts {
md.Printf("- %v (%v)\n", a.FileName, a.ContentType)
if a.ContentID != "" {
md.Printf(" Content-ID: %s\n", a.ContentID)
}
}
md.Println()
md.H2("MIME Part Tree")
if e.Root == nil {
md.Println("Message was not MIME encoded")
} else {
FormatPart(md, e.Root, " ")
}
if len(e.Errors) > 0 {
md.Println()
md.H2("Errors")
for _, perr := range e.Errors {
md.Println("-", perr)
}
}
return md.Flush()
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/event.go#L58-L69
|
func kindList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
kinds, err := event.GetKinds()
if err != nil {
return err
}
if len(kinds) == 0 {
w.WriteHeader(http.StatusNoContent)
return nil
}
w.Header().Add("Content-Type", "application/json")
return json.NewEncoder(w).Encode(kinds)
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/manifest/docker_schema1.go#L126-L135
|
func (m *Schema1) LayerInfos() []LayerInfo {
layers := make([]LayerInfo, len(m.FSLayers))
for i, layer := range m.FSLayers { // NOTE: This includes empty layers (where m.History.V1Compatibility->ThrowAway)
layers[(len(m.FSLayers)-1)-i] = LayerInfo{
BlobInfo: types.BlobInfo{Digest: layer.BlobSum, Size: -1},
EmptyLayer: m.ExtractedV1Compatibility[i].ThrowAway,
}
}
return layers
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/app.go#L697-L715
|
func setNodeStatus(w http.ResponseWriter, r *http.Request, t auth.Token) error {
if t.GetAppName() != app.InternalAppName {
return &errors.HTTP{Code: http.StatusForbidden, Message: "this token is not allowed to execute this action"}
}
var hostInput provision.NodeStatusData
err := ParseInput(r, &hostInput)
if err != nil {
return err
}
result, err := app.UpdateNodeStatus(hostInput)
if err != nil {
if err == provision.ErrNodeNotFound {
return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
}
return err
}
w.Header().Add("Content-Type", "application/json")
return json.NewEncoder(w).Encode(result)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/types.go#L66-L68
|
func (t *RequestStage) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/cachestorage/types.go#L75-L77
|
func (t *CachedResponseType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
|
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/internal/stack/stack.go#L32-L37
|
func (s *Stack) Top() (interface{}, error) {
if len(*s) == 0 {
return nil, errors.New("nothing on stack")
}
return (*s)[len(*s)-1], nil
}
|
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/nic.go#L67-L73
|
func (c *Client) GetNic(dcid, srvid, nicid string) (*Nic, error) {
url := nicPath(dcid, srvid, nicid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty)
ret := &Nic{}
err := c.client.Get(url, ret, http.StatusOK)
return ret, err
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L347-L350
|
func (p GetBoxModelParams) WithObjectID(objectID runtime.RemoteObjectID) *GetBoxModelParams {
p.ObjectID = objectID
return &p
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L986-L990
|
func (v *SetBreakpointReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger10(&r, v)
return r.Error()
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/errutil/http.go#L33-L37
|
func PrettyPrintCode(h *HTTPError) string {
codeNumber := h.Code()
codeText := http.StatusText(h.Code())
return fmt.Sprintf("%d %s", codeNumber, codeText)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L6805-L6809
|
func (v AddRuleParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss64(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L6434-L6438
|
func (v EventRequestWillBeSent) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork50(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/deck/job_history.go#L119-L127
|
func (bucket gcsBucket) resolveSymLink(symLink string) (string, error) {
data, err := bucket.readObject(symLink)
if err != nil {
return "", fmt.Errorf("failed to read %s: %v", symLink, err)
}
// strip gs://<bucket-name> from global address `u`
u := string(data)
return prefixRe.ReplaceAllString(u, ""), nil
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/path.go#L110-L136
|
func (p *Path) ArcTo(cx, cy, rx, ry, startAngle, angle float64) {
endAngle := startAngle + angle
clockWise := true
if angle < 0 {
clockWise = false
}
// normalize
if clockWise {
for endAngle < startAngle {
endAngle += math.Pi * 2.0
}
} else {
for startAngle < endAngle {
startAngle += math.Pi * 2.0
}
}
startX := cx + math.Cos(startAngle)*rx
startY := cy + math.Sin(startAngle)*ry
if len(p.Components) > 0 {
p.LineTo(startX, startY)
} else {
p.MoveTo(startX, startY)
}
p.appendToPath(ArcToCmp, cx, cy, rx, ry, startAngle, angle)
p.x = cx + math.Cos(endAngle)*rx
p.y = cy + math.Sin(endAngle)*ry
}
|
https://github.com/cloudfoundry-incubator/cf-test-helpers/blob/83791edc4b0a2d48b602088c30332063b8f02f32/workflowhelpers/internal/user.go#L144-L155
|
func generatePassword() string {
const randomBytesLength = 16
encoding := base64.RawURLEncoding
randomBytes := make([]byte, encoding.DecodedLen(randomBytesLength))
_, err := rand.Read(randomBytes)
if err != nil {
panic(fmt.Errorf("Could not generate random password: %s", err.Error()))
}
return "A0a!" + encoding.EncodeToString(randomBytes)
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/key_index.go#L127-L145
|
func (ki *keyIndex) tombstone(lg *zap.Logger, main int64, sub int64) error {
if ki.isEmpty() {
if lg != nil {
lg.Panic(
"'tombstone' got an unexpected empty keyIndex",
zap.String("key", string(ki.key)),
)
} else {
plog.Panicf("store.keyindex: unexpected tombstone on empty keyIndex %s", string(ki.key))
}
}
if ki.generations[len(ki.generations)-1].isEmpty() {
return ErrRevisionNotFound
}
ki.put(lg, main, sub)
ki.generations = append(ki.generations, generation{})
keysGauge.Dec()
return nil
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/oci/internal/oci_util.go#L23-L33
|
func ValidateImageName(image string) error {
if len(image) == 0 {
return nil
}
var err error
if !refRegexp.MatchString(image) {
err = errors.Errorf("Invalid image %s", image)
}
return err
}
|
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cv.go#L61-L63
|
func Laplace(src, dst *IplImage, aperture_size int) {
C.cvLaplace(unsafe.Pointer(src), unsafe.Pointer(dst), C.int(aperture_size))
}
|
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/dominator.go#L303-L333
|
func (d *dominators) reverse() {
// One inbound edge per vertex. Then we need an extra so that you can
// always look at ridx[i+1], and another for working storage while
// populating redge.
cnt := make([]int, len(d.idom)+2)
// Fill cnt[2:] with the number of outbound edges for each vertex.
tmp := cnt[2:]
for _, idom := range d.idom {
tmp[idom]++
}
// Make tmp cumulative. After this step, cnt[1:] is what we want for
// ridx, but the next step messes it up.
var n int
for idx, c := range tmp {
n += c
tmp[idx] = n
}
// Store outbound edges in redge, using cnt[1:] as the index to store
// the next edge for each vertex. After we're done, everything's been
// shifted over one, and cnt is ridx.
redge := make([]vName, len(d.idom))
tmp = cnt[1:]
for i, idom := range d.idom {
redge[tmp[idom]] = vName(i)
tmp[idom]++
}
d.redge, d.ridx = redge, cnt[:len(cnt)-1]
}
|
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/stats.go#L70-L76
|
func (s *Stats) AddInt64(src *int64, val int64) {
if s.isLocal {
*src += val
} else {
atomic.AddInt64(src, val)
}
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/arena.go#L84-L93
|
func (s *Arena) putVal(v y.ValueStruct) uint32 {
l := uint32(v.EncodedSize())
n := atomic.AddUint32(&s.n, l)
y.AssertTruef(int(n) <= len(s.buf),
"Arena too small, toWrite:%d newTotal:%d limit:%d",
l, n, len(s.buf))
m := n - l
v.Encode(s.buf[m:])
return m
}
|
https://github.com/go-openapi/loads/blob/74628589c3b94e3526a842d24f46589980f5ab22/spec.go#L99-L112
|
func Embedded(orig, flat json.RawMessage) (*Document, error) {
var origSpec, flatSpec spec.Swagger
if err := json.Unmarshal(orig, &origSpec); err != nil {
return nil, err
}
if err := json.Unmarshal(flat, &flatSpec); err != nil {
return nil, err
}
return &Document{
raw: orig,
origSpec: &origSpec,
spec: &flatSpec,
}, nil
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L3250-L3257
|
func (u SetOptionsResult) ArmForSwitch(sw int32) (string, bool) {
switch SetOptionsResultCode(sw) {
case SetOptionsResultCodeSetOptionsSuccess:
return "", true
default:
return "", true
}
}
|
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/page.go#L283-L289
|
func (p *Page) PopupText() (string, error) {
text, err := p.session.GetAlertText()
if err != nil {
return "", fmt.Errorf("failed to retrieve popup text: %s", err)
}
return text, nil
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/sidecar/options.go#L61-L73
|
func (o *Options) Validate() error {
ents := o.entries()
if len(ents) == 0 {
return errors.New("no wrapper.Option entries")
}
for i, e := range ents {
if err := e.Validate(); err != nil {
return fmt.Errorf("entry %d: %v", i, err)
}
}
return o.GcsOptions.Validate()
}
|
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodelist.go#L64-L67
|
func (l *NodeList) Add(node *skiplist.Node) {
node.SetLink(l.head)
l.head = node
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L6243-L6247
|
func (v EventFrameAttached) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage66(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/parser/symbols.go#L71-L77
|
func (l *LexSymbolSet) Copy() *LexSymbolSet {
c := NewLexSymbolSet()
for k, v := range l.Map {
c.Map[k] = LexSymbol{v.Name, v.Type, v.Priority}
}
return c
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/fragmenting_writer.go#L161-L197
|
func (w *fragmentingWriter) BeginArgument(last bool) error {
if w.err != nil {
return w.err
}
switch {
case w.state == fragmentingWriteComplete:
w.err = errComplete
return w.err
case w.state.isWritingArgument():
w.err = errAlreadyWritingArgument
return w.err
}
// If we don't have a fragment, request one
if w.curFragment == nil {
initial := w.state == fragmentingWriteStart
if w.curFragment, w.err = w.sender.newFragment(initial, w.checksum); w.err != nil {
return w.err
}
}
// If there's no room in the current fragment, freak out. This will
// only happen due to an implementation error in the TChannel stack
// itself
if w.curFragment.contents.BytesRemaining() <= chunkHeaderSize {
panic(fmt.Errorf("attempting to begin an argument in a fragment with only %d bytes available",
w.curFragment.contents.BytesRemaining()))
}
w.curChunk = newWritableChunk(w.checksum, w.curFragment.contents)
w.state = fragmentingWriteInArgument
if last {
w.state = fragmentingWriteInLastArgument
}
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L2083-L2087
|
func (v SearchInContentParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger21(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/fuzzy/cluster.go#L369-L388
|
func assertLogEntryEqual(t *testing.T, node string, exp *raft.Log, act *raft.Log) bool {
res := true
if exp.Term != act.Term {
t.Errorf("Log Entry at Index %d for node %v has mismatched terms %d/%d", exp.Index, node, exp.Term, act.Term)
res = false
}
if exp.Index != act.Index {
t.Errorf("Node %v, Log Entry should be Index %d,but is %d", node, exp.Index, act.Index)
res = false
}
if exp.Type != act.Type {
t.Errorf("Node %v, Log Entry at Index %d should have type %v but is %v", node, exp.Index, exp.Type, act.Type)
res = false
}
if !bytes.Equal(exp.Data, act.Data) {
t.Errorf("Node %v, Log Entry at Index %d should have data %v, but has %v", node, exp.Index, exp.Data, act.Data)
res = false
}
return res
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/tide.go#L189-L219
|
func (tq *TideQuery) Query() string {
toks := []string{"is:pr", "state:open"}
for _, o := range tq.Orgs {
toks = append(toks, fmt.Sprintf("org:\"%s\"", o))
}
for _, r := range tq.Repos {
toks = append(toks, fmt.Sprintf("repo:\"%s\"", r))
}
for _, r := range tq.ExcludedRepos {
toks = append(toks, fmt.Sprintf("-repo:\"%s\"", r))
}
for _, b := range tq.ExcludedBranches {
toks = append(toks, fmt.Sprintf("-base:\"%s\"", b))
}
for _, b := range tq.IncludedBranches {
toks = append(toks, fmt.Sprintf("base:\"%s\"", b))
}
for _, l := range tq.Labels {
toks = append(toks, fmt.Sprintf("label:\"%s\"", l))
}
for _, l := range tq.MissingLabels {
toks = append(toks, fmt.Sprintf("-label:\"%s\"", l))
}
if tq.Milestone != "" {
toks = append(toks, fmt.Sprintf("milestone:\"%s\"", tq.Milestone))
}
if tq.ReviewApprovedRequired {
toks = append(toks, "review:approved")
}
return strings.Join(toks, " ")
}
|
https://github.com/skyrings/skyring-common/blob/d1c0bb1cbd5ed8438be1385c85c4f494608cde1e/dbprovider/mongodb/user.go#L65-L76
|
func (m MongoDb) DeleteUser(username string) error {
c := m.Connect(models.COLL_NAME_USER)
defer m.Close(c)
// raises error if "username" doesn't exist
err := c.Remove(bson.M{"username": username})
if err != nil {
logger.Get().Error("Error deleting record from DB for user: %s. error: %v", username, err)
return mkmgoerror(err.Error())
}
return err
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/cmds/cmds.go#L139-L146
|
func containsEmpty(vals []string) bool {
for _, val := range vals {
if val == "" {
return true
}
}
return false
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L11-L36
|
func (key *LedgerKey) Equals(other LedgerKey) bool {
if key.Type != other.Type {
return false
}
switch key.Type {
case LedgerEntryTypeAccount:
l := key.MustAccount()
r := other.MustAccount()
return l.AccountId.Equals(r.AccountId)
case LedgerEntryTypeData:
l := key.MustData()
r := other.MustData()
return l.AccountId.Equals(r.AccountId) && l.DataName == r.DataName
case LedgerEntryTypeOffer:
l := key.MustOffer()
r := other.MustOffer()
return l.SellerId.Equals(r.SellerId) && l.OfferId == r.OfferId
case LedgerEntryTypeTrustline:
l := key.MustTrustLine()
r := other.MustTrustLine()
return l.AccountId.Equals(r.AccountId) && l.Asset.Equals(r.Asset)
default:
panic(fmt.Errorf("Unknown ledger key type: %v", key.Type))
}
}
|
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/ttnctx/context.go#L88-L90
|
func OutgoingContextWithID(ctx context.Context, id string) context.Context {
return outgoingContextWithMergedMetadata(ctx, "id", id)
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L52-L61
|
func (key *LedgerKey) SetData(account AccountId, name string) error {
data := LedgerKeyData{account, String64(name)}
nkey, err := NewLedgerKey(LedgerEntryTypeData, data)
if err != nil {
return err
}
*key = nkey
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/memory/easyjson.go#L580-L584
|
func (v SamplingProfile) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoMemory5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/common.go#L57-L105
|
func capitalizeYUI(word *snowballword.SnowballWord) {
// Keep track of vowels that we see
vowelPreviously := false
// Peak ahead to see if the next rune is a vowel
vowelNext := func(j int) bool {
return (j+1 < len(word.RS) && isLowerVowel(word.RS[j+1]))
}
// Look at all runes
for i := 0; i < len(word.RS); i++ {
// Nothing to do for non-vowels
if isLowerVowel(word.RS[i]) == false {
vowelPreviously = false
continue
}
vowelHere := true
switch word.RS[i] {
case 121: // y
// Is this "y" preceded OR followed by a vowel?
if vowelPreviously || vowelNext(i) {
word.RS[i] = 89 // Y
vowelHere = false
}
case 117: // u
// Is this "u" is flanked by vowels OR preceded by a "q"?
if (vowelPreviously && vowelNext(i)) || (i >= 1 && word.RS[i-1] == 113) {
word.RS[i] = 85 // U
vowelHere = false
}
case 105: // i
// Is this "i" is flanked by vowels?
if vowelPreviously && vowelNext(i) {
word.RS[i] = 73 // I
vowelHere = false
}
}
vowelPreviously = vowelHere
}
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dgl/gc.go#L115-L120
|
func NewPainter() *Painter {
p := new(Painter)
p.vertices = make([]int32, 0, 1024)
p.colors = make([]uint8, 0, 1024)
return p
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/manifest/docker_schema2.go#L22-L29
|
func BlobInfoFromSchema2Descriptor(desc Schema2Descriptor) types.BlobInfo {
return types.BlobInfo{
Digest: desc.Digest,
Size: desc.Size,
URLs: desc.URLs,
MediaType: desc.MediaType,
}
}
|
https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/format.go#L132-L136
|
func SetFormatter(f Formatter) {
formatter.Lock()
defer formatter.Unlock()
formatter.def = f
}
|
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/client/service_manager.go#L98-L101
|
func (s *ServiceManager) List() map[int]*exec.Cmd {
log.Println("[DEBUG] listing services")
return s.processMap.processes
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/lease.go#L472-L491
|
func (l *lessor) resetRecv() (pb.Lease_LeaseKeepAliveClient, error) {
sctx, cancel := context.WithCancel(l.stopCtx)
stream, err := l.remote.LeaseKeepAlive(sctx, append(l.callOpts, withMax(0))...)
if err != nil {
cancel()
return nil, err
}
l.mu.Lock()
defer l.mu.Unlock()
if l.stream != nil && l.streamCancel != nil {
l.streamCancel()
}
l.streamCancel = cancel
l.stream = stream
go l.sendKeepAliveLoop(stream)
return stream, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/types.go#L303-L317
|
func (t *CookieSameSite) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch CookieSameSite(in.String()) {
case CookieSameSiteStrict:
*t = CookieSameSiteStrict
case CookieSameSiteLax:
*t = CookieSameSiteLax
case CookieSameSiteExtended:
*t = CookieSameSiteExtended
case CookieSameSiteNone:
*t = CookieSameSiteNone
default:
in.AddError(errors.New("unknown CookieSameSite value"))
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/easyjson.go#L1593-L1597
|
func (v CrashParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser17(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/api.go#L681-L691
|
func (r *Raft) GetConfiguration() ConfigurationFuture {
configReq := &configurationsFuture{}
configReq.init()
select {
case <-r.shutdownCh:
configReq.respond(ErrRaftShutdown)
return configReq
case r.configurationsCh <- configReq:
return configReq
}
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/net.go#L19-L30
|
func InMemoryNetwork() (net.Listener, func() net.Conn) {
listener := &inMemoryListener{
conns: make(chan net.Conn, 16),
closed: make(chan struct{}),
}
dialer := func() net.Conn {
server, client := net.Pipe()
listener.conns <- server
return client
}
return listener, dialer
}
|
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/ranges/ranges.go#L381-L386
|
func (l *InclusiveRanges) rangeAt(idx int) *InclusiveRange {
if idx < 0 || idx >= l.numRanges() {
return nil
}
return l.blocks[idx]
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/client.go#L2044-L2074
|
func (c *Client) EditTeam(t Team) (*Team, error) {
c.log("EditTeam", t)
if t.ID == 0 {
return nil, errors.New("team.ID must be non-zero")
}
if c.dry {
return &t, nil
}
id := t.ID
t.ID = 0
// Need to send parent_team_id: null
team := struct {
Team
ParentTeamID *int `json:"parent_team_id"`
}{
Team: t,
ParentTeamID: t.ParentTeamID,
}
var retTeam Team
path := fmt.Sprintf("/teams/%d", id)
_, err := c.request(&request{
method: http.MethodPatch,
path: path,
// This accept header enables the nested teams preview.
// https://developer.github.com/changes/2017-08-30-preview-nested-teams/
accept: "application/vnd.github.hellcat-preview+json",
requestBody: &team,
exitCodes: []int{200, 201},
}, &retTeam)
return &retTeam, err
}
|
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/cookies.go#L52-L60
|
func (c *Cookies) SetWithPath(name, value, path string) {
ck := http.Cookie{
Name: name,
Value: value,
Path: path,
}
http.SetCookie(c.res, &ck)
}
|
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L725-L732
|
func SubScalarWithMaskRev(value Scalar, src, dst, mask *IplImage) {
C.cvSubRS(
unsafe.Pointer(src),
(C.CvScalar)(value),
unsafe.Pointer(dst),
unsafe.Pointer(mask),
)
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L212-L249
|
func (ch *Channel) RunWithRetry(runCtx context.Context, f RetriableFunc) error {
var err error
opts := getRetryOptions(runCtx)
rs := ch.getRequestState(opts)
defer requestStatePool.Put(rs)
for i := 0; i < opts.MaxAttempts; i++ {
rs.Attempt++
if opts.TimeoutPerAttempt == 0 {
err = f(runCtx, rs)
} else {
attemptCtx, cancel := context.WithTimeout(runCtx, opts.TimeoutPerAttempt)
err = f(attemptCtx, rs)
cancel()
}
if err == nil {
return nil
}
if !opts.RetryOn.CanRetry(err) {
if ch.log.Enabled(LogLevelInfo) {
ch.log.WithFields(ErrField(err)).Info("Failed after non-retriable error.")
}
return err
}
ch.log.WithFields(
ErrField(err),
LogField{"attempt", rs.Attempt},
LogField{"maxAttempts", opts.MaxAttempts},
).Info("Retrying request after retryable error.")
}
// Too many retries, return the last error
return err
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm16/codegen_client.go#L521-L523
|
func (r *Image) Locator(api *API) *ImageLocator {
return api.ImageLocator(r.Href)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/ancestry/ancestry.go#L54-L56
|
func Add(s string, ancestors int) string {
return fmt.Sprintf("%s~%d", s, ancestors)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/layertree/easyjson.go#L1131-L1135
|
func (v MakeSnapshotParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoLayertree11(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L55-L60
|
func NewClientHandler(lg *zap.Logger, server etcdserver.ServerPeer, timeout time.Duration) http.Handler {
mux := http.NewServeMux()
etcdhttp.HandleBasic(mux, server)
handleV2(lg, mux, server, timeout)
return requestLogger(lg, mux)
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L1866-L1875
|
func (u OperationBody) GetPaymentOp() (result PaymentOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "PaymentOp" {
result = *u.PaymentOp
ok = true
}
return
}
|
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/route_info.go#L73-L92
|
func (ri *RouteInfo) BuildPathHelper() RouteHelperFunc {
cRoute := ri
return func(opts map[string]interface{}) (template.HTML, error) {
pairs := []string{}
for k, v := range opts {
pairs = append(pairs, k)
pairs = append(pairs, fmt.Sprintf("%v", v))
}
url, err := cRoute.MuxRoute.URL(pairs...)
if err != nil {
return "", errors.Wrapf(err, "missing parameters for %v", cRoute.Path)
}
result := url.Path
result = addExtraParamsTo(result, opts)
return template.HTML(result), nil
}
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/conversion.go#L133-L149
|
func newAssignees(issueID int, gAssignees []*github.User, repository string) ([]sql.Assignee, error) {
assignees := []sql.Assignee{}
repository = strings.ToLower(repository)
for _, assignee := range gAssignees {
if assignee != nil && assignee.Login == nil {
return nil, fmt.Errorf("Assignee is missing Login field")
}
assignees = append(assignees, sql.Assignee{
IssueID: strconv.Itoa(issueID),
Name: *assignee.Login,
Repository: repository,
})
}
return assignees, nil
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dgl/gc.go#L134-L146
|
func NewGraphicContext(width, height int) *GraphicContext {
gc := &GraphicContext{
draw2dbase.NewStackGraphicContext(),
NewPainter(),
raster.NewRasterizer(width, height),
raster.NewRasterizer(width, height),
draw2d.GetGlobalFontCache(),
draw2dbase.NewGlyphCache(),
&truetype.GlyphBuf{},
92,
}
return gc
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/clone/clone.go#L173-L178
|
func gitTimestampEnvs(timestamp int) []string {
return []string{
fmt.Sprintf("GIT_AUTHOR_DATE=%d", timestamp),
fmt.Sprintf("GIT_COMMITTER_DATE=%d", timestamp),
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/heapprofiler/easyjson.go#L232-L236
|
func (v *StopSamplingReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler2(&r, v)
return r.Error()
}
|
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/page.go#L423-L429
|
func (p *Page) LogTypes() ([]string, error) {
types, err := p.session.GetLogTypes()
if err != nil {
return nil, fmt.Errorf("failed to retrieve log types: %s", err)
}
return types, nil
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L64-L89
|
func (o *GitHubOptions) Validate(dryRun bool) error {
for _, uri := range o.endpoint.Strings() {
if uri == "" {
uri = github.DefaultAPIEndpoint
} else if _, err := url.ParseRequestURI(uri); err != nil {
return fmt.Errorf("invalid -github-endpoint URI: %q", uri)
}
}
if o.graphqlEndpoint == "" {
o.graphqlEndpoint = github.DefaultGraphQLEndpoint
} else if _, err := url.Parse(o.graphqlEndpoint); err != nil {
return fmt.Errorf("invalid -github-graphql-endpoint URI: %q", o.graphqlEndpoint)
}
if o.deprecatedTokenFile != "" {
o.TokenPath = o.deprecatedTokenFile
logrus.Error("-github-token-file is deprecated and may be removed anytime after 2019-01-01. Use -github-token-path instead.")
}
if o.TokenPath == "" {
logrus.Warn("empty -github-token-path, will use anonymous github client")
}
return nil
}
|
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/connection_maker.go#L178-L187
|
func (cm *connectionMaker) connectionCreated(conn Connection) {
cm.actionChan <- func() bool {
cm.connections[conn] = struct{}{}
if conn.isOutbound() {
target := cm.targets[conn.remoteTCPAddress()]
target.state = targetConnected
}
return false
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domdebugger/domdebugger.go#L252-L254
|
func (p *SetInstrumentationBreakpointParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetInstrumentationBreakpoint, p, nil)
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/report.go#L56-L71
|
func (r *CSVReport) Write() error {
file, err := os.OpenFile(r.Filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0640)
if err != nil {
return err
}
defer file.Close()
writer := csv.NewWriter(file)
err = writer.WriteAll(r.records)
if err != nil {
return err
}
logf("Written report file %s", r.Filename)
return nil
}
|
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L128-L133
|
func (c *Client) DetachCdrom(dcid, srvid, cdid string) (*http.Header, error) {
url := serverCdromPath(dcid, srvid, cdid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty)
ret := &http.Header{}
err := c.client.Delete(url, ret, http.StatusAccepted)
return ret, err
}
|
https://github.com/achiku/soapc/blob/cfbdfe6e4caffe57a9cba89996e8b1cedb512be0/client.go#L72-L95
|
func (h *Header) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var (
token xml.Token
err error
)
Loop:
for {
if token, err = d.Token(); err != nil {
return err
}
if token == nil {
break
}
switch se := token.(type) {
case xml.StartElement:
if err = d.DecodeElement(h.Content, &se); err != nil {
return err
}
case xml.EndElement:
break Loop
}
}
return nil
}
|
https://github.com/blacklabeldata/namedtuple/blob/c341f1db44f30b8164294aa8605ede42be604aba/timestamp.go#L11-L36
|
func (b *TupleBuilder) PutTimestamp(field string, value time.Time) (wrote uint64, err error) {
// field type should be
if err = b.typeCheck(field, TimestampField); err != nil {
return 0, err
}
// write value
// length check performed by xbinary
wrote, err = xbinary.LittleEndian.PutInt64(b.buffer, b.pos+1, value.UnixNano())
if err != nil {
return 0, err
}
// write type code
b.buffer[b.pos] = byte(TimestampCode.OpCode)
// set field offset
b.offsets[field] = b.pos
// incr pos
b.pos += 9
// wrote 9 bytes
return 9, nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.go#L83-L118
|
func (c *Cluster) Profiles(project string) ([]string, error) {
err := c.Transaction(func(tx *ClusterTx) error {
enabled, err := tx.ProjectHasProfiles(project)
if err != nil {
return errors.Wrap(err, "Check if project has profiles")
}
if !enabled {
project = "default"
}
return nil
})
if err != nil {
return nil, err
}
q := fmt.Sprintf(`
SELECT profiles.name
FROM profiles
JOIN projects ON projects.id = profiles.project_id
WHERE projects.name = ?
`)
inargs := []interface{}{project}
var name string
outfmt := []interface{}{name}
result, err := queryScan(c.db, q, inargs, outfmt)
if err != nil {
return []string{}, err
}
response := []string{}
for _, r := range result {
response = append(response, r[0].(string))
}
return response, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domstorage/easyjson.go#L295-L299
|
func (v *RemoveDOMStorageItemParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDomstorage2(&r, v)
return r.Error()
}
|
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/examples/increment-only-counter/peer.go#L86-L90
|
func (p *peer) Gossip() (complete mesh.GossipData) {
complete = p.st.copy()
p.logger.Printf("Gossip => complete %v", complete.(*state).set)
return complete
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L2178-L2182
|
func (v *ScriptPosition) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger22(&r, v)
return r.Error()
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/font.go#L219-L223
|
func (cache *SyncFolderFontCache) Store(fontData FontData, font *truetype.Font) {
cache.Lock()
cache.fonts[cache.namer(fontData)] = font
cache.Unlock()
}
|
https://github.com/mattn/go-xmpp/blob/6093f50721ed2204a87a81109ca5a466a5bec6c1/xmpp.go#L530-L562
|
func (c *Client) startStream(o *Options, domain string) (*streamFeatures, error) {
if o.Debug {
c.p = xml.NewDecoder(tee{c.conn, DebugWriter})
} else {
c.p = xml.NewDecoder(c.conn)
}
_, err := fmt.Fprintf(c.conn, "<?xml version='1.0'?>\n"+
"<stream:stream to='%s' xmlns='%s'\n"+
" xmlns:stream='%s' version='1.0'>\n",
xmlEscape(domain), nsClient, nsStream)
if err != nil {
return nil, err
}
// We expect the server to start a <stream>.
se, err := nextStart(c.p)
if err != nil {
return nil, err
}
if se.Name.Space != nsStream || se.Name.Local != "stream" {
return nil, fmt.Errorf("expected <stream> but got <%v> in %v", se.Name.Local, se.Name.Space)
}
// Now we're in the stream and can use Unmarshal.
// Next message should be <features> to tell us authentication options.
// See section 4.6 in RFC 3920.
f := new(streamFeatures)
if err = c.p.DecodeElement(f, nil); err != nil {
return f, errors.New("unmarshal <features>: " + err.Error())
}
return f, nil
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L71-L80
|
func (c URLsMap) URLs() []string {
var urls []string
for _, us := range c {
for _, u := range us {
urls = append(urls, u.String())
}
}
sort.Strings(urls)
return urls
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.