_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/piotrkowalczuk/mnemosyne/blob/66d59c3c5b886e8e869915bb76257bcba4a47250/internal/storage/postgres/storage.go#L254-L270
func (s *Storage) Exists(ctx context.Context, accessToken string) (exists bool, err error) { span, ctx := opentracing.StartSpanFromContext(ctx, "postgres.storage.exists") defer span.Finish() start := time.Now() labels := prometheus.Labels{"query": "exists"} err = s.db.QueryRowContext(ctx, s.queryExists, accessToken).Scan( &exists, ) s.incQueries(labels, start) if err != nil { s.incError(labels) } return }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/oci/archive/oci_src.go#L87-L89
func (s *ociArchiveImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) { return s.unpackedSrc.GetBlob(ctx, info, cache) }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/goimage.go#L43-L59
func FromImageUnsafe(img *image.RGBA) *IplImage { b := img.Bounds() buf := CreateImageHeader( b.Max.X-b.Min.X, b.Max.Y-b.Min.Y, IPL_DEPTH_8U, 4) dst := CreateImage( b.Max.X-b.Min.X, b.Max.Y-b.Min.Y, IPL_DEPTH_8U, 4) buf.SetData(unsafe.Pointer(&img.Pix[0]), CV_AUTOSTEP) CvtColor(buf, dst, CV_RGBA2BGRA) buf.Release() return dst }
https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L471-L473
func (l *slog) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&l.lvl), uint32(level)) }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L2620-L2623
func (e PaymentResultCode) String() string { name, _ := paymentResultCodeMap[int32(e)] return name }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/resource/options.go#L23-L46
func (opts *Options) Validate() error { if opts.App.IsZero() { opts.App = meta.New(".") } if len(opts.Name) == 0 { return errors.New("you must provide a name") } if len(opts.Model) == 0 { opts.Model = opts.Name } if strings.Contains(opts.Model, "/") { parts := strings.Split(opts.Model, "/") opts.Model = parts[len(parts)-1] } if opts.App.AsAPI { opts.SkipTemplates = true } return nil }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1652-L1661
func (o *Ordered) MkdirAll(path string) { var paths []string for path != "" { paths = append(paths, path) path, _ = split(path) } for i := len(paths) - 1; i >= 0; i-- { o.PutDir(paths[i]) } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L1784-L1788
func (v *ResetNavigationHistoryParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage19(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/accessibility/easyjson.go#L488-L492
func (v *RelatedNode) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoAccessibility2(&r, v) return r.Error() }
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/readwriteseeker/readwriteseeker.go#L31-L46
func (rws *ReadWriteSeeker) Seek(offset int64, whence int) (int64, error) { newPos, offs := 0, int(offset) switch whence { case io.SeekStart: newPos = offs case io.SeekCurrent: newPos = rws.pos + offs case io.SeekEnd: newPos = len(rws.buf) + offs } if newPos < 0 { return 0, errors.New("negative result pos") } rws.pos = newPos return int64(newPos), nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/client.go#L1249-L1270
func (c *Client) ListReviews(org, repo string, number int) ([]Review, error) { c.log("ListReviews", org, repo, number) if c.fake { return nil, nil } path := fmt.Sprintf("/repos/%s/%s/pulls/%d/reviews", org, repo, number) var reviews []Review err := c.readPaginatedResults( path, acceptNone, func() interface{} { return &[]Review{} }, func(obj interface{}) { reviews = append(reviews, *(obj.(*[]Review))...) }, ) if err != nil { return nil, err } return reviews, nil }
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L39-L41
func Errorf(message string, a ...interface{}) error { return wrap(fmt.Errorf(message, a...)) }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L406-L417
func CreateMatNDHeader(sizes []int, type_ int) *MatND { dims := C.int(len(sizes)) sizes_c := make([]C.int, len(sizes)) for i := 0; i < len(sizes); i++ { sizes_c[i] = C.int(sizes[i]) } mat := C.cvCreateMatNDHeader( dims, (*C.int)(&sizes_c[0]), C.int(type_), ) return (*MatND)(mat) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L311-L319
func (c APIClient) StopJob(jobID string) error { _, err := c.PpsAPIClient.StopJob( c.Ctx(), &pps.StopJobRequest{ Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/alias.go#L15-L17
func (acc *Account) Alias(name string) *Alias { return &Alias{account: acc, Name: name} }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/webaudio/types.go#L40-L42
func (t ContextType) MarshalEasyJSON(out *jwriter.Writer) { out.String(string(t)) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L1654-L1658
func (v *ScreencastFrameMetadata) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage17(&r, v) return r.Error() }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L308-L320
func Glob(rs []io.ReadCloser, pattern string, f func(string, *NodeProto) error) (retErr error) { pattern = clean(pattern) g, err := globlib.Compile(pattern, '/') if err != nil { return errorf(MalformedGlob, err.Error()) } return nodes(rs, func(path string, node *NodeProto) error { if g.Match(path) { return f(externalDefault(path), node) } return nil }) }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L3800-L3803
func (e OperationResultCode) ValidEnum(v int32) bool { _, ok := operationResultCodeMap[v] return ok }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L871-L873
func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) { s.r.ReportSnapshot(id, status) }
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/mocktracer/mockspan.go#L274-L279
func (s *MockSpan) SetOperationName(operationName string) opentracing.Span { s.Lock() defer s.Unlock() s.OperationName = operationName return s }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L158-L178
func (s *Skiplist) NewLevel(randFn func() float32) int { var nextLevel int for ; randFn() < p; nextLevel++ { } if nextLevel > MaxLevel { nextLevel = MaxLevel } level := int(atomic.LoadInt32(&s.level)) if nextLevel > level { if atomic.CompareAndSwapInt32(&s.level, int32(level), int32(level+1)) { nextLevel = level + 1 } else { nextLevel = level } } return nextLevel }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L3644-L3648
func (v *Media) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss31(&r, v) return r.Error() }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/file_snapshot.go#L433-L448
func (s *FileSnapshotSink) Cancel() error { // Make sure close is idempotent if s.closed { return nil } s.closed = true // Close the open handles if err := s.finalize(); err != nil { s.logger.Printf("[ERR] snapshot: Failed to finalize snapshot: %v", err) return err } // Attempt to remove all artifacts return os.RemoveAll(s.dir) }
https://github.com/mattn/go-xmpp/blob/6093f50721ed2204a87a81109ca5a466a5bec6c1/xmpp_muc.go#L85-L129
func (c *Client) JoinProtectedMUC(jid, nick string, password string, history_type, history int, history_date *time.Time) (n int, err error) { if nick == "" { nick = c.jid } switch history_type { case NoHistory: return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+ "<x xmlns='%s'>\n"+ "<password>%s</password>"+ "</x>\n"+ "</presence>", xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password)) case CharHistory: return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+ "<x xmlns='%s'>\n"+ "<password>%s</password>\n"+ "<history maxchars='%d'/></x>\n"+ "</presence>", xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history) case StanzaHistory: return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+ "<x xmlns='%s'>\n"+ "<password>%s</password>\n"+ "<history maxstanzas='%d'/></x>\n"+ "</presence>", xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history) case SecondsHistory: return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+ "<x xmlns='%s'>\n"+ "<password>%s</password>\n"+ "<history seconds='%d'/></x>\n"+ "</presence>", xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history) case SinceHistory: if history_date != nil { return fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+ "<x xmlns='%s'>\n"+ "<password>%s</password>\n"+ "<history since='%s'/></x>\n"+ "</presence>", xmlEscape(jid), xmlEscape(nick), nsMUC, xmlEscape(password), history_date.Format(time.RFC3339)) } } return 0, errors.New("Unknown history option") }
https://github.com/mikespook/possum/blob/56d7ebb6470b670001632b11be7fc089038f4dd7/view/template.go#L47-L50
func InitTextTemplates(pattern string) (err error) { textTemp.Template, err = text.ParseGlob(pattern) return nil }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L2869-L2878
func (u PathPaymentResult) GetNoIssuer() (result Asset, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Code)) if armName == "NoIssuer" { result = *u.NoIssuer ok = true } return }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/report/report.go#L50-L66
func prowjobStateToGitHubStatus(pjState prowapi.ProwJobState) (string, error) { switch pjState { case prowapi.TriggeredState: return github.StatusPending, nil case prowapi.PendingState: return github.StatusPending, nil case prowapi.SuccessState: return github.StatusSuccess, nil case prowapi.ErrorState: return github.StatusError, nil case prowapi.FailureState: return github.StatusFailure, nil case prowapi.AbortedState: return github.StatusFailure, nil } return "", fmt.Errorf("Unknown prowjob state: %v", pjState) }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/get_apps_app_routes_route_parameters.go#L93-L96
func (o *GetAppsAppRoutesRouteParams) WithContext(ctx context.Context) *GetAppsAppRoutesRouteParams { o.SetContext(ctx) return o }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/isolate_linux.go#L70-L82
func RemoveLatency() error { ifces, err := GetDefaultInterfaces() if err != nil { return err } for ifce := range ifces { _, err = exec.Command("/bin/sh", "-c", fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce)).Output() if err != nil { return err } } return nil }
https://github.com/guregu/null/blob/80515d440932108546bcade467bb7d6968e812e2/float.go#L54-L80
func (f *Float) UnmarshalJSON(data []byte) error { var err error var v interface{} if err = json.Unmarshal(data, &v); err != nil { return err } switch x := v.(type) { case float64: f.Float64 = float64(x) case string: str := string(x) if len(str) == 0 { f.Valid = false return nil } f.Float64, err = strconv.ParseFloat(str, 64) case map[string]interface{}: err = json.Unmarshal(data, &f.NullFloat64) case nil: f.Valid = false return nil default: err = fmt.Errorf("json: cannot unmarshal %v into Go value of type null.Float", reflect.TypeOf(v).Name()) } f.Valid = err == nil return err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pluginhelp/externalplugins/externalplugins.go#L40-L85
func ServeExternalPluginHelp(mux *http.ServeMux, log *logrus.Entry, provider ExternalPluginHelpProvider) { mux.HandleFunc( "/help", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache") serverError := func(action string, err error) { log.WithError(err).Errorf("Error %s.", action) msg := fmt.Sprintf("500 Internal server error %s: %v", action, err) http.Error(w, msg, http.StatusInternalServerError) } if r.Method != http.MethodPost { log.Errorf("Invalid request method: %v.", r.Method) http.Error(w, "405 Method not allowed", http.StatusMethodNotAllowed) return } b, err := ioutil.ReadAll(r.Body) if err != nil { serverError("reading request body", err) return } var enabledRepos []string if err := json.Unmarshal(b, &enabledRepos); err != nil { serverError("unmarshaling request body", err) return } if provider == nil { serverError("generating plugin help", errors.New("help provider is nil")) return } help, err := provider(enabledRepos) if err != nil { serverError("generating plugin help", err) return } b, err = json.Marshal(help) if err != nil { serverError("marshaling plugin help", err) return } fmt.Fprint(w, string(b)) }, ) }
https://github.com/kr/s3/blob/c070c8f9a8f0032d48f0d2a77d4e382788bd8a1d/s3util/readdir.go#L78-L96
func NewFile(rawurl string, c *Config) (*File, error) { u, err := url.Parse(rawurl) if err != nil { return nil, err } if u.RawQuery != "" { return nil, errors.New("url cannot have raw query parameters.") } if u.Fragment != "" { return nil, errors.New("url cannot have a fragment.") } prefix := strings.TrimLeft(u.Path, "/") if prefix != "" && !strings.HasSuffix(prefix, "/") { prefix += "/" } u.Path = "" return &File{u.String(), prefix, c, nil}, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/clientset/versioned/typed/prowjobs/v1/fake/fake_prowjob.go#L42-L50
func (c *FakeProwJobs) Get(name string, options v1.GetOptions) (result *prowjobsv1.ProwJob, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(prowjobsResource, c.ns, name), &prowjobsv1.ProwJob{}) if obj == nil { return nil, err } return obj.(*prowjobsv1.ProwJob), err }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/assets/assets.go#L1291-L1297
func MicrosoftSecret(container string, id string, secret string) map[string][]byte { return map[string][]byte{ "microsoft-container": []byte(container), "microsoft-id": []byte(id), "microsoft-secret": []byte(secret), } }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/mm/malloc.go#L53-L70
func Stats() string { mu.Lock() defer mu.Unlock() buf := C.mm_stats() s := "==== Stats ====\n" if Debug { s += fmt.Sprintf("Mallocs = %d\n"+ "Frees = %d\n", stats.allocs, stats.frees) } if buf != nil { s += C.GoString(buf) C.free(unsafe.Pointer(buf)) } return s }
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/vm/op.go#L111-L170
func (o *op) UnmarshalBinary(data []byte) error { buf := bytes.NewReader(data) var t int64 if err := binary.Read(buf, binary.LittleEndian, &t); err != nil { return errors.Wrap(err, "optype check failed during UnmarshalBinary") } o.OpType = OpType(t) o.OpHandler = optypeToHandler(o.OpType) var hasArg int8 if err := binary.Read(buf, binary.LittleEndian, &hasArg); err != nil { return errors.Wrap(err, "hasArg check failed during UnmarshalBinary") } if hasArg == 1 { var tArg int64 if err := binary.Read(buf, binary.LittleEndian, &tArg); err != nil { return errors.Wrap(err, "failed to read argument from buffer during UnmarshalBinary") } switch tArg { case 2: var i int64 if err := binary.Read(buf, binary.LittleEndian, &i); err != nil { return errors.Wrap(err, "failed to read integer argument during UnmarshalBinary") } o.uArg = i case 5: var l int64 if err := binary.Read(buf, binary.LittleEndian, &l); err != nil { return errors.Wrap(err, "failed to read length argument during UnmarshalBinary") } b := make([]byte, l) for i := int64(0); i < l; i++ { if err := binary.Read(buf, binary.LittleEndian, &b[i]); err != nil { return errors.Wrap(err, "failed to read bytes from buffer during UnmarshalBinary") } } o.uArg = b default: panic(fmt.Sprintf("Unknown tArg: %d", tArg)) } } var hasComment int8 if err := binary.Read(buf, binary.LittleEndian, &hasComment); err != nil { return errors.Wrap(err, "hasComment check failed during UnmarshalBinary") } if hasComment == 1 { if err := binary.Read(buf, binary.LittleEndian, &o.comment); err != nil { return errors.Wrap(err, "failed to read comment bytes during UnmarshalBinary") } } return nil }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/errors.go#L177-L179
func (se SystemError) Error() string { return fmt.Sprintf("tchannel error %v: %s", se.Code(), se.msg) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/log/types.go#L67-L69
func (t Source) MarshalEasyJSON(out *jwriter.Writer) { out.String(string(t)) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/exec/exec.go#L500-L512
func (c *Cmd) CombinedOutput() ([]byte, error) { if c.Stdout != nil { return nil, errors.New("exec: Stdout already set") } if c.Stderr != nil { return nil, errors.New("exec: Stderr already set") } var b bytes.Buffer c.Stdout = &b c.Stderr = &b err := c.Run() return b.Bytes(), err }
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/log/field.go#L63-L69
func Int(key string, val int) Field { return Field{ key: key, fieldType: intType, numericVal: int64(val), } }
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L481-L490
func (g *Glg) EnableLevelColor(lv LEVEL) *Glg { ins, ok := g.logger.Load(lv) if ok { l := ins.(*logger) l.isColor = true l.updateMode() g.logger.Store(lv, l) } return g }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/oci/layout/oci_dest.go#L212-L246
func (d *ociImageDestination) PutManifest(ctx context.Context, m []byte) error { digest, err := manifest.Digest(m) if err != nil { return err } desc := imgspecv1.Descriptor{} desc.Digest = digest // TODO(runcom): beaware and add support for OCI manifest list desc.MediaType = imgspecv1.MediaTypeImageManifest desc.Size = int64(len(m)) blobPath, err := d.ref.blobPath(digest, d.sharedBlobDir) if err != nil { return err } if err := ensureParentDirectoryExists(blobPath); err != nil { return err } if err := ioutil.WriteFile(blobPath, m, 0644); err != nil { return err } if d.ref.image != "" { annotations := make(map[string]string) annotations["org.opencontainers.image.ref.name"] = d.ref.image desc.Annotations = annotations } desc.Platform = &imgspecv1.Platform{ Architecture: runtime.GOARCH, OS: runtime.GOOS, } d.addManifest(&desc) return nil }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/pkg/blobinfocache/boltdb/boltdb.go#L188-L221
func (bdc *cache) RecordDigestUncompressedPair(anyDigest digest.Digest, uncompressed digest.Digest) { _ = bdc.update(func(tx *bolt.Tx) error { b, err := tx.CreateBucketIfNotExists(uncompressedDigestBucket) if err != nil { return err } key := []byte(anyDigest.String()) if previousBytes := b.Get(key); previousBytes != nil { previous, err := digest.Parse(string(previousBytes)) if err != nil { return err } if previous != uncompressed { logrus.Warnf("Uncompressed digest for blob %s previously recorded as %s, now %s", anyDigest, previous, uncompressed) } } if err := b.Put(key, []byte(uncompressed.String())); err != nil { return err } b, err = tx.CreateBucketIfNotExists(digestByUncompressedBucket) if err != nil { return err } b, err = b.CreateBucketIfNotExists([]byte(uncompressed.String())) if err != nil { return err } if err := b.Put([]byte(anyDigest.String()), []byte{}); err != nil { // Possibly writing the same []byte{} presence marker again. return err } return nil }) // FIXME? Log error (but throttle the log volume on repeated accesses)? }
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L310-L314
func (c *Client) GetJobSummariesForProject(projectName string) ([]JobSummary, error) { jobList := &jobSummaryList{} err := c.get([]string{"project", projectName, "jobs"}, nil, jobList) return jobList.Jobs, err }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/http.go#L74-L97
func writeMultipartParams(w *multipart.Writer, payload APIParams, prefix string) error { for k, v := range payload { fieldName := k if prefix != "" { fieldName = fmt.Sprintf("%s[%s]", prefix, k) } // Add more types as needed. These two cover both CM15 and SS. switch v.(type) { case string: err := w.WriteField(fieldName, v.(string)) if err != nil { return err } case APIParams: err := writeMultipartParams(w, v.(APIParams), fieldName) if err != nil { return err } default: return fmt.Errorf("Unknown type for multipart form section %s: %#v", fieldName, v) } } return nil }
https://github.com/malice-plugins/go-plugin-utils/blob/9ee76663c3b0a531b8c529f03f12a5a84ff9b61b/utils/utils.go#L67-L77
func Getopts(userInput, envVar, dfault string) string { if len(strings.TrimSpace(userInput)) > 0 { return userInput } value := os.Getenv(envVar) if value == "" { value = dfault } return value }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/auth.go#L545-L586
func addKeyToUser(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) { key := repository.Key{ Body: InputValue(r, "key"), Name: InputValue(r, "name"), } var force bool if InputValue(r, "force") == "true" { force = true } allowed := permission.Check(t, permission.PermUserUpdateKeyAdd, permission.Context(permTypes.CtxUser, t.GetUserName()), ) if !allowed { return permission.ErrUnauthorized } evt, err := event.New(&event.Opts{ Target: userTarget(t.GetUserName()), Kind: permission.PermUserUpdateKeyAdd, Owner: t, CustomData: event.FormToCustomData(InputFields(r)), Allowed: event.Allowed(permission.PermUserReadEvents, permission.Context(permTypes.CtxUser, t.GetUserName())), }) if err != nil { return err } defer func() { evt.Done(err) }() if key.Body == "" { return &errors.HTTP{Code: http.StatusBadRequest, Message: "Missing key content"} } u, err := auth.ConvertNewUser(t.User()) if err != nil { return err } err = u.AddKey(key, force) if err == authTypes.ErrKeyDisabled || err == repository.ErrUserNotFound { return &errors.HTTP{Code: http.StatusBadRequest, Message: err.Error()} } if err == repository.ErrKeyAlreadyExists { return &errors.HTTP{Code: http.StatusConflict, Message: err.Error()} } return err }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/delete_apps_app_routes_route_responses.go#L25-L52
func (o *DeleteAppsAppRoutesRouteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { case 200: result := NewDeleteAppsAppRoutesRouteOK() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil case 404: result := NewDeleteAppsAppRoutesRouteNotFound() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result default: result := NewDeleteAppsAppRoutesRouteDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } if response.Code()/100 == 2 { return result, nil } return nil, result } }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/openshift/openshift_transport.go#L31-L33
func (t openshiftTransport) ParseReference(reference string) (types.ImageReference, error) { return ParseReference(reference) }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/app/app.go#L1975-L2022
func List(filter *Filter) ([]App, error) { apps := []App{} query := filter.Query() conn, err := db.Conn() if err != nil { return nil, err } err = conn.Apps().Find(query).All(&apps) conn.Close() if err != nil { return nil, err } if filter != nil && len(filter.Statuses) > 0 { appsProvisionerMap := make(map[string][]provision.App) var prov provision.Provisioner for i := range apps { a := &apps[i] prov, err = a.getProvisioner() if err != nil { return nil, err } appsProvisionerMap[prov.GetName()] = append(appsProvisionerMap[prov.GetName()], a) } var provisionApps []provision.App for provName, apps := range appsProvisionerMap { prov, err = provision.Get(provName) if err != nil { return nil, err } if filterProv, ok := prov.(provision.AppFilterProvisioner); ok { apps, err = filterProv.FilterAppsByUnitStatus(apps, filter.Statuses) if err != nil { return nil, err } } provisionApps = append(provisionApps, apps...) } for i := range provisionApps { apps[i] = *(provisionApps[i].(*App)) } apps = apps[:len(provisionApps)] } err = loadCachedAddrsInApps(apps) if err != nil { return nil, err } return apps, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/layertree/easyjson.go#L1329-L1333
func (v *LoadSnapshotParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoLayertree13(&r, v) return r.Error() }
https://github.com/mipearson/rfw/blob/6f0a6f3266ba1058df9ef0c94cda1cecd2e62852/rfw.go#L55-L60
func (l *Writer) Close() error { l.mutex.Lock() defer l.mutex.Unlock() return l.file.Close() }
https://github.com/mikespook/possum/blob/56d7ebb6470b670001632b11be7fc089038f4dd7/server.go#L36-L42
func NewServerMux() (mux *ServerMux) { nf := struct { View view.View Handler HandlerFunc }{view.Simple(view.ContentTypePlain, view.CharSetUTF8), defaultNotFound} return &ServerMux{NewRouters(), nil, nil, nil, nf} }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/auth.go#L45-L61
func HostFromLogin(host string) string { urlElems := strings.Split(host, ".") hostPrefix := urlElems[0] elems := strings.Split(hostPrefix, "-") if len(elems) == 1 && elems[0] == "cm" { // accommodates micromoo host inference, such as "cm.rightscale.local" => "selfservice.rightscale.local" elems[0] = "governance" } else if len(elems) < 2 { // don't know how to compute this policy host; use the cm host return host } else { elems[len(elems)-2] = "governance" } policyHostPrefix := strings.Join(elems, "-") return strings.Join(append([]string{policyHostPrefix}, urlElems[1:]...), ".") }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/status.go#L69-L86
func (s Status) MarshalJSON() ([]byte, error) { j := fmt.Sprintf(`{"id":"%x","term":%d,"vote":"%x","commit":%d,"lead":"%x","raftState":%q,"applied":%d,"progress":{`, s.ID, s.Term, s.Vote, s.Commit, s.Lead, s.RaftState, s.Applied) if len(s.Progress) == 0 { j += "}," } else { for k, v := range s.Progress { subj := fmt.Sprintf(`"%x":{"match":%d,"next":%d,"state":%q},`, k, v.Match, v.Next, v.State) j += subj } // remove the trailing "," j = j[:len(j)-1] + "}," } j += fmt.Sprintf(`"leadtransferee":"%x"}`, s.LeadTransferee) return []byte(j), nil }
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/sequence.go#L480-L485
func (s *FileSequence) Len() int { if s.frameSet == nil { return 1 } return s.frameSet.Len() }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/compaction_command.go#L28-L36
func NewCompactionCommand() *cobra.Command { cmd := &cobra.Command{ Use: "compaction [options] <revision>", Short: "Compacts the event history in etcd", Run: compactionCommandFunc, } cmd.Flags().BoolVar(&compactPhysical, "physical", false, "'true' to wait for compaction to physically remove all old revisions") return cmd }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/raw/call.go#L50-L71
func WriteArgs(call *tchannel.OutboundCall, arg2, arg3 []byte) ([]byte, []byte, *tchannel.OutboundCallResponse, error) { if err := tchannel.NewArgWriter(call.Arg2Writer()).Write(arg2); err != nil { return nil, nil, nil, err } if err := tchannel.NewArgWriter(call.Arg3Writer()).Write(arg3); err != nil { return nil, nil, nil, err } resp := call.Response() var respArg2 []byte if err := tchannel.NewArgReader(resp.Arg2Reader()).Read(&respArg2); err != nil { return nil, nil, nil, err } var respArg3 []byte if err := tchannel.NewArgReader(resp.Arg3Reader()).Read(&respArg3); err != nil { return nil, nil, nil, err } return respArg2, respArg3, resp, nil }
https://github.com/getantibody/folder/blob/e65aa38ebeb03e6d6e91b90a637f3b7c17e1b6d6/main.go#L21-L27
func ToURL(folder string) string { result := folder for _, replace := range replaces { result = strings.Replace(result, replace.b, replace.a, -1) } return result }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/rwmutex.go#L68-L86
func (rwm *RWMutex) waitOnLastRev(pfx string) (bool, error) { client := rwm.s.Client() // get key that's blocking myKey opts := append(v3.WithLastRev(), v3.WithMaxModRev(rwm.myKey.Revision()-1)) lastKey, err := client.Get(rwm.ctx, pfx, opts...) if err != nil { return false, err } if len(lastKey.Kvs) == 0 { return true, nil } // wait for release on blocking key _, err = WaitEvents( client, string(lastKey.Kvs[0].Key), rwm.myKey.Revision(), []mvccpb.Event_EventType{mvccpb.DELETE}) return false, err }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L6628-L6630
func (api *API) NetworkOptionGroupLocator(href string) *NetworkOptionGroupLocator { return &NetworkOptionGroupLocator{Href(href), api} }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L690-L716
func (c *Cluster) StoragePoolVolumesGet(project string, poolID int64, volumeTypes []int) ([]*api.StorageVolume, error) { var nodeIDs []int err := c.Transaction(func(tx *ClusterTx) error { var err error nodeIDs, err = query.SelectIntegers(tx.tx, ` SELECT DISTINCT node_id FROM storage_volumes JOIN projects ON projects.id = storage_volumes.project_id WHERE (projects.name=? OR storage_volumes.type=?) AND storage_pool_id=? `, project, StoragePoolVolumeTypeCustom, poolID) return err }) if err != nil { return nil, err } volumes := []*api.StorageVolume{} for _, nodeID := range nodeIDs { nodeVolumes, err := c.storagePoolVolumesGet(project, poolID, int64(nodeID), volumeTypes) if err != nil { return nil, err } volumes = append(volumes, nodeVolumes...) } return volumes, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L787-L791
func (v *SignedExchangeSignature) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork5(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/easyjson.go#L1534-L1538
func (v GetBrowserCommandLineParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser16(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/safe.go#L14-L28
func SafeLoad(schema Schema, values map[string]string) (Map, error) { m, err := Load(schema, values) if err != nil { errors, ok := err.(ErrorList) if !ok { return m, err } for _, error := range errors { message := fmt.Sprintf("Invalid configuration key: %s", error.Reason) logger.Error(message, log.Ctx{"key": error.Name}) } } return m, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/clientset/versioned/typed/prowjobs/v1/fake/fake_prowjob.go#L124-L129
func (c *FakeProwJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(prowjobsResource, c.ns, listOptions) _, err := c.Fake.Invokes(action, &prowjobsv1.ProwJobList{}) return err }
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/domain.go#L35-L42
func (dom Domain) Aliases() ([]string, error) { var vl valueList err := dom.cgp.request(getDomainAliases{Domain: dom.Name}, &vl) if err != nil { return []string{}, err } return vl.compact(), nil }
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/step1.go#L152-L158
func precededByARinRV(word *snowballword.SnowballWord, suffixLen int) bool { idx := len(word.RS) - suffixLen - 1 if idx >= word.RVstart && (word.RS[idx] == 'а' || word.RS[idx] == 'я') { return true } return false }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L4588-L4595
func (r *InstanceType) Locator(api *API) *InstanceTypeLocator { for _, l := range r.Links { if l["rel"] == "self" { return api.InstanceTypeLocator(l["href"]) } } return nil }
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/config.go#L74-L87
func readConfig() (*userConfig, error) { b, err := ioutil.ReadFile(filepath.Join(configDir, accountFile)) if err != nil { return nil, err } uc := &userConfig{} if err := json.Unmarshal(b, uc); err != nil { return nil, err } if key, err := readKey(filepath.Join(configDir, accountKey)); err == nil { uc.key = key } return uc, nil }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/provision/kubernetes/pkg/client/informers/externalversions/factory.go#L46-L55
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { return &sharedInformerFactory{ client: client, namespace: namespace, tweakListOptions: tweakListOptions, defaultResync: defaultResync, informers: make(map[reflect.Type]cache.SharedIndexInformer), startedInformers: make(map[reflect.Type]bool), } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/easyjson.go#L1664-L1668
func (v *CrashGpuProcessParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoBrowser18(&r, v) return r.Error() }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/operations.go#L100-L124
func (op *operation) Wait() error { // Check if not done already if op.StatusCode.IsFinal() { if op.Err != "" { return fmt.Errorf(op.Err) } return nil } // Make sure we have a listener setup err := op.setupListener() if err != nil { return err } <-op.chActive // We're done, parse the result if op.Err != "" { return fmt.Errorf(op.Err) } return nil }
https://github.com/coryb/figtree/blob/e5fa026ccd54e0a6a99b6d81f73bfcc8e6fe6a6b/gen-rawoption.go#L4096-L4105
func (o *MapUint64Option) Set(value string) error { parts := stringMapRegex.Split(value, 2) if len(parts) != 2 { return fmt.Errorf("expected KEY=VALUE got '%s'", value) } val := Uint64Option{} val.Set(parts[1]) (*o)[parts[0]] = val return nil }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/signature/policy_config.go#L341-L343
func NewPRSignedByKeyData(keyType sbKeyType, keyData []byte, signedIdentity PolicyReferenceMatch) (PolicyRequirement, error) { return newPRSignedByKeyData(keyType, keyData, signedIdentity) }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L5712-L5714
func (api *API) MultiCloudImageMatcherLocator(href string) *MultiCloudImageMatcherLocator { return &MultiCloudImageMatcherLocator{Href(href), api} }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm16/codegen_client.go#L71-L73
func (r *Account) Locator(api *API) *AccountLocator { return api.AccountLocator(r.Href) }
https://github.com/mota/klash/blob/ca6c37a4c8c2e69831c428cf0c6daac80ab56c22/parameter.go#L21-L27
func NewParameter(name string, value reflect.Value) *Parameter { parameter := Parameter{ Name: name, Value: value, } return &parameter }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/taskqueue/taskqueue.go#L436-L438
func Lease(c context.Context, maxTasks int, queueName string, leaseTime int) ([]*Task, error) { return lease(c, maxTasks, queueName, leaseTime, false, nil) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/branchprotector/request.go#L69-L79
func makeRestrictions(rp *branchprotection.Restrictions) *github.Restrictions { if rp == nil { return nil } teams := append([]string{}, sets.NewString(rp.Teams...).List()...) users := append([]string{}, sets.NewString(rp.Users...).List()...) return &github.Restrictions{ Teams: &teams, Users: &users, } }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/path.go#L63-L65
func split(p string) (string, string) { return clean(path.Dir(p)), base(p) }
https://github.com/geoffgarside/ber/blob/27a1aff36ce64dbe5d93c08cc5f161983134ddc5/ber.go#L115-L133
func parseBigInt(bytes []byte) (*big.Int, error) { if err := checkInteger(bytes); err != nil { return nil, err } ret := new(big.Int) if len(bytes) > 0 && bytes[0]&0x80 == 0x80 { // This is a negative number. notBytes := make([]byte, len(bytes)) for i := range notBytes { notBytes[i] = ^bytes[i] } ret.SetBytes(notBytes) ret.Add(ret, bigOne) ret.Neg(ret) return ret, nil } ret.SetBytes(bytes) return ret, nil }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/db/storage.go#L145-L150
func (s *Storage) SAMLRequests() *storage.Collection { id := mgo.Index{Key: []string{"id"}} coll := s.Collection("saml_requests") coll.EnsureIndex(id) return coll }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L119-L125
func (u PublicKey) ArmForSwitch(sw int32) (string, bool) { switch CryptoKeyType(sw) { case CryptoKeyTypeKeyTypeEd25519: return "Ed25519", true } return "-", false }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L1055-L1057
func (p *RemoveNodeParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandRemoveNode, p, nil) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domsnapshot/easyjson.go#L1188-L1192
func (v NodeTreeSnapshot) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDomsnapshot4(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/daemon/daemon_transport.go#L124-L133
func (ref daemonReference) StringWithinTransport() string { switch { case ref.id != "": return ref.id.String() case ref.ref != nil: return reference.FamiliarString(ref.ref) default: // Coverage: Should never happen, NewReference above should refuse such values. panic("Internal inconsistency: daemonReference has empty id and nil ref") } }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/pkg/tlsclientconfig/tlsclientconfig.go#L94-L112
func NewTransport() *http.Transport { direct := &net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, } tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: direct.Dial, TLSHandshakeTimeout: 10 * time.Second, // TODO(dmcgowan): Call close idle connections when complete and use keep alive DisableKeepAlives: true, } proxyDialer, err := sockets.DialerFromEnvironment(direct) if err == nil { tr.Dial = proxyDialer.Dial } return tr }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L135-L145
func getRemotePeerURLs(cl *membership.RaftCluster, local string) []string { us := make([]string, 0) for _, m := range cl.Members() { if m.Name == local { continue } us = append(us, m.PeerURLs...) } sort.Strings(us) return us }
https://github.com/Unknwon/goconfig/blob/3dba17dd7b9ec8509b3621a73a30a4b333eb28da/read.go#L201-L205
func LoadFromReader(in io.Reader) (c *ConfigFile, err error) { c = newConfigFile([]string{""}) err = c.read(in) return c, err }
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/read.go#L106-L108
func (p *Process) ReadInt32(a Address) int32 { return int32(p.ReadUint32(a)) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/target/target.go#L533-L535
func (p *SetDiscoverTargetsParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetDiscoverTargets, p, nil) }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/apps/get_apps_responses.go#L25-L45
func (o *GetAppsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { case 200: result := NewGetAppsOK() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil default: result := NewGetAppsDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } if response.Code()/100 == 2 { return result, nil } return nil, result } }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/main.go#L72-L98
func generateClient(descriptor *gen.APIDescriptor, codegen string) error { f, err := os.Create(codegen) if err != nil { return err } c, err := writers.NewClientWriter() if err != nil { return err } kingpin.FatalIfError(c.WriteHeader("cm15", "1.5", false /*needTime*/, true /*needJSON*/, f), "") for _, name := range descriptor.ResourceNames { resource := descriptor.Resources[name] c.WriteResourceHeader(name, f) kingpin.FatalIfError(c.WriteResource(resource, f), "") } c.WriteTypeSectionHeader(f) for _, name := range descriptor.TypeNames { t := descriptor.Types[name] c.WriteType(t, f) } f.Close() o, err := exec.Command("go", "fmt", codegen).CombinedOutput() if err != nil { return fmt.Errorf("Failed to format generated client code:\n%s", o) } return nil }
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/ext/tags.go#L208-L210
func (tag ipv4Tag) SetString(span opentracing.Span, value string) { span.SetTag(string(tag), value) }
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash_unsafe.go#L20-L26
func ChecksumString32S(s string, seed uint32) uint32 { if len(s) == 0 { return Checksum32S(nil, seed) } ss := (*reflect.StringHeader)(unsafe.Pointer(&s)) return Checksum32S((*[maxInt32]byte)(unsafe.Pointer(ss.Data))[:len(s):len(s)], seed) }
https://github.com/ip2location/ip2location-go/blob/a417f19539fd2a0eb0adf273b4190241cacc0499/ip2location.go#L236-L252
func readstr(pos uint32) string { pos2 := int64(pos) var retval string lenbyte := make([]byte, 1) _, err := f.ReadAt(lenbyte, pos2) if err != nil { fmt.Println("File read failed:", err) } strlen := lenbyte[0] data := make([]byte, strlen) _, err = f.ReadAt(data, pos2 + 1) if err != nil { fmt.Println("File read failed:", err) } retval = string(data[:strlen]) return retval }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cv.go#L198-L202
func (k *IplConvKernel) ReleaseElement() { C.cvReleaseStructuringElement( (**C.IplConvKernel)(unsafe.Pointer(&k)), ) }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/auth/token.go#L41-L51
func ParseToken(header string) (string, error) { s := strings.Split(header, " ") var value string if len(s) < 3 { value = s[len(s)-1] } if value != "" { return value, nil } return value, ErrInvalidToken }