_id
stringlengths 86
170
| text
stringlengths 54
39.3k
|
|---|---|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/require/require.go#L358-L363
|
func YesError(tb testing.TB, err error, msgAndArgs ...interface{}) {
tb.Helper()
if err == nil {
fatal(tb, msgAndArgs, "Error is expected but got %v", err)
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/easyjson.go#L440-L444
|
func (v *SetShowDebugBordersParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay5(&r, v)
return r.Error()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/css.go#L617-L623
|
func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams {
return &SetRuleSelectorParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
Selector: selector,
}
}
|
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcsecrets/tcsecrets.go#L153-L156
|
func (secrets *Secrets) Get_SignedURL(name string, duration time.Duration) (*url.URL, error) {
cd := tcclient.Client(*secrets)
return (&cd).SignedURL("/secret/"+url.QueryEscape(name), nil, duration)
}
|
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L875-L877
|
func (seq *Seq) RemoveAt(index int) {
C.cvSeqRemove((*C.struct_CvSeq)(seq), C.int(index))
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6535-L6544
|
func (u StellarMessage) GetAuth() (result Auth, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Auth" {
result = *u.Auth
ok = true
}
return
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/boskos.go#L117-L121
|
func handleDefault(r *ranch.Ranch) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
logrus.WithField("handler", "handleDefault").Infof("From %v", req.RemoteAddr)
}
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/cmd/target.go#L177-L189
|
func WriteTarget(t string) error {
targetPath := JoinWithUserDir(".tsuru", "target")
targetFile, err := filesystem().OpenFile(targetPath, syscall.O_WRONLY|syscall.O_CREAT|syscall.O_TRUNC, 0600)
if err != nil {
return err
}
defer targetFile.Close()
n, err := targetFile.WriteString(t)
if n != len(t) || err != nil {
return errors.New("Failed to write the target file")
}
return nil
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/level_handler.go#L159-L173
|
func (s *levelHandler) tryAddLevel0Table(t *table.Table) bool {
y.AssertTrue(s.level == 0)
// Need lock as we may be deleting the first table during a level 0 compaction.
s.Lock()
defer s.Unlock()
if len(s.tables) >= s.db.opt.NumLevelZeroTablesStall {
return false
}
s.tables = append(s.tables, t)
t.IncrRef()
s.totalSize += t.Size()
return true
}
|
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/errors/http.go#L122-L135
|
func ToHTTP(in error, w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
if err, ok := in.(Error); ok {
w.Header().Set(CodeHeader, err.Code().String())
w.WriteHeader(err.Type().HTTPStatusCode())
return json.NewEncoder(w).Encode(toJSON(err))
}
w.WriteHeader(http.StatusInternalServerError)
return json.NewEncoder(w).Encode(&jsonError{
Message: in.Error(),
Type: Unknown,
})
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L627-L671
|
func (c *Client) ListBuilds(jobs []BuildQueryParams) (map[string]Build, error) {
// Get queued builds.
jenkinsBuilds, err := c.GetEnqueuedBuilds(jobs)
if err != nil {
return nil, err
}
buildChan := make(chan map[string]Build, len(jobs))
errChan := make(chan error, len(jobs))
wg := &sync.WaitGroup{}
wg.Add(len(jobs))
// Get all running builds for all provided jobs.
for _, job := range jobs {
// Start a goroutine per list
go func(job string) {
defer wg.Done()
builds, err := c.GetBuilds(job)
if err != nil {
errChan <- err
} else {
buildChan <- builds
}
}(job.JobName)
}
wg.Wait()
close(buildChan)
close(errChan)
for err := range errChan {
if err != nil {
return nil, err
}
}
for builds := range buildChan {
for id, build := range builds {
jenkinsBuilds[id] = build
}
}
return jenkinsBuilds, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/animation/animation.go#L214-L219
|
func SetPaused(animations []string, paused bool) *SetPausedParams {
return &SetPausedParams{
Animations: animations,
Paused: paused,
}
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/gcsartifact.go#L213-L241
|
func (a *GCSArtifact) ReadTail(n int64) ([]byte, error) {
gzipped, err := a.gzipped()
if err != nil {
return nil, fmt.Errorf("error checking artifact for gzip compression: %v", err)
}
if gzipped {
return nil, lenses.ErrGzipOffsetRead
}
size, err := a.Size()
if err != nil {
return nil, fmt.Errorf("error getting artifact size: %v", err)
}
var offset int64
if n >= size {
offset = 0
} else {
offset = size - n
}
reader, err := a.handle.NewRangeReader(a.ctx, offset, -1)
defer reader.Close()
if err != nil && err != io.EOF {
return nil, fmt.Errorf("error getting artifact reader: %v", err)
}
read, err := ioutil.ReadAll(reader)
if err != nil {
return nil, fmt.Errorf("error reading all from artiact: %v", err)
}
return read, nil
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/signature/policy_eval.go#L130-L132
|
func policyIdentityLogName(ref types.ImageReference) string {
return ref.Transport().Name() + ":" + ref.PolicyConfigurationIdentity()
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L63-L78
|
func createPostRequest(u url.URL, path string, body io.Reader, ct string, urls types.URLs, from, cid types.ID) *http.Request {
uu := u
uu.Path = path
req, err := http.NewRequest("POST", uu.String(), body)
if err != nil {
plog.Panicf("unexpected new request error (%v)", err)
}
req.Header.Set("Content-Type", ct)
req.Header.Set("X-Server-From", from.String())
req.Header.Set("X-Server-Version", version.Version)
req.Header.Set("X-Min-Cluster-Version", version.MinClusterVersion)
req.Header.Set("X-Etcd-Cluster-ID", cid.String())
setPeerURLsHeader(req, urls)
return req
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L590-L594
|
func (v *TakeResponseBodyForInterceptionAsStreamParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork4(&r, v)
return r.Error()
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L380-L396
|
func (ap Approvers) GetFilesApprovers() map[string]sets.String {
filesApprovers := map[string]sets.String{}
currentApprovers := ap.GetCurrentApproversSetCased()
for fn, potentialApprovers := range ap.owners.GetApprovers() {
// The order of parameter matters here:
// - currentApprovers is the list of github handles that have approved
// - potentialApprovers is the list of handles in the OWNER
// files (lower case).
//
// We want to keep the syntax of the github handle
// rather than the potential mis-cased username found in
// the OWNERS file, that's why it's the first parameter.
filesApprovers[fn] = IntersectSetsCase(currentApprovers, potentialApprovers)
}
return filesApprovers
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/node.go#L438-L445
|
func (n *node) Tick() {
select {
case n.tickc <- struct{}{}:
case <-n.done:
default:
n.logger.Warningf("A tick missed to fire. Node blocks too long!")
}
}
|
https://github.com/malice-plugins/go-plugin-utils/blob/9ee76663c3b0a531b8c529f03f12a5a84ff9b61b/utils/utils.go#L87-L97
|
func GetSHA256(name string) string {
dat, err := ioutil.ReadFile(name)
Assert(err)
h256 := sha256.New()
_, err = h256.Write(dat)
Assert(err)
return fmt.Sprintf("%x", h256.Sum(nil))
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/contention/contention.go#L53-L69
|
func (td *TimeoutDetector) Observe(which uint64) (bool, time.Duration) {
td.mu.Lock()
defer td.mu.Unlock()
ok := true
now := time.Now()
exceed := time.Duration(0)
if pt, found := td.records[which]; found {
exceed = now.Sub(pt) - td.maxDuration
if exceed > 0 {
ok = false
}
}
td.records[which] = now
return ok, exceed
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/easyjson.go#L929-L933
|
func (v EventRequestPaused) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoFetch8(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/provision/docker/nodecontainer/queue.go#L20-L26
|
func RegisterQueueTask(p DockerProvisioner) error {
q, err := queue.Queue()
if err != nil {
return err
}
return q.RegisterTask(&runBs{provisioner: p})
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go#L85-L87
|
func RegisterLockHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterLockHandlerClient(ctx, mux, v3lockpb.NewLockClient(conn))
}
|
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/file-server/hasher.go#L29-L39
|
func (s MD5Hasher) Hash(reader io.Reader) (string, error) {
hash := md5.New()
if _, err := io.Copy(hash, reader); err != nil {
return "", err
}
h := hash.Sum(nil)
if len(h) < s.HashLength {
return "", nil
}
return strings.TrimRight(hex.EncodeToString(h)[:s.HashLength], "="), nil
}
|
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/internal/coding/quotedprint.go#L19-L23
|
func NewQPCleaner(r io.Reader) *QPCleaner {
return &QPCleaner{
in: bufio.NewReader(r),
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/target/easyjson.go#L2433-L2437
|
func (v *AttachToTargetReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget28(&r, v)
return r.Error()
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1049-L1088
|
func (c *Cluster) ContainerBackupCreate(args ContainerBackupArgs) error {
_, err := c.ContainerBackupID(args.Name)
if err == nil {
return ErrAlreadyDefined
}
err = c.Transaction(func(tx *ClusterTx) error {
containerOnlyInt := 0
if args.ContainerOnly {
containerOnlyInt = 1
}
optimizedStorageInt := 0
if args.OptimizedStorage {
optimizedStorageInt = 1
}
str := fmt.Sprintf("INSERT INTO containers_backups (container_id, name, creation_date, expiry_date, container_only, optimized_storage) VALUES (?, ?, ?, ?, ?, ?)")
stmt, err := tx.tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close()
result, err := stmt.Exec(args.ContainerID, args.Name,
args.CreationDate.Unix(), args.ExpiryDate.Unix(), containerOnlyInt,
optimizedStorageInt)
if err != nil {
return err
}
_, err = result.LastInsertId()
if err != nil {
return fmt.Errorf("Error inserting %s into database", args.Name)
}
return nil
})
return err
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L5180-L5184
|
func (v *EventNavigatedWithinDocument) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage53(&r, v)
return r.Error()
}
|
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/usermanagment.go#L206-L211
|
func (c *Client) ListShares(grpid string) (*Shares, error) {
url := umGroupShares(grpid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty)
ret := &Shares{}
err := c.client.Get(url, ret, http.StatusOK)
return ret, err
}
|
https://github.com/aphistic/gomol/blob/1546845ba714699f76f484ad3af64cf0503064d1/base.go#L536-L540
|
func (b *Base) Die(exitCode int, msg string) {
b.Log(LevelFatal, nil, msg)
b.ShutdownLoggers()
curExiter.Exit(exitCode)
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/permission.go#L274-L321
|
func addPermissions(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
if !permission.Check(t, permission.PermRoleUpdatePermissionAdd) {
return permission.ErrUnauthorized
}
roleName := r.URL.Query().Get(":name")
evt, err := event.New(&event.Opts{
Target: event.Target{Type: event.TargetTypeRole, Value: roleName},
Kind: permission.PermRoleUpdatePermissionAdd,
Owner: t,
CustomData: event.FormToCustomData(InputFields(r)),
Allowed: event.Allowed(permission.PermRoleReadEvents),
})
if err != nil {
return err
}
defer func() { evt.Done(err) }()
role, err := permission.FindRole(roleName)
if err != nil {
return err
}
users, err := auth.ListUsersWithRole(roleName)
if err != nil {
return err
}
err = runWithPermSync(users, func() error {
permissions, _ := InputValues(r, "permission")
return role.AddPermissions(permissions...)
})
if err == permTypes.ErrInvalidPermissionName {
return &errors.HTTP{
Code: http.StatusBadRequest,
Message: err.Error(),
}
}
if perr, ok := err.(*permTypes.ErrPermissionNotFound); ok {
return &errors.HTTP{
Code: http.StatusBadRequest,
Message: perr.Error(),
}
}
if perr, ok := err.(*permTypes.ErrPermissionNotAllowed); ok {
return &errors.HTTP{
Code: http.StatusConflict,
Message: perr.Error(),
}
}
return err
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L308-L315
|
func (f *FakeClient) RemoveLabel(owner, repo string, number int, label string) error {
labelString := fmt.Sprintf("%s/%s#%d:%s", owner, repo, number, label)
if !sets.NewString(f.IssueLabelsRemoved...).Has(labelString) {
f.IssueLabelsRemoved = append(f.IssueLabelsRemoved, labelString)
return nil
}
return fmt.Errorf("cannot remove %v from %s/%s/#%d", label, owner, repo, number)
}
|
https://github.com/Knetic/govaluate/blob/9aa49832a739dcd78a5542ff189fb82c3e423116/stagePlanner.go#L295-L320
|
func planFunction(stream *tokenStream) (*evaluationStage, error) {
var token ExpressionToken
var rightStage *evaluationStage
var err error
token = stream.next()
if token.Kind != FUNCTION {
stream.rewind()
return planAccessor(stream)
}
rightStage, err = planAccessor(stream)
if err != nil {
return nil, err
}
return &evaluationStage{
symbol: FUNCTIONAL,
rightStage: rightStage,
operator: makeFunctionStage(token.Value.(ExpressionFunction)),
typeErrorFormat: "Unable to run function '%v': %v",
}, nil
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/typed/buffer.go#L99-L106
|
func (r *ReadBuffer) ReadString(n int) string {
if b := r.ReadBytes(n); b != nil {
// TODO(mmihic): This creates a copy, which sucks
return string(b)
}
return ""
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L336-L365
|
func (c APIClient) ListDatum(jobID string, pageSize int64, page int64) (*pps.ListDatumResponse, error) {
client, err := c.PpsAPIClient.ListDatumStream(
c.Ctx(),
&pps.ListDatumRequest{
Job: NewJob(jobID),
PageSize: pageSize,
Page: page,
},
)
if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
resp := &pps.ListDatumResponse{}
first := true
for {
r, err := client.Recv()
if err == io.EOF {
break
} else if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
if first {
resp.TotalPages = r.TotalPages
resp.Page = r.Page
first = false
}
resp.DatumInfos = append(resp.DatumInfos, r.DatumInfo)
}
return resp, nil
}
|
https://github.com/segmentio/nsq-go/blob/ff4eef968f46eb580d9dba4f637c5dfb1e5b2208/consumer.go#L85-L110
|
func NewConsumer(config ConsumerConfig) (c *Consumer, err error) {
if err = config.validate(); err != nil {
return
}
config.defaults()
c = &Consumer{
msgs: make(chan Message, config.MaxInFlight),
done: make(chan struct{}),
topic: config.Topic,
channel: config.Channel,
address: config.Address,
lookup: append([]string{}, config.Lookup...),
maxInFlight: config.MaxInFlight,
identify: setIdentifyDefaults(config.Identify),
dialTimeout: config.DialTimeout,
readTimeout: config.ReadTimeout,
writeTimeout: config.WriteTimeout,
conns: make(map[string](chan<- Command)),
}
return
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L762-L765
|
func (p MoveToParams) WithInsertBeforeNodeID(insertBeforeNodeID cdp.NodeID) *MoveToParams {
p.InsertBeforeNodeID = insertBeforeNodeID
return &p
}
|
https://github.com/glycerine/rbuf/blob/75b78581bebe959bc9a3df4c5f64e82c187d7531/fbuf.go#L199-L208
|
func (b *Float64RingBuf) Advance(n int) {
if n <= 0 {
return
}
if n > b.Readable {
n = b.Readable
}
b.Readable -= n
b.Beg = (b.Beg + n) % b.N
}
|
https://github.com/pivotal-pez/pezdispenser/blob/768e2777520868857916b66cfd4cfb7149383ca5/taskmanager/task.go#L75-L82
|
func (s Task) Equal(b Task) bool {
return (s.ID == b.ID &&
s.Timestamp == b.Timestamp &&
s.Expires == b.Expires &&
s.Status == b.Status &&
s.Profile == b.Profile &&
s.CallerName == b.CallerName)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/types.go#L786-L788
|
func (t SignedExchangeErrorField) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L593-L599
|
func (c *Connection) withStateRLock(f func() error) error {
c.stateMut.RLock()
err := f()
c.stateMut.RUnlock()
return err
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L5917-L5926
|
func (u TransactionMeta) GetOperations() (result []OperationMeta, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.V))
if armName == "Operations" {
result = *u.Operations
ok = true
}
return
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/builder.go#L55-L61
|
func (h *header) Decode(buf []byte) int {
h.plen = binary.BigEndian.Uint16(buf[0:2])
h.klen = binary.BigEndian.Uint16(buf[2:4])
h.vlen = binary.BigEndian.Uint16(buf[4:6])
h.prev = binary.BigEndian.Uint32(buf[6:10])
return h.Size()
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/merge.go#L145-L149
|
func (op *MergeOperator) Add(val []byte) error {
return op.db.Update(func(txn *Txn) error {
return txn.Set(op.key, val)
})
}
|
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L54-L68
|
func (s *Server) CreateStream(id string) *Stream {
s.mu.Lock()
defer s.mu.Unlock()
if s.Streams[id] != nil {
return s.Streams[id]
}
str := newStream(s.BufferSize, s.AutoReplay)
str.run()
s.Streams[id] = str
return str
}
|
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/reverse.go#L87-L115
|
func (p *Process) ForEachReversePtr(y Object, fn func(x Object, r *Root, i, j int64) bool) {
p.reverseEdges()
idx, _ := p.findObjectIndex(p.Addr(y))
for _, a := range p.redge[p.ridx[idx]:p.ridx[idx+1]] {
// Read pointer, compute offset in y.
ptr := p.proc.ReadPtr(a)
j := ptr.Sub(p.Addr(y))
// Find source of pointer.
x, i := p.FindObject(a)
if x != 0 {
// Source is an object.
if !fn(x, nil, i, j) {
return
}
continue
}
// Source is a root.
k := sort.Search(len(p.rootIdx), func(k int) bool {
r := p.rootIdx[k]
return a < r.Addr.Add(r.Type.Size)
})
r := p.rootIdx[k]
if !fn(0, r, a.Sub(r.Addr), j) {
return
}
}
}
|
https://github.com/blacklabeldata/namedtuple/blob/c341f1db44f30b8164294aa8605ede42be604aba/floats.go#L6-L30
|
func (b *TupleBuilder) PutFloat32(field string, value float32) (wrote uint64, err error) {
// field type should be
if err = b.typeCheck(field, Float32Field); err != nil {
return 0, err
}
// write value
// length check performed by xbinary
wrote, err = xbinary.LittleEndian.PutFloat32(b.buffer, b.pos+1, value)
if err != nil {
return 0, err
}
// write type code
b.buffer[b.pos] = byte(FloatCode.OpCode)
// set field offset
b.offsets[field] = b.pos
// incr pos
b.pos += 5
return 5, nil
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L119-L127
|
func (r Ref) Type() string {
if _, ok := r["$ref"]; ok {
return "object"
}
if refIF, ok := r["type"]; ok {
return refIF.(string)
}
return ""
}
|
https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L696-L745
|
func (c *Consumer) syncGroup(strategy *balancer) (map[string][]int32, error) {
memberID, generationID := c.membership()
req := &sarama.SyncGroupRequest{
GroupId: c.groupID,
MemberId: memberID,
GenerationId: generationID,
}
if strategy != nil {
for memberID, topics := range strategy.Perform() {
if err := req.AddGroupAssignmentMember(memberID, &sarama.ConsumerGroupMemberAssignment{
Topics: topics,
}); err != nil {
return nil, err
}
}
}
broker, err := c.client.Coordinator(c.groupID)
if err != nil {
c.closeCoordinator(broker, err)
return nil, err
}
resp, err := broker.SyncGroup(req)
if err != nil {
c.closeCoordinator(broker, err)
return nil, err
} else if resp.Err != sarama.ErrNoError {
c.closeCoordinator(broker, resp.Err)
return nil, resp.Err
}
// Return if there is nothing to subscribe to
if len(resp.MemberAssignment) == 0 {
return nil, nil
}
// Get assigned subscriptions
members, err := resp.GetMemberAssignment()
if err != nil {
return nil, err
}
// Sort partitions, for each topic
for topic := range members.Topics {
sort.Sort(int32Slice(members.Topics[topic]))
}
return members.Topics, nil
}
|
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/log/field.go#L72-L78
|
func Int32(key string, val int32) Field {
return Field{
key: key,
fieldType: int32Type,
numericVal: int64(val),
}
}
|
https://github.com/google/subcommands/blob/d47216cd17848d55a33e6f651cbe408243ed55b8/subcommands.go#L123-L149
|
func (cdr *Commander) Execute(ctx context.Context, args ...interface{}) ExitStatus {
if cdr.topFlags.NArg() < 1 {
cdr.topFlags.Usage()
return ExitUsageError
}
name := cdr.topFlags.Arg(0)
for _, group := range cdr.commands {
for _, cmd := range group.commands {
if name != cmd.Name() {
continue
}
f := flag.NewFlagSet(name, flag.ContinueOnError)
f.Usage = func() { explain(cdr.Error, cmd) }
cmd.SetFlags(f)
if f.Parse(cdr.topFlags.Args()[1:]) != nil {
return ExitUsageError
}
return cmd.Execute(ctx, f, args...)
}
}
// Cannot find this command.
cdr.topFlags.Usage()
return ExitUsageError
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L500-L503
|
func (p GetFlattenedDocumentParams) WithDepth(depth int64) *GetFlattenedDocumentParams {
p.Depth = depth
return &p
}
|
https://github.com/rlmcpherson/s3gof3r/blob/864ae0bf7cf2e20c0002b7ea17f4d84fec1abc14/putter.go#L339-L363
|
func (p *putter) putMd5() (err error) {
calcMd5 := fmt.Sprintf("%x", p.md5.Sum(nil))
md5Reader := strings.NewReader(calcMd5)
md5Path := fmt.Sprint(".md5", p.url.Path, ".md5")
md5Url, err := p.b.url(md5Path, p.c)
if err != nil {
return err
}
logger.debugPrintln("md5: ", calcMd5)
logger.debugPrintln("md5Path: ", md5Path)
r, err := http.NewRequest("PUT", md5Url.String(), md5Reader)
if err != nil {
return
}
p.b.Sign(r)
resp, err := p.c.Client.Do(r)
if err != nil {
return
}
defer checkClose(resp.Body, err)
if resp.StatusCode != 200 {
return newRespError(resp)
}
return
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L22-L27
|
func NewBranch(repoName string, branchName string) *pfs.Branch {
return &pfs.Branch{
Repo: NewRepo(repoName),
Name: branchName,
}
}
|
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/api.go#L732-L743
|
func (r *Raft) AddVoter(id ServerID, address ServerAddress, prevIndex uint64, timeout time.Duration) IndexFuture {
if r.protocolVersion < 2 {
return errorFuture{ErrUnsupportedProtocol}
}
return r.requestConfigChange(configurationChangeRequest{
command: AddStaging,
serverID: id,
serverAddress: address,
prevIndex: prevIndex,
}, timeout)
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log.go#L34-L38
|
func Debug(msg string, ctx ...interface{}) {
if Log != nil {
Log.Debug(msg, ctx...)
}
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/encrypt.go#L48-L66
|
func Decrypt(text string) (string, error) {
if text == "" {
return "", nil
}
key := seekret()
bytes := decodeBase64([]byte(text))
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
if len(bytes) < aes.BlockSize {
return "", errors.New("ciphertext too short")
}
iv := bytes[:aes.BlockSize]
bytes = bytes[aes.BlockSize:]
cfb := cipher.NewCFBDecrypter(block, iv)
cfb.XORKeyStream(bytes, bytes)
return string(decodeBase64(bytes)), nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/page.go#L398-L407
|
func (p *GetLayoutMetricsParams) Do(ctx context.Context) (layoutViewport *LayoutViewport, visualViewport *VisualViewport, contentSize *dom.Rect, err error) {
// execute
var res GetLayoutMetricsReturns
err = cdp.Execute(ctx, CommandGetLayoutMetrics, nil, &res)
if err != nil {
return nil, nil, nil, err
}
return res.LayoutViewport, res.VisualViewport, res.ContentSize, nil
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pjutil/tot.go#L71-L76
|
func PeriodicToJobSpec(periodic config.Periodic) *downwardapi.JobSpec {
return &downwardapi.JobSpec{
Type: prowapi.PeriodicJob,
Job: periodic.Name,
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/tracing/tracing.go#L155-L158
|
func (p StartParams) WithStreamCompression(streamCompression StreamCompression) *StartParams {
p.StreamCompression = streamCompression
return &p
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/idle_sweep.go#L51-L64
|
func (is *idleSweep) start() {
if is.started || is.idleCheckInterval <= 0 {
return
}
is.ch.log.WithFields(
LogField{"idleCheckInterval", is.idleCheckInterval},
LogField{"maxIdleTime", is.maxIdleTime},
).Info("Starting idle connections poller.")
is.started = true
is.stopCh = make(chan struct{})
go is.pollerLoop()
}
|
https://github.com/ant0ine/go-json-rest/blob/ebb33769ae013bd5f518a8bac348c310dea768b8/rest/recorder.go#L92-L100
|
func (w *recorderResponseWriter) Write(b []byte) (int, error) {
if !w.wroteHeader {
w.WriteHeader(http.StatusOK)
}
writer := w.ResponseWriter.(http.ResponseWriter)
written, err := writer.Write(b)
w.bytesWritten += int64(written)
return written, err
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/indexeddb/indexeddb.go#L225-L234
|
func (p *GetMetadataParams) Do(ctx context.Context) (entriesCount float64, keyGeneratorValue float64, err error) {
// execute
var res GetMetadataReturns
err = cdp.Execute(ctx, CommandGetMetadata, p, &res)
if err != nil {
return 0, 0, err
}
return res.EntriesCount, res.KeyGeneratorValue, nil
}
|
https://github.com/jinzhu/now/blob/8ec929ed50c3ac25ce77ba4486e1f277c552c591/main.go#L116-L118
|
func Parse(strs ...string) (time.Time, error) {
return New(time.Now()).Parse(strs...)
}
|
https://github.com/blacklabeldata/namedtuple/blob/c341f1db44f30b8164294aa8605ede42be604aba/tuple.go#L92-L200
|
func (b *TupleBuilder) PutTuple(field string, value Tuple) (wrote int, err error) {
// field type should be
if err = b.typeCheck(field, TupleField); err != nil {
return 0, err
}
size := value.Size() + value.Header.Size()
if size < math.MaxUint8 {
// check length
if b.available() < size+2 {
return 0, xbinary.ErrOutOfRange
}
// write type code
b.buffer[b.pos] = byte(Tuple8Code.OpCode)
// write length
b.buffer[b.pos+1] = byte(size)
wrote += 2
// Write tuple
n, err := b.writeTuple(value, b.pos+wrote, size)
wrote += int(n)
// Return err
if err != nil {
return 0, err
}
} else if size < math.MaxUint16 {
// check length
if b.available() < size+3 {
return 0, xbinary.ErrOutOfRange
}
// write type code
b.buffer[b.pos] = byte(Tuple16Code.OpCode)
// write length
xbinary.LittleEndian.PutUint16(b.buffer, b.pos+1, uint16(size))
wrote += 3
// write tuple
n, err := b.writeTuple(value, b.pos+wrote, size)
// n, err := value.WriteAt(&b.buffer, int64(b.pos+3))
wrote += int(n)
// Return err
if err != nil {
return 0, err
}
} else if size < math.MaxUint32 {
// check length
if b.available() < size+5 {
return 0, xbinary.ErrOutOfRange
}
// write type code
b.buffer[b.pos] = byte(Tuple32Code.OpCode)
// write length
xbinary.LittleEndian.PutUint32(b.buffer, b.pos+1, uint32(size))
wrote += 5
// write tuple
n, err := b.writeTuple(value, b.pos+wrote, size)
// n, err := value.WriteAt(&b.buffer, int64(b.pos+5))
wrote += int(n)
// Return err
if err != nil {
return 0, err
}
} else {
// check length
if b.available() < size+9 {
return 0, xbinary.ErrOutOfRange
}
// write type code
b.buffer[b.pos] = byte(Tuple64Code.OpCode)
// write length
xbinary.LittleEndian.PutUint64(b.buffer, b.pos+1, uint64(size))
wrote += 9
// write tuple
n, err := b.writeTuple(value, b.pos+wrote, size)
// n, err := value.WriteAt(&b.buffer, int64(b.pos+9))
wrote += int(n)
// Return err
if err != nil {
return 0, err
}
}
// store offset and increment position
b.offsets[field] = b.pos
b.pos += wrote
return
}
|
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/recovery/recovery.go#L142-L144
|
func (f NotifierFunc) Notify(subject, body string) error {
return f(subject, body)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/easyjson.go#L1472-L1476
|
func (v *HighlightConfig) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay13(&r, v)
return r.Error()
}
|
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L54-L67
|
func (api *TelegramBotAPI) NewOutgoingVideo(recipient Recipient, fileName string, reader io.Reader) *OutgoingVideo {
return &OutgoingVideo{
outgoingMessageBase: outgoingMessageBase{
outgoingBase: outgoingBase{
api: api,
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1015-L1052
|
func (w *Writer) Write(n *MergeNode) error {
// Marshal node if it was merged
if n.nodeProto != nil {
var err error
n.v, err = n.nodeProto.Marshal()
if err != nil {
return err
}
}
// Get size info from root node
if bytes.Equal(n.k, nullByte) {
if n.nodeProto == nil {
n.nodeProto = &NodeProto{}
if err := n.nodeProto.Unmarshal(n.v); err != nil {
return err
}
}
w.size = uint64(n.nodeProto.SubtreeSize)
}
// Write index for every index size bytes
if w.offset > uint64(len(w.idxs)+1)*IndexSize {
w.idxs = append(w.idxs, &Index{
K: n.k,
Offset: w.offset,
})
}
b, err := w.pbw.WriteBytes(n.k)
if err != nil {
return err
}
w.offset += uint64(b)
b, err = w.pbw.WriteBytes(n.v)
if err != nil {
return err
}
w.offset += uint64(b)
return nil
}
|
https://github.com/segmentio/nsq-go/blob/ff4eef968f46eb580d9dba4f637c5dfb1e5b2208/producer.go#L105-L117
|
func (p *Producer) Start() {
if p.started {
panic("(*Producer).Start has already been called")
}
concurrency := cap(p.reqs)
p.join.Add(concurrency)
for i := 0; i != concurrency; i++ {
go p.run()
}
p.started = true
}
|
https://github.com/siddontang/go-log/blob/1e957dd83bed18c84716181da7b80d4af48eaefe/log/log.go#L95-L97
|
func Debugf(format string, args ...interface{}) {
logger.Output(2, LevelDebug, fmt.Sprintf(format, args...))
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/profiler/easyjson.go#L1786-L1790
|
func (v Profile) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler17(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domsnapshot/easyjson.go#L1200-L1204
|
func (v *NodeTreeSnapshot) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDomsnapshot4(&r, v)
return r.Error()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L793-L796
|
func (p SetCookieParams) WithSameSite(sameSite CookieSameSite) *SetCookieParams {
p.SameSite = sameSite
return &p
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/server/api_server.go#L1618-L1639
|
func (a *apiServer) makePipelineInfoCommit(pachClient *client.APIClient, pipelineInfo *pps.PipelineInfo) (result *pfs.Commit, retErr error) {
pipelineName := pipelineInfo.Pipeline.Name
var commit *pfs.Commit
if err := a.sudo(pachClient, func(superUserClient *client.APIClient) error {
data, err := pipelineInfo.Marshal()
if err != nil {
return fmt.Errorf("could not marshal PipelineInfo: %v", err)
}
if _, err = superUserClient.PutFileOverwrite(ppsconsts.SpecRepo, pipelineName, ppsconsts.SpecFile, bytes.NewReader(data), 0); err != nil {
return err
}
branchInfo, err := superUserClient.InspectBranch(ppsconsts.SpecRepo, pipelineName)
if err != nil {
return err
}
commit = branchInfo.Head
return nil
}); err != nil {
return nil, err
}
return commit, nil
}
|
https://github.com/Unknwon/goconfig/blob/3dba17dd7b9ec8509b3621a73a30a4b333eb28da/read.go#L257-L268
|
func (c *ConfigFile) ReloadData(in io.Reader) (err error) {
var cfg *ConfigFile
if len(c.fileNames) != 1 {
return fmt.Errorf("Multiple files loaded, unable to mix in-memory and file data")
}
cfg, err = LoadFromReader(in)
if err == nil {
*c = *cfg
}
return err
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L548-L554
|
func (c APIClient) PutObjectAsync(tags []*pfs.Tag) (*PutObjectWriteCloserAsync, error) {
w, err := c.newPutObjectWriteCloserAsync(tags)
if err != nil {
return nil, grpcutil.ScrubGRPC(err)
}
return w, nil
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/role_command.go#L183-L194
|
func roleRevokePermissionCommandFunc(cmd *cobra.Command, args []string) {
if len(args) < 2 {
ExitWithError(ExitBadArgs, fmt.Errorf("role revoke-permission command requires role name and key [endkey] as its argument"))
}
key, rangeEnd := permRange(args[1:])
resp, err := mustClientFromCmd(cmd).Auth.RoleRevokePermission(context.TODO(), args[0], key, rangeEnd)
if err != nil {
ExitWithError(ExitError, err)
}
display.RoleRevokePermission(args[0], args[1], rangeEnd, *resp)
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/db.go#L499-L501
|
func queryScan(db *sql.DB, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error) {
return doDbQueryScan(db, q, inargs, outfmt)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1089-L1144
|
func GetRangeFromIndex(r io.Reader, prefix string) (uint64, uint64, error) {
prefix = clean(prefix)
pbr := pbutil.NewReader(r)
idx := &Index{}
k := b(prefix)
var lower, upper uint64
iter := func(f func(int) bool) error {
for {
if err := pbr.Read(idx); err != nil {
if err == io.EOF {
break
}
return err
}
var cmp int
if len(k) < len(idx.K) {
cmp = bytes.Compare(k, idx.K[:len(k)])
} else {
cmp = bytes.Compare(k[:len(idx.K)], idx.K)
}
if f(cmp) {
break
}
}
return nil
}
low := func(cmp int) bool {
if cmp > 0 {
lower = idx.Offset
return false
} else if cmp < 0 {
// Handles the case where a prefix fits within one range
upper = idx.Offset
}
return true
}
up := func(cmp int) bool {
if cmp < 0 {
upper = idx.Offset
return true
}
return false
}
// Find lower
iter(low)
// Find upper
if upper <= 0 {
iter(up)
}
// Handles the case when at the end of the indexes
if upper <= 0 {
return lower, 0, nil
}
// Return offset and size
return lower, upper - lower, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/memory/easyjson.go#L758-L762
|
func (v *Module) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoMemory7(&r, v)
return r.Error()
}
|
https://github.com/segmentio/nsq-go/blob/ff4eef968f46eb580d9dba4f637c5dfb1e5b2208/consumer.go#L126-L134
|
func (c *Consumer) Start() {
if c.started {
panic("(*Consumer).Start has already been called")
}
go c.run()
c.started = true
}
|
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L67-L70
|
func (w *SnowballWord) RemoveLastNRunes(n int) {
w.RS = w.RS[:len(w.RS)-n]
w.resetR1R2()
}
|
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L123-L131
|
func (s *Servers) Add(name, address string, srv Server) {
s.mu.Lock()
s.servers = append(s.servers, &server{
Server: srv,
name: name,
address: address,
})
s.mu.Unlock()
}
|
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/errors/http.go#L94-L119
|
func FromHTTP(resp *http.Response) Error {
if resp.StatusCode < 399 {
return nil
}
typ := HTTPStatusToType(resp.StatusCode)
out := &impl{
message: typ.String(),
code: parseCode(resp.Header.Get(CodeHeader)),
typ: typ,
}
// try to decode the error from the body
defer resp.Body.Close()
j := new(jsonError)
err := json.NewDecoder(resp.Body).Decode(j)
if err == nil {
out.message = j.Message
out.code = j.Code
out.typ = j.Type
out.attributes = j.Attributes
}
return out
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dpdf/path_converter.go#L15-L44
|
func ConvertPath(path *draw2d.Path, pdf Vectorizer) {
var startX, startY float64 = 0, 0
i := 0
for _, cmp := range path.Components {
switch cmp {
case draw2d.MoveToCmp:
startX, startY = path.Points[i], path.Points[i+1]
pdf.MoveTo(startX, startY)
i += 2
case draw2d.LineToCmp:
pdf.LineTo(path.Points[i], path.Points[i+1])
i += 2
case draw2d.QuadCurveToCmp:
pdf.CurveTo(path.Points[i], path.Points[i+1], path.Points[i+2], path.Points[i+3])
i += 4
case draw2d.CubicCurveToCmp:
pdf.CurveBezierCubicTo(path.Points[i], path.Points[i+1], path.Points[i+2], path.Points[i+3], path.Points[i+4], path.Points[i+5])
i += 6
case draw2d.ArcToCmp:
pdf.ArcTo(path.Points[i], path.Points[i+1], path.Points[i+2], path.Points[i+3],
0, // degRotate
path.Points[i+4]*deg, // degStart = startAngle
(path.Points[i+4]-path.Points[i+5])*deg) // degEnd = startAngle-angle
i += 6
case draw2d.CloseCmp:
pdf.LineTo(startX, startY)
pdf.ClosePath()
}
}
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L94-L104
|
func unionStrings(parent, child []string) []string {
if child == nil {
return parent
}
if parent == nil {
return child
}
s := sets.NewString(parent...)
s.Insert(child...)
return s.List()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L4304-L4308
|
func (v *GetPlatformFontsForNodeReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss37(&r, v)
return r.Error()
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/apis/prowjobs/v1/types.go#L275-L306
|
func (d *DecorationConfig) Validate() error {
if d.UtilityImages == nil {
return errors.New("utility image config is not specified")
}
var missing []string
if d.UtilityImages.CloneRefs == "" {
missing = append(missing, "clonerefs")
}
if d.UtilityImages.InitUpload == "" {
missing = append(missing, "initupload")
}
if d.UtilityImages.Entrypoint == "" {
missing = append(missing, "entrypoint")
}
if d.UtilityImages.Sidecar == "" {
missing = append(missing, "sidecar")
}
if len(missing) > 0 {
return fmt.Errorf("the following utility images are not specified: %q", missing)
}
if d.GCSConfiguration == nil {
return errors.New("GCS upload configuration is not specified")
}
if d.GCSCredentialsSecret == "" {
return errors.New("GCS upload credential secret is not specified")
}
if err := d.GCSConfiguration.Validate(); err != nil {
return fmt.Errorf("GCS configuration is invalid: %v", err)
}
return nil
}
|
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L164-L167
|
func (img *IplImage) Get2D(x, y int) Scalar {
ret := C.cvGet2D(unsafe.Pointer(img), C.int(y), C.int(x))
return Scalar(ret)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L629-L637
|
func (b *BackoffWriteCloser) Close() error {
span, _ := tracing.AddSpanToAnyExisting(b.ctx, "obj/BackoffWriteCloser.Close")
defer tracing.FinishAnySpan(span)
err := b.writer.Close()
if b.client.IsIgnorable(err) {
return nil
}
return err
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L260-L290
|
func NewClient(
url string,
dryRun bool,
tlsConfig *tls.Config,
authConfig *AuthConfig,
logger *logrus.Entry,
metrics *ClientMetrics,
) (*Client, error) {
if logger == nil {
logger = logrus.NewEntry(logrus.StandardLogger())
}
c := &Client{
logger: logger.WithField("client", "jenkins"),
dryRun: dryRun,
baseURL: url,
authConfig: authConfig,
client: &http.Client{
Timeout: 30 * time.Second,
},
metrics: metrics,
}
if tlsConfig != nil {
c.client.Transport = &http.Transport{TLSClientConfig: tlsConfig}
}
if c.authConfig.CSRFProtect {
if err := c.CrumbRequest(); err != nil {
return nil, fmt.Errorf("cannot get Jenkins crumb: %v", err)
}
}
return c, nil
}
|
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/dsl/interaction.go#L24-L28
|
func (i *Interaction) Given(state string) *Interaction {
i.State = state
return i
}
|
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/ttnctx/context.go#L53-L59
|
func KeyFromMetadata(md metadata.MD) (string, error) {
key, ok := md["key"]
if !ok || len(key) == 0 {
return "", ErrNoKey
}
return key[0], nil
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/node.go#L480-L517
|
func (n *node) stepWithWaitOption(ctx context.Context, m pb.Message, wait bool) error {
if m.Type != pb.MsgProp {
select {
case n.recvc <- m:
return nil
case <-ctx.Done():
return ctx.Err()
case <-n.done:
return ErrStopped
}
}
ch := n.propc
pm := msgWithResult{m: m}
if wait {
pm.result = make(chan error, 1)
}
select {
case ch <- pm:
if !wait {
return nil
}
case <-ctx.Done():
return ctx.Err()
case <-n.done:
return ErrStopped
}
select {
case err := <-pm.result:
if err != nil {
return err
}
case <-ctx.Done():
return ctx.Err()
case <-n.done:
return ErrStopped
}
return nil
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/service/service_instance.go#L132-L147
|
func (si *ServiceInstance) ToInfo() (ServiceInstanceWithInfo, error) {
info, err := si.Info("")
if err != nil {
info = nil
}
return ServiceInstanceWithInfo{
Id: si.Id,
Name: si.Name,
Teams: si.Teams,
PlanName: si.PlanName,
Apps: si.Apps,
ServiceName: si.ServiceName,
Info: info,
TeamOwner: si.TeamOwner,
}, nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/lex/case.go#L20-L26
|
func Camel(s string) string {
words := strings.Split(s, "_")
for i := range words {
words[i] = Capital(words[i])
}
return strings.Join(words, "")
}
|
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/identity.go#L57-L64
|
func (id *Identity) ChainPool() *x509.CertPool {
chain := x509.NewCertPool()
for this := id; this != nil; this = this.Issuer {
chain.AddCert(this.Certificate)
}
return chain
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/types.go#L372-L374
|
func (t *CaptureScreenshotFormat) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L593-L615
|
func ContainerConfigInsert(tx *sql.Tx, id int, config map[string]string) error {
str := "INSERT INTO containers_config (container_id, key, value) values (?, ?, ?)"
stmt, err := tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close()
for k, v := range config {
if v == "" {
continue
}
_, err := stmt.Exec(id, k, v)
if err != nil {
logger.Debugf("Error adding configuration item %s = %s to container %d",
k, v, id)
return err
}
}
return nil
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.