_id
stringlengths 86
170
| text
stringlengths 54
39.3k
|
|---|---|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L3463-L3467
|
func (v *MediaQuery) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss30(&r, v)
return r.Error()
}
|
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/dsl/pact.go#L432-L448
|
func AfterEachMiddleware(AfterEach types.Hook) proxy.Middleware {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r)
if r.URL.Path != "/__setup" {
log.Println("[DEBUG] executing after hook")
err := AfterEach()
if err != nil {
log.Println("[ERROR] error executing after hook:", err)
w.WriteHeader(http.StatusInternalServerError)
}
}
})
}
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L37-L92
|
func (c *Client) unaryClientInterceptor(logger *zap.Logger, optFuncs ...retryOption) grpc.UnaryClientInterceptor {
intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs)
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
grpcOpts, retryOpts := filterCallOptions(opts)
callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts)
// short circuit for simplicity, and avoiding allocations.
if callOpts.max == 0 {
return invoker(ctx, method, req, reply, cc, grpcOpts...)
}
var lastErr error
for attempt := uint(0); attempt < callOpts.max; attempt++ {
if err := waitRetryBackoff(ctx, attempt, callOpts); err != nil {
return err
}
logger.Debug(
"retrying of unary invoker",
zap.String("target", cc.Target()),
zap.Uint("attempt", attempt),
)
lastErr = invoker(ctx, method, req, reply, cc, grpcOpts...)
if lastErr == nil {
return nil
}
logger.Warn(
"retrying of unary invoker failed",
zap.String("target", cc.Target()),
zap.Uint("attempt", attempt),
zap.Error(lastErr),
)
if isContextError(lastErr) {
if ctx.Err() != nil {
// its the context deadline or cancellation.
return lastErr
}
// its the callCtx deadline or cancellation, in which case try again.
continue
}
if callOpts.retryAuth && rpctypes.Error(lastErr) == rpctypes.ErrInvalidAuthToken {
gterr := c.getToken(ctx)
if gterr != nil {
logger.Warn(
"retrying of unary invoker failed to fetch new auth token",
zap.String("target", cc.Target()),
zap.Error(gterr),
)
return lastErr // return the original error for simplicity
}
continue
}
if !isSafeRetry(c.lg, lastErr, callOpts) {
return lastErr
}
}
return lastErr
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L81-L86
|
func CopyTo(nodeID cdp.NodeID, targetNodeID cdp.NodeID) *CopyToParams {
return &CopyToParams{
NodeID: nodeID,
TargetNodeID: targetNodeID,
}
}
|
https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode29.go#L203-L220
|
func (d *decoder29) readBlockHeader() error {
d.br.alignByte()
n, err := d.br.readBits(1)
if err == nil {
if n > 0 {
d.decode = d.ppm.decode
err = d.ppm.init(d.br)
} else {
d.decode = d.lz.decode
err = d.lz.init(d.br)
}
}
if err == io.EOF {
err = errDecoderOutOfData
}
return err
}
|
https://github.com/geoffgarside/ber/blob/27a1aff36ce64dbe5d93c08cc5f161983134ddc5/ber.go#L287-L301
|
func isPrintable(b byte) bool {
return 'a' <= b && b <= 'z' ||
'A' <= b && b <= 'Z' ||
'0' <= b && b <= '9' ||
'\'' <= b && b <= ')' ||
'+' <= b && b <= '/' ||
b == ' ' ||
b == ':' ||
b == '=' ||
b == '?' ||
// This is technically not allowed in a PrintableString.
// However, x509 certificates with wildcard strings don't
// always use the correct string type so we permit it.
b == '*'
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/types.go#L328-L330
|
func (t *ClientNavigationReason) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/migration/migration.go#L88-L96
|
func Run(args RunArgs) error {
if args.Name != "" {
return runOptional(args)
}
if args.Force {
return ErrCannotForceMandatory
}
return run(args)
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/iterator.go#L275-L312
|
func (itr *Iterator) seekFrom(key []byte, whence int) {
itr.err = nil
switch whence {
case origin:
itr.reset()
case current:
}
idx := sort.Search(len(itr.t.blockIndex), func(idx int) bool {
ko := itr.t.blockIndex[idx]
return y.CompareKeys(ko.key, key) > 0
})
if idx == 0 {
// The smallest key in our table is already strictly > key. We can return that.
// This is like a SeekToFirst.
itr.seekHelper(0, key)
return
}
// block[idx].smallest is > key.
// Since idx>0, we know block[idx-1].smallest is <= key.
// There are two cases.
// 1) Everything in block[idx-1] is strictly < key. In this case, we should go to the first
// element of block[idx].
// 2) Some element in block[idx-1] is >= key. We should go to that element.
itr.seekHelper(idx-1, key)
if itr.err == io.EOF {
// Case 1. Need to visit block[idx].
if idx == len(itr.t.blockIndex) {
// If idx == len(itr.t.blockIndex), then input key is greater than ANY element of table.
// There's nothing we can do. Valid() should return false as we seek to end of table.
return
}
// Since block[idx].smallest is > key. This is essentially a block[idx].SeekToFirst.
itr.seekHelper(idx, key)
}
// Case 2: No need to do anything. We already did the seek in block[idx-1].
}
|
https://github.com/kr/s3/blob/c070c8f9a8f0032d48f0d2a77d4e382788bd8a1d/sign.go#L68-L73
|
func AmazonBucket(subdomain string) string {
if i := strings.LastIndex(subdomain, "."); i != -1 {
return subdomain[:i]
}
return ""
}
|
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/frameset.go#L144-L146
|
func (s *FrameSet) Index(frame int) int {
return s.rangePtr.Index(frame)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/apis/prowjobs/v1/zz_generated.deepcopy.go#L183-L223
|
func (in *ProwJobSpec) DeepCopyInto(out *ProwJobSpec) {
*out = *in
if in.Refs != nil {
in, out := &in.Refs, &out.Refs
*out = new(Refs)
(*in).DeepCopyInto(*out)
}
if in.ExtraRefs != nil {
in, out := &in.ExtraRefs, &out.ExtraRefs
*out = make([]Refs, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.PodSpec != nil {
in, out := &in.PodSpec, &out.PodSpec
*out = new(corev1.PodSpec)
(*in).DeepCopyInto(*out)
}
if in.BuildSpec != nil {
in, out := &in.BuildSpec, &out.BuildSpec
*out = new(v1alpha1.BuildSpec)
(*in).DeepCopyInto(*out)
}
if in.JenkinsSpec != nil {
in, out := &in.JenkinsSpec, &out.JenkinsSpec
*out = new(JenkinsSpec)
**out = **in
}
if in.PipelineRunSpec != nil {
in, out := &in.PipelineRunSpec, &out.PipelineRunSpec
*out = new(pipelinev1alpha1.PipelineRunSpec)
(*in).DeepCopyInto(*out)
}
if in.DecorationConfig != nil {
in, out := &in.DecorationConfig, &out.DecorationConfig
*out = new(DecorationConfig)
(*in).DeepCopyInto(*out)
}
return
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/tracing/tracing.go#L49-L58
|
func (p *GetCategoriesParams) Do(ctx context.Context) (categories []string, err error) {
// execute
var res GetCategoriesReturns
err = cdp.Execute(ctx, CommandGetCategories, nil, &res)
if err != nil {
return nil, err
}
return res.Categories, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/easyjson.go#L1239-L1243
|
func (v *RequestNodeReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom12(&r, v)
return r.Error()
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L31-L42
|
func RunBoundedArgs(min int, max int, run func([]string) error) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
if len(args) < min || len(args) > max {
fmt.Printf("expected %d to %d arguments, got %d\n\n", min, max, len(args))
cmd.Usage()
} else {
if err := run(args); err != nil {
ErrorAndExit("%v", err)
}
}
}
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/base.go#L48-L56
|
func HandleBasic(mux *http.ServeMux, server etcdserver.ServerPeer) {
mux.HandleFunc(varsPath, serveVars)
// TODO: deprecate '/config/local/log' in v3.5
mux.HandleFunc(configPath+"/local/log", logHandleFunc)
HandleMetricsHealth(mux, server)
mux.HandleFunc(versionPath, versionHandler(server.Cluster(), serveVersion))
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/client.go#L649-L652
|
func (c *Client) EditRepoHook(org, repo string, id int, req HookRequest) error {
c.log("EditRepoHook", org, repo, id)
return c.editHook(org, &repo, id, req)
}
|
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcqueue/tcqueue.go#L147-L158
|
func (queue *Queue) ListTaskGroup(taskGroupId, continuationToken, limit string) (*ListTaskGroupResponse, error) {
v := url.Values{}
if continuationToken != "" {
v.Add("continuationToken", continuationToken)
}
if limit != "" {
v.Add("limit", limit)
}
cd := tcclient.Client(*queue)
responseObject, _, err := (&cd).APICall(nil, "GET", "/task-group/"+url.QueryEscape(taskGroupId)+"/list", new(ListTaskGroupResponse), v)
return responseObject.(*ListTaskGroupResponse), err
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/storage/chunk/storage.go#L41-L43
|
func (s *Storage) NewWriter(ctx context.Context) *Writer {
return newWriter(ctx, s.objC, s.prefix)
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/txn.go#L685-L687
|
func (db *DB) NewTransaction(update bool) *Txn {
return db.newTransaction(update, false)
}
|
https://github.com/siddontang/go-log/blob/1e957dd83bed18c84716181da7b80d4af48eaefe/log/logger.go#L301-L303
|
func (l *Logger) Debug(args ...interface{}) {
l.Output(2, LevelDebug, fmt.Sprint(args...))
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/method.go#L506-L539
|
func (m *Method) fillSliceReferenceField(buf *file.Buffer, nk []*Field, field *Field) error {
objectsVar := fmt.Sprintf("%sObjects", lex.Minuscule(field.Name))
methodName := fmt.Sprintf("%s%sRef", lex.Capital(m.entity), field.Name)
buf.L("// Fill field %s.", field.Name)
buf.L("%s, err := c.%s(filter)", objectsVar, methodName)
buf.L("if err != nil {")
buf.L(" return nil, errors.Wrap(err, \"Failed to fetch field %s\")", field.Name)
buf.L("}")
buf.N()
buf.L("for i := range objects {")
needle := ""
for i, key := range nk[:len(nk)-1] {
needle += fmt.Sprintf("[objects[i].%s]", key.Name)
subIndexTyp := indexType(nk[i+1:], field.Type.Name)
buf.L(" _, ok := %s%s", objectsVar, needle)
buf.L(" if !ok {")
buf.L(" subIndex := %s{}", subIndexTyp)
buf.L(" %s%s = subIndex", objectsVar, needle)
buf.L(" }")
buf.N()
}
needle += fmt.Sprintf("[objects[i].%s]", nk[len(nk)-1].Name)
buf.L(" value := %s%s", objectsVar, needle)
buf.L(" if value == nil {")
buf.L(" value = %s{}", field.Type.Name)
buf.L(" }")
buf.L(" objects[i].%s = value", field.Name)
buf.L("}")
buf.N()
return nil
}
|
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/gossip_channel.go#L87-L89
|
func (c *gossipChannel) Send(data GossipData) {
c.relay(c.ourself.Name, data)
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L419-L421
|
func (s *Iterator) Key() []byte {
return s.list.arena.getKey(s.n.keyOffset, s.n.keySize)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/clone/clone.go#L81-L89
|
func PathForRefs(baseDir string, refs prowapi.Refs) string {
var clonePath string
if refs.PathAlias != "" {
clonePath = refs.PathAlias
} else {
clonePath = fmt.Sprintf("github.com/%s/%s", refs.Org, refs.Repo)
}
return fmt.Sprintf("%s/src/%s", baseDir, clonePath)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/tide.go#L304-L323
|
func (qm *QueryMap) ForRepo(org, repo string) TideQueries {
res := TideQueries(nil)
fullName := fmt.Sprintf("%s/%s", org, repo)
qm.Lock()
defer qm.Unlock()
if qs, ok := qm.cache[fullName]; ok {
return append(res, qs...) // Return a copy.
}
// Cache miss. Need to determine relevant queries.
for _, query := range qm.queries {
if query.ForRepo(org, repo) {
res = append(res, query)
}
}
qm.cache[fullName] = res
return res
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L461-L465
|
func (v *SetCustomObjectFormatterEnabledParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime4(&r, v)
return r.Error()
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L5428-L5434
|
func (u TransactionHistoryResultEntryExt) ArmForSwitch(sw int32) (string, bool) {
switch int32(sw) {
case 0:
return "", true
}
return "-", false
}
|
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/token_bucket.go#L18-L27
|
func newTokenBucket(capacity int64, tokenInterval time.Duration) *tokenBucket {
tb := tokenBucket{
capacity: capacity,
tokenInterval: tokenInterval,
refillDuration: tokenInterval * time.Duration(capacity)}
tb.earliestUnspentToken = tb.capacityToken()
return &tb
}
|
https://github.com/ChrisTrenkamp/goxpath/blob/c385f95c6022e7756e91beac5f5510872f7dcb7d/marshal.go#L12-L14
|
func Marshal(n tree.Node, w io.Writer) error {
return marshal(n, w)
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L712-L714
|
func (api *API) Rl10Locator(href string) *Rl10Locator {
return &Rl10Locator{Href(href), api}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L8343-L8347
|
func (v ClearBrowserCacheParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork65(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/issue-creator/sources/flakyjob-reporter.go#L231-L238
|
func (fj *FlakyJob) Labels() []string {
labels := []string{"kind/flake"}
// get sig labels
for sig := range fj.reporter.creator.TestsSIGs(fj.TestsSorted()) {
labels = append(labels, "sig/"+sig)
}
return labels
}
|
https://github.com/google/go-cmp/blob/6f77996f0c42f7b84e5a2b252227263f93432e9b/cmp/cmpopts/struct_filter.go#L95-L106
|
func (ft *fieldTree) insert(cname []string) {
if ft.sub == nil {
ft.sub = make(map[string]fieldTree)
}
if len(cname) == 0 {
ft.ok = true
return
}
sub := ft.sub[cname[0]]
sub.insert(cname[1:])
ft.sub[cname[0]] = sub
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L3554-L3563
|
func (u AccountMergeResult) GetSourceAccountBalance() (result Int64, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Code))
if armName == "SourceAccountBalance" {
result = *u.SourceAccountBalance
ok = true
}
return
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dimg/ftgc.go#L118-L120
|
func (gc *GraphicContext) DrawImage(img image.Image) {
DrawImage(img, gc.img, gc.Current.Tr, draw.Over, BilinearFilter)
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L8294-L8301
|
func (r *Repository) Locator(api *API) *RepositoryLocator {
for _, l := range r.Links {
if l["rel"] == "self" {
return api.RepositoryLocator(l["href"])
}
}
return nil
}
|
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L824-L831
|
func CheckInternalVisibility(rel, visibility string) string {
if i := strings.LastIndex(rel, "/internal/"); i >= 0 {
visibility = fmt.Sprintf("//%s:__subpackages__", rel[:i])
} else if strings.HasPrefix(rel, "internal/") {
visibility = "//:__subpackages__"
}
return visibility
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L323-L336
|
func (f *FakeClient) AssignIssue(owner, repo string, number int, assignees []string) error {
var m github.MissingUsers
for _, a := range assignees {
if a == "not-in-the-org" {
m.Users = append(m.Users, a)
continue
}
f.AssigneesAdded = append(f.AssigneesAdded, fmt.Sprintf("%s/%s#%d:%s", owner, repo, number, a))
}
if m.Users == nil {
return nil
}
return m
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/manifest.go#L413-L420
|
func applyChangeSet(build *Manifest, changeSet *pb.ManifestChangeSet) error {
for _, change := range changeSet.Changes {
if err := applyManifestChange(build, change); err != nil {
return err
}
}
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L1376-L1378
|
func (p *SetInspectedNodeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetInspectedNode, p, nil)
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/reqres.go#L260-L266
|
func (r *reqResReader) releasePreviousFragment() {
fragment := r.previousFragment
r.previousFragment = nil
if fragment != nil {
fragment.done()
}
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/peer.go#L34-L36
|
func NewPeerHandler(lg *zap.Logger, s etcdserver.ServerPeer) http.Handler {
return newPeerHandler(lg, s.Cluster(), s.RaftHandler(), s.LeaseHandler())
}
|
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/exp/cpp/export/export.go#L526-L531
|
func FileSequence_SetExt(id FileSeqId, ext *C.char) {
if fs, ok := sFileSeqs.Get(id); ok {
str := C.GoString(ext)
fs.SetExt(str)
}
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/raft.go#L49-L78
|
func newRaft(database *db.Node, cert *shared.CertInfo, latency float64) (*raftInstance, error) {
if latency <= 0 {
return nil, fmt.Errorf("latency should be positive")
}
// Figure out if we actually need to act as dqlite node.
var info *db.RaftNode
err := database.Transaction(func(tx *db.NodeTx) error {
var err error
info, err = node.DetermineRaftNode(tx)
return err
})
if err != nil {
return nil, err
}
// If we're not part of the dqlite cluster, there's nothing to do.
if info == nil {
return nil, nil
}
logger.Debug("Start database node", log15.Ctx{"id": info.ID, "address": info.Address})
// Initialize a raft instance along with all needed dependencies.
instance, err := raftInstanceInit(database, info, cert, latency)
if err != nil {
return nil, err
}
return instance, nil
}
|
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/datastore/datastore.go#L197-L220
|
func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) {
if v.Kind() != reflect.Slice {
return multiArgTypeInvalid, nil
}
if v.Type() == typeOfPropertyList {
return multiArgTypeInvalid, nil
}
elemType = v.Type().Elem()
if reflect.PtrTo(elemType).Implements(typeOfPropertyLoadSaver) {
return multiArgTypePropertyLoadSaver, elemType
}
switch elemType.Kind() {
case reflect.Struct:
return multiArgTypeStruct, elemType
case reflect.Interface:
return multiArgTypeInterface, elemType
case reflect.Ptr:
elemType = elemType.Elem()
if elemType.Kind() == reflect.Struct {
return multiArgTypeStructPtr, elemType
}
}
return multiArgTypeInvalid, nil
}
|
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/page.go#L414-L420
|
func (p *Page) WindowCount() (int, error) {
windows, err := p.session.GetWindows()
if err != nil {
return 0, fmt.Errorf("failed to find available windows: %s", err)
}
return len(windows), nil
}
|
https://github.com/marcuswestin/go-errs/blob/b09b17aacd5a8213690bc30f9ccfe7400be7b380/errs.go#L120-L123
|
func IsErr(err error) (Err, bool) {
errsErr, isErr := err.(Err)
return errsErr, isErr
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/easyjson.go#L57-L61
|
func (v empty) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdproto(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L95-L101
|
func (r *relayItems) Get(id uint32) (relayItem, bool) {
r.RLock()
item, ok := r.items[id]
r.RUnlock()
return item, ok
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/fake_open_wrapper.go#L40-L46
|
func (t *EventTimeHeap) Pop() interface{} {
old := *t
n := len(old)
x := old[n-1]
*t = old[0 : n-1]
return x
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/events.go#L28-L47
|
func (e *EventListener) AddHandler(types []string, function func(api.Event)) (*EventTarget, error) {
if function == nil {
return nil, fmt.Errorf("A valid function must be provided")
}
// Handle locking
e.targetsLock.Lock()
defer e.targetsLock.Unlock()
// Create a new target
target := EventTarget{
function: function,
types: types,
}
// And add it to the targets
e.targets = append(e.targets, &target)
return &target, nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/networks.go#L298-L344
|
func (c *Cluster) NetworkGet(name string) (int64, *api.Network, error) {
description := sql.NullString{}
id := int64(-1)
state := 0
q := "SELECT id, description, state FROM networks WHERE name=?"
arg1 := []interface{}{name}
arg2 := []interface{}{&id, &description, &state}
err := dbQueryRowScan(c.db, q, arg1, arg2)
if err != nil {
if err == sql.ErrNoRows {
return -1, nil, ErrNoSuchObject
}
return -1, nil, err
}
config, err := c.NetworkConfigGet(id)
if err != nil {
return -1, nil, err
}
network := api.Network{
Name: name,
Managed: true,
Type: "bridge",
}
network.Description = description.String
network.Config = config
switch state {
case networkPending:
network.Status = "Pending"
case networkCreated:
network.Status = "Created"
default:
network.Status = "Unknown"
}
nodes, err := c.networkNodes(id)
if err != nil {
return -1, nil, err
}
network.Locations = nodes
return id, &network, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/cdproto.go#L646-L2297
|
func UnmarshalMessage(msg *Message) (interface{}, error) {
var v easyjson.Unmarshaler
switch msg.Method {
case CommandAccessibilityDisable:
return emptyVal, nil
case CommandAccessibilityEnable:
return emptyVal, nil
case CommandAccessibilityGetPartialAXTree:
v = new(accessibility.GetPartialAXTreeReturns)
case CommandAccessibilityGetFullAXTree:
v = new(accessibility.GetFullAXTreeReturns)
case CommandAnimationDisable:
return emptyVal, nil
case CommandAnimationEnable:
return emptyVal, nil
case CommandAnimationGetCurrentTime:
v = new(animation.GetCurrentTimeReturns)
case CommandAnimationGetPlaybackRate:
v = new(animation.GetPlaybackRateReturns)
case CommandAnimationReleaseAnimations:
return emptyVal, nil
case CommandAnimationResolveAnimation:
v = new(animation.ResolveAnimationReturns)
case CommandAnimationSeekAnimations:
return emptyVal, nil
case CommandAnimationSetPaused:
return emptyVal, nil
case CommandAnimationSetPlaybackRate:
return emptyVal, nil
case CommandAnimationSetTiming:
return emptyVal, nil
case EventAnimationAnimationCanceled:
v = new(animation.EventAnimationCanceled)
case EventAnimationAnimationCreated:
v = new(animation.EventAnimationCreated)
case EventAnimationAnimationStarted:
v = new(animation.EventAnimationStarted)
case CommandApplicationCacheEnable:
return emptyVal, nil
case CommandApplicationCacheGetApplicationCacheForFrame:
v = new(applicationcache.GetApplicationCacheForFrameReturns)
case CommandApplicationCacheGetFramesWithManifests:
v = new(applicationcache.GetFramesWithManifestsReturns)
case CommandApplicationCacheGetManifestForFrame:
v = new(applicationcache.GetManifestForFrameReturns)
case EventApplicationCacheApplicationCacheStatusUpdated:
v = new(applicationcache.EventApplicationCacheStatusUpdated)
case EventApplicationCacheNetworkStateUpdated:
v = new(applicationcache.EventNetworkStateUpdated)
case CommandAuditsGetEncodedResponse:
v = new(audits.GetEncodedResponseReturns)
case CommandBackgroundServiceStartObserving:
return emptyVal, nil
case CommandBackgroundServiceStopObserving:
return emptyVal, nil
case CommandBackgroundServiceSetRecording:
return emptyVal, nil
case CommandBackgroundServiceClearEvents:
return emptyVal, nil
case EventBackgroundServiceRecordingStateChanged:
v = new(backgroundservice.EventRecordingStateChanged)
case EventBackgroundServiceBackgroundServiceEventReceived:
v = new(backgroundservice.EventBackgroundServiceEventReceived)
case CommandBrowserGrantPermissions:
return emptyVal, nil
case CommandBrowserResetPermissions:
return emptyVal, nil
case CommandBrowserClose:
return emptyVal, nil
case CommandBrowserCrash:
return emptyVal, nil
case CommandBrowserCrashGpuProcess:
return emptyVal, nil
case CommandBrowserGetVersion:
v = new(browser.GetVersionReturns)
case CommandBrowserGetBrowserCommandLine:
v = new(browser.GetBrowserCommandLineReturns)
case CommandBrowserGetHistograms:
v = new(browser.GetHistogramsReturns)
case CommandBrowserGetHistogram:
v = new(browser.GetHistogramReturns)
case CommandBrowserGetWindowBounds:
v = new(browser.GetWindowBoundsReturns)
case CommandBrowserGetWindowForTarget:
v = new(browser.GetWindowForTargetReturns)
case CommandBrowserSetWindowBounds:
return emptyVal, nil
case CommandBrowserSetDockTile:
return emptyVal, nil
case CommandCSSAddRule:
v = new(css.AddRuleReturns)
case CommandCSSCollectClassNames:
v = new(css.CollectClassNamesReturns)
case CommandCSSCreateStyleSheet:
v = new(css.CreateStyleSheetReturns)
case CommandCSSDisable:
return emptyVal, nil
case CommandCSSEnable:
return emptyVal, nil
case CommandCSSForcePseudoState:
return emptyVal, nil
case CommandCSSGetBackgroundColors:
v = new(css.GetBackgroundColorsReturns)
case CommandCSSGetComputedStyleForNode:
v = new(css.GetComputedStyleForNodeReturns)
case CommandCSSGetInlineStylesForNode:
v = new(css.GetInlineStylesForNodeReturns)
case CommandCSSGetMatchedStylesForNode:
v = new(css.GetMatchedStylesForNodeReturns)
case CommandCSSGetMediaQueries:
v = new(css.GetMediaQueriesReturns)
case CommandCSSGetPlatformFontsForNode:
v = new(css.GetPlatformFontsForNodeReturns)
case CommandCSSGetStyleSheetText:
v = new(css.GetStyleSheetTextReturns)
case CommandCSSSetEffectivePropertyValueForNode:
return emptyVal, nil
case CommandCSSSetKeyframeKey:
v = new(css.SetKeyframeKeyReturns)
case CommandCSSSetMediaText:
v = new(css.SetMediaTextReturns)
case CommandCSSSetRuleSelector:
v = new(css.SetRuleSelectorReturns)
case CommandCSSSetStyleSheetText:
v = new(css.SetStyleSheetTextReturns)
case CommandCSSSetStyleTexts:
v = new(css.SetStyleTextsReturns)
case CommandCSSStartRuleUsageTracking:
return emptyVal, nil
case CommandCSSStopRuleUsageTracking:
v = new(css.StopRuleUsageTrackingReturns)
case CommandCSSTakeCoverageDelta:
v = new(css.TakeCoverageDeltaReturns)
case EventCSSFontsUpdated:
v = new(css.EventFontsUpdated)
case EventCSSMediaQueryResultChanged:
v = new(css.EventMediaQueryResultChanged)
case EventCSSStyleSheetAdded:
v = new(css.EventStyleSheetAdded)
case EventCSSStyleSheetChanged:
v = new(css.EventStyleSheetChanged)
case EventCSSStyleSheetRemoved:
v = new(css.EventStyleSheetRemoved)
case CommandCacheStorageDeleteCache:
return emptyVal, nil
case CommandCacheStorageDeleteEntry:
return emptyVal, nil
case CommandCacheStorageRequestCacheNames:
v = new(cachestorage.RequestCacheNamesReturns)
case CommandCacheStorageRequestCachedResponse:
v = new(cachestorage.RequestCachedResponseReturns)
case CommandCacheStorageRequestEntries:
v = new(cachestorage.RequestEntriesReturns)
case CommandCastEnable:
return emptyVal, nil
case CommandCastDisable:
return emptyVal, nil
case CommandCastSetSinkToUse:
return emptyVal, nil
case CommandCastStartTabMirroring:
return emptyVal, nil
case CommandCastStopCasting:
return emptyVal, nil
case EventCastSinksUpdated:
v = new(cast.EventSinksUpdated)
case EventCastIssueUpdated:
v = new(cast.EventIssueUpdated)
case CommandDOMCollectClassNamesFromSubtree:
v = new(dom.CollectClassNamesFromSubtreeReturns)
case CommandDOMCopyTo:
v = new(dom.CopyToReturns)
case CommandDOMDescribeNode:
v = new(dom.DescribeNodeReturns)
case CommandDOMDisable:
return emptyVal, nil
case CommandDOMDiscardSearchResults:
return emptyVal, nil
case CommandDOMEnable:
return emptyVal, nil
case CommandDOMFocus:
return emptyVal, nil
case CommandDOMGetAttributes:
v = new(dom.GetAttributesReturns)
case CommandDOMGetBoxModel:
v = new(dom.GetBoxModelReturns)
case CommandDOMGetContentQuads:
v = new(dom.GetContentQuadsReturns)
case CommandDOMGetDocument:
v = new(dom.GetDocumentReturns)
case CommandDOMGetFlattenedDocument:
v = new(dom.GetFlattenedDocumentReturns)
case CommandDOMGetNodeForLocation:
v = new(dom.GetNodeForLocationReturns)
case CommandDOMGetOuterHTML:
v = new(dom.GetOuterHTMLReturns)
case CommandDOMGetRelayoutBoundary:
v = new(dom.GetRelayoutBoundaryReturns)
case CommandDOMGetSearchResults:
v = new(dom.GetSearchResultsReturns)
case CommandDOMMarkUndoableState:
return emptyVal, nil
case CommandDOMMoveTo:
v = new(dom.MoveToReturns)
case CommandDOMPerformSearch:
v = new(dom.PerformSearchReturns)
case CommandDOMPushNodeByPathToFrontend:
v = new(dom.PushNodeByPathToFrontendReturns)
case CommandDOMPushNodesByBackendIdsToFrontend:
v = new(dom.PushNodesByBackendIdsToFrontendReturns)
case CommandDOMQuerySelector:
v = new(dom.QuerySelectorReturns)
case CommandDOMQuerySelectorAll:
v = new(dom.QuerySelectorAllReturns)
case CommandDOMRedo:
return emptyVal, nil
case CommandDOMRemoveAttribute:
return emptyVal, nil
case CommandDOMRemoveNode:
return emptyVal, nil
case CommandDOMRequestChildNodes:
return emptyVal, nil
case CommandDOMRequestNode:
v = new(dom.RequestNodeReturns)
case CommandDOMResolveNode:
v = new(dom.ResolveNodeReturns)
case CommandDOMSetAttributeValue:
return emptyVal, nil
case CommandDOMSetAttributesAsText:
return emptyVal, nil
case CommandDOMSetFileInputFiles:
return emptyVal, nil
case CommandDOMGetFileInfo:
v = new(dom.GetFileInfoReturns)
case CommandDOMSetInspectedNode:
return emptyVal, nil
case CommandDOMSetNodeName:
v = new(dom.SetNodeNameReturns)
case CommandDOMSetNodeValue:
return emptyVal, nil
case CommandDOMSetOuterHTML:
return emptyVal, nil
case CommandDOMUndo:
return emptyVal, nil
case CommandDOMGetFrameOwner:
v = new(dom.GetFrameOwnerReturns)
case EventDOMAttributeModified:
v = new(dom.EventAttributeModified)
case EventDOMAttributeRemoved:
v = new(dom.EventAttributeRemoved)
case EventDOMCharacterDataModified:
v = new(dom.EventCharacterDataModified)
case EventDOMChildNodeCountUpdated:
v = new(dom.EventChildNodeCountUpdated)
case EventDOMChildNodeInserted:
v = new(dom.EventChildNodeInserted)
case EventDOMChildNodeRemoved:
v = new(dom.EventChildNodeRemoved)
case EventDOMDistributedNodesUpdated:
v = new(dom.EventDistributedNodesUpdated)
case EventDOMDocumentUpdated:
v = new(dom.EventDocumentUpdated)
case EventDOMInlineStyleInvalidated:
v = new(dom.EventInlineStyleInvalidated)
case EventDOMPseudoElementAdded:
v = new(dom.EventPseudoElementAdded)
case EventDOMPseudoElementRemoved:
v = new(dom.EventPseudoElementRemoved)
case EventDOMSetChildNodes:
v = new(dom.EventSetChildNodes)
case EventDOMShadowRootPopped:
v = new(dom.EventShadowRootPopped)
case EventDOMShadowRootPushed:
v = new(dom.EventShadowRootPushed)
case CommandDOMDebuggerGetEventListeners:
v = new(domdebugger.GetEventListenersReturns)
case CommandDOMDebuggerRemoveDOMBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerRemoveEventListenerBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerRemoveInstrumentationBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerRemoveXHRBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerSetDOMBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerSetEventListenerBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerSetInstrumentationBreakpoint:
return emptyVal, nil
case CommandDOMDebuggerSetXHRBreakpoint:
return emptyVal, nil
case CommandDOMSnapshotDisable:
return emptyVal, nil
case CommandDOMSnapshotEnable:
return emptyVal, nil
case CommandDOMSnapshotCaptureSnapshot:
v = new(domsnapshot.CaptureSnapshotReturns)
case CommandDOMStorageClear:
return emptyVal, nil
case CommandDOMStorageDisable:
return emptyVal, nil
case CommandDOMStorageEnable:
return emptyVal, nil
case CommandDOMStorageGetDOMStorageItems:
v = new(domstorage.GetDOMStorageItemsReturns)
case CommandDOMStorageRemoveDOMStorageItem:
return emptyVal, nil
case CommandDOMStorageSetDOMStorageItem:
return emptyVal, nil
case EventDOMStorageDomStorageItemAdded:
v = new(domstorage.EventDomStorageItemAdded)
case EventDOMStorageDomStorageItemRemoved:
v = new(domstorage.EventDomStorageItemRemoved)
case EventDOMStorageDomStorageItemUpdated:
v = new(domstorage.EventDomStorageItemUpdated)
case EventDOMStorageDomStorageItemsCleared:
v = new(domstorage.EventDomStorageItemsCleared)
case CommandDatabaseDisable:
return emptyVal, nil
case CommandDatabaseEnable:
return emptyVal, nil
case CommandDatabaseExecuteSQL:
v = new(database.ExecuteSQLReturns)
case CommandDatabaseGetDatabaseTableNames:
v = new(database.GetDatabaseTableNamesReturns)
case EventDatabaseAddDatabase:
v = new(database.EventAddDatabase)
case CommandDebuggerContinueToLocation:
return emptyVal, nil
case CommandDebuggerDisable:
return emptyVal, nil
case CommandDebuggerEnable:
v = new(debugger.EnableReturns)
case CommandDebuggerEvaluateOnCallFrame:
v = new(debugger.EvaluateOnCallFrameReturns)
case CommandDebuggerGetPossibleBreakpoints:
v = new(debugger.GetPossibleBreakpointsReturns)
case CommandDebuggerGetScriptSource:
v = new(debugger.GetScriptSourceReturns)
case CommandDebuggerGetStackTrace:
v = new(debugger.GetStackTraceReturns)
case CommandDebuggerPause:
return emptyVal, nil
case CommandDebuggerPauseOnAsyncCall:
return emptyVal, nil
case CommandDebuggerRemoveBreakpoint:
return emptyVal, nil
case CommandDebuggerRestartFrame:
v = new(debugger.RestartFrameReturns)
case CommandDebuggerResume:
return emptyVal, nil
case CommandDebuggerSearchInContent:
v = new(debugger.SearchInContentReturns)
case CommandDebuggerSetAsyncCallStackDepth:
return emptyVal, nil
case CommandDebuggerSetBlackboxPatterns:
return emptyVal, nil
case CommandDebuggerSetBlackboxedRanges:
return emptyVal, nil
case CommandDebuggerSetBreakpoint:
v = new(debugger.SetBreakpointReturns)
case CommandDebuggerSetBreakpointByURL:
v = new(debugger.SetBreakpointByURLReturns)
case CommandDebuggerSetBreakpointOnFunctionCall:
v = new(debugger.SetBreakpointOnFunctionCallReturns)
case CommandDebuggerSetBreakpointsActive:
return emptyVal, nil
case CommandDebuggerSetPauseOnExceptions:
return emptyVal, nil
case CommandDebuggerSetReturnValue:
return emptyVal, nil
case CommandDebuggerSetScriptSource:
v = new(debugger.SetScriptSourceReturns)
case CommandDebuggerSetSkipAllPauses:
return emptyVal, nil
case CommandDebuggerSetVariableValue:
return emptyVal, nil
case CommandDebuggerStepInto:
return emptyVal, nil
case CommandDebuggerStepOut:
return emptyVal, nil
case CommandDebuggerStepOver:
return emptyVal, nil
case EventDebuggerBreakpointResolved:
v = new(debugger.EventBreakpointResolved)
case EventDebuggerPaused:
v = new(debugger.EventPaused)
case EventDebuggerResumed:
v = new(debugger.EventResumed)
case EventDebuggerScriptFailedToParse:
v = new(debugger.EventScriptFailedToParse)
case EventDebuggerScriptParsed:
v = new(debugger.EventScriptParsed)
case CommandDeviceOrientationClearDeviceOrientationOverride:
return emptyVal, nil
case CommandDeviceOrientationSetDeviceOrientationOverride:
return emptyVal, nil
case CommandEmulationCanEmulate:
v = new(emulation.CanEmulateReturns)
case CommandEmulationClearDeviceMetricsOverride:
return emptyVal, nil
case CommandEmulationClearGeolocationOverride:
return emptyVal, nil
case CommandEmulationResetPageScaleFactor:
return emptyVal, nil
case CommandEmulationSetFocusEmulationEnabled:
return emptyVal, nil
case CommandEmulationSetCPUThrottlingRate:
return emptyVal, nil
case CommandEmulationSetDefaultBackgroundColorOverride:
return emptyVal, nil
case CommandEmulationSetDeviceMetricsOverride:
return emptyVal, nil
case CommandEmulationSetScrollbarsHidden:
return emptyVal, nil
case CommandEmulationSetDocumentCookieDisabled:
return emptyVal, nil
case CommandEmulationSetEmitTouchEventsForMouse:
return emptyVal, nil
case CommandEmulationSetEmulatedMedia:
return emptyVal, nil
case CommandEmulationSetGeolocationOverride:
return emptyVal, nil
case CommandEmulationSetPageScaleFactor:
return emptyVal, nil
case CommandEmulationSetScriptExecutionDisabled:
return emptyVal, nil
case CommandEmulationSetTouchEmulationEnabled:
return emptyVal, nil
case CommandEmulationSetVirtualTimePolicy:
v = new(emulation.SetVirtualTimePolicyReturns)
case CommandEmulationSetUserAgentOverride:
return emptyVal, nil
case EventEmulationVirtualTimeBudgetExpired:
v = new(emulation.EventVirtualTimeBudgetExpired)
case CommandFetchDisable:
return emptyVal, nil
case CommandFetchEnable:
return emptyVal, nil
case CommandFetchFailRequest:
return emptyVal, nil
case CommandFetchFulfillRequest:
return emptyVal, nil
case CommandFetchContinueRequest:
return emptyVal, nil
case CommandFetchContinueWithAuth:
return emptyVal, nil
case CommandFetchGetResponseBody:
v = new(fetch.GetResponseBodyReturns)
case CommandFetchTakeResponseBodyAsStream:
v = new(fetch.TakeResponseBodyAsStreamReturns)
case EventFetchRequestPaused:
v = new(fetch.EventRequestPaused)
case EventFetchAuthRequired:
v = new(fetch.EventAuthRequired)
case CommandHeadlessExperimentalBeginFrame:
v = new(headlessexperimental.BeginFrameReturns)
case CommandHeadlessExperimentalDisable:
return emptyVal, nil
case CommandHeadlessExperimentalEnable:
return emptyVal, nil
case EventHeadlessExperimentalNeedsBeginFramesChanged:
v = new(headlessexperimental.EventNeedsBeginFramesChanged)
case CommandHeapProfilerAddInspectedHeapObject:
return emptyVal, nil
case CommandHeapProfilerCollectGarbage:
return emptyVal, nil
case CommandHeapProfilerDisable:
return emptyVal, nil
case CommandHeapProfilerEnable:
return emptyVal, nil
case CommandHeapProfilerGetHeapObjectID:
v = new(heapprofiler.GetHeapObjectIDReturns)
case CommandHeapProfilerGetObjectByHeapObjectID:
v = new(heapprofiler.GetObjectByHeapObjectIDReturns)
case CommandHeapProfilerGetSamplingProfile:
v = new(heapprofiler.GetSamplingProfileReturns)
case CommandHeapProfilerStartSampling:
return emptyVal, nil
case CommandHeapProfilerStartTrackingHeapObjects:
return emptyVal, nil
case CommandHeapProfilerStopSampling:
v = new(heapprofiler.StopSamplingReturns)
case CommandHeapProfilerStopTrackingHeapObjects:
return emptyVal, nil
case CommandHeapProfilerTakeHeapSnapshot:
return emptyVal, nil
case EventHeapProfilerAddHeapSnapshotChunk:
v = new(heapprofiler.EventAddHeapSnapshotChunk)
case EventHeapProfilerHeapStatsUpdate:
v = new(heapprofiler.EventHeapStatsUpdate)
case EventHeapProfilerLastSeenObjectID:
v = new(heapprofiler.EventLastSeenObjectID)
case EventHeapProfilerReportHeapSnapshotProgress:
v = new(heapprofiler.EventReportHeapSnapshotProgress)
case EventHeapProfilerResetProfiles:
v = new(heapprofiler.EventResetProfiles)
case CommandIOClose:
return emptyVal, nil
case CommandIORead:
v = new(io.ReadReturns)
case CommandIOResolveBlob:
v = new(io.ResolveBlobReturns)
case CommandIndexedDBClearObjectStore:
return emptyVal, nil
case CommandIndexedDBDeleteDatabase:
return emptyVal, nil
case CommandIndexedDBDeleteObjectStoreEntries:
return emptyVal, nil
case CommandIndexedDBDisable:
return emptyVal, nil
case CommandIndexedDBEnable:
return emptyVal, nil
case CommandIndexedDBRequestData:
v = new(indexeddb.RequestDataReturns)
case CommandIndexedDBGetMetadata:
v = new(indexeddb.GetMetadataReturns)
case CommandIndexedDBRequestDatabase:
v = new(indexeddb.RequestDatabaseReturns)
case CommandIndexedDBRequestDatabaseNames:
v = new(indexeddb.RequestDatabaseNamesReturns)
case CommandInputDispatchKeyEvent:
return emptyVal, nil
case CommandInputInsertText:
return emptyVal, nil
case CommandInputDispatchMouseEvent:
return emptyVal, nil
case CommandInputDispatchTouchEvent:
return emptyVal, nil
case CommandInputEmulateTouchFromMouseEvent:
return emptyVal, nil
case CommandInputSetIgnoreInputEvents:
return emptyVal, nil
case CommandInputSynthesizePinchGesture:
return emptyVal, nil
case CommandInputSynthesizeScrollGesture:
return emptyVal, nil
case CommandInputSynthesizeTapGesture:
return emptyVal, nil
case CommandInspectorDisable:
return emptyVal, nil
case CommandInspectorEnable:
return emptyVal, nil
case EventInspectorDetached:
v = new(inspector.EventDetached)
case EventInspectorTargetCrashed:
v = new(inspector.EventTargetCrashed)
case EventInspectorTargetReloadedAfterCrash:
v = new(inspector.EventTargetReloadedAfterCrash)
case CommandLayerTreeCompositingReasons:
v = new(layertree.CompositingReasonsReturns)
case CommandLayerTreeDisable:
return emptyVal, nil
case CommandLayerTreeEnable:
return emptyVal, nil
case CommandLayerTreeLoadSnapshot:
v = new(layertree.LoadSnapshotReturns)
case CommandLayerTreeMakeSnapshot:
v = new(layertree.MakeSnapshotReturns)
case CommandLayerTreeProfileSnapshot:
v = new(layertree.ProfileSnapshotReturns)
case CommandLayerTreeReleaseSnapshot:
return emptyVal, nil
case CommandLayerTreeReplaySnapshot:
v = new(layertree.ReplaySnapshotReturns)
case CommandLayerTreeSnapshotCommandLog:
v = new(layertree.SnapshotCommandLogReturns)
case EventLayerTreeLayerPainted:
v = new(layertree.EventLayerPainted)
case EventLayerTreeLayerTreeDidChange:
v = new(layertree.EventLayerTreeDidChange)
case CommandLogClear:
return emptyVal, nil
case CommandLogDisable:
return emptyVal, nil
case CommandLogEnable:
return emptyVal, nil
case CommandLogStartViolationsReport:
return emptyVal, nil
case CommandLogStopViolationsReport:
return emptyVal, nil
case EventLogEntryAdded:
v = new(log.EventEntryAdded)
case CommandMemoryGetDOMCounters:
v = new(memory.GetDOMCountersReturns)
case CommandMemoryPrepareForLeakDetection:
return emptyVal, nil
case CommandMemoryForciblyPurgeJavaScriptMemory:
return emptyVal, nil
case CommandMemorySetPressureNotificationsSuppressed:
return emptyVal, nil
case CommandMemorySimulatePressureNotification:
return emptyVal, nil
case CommandMemoryStartSampling:
return emptyVal, nil
case CommandMemoryStopSampling:
return emptyVal, nil
case CommandMemoryGetAllTimeSamplingProfile:
v = new(memory.GetAllTimeSamplingProfileReturns)
case CommandMemoryGetBrowserSamplingProfile:
v = new(memory.GetBrowserSamplingProfileReturns)
case CommandMemoryGetSamplingProfile:
v = new(memory.GetSamplingProfileReturns)
case CommandNetworkClearBrowserCache:
return emptyVal, nil
case CommandNetworkClearBrowserCookies:
return emptyVal, nil
case CommandNetworkContinueInterceptedRequest:
return emptyVal, nil
case CommandNetworkDeleteCookies:
return emptyVal, nil
case CommandNetworkDisable:
return emptyVal, nil
case CommandNetworkEmulateNetworkConditions:
return emptyVal, nil
case CommandNetworkEnable:
return emptyVal, nil
case CommandNetworkGetAllCookies:
v = new(network.GetAllCookiesReturns)
case CommandNetworkGetCertificate:
v = new(network.GetCertificateReturns)
case CommandNetworkGetCookies:
v = new(network.GetCookiesReturns)
case CommandNetworkGetResponseBody:
v = new(network.GetResponseBodyReturns)
case CommandNetworkGetRequestPostData:
v = new(network.GetRequestPostDataReturns)
case CommandNetworkGetResponseBodyForInterception:
v = new(network.GetResponseBodyForInterceptionReturns)
case CommandNetworkTakeResponseBodyForInterceptionAsStream:
v = new(network.TakeResponseBodyForInterceptionAsStreamReturns)
case CommandNetworkReplayXHR:
return emptyVal, nil
case CommandNetworkSearchInResponseBody:
v = new(network.SearchInResponseBodyReturns)
case CommandNetworkSetBlockedURLS:
return emptyVal, nil
case CommandNetworkSetBypassServiceWorker:
return emptyVal, nil
case CommandNetworkSetCacheDisabled:
return emptyVal, nil
case CommandNetworkSetCookie:
v = new(network.SetCookieReturns)
case CommandNetworkSetCookies:
return emptyVal, nil
case CommandNetworkSetDataSizeLimitsForTest:
return emptyVal, nil
case CommandNetworkSetExtraHTTPHeaders:
return emptyVal, nil
case CommandNetworkSetRequestInterception:
return emptyVal, nil
case EventNetworkDataReceived:
v = new(network.EventDataReceived)
case EventNetworkEventSourceMessageReceived:
v = new(network.EventEventSourceMessageReceived)
case EventNetworkLoadingFailed:
v = new(network.EventLoadingFailed)
case EventNetworkLoadingFinished:
v = new(network.EventLoadingFinished)
case EventNetworkRequestIntercepted:
v = new(network.EventRequestIntercepted)
case EventNetworkRequestServedFromCache:
v = new(network.EventRequestServedFromCache)
case EventNetworkRequestWillBeSent:
v = new(network.EventRequestWillBeSent)
case EventNetworkResourceChangedPriority:
v = new(network.EventResourceChangedPriority)
case EventNetworkSignedExchangeReceived:
v = new(network.EventSignedExchangeReceived)
case EventNetworkResponseReceived:
v = new(network.EventResponseReceived)
case EventNetworkWebSocketClosed:
v = new(network.EventWebSocketClosed)
case EventNetworkWebSocketCreated:
v = new(network.EventWebSocketCreated)
case EventNetworkWebSocketFrameError:
v = new(network.EventWebSocketFrameError)
case EventNetworkWebSocketFrameReceived:
v = new(network.EventWebSocketFrameReceived)
case EventNetworkWebSocketFrameSent:
v = new(network.EventWebSocketFrameSent)
case EventNetworkWebSocketHandshakeResponseReceived:
v = new(network.EventWebSocketHandshakeResponseReceived)
case EventNetworkWebSocketWillSendHandshakeRequest:
v = new(network.EventWebSocketWillSendHandshakeRequest)
case CommandOverlayDisable:
return emptyVal, nil
case CommandOverlayEnable:
return emptyVal, nil
case CommandOverlayGetHighlightObjectForTest:
v = new(overlay.GetHighlightObjectForTestReturns)
case CommandOverlayHideHighlight:
return emptyVal, nil
case CommandOverlayHighlightFrame:
return emptyVal, nil
case CommandOverlayHighlightNode:
return emptyVal, nil
case CommandOverlayHighlightQuad:
return emptyVal, nil
case CommandOverlayHighlightRect:
return emptyVal, nil
case CommandOverlaySetInspectMode:
return emptyVal, nil
case CommandOverlaySetShowAdHighlights:
return emptyVal, nil
case CommandOverlaySetPausedInDebuggerMessage:
return emptyVal, nil
case CommandOverlaySetShowDebugBorders:
return emptyVal, nil
case CommandOverlaySetShowFPSCounter:
return emptyVal, nil
case CommandOverlaySetShowPaintRects:
return emptyVal, nil
case CommandOverlaySetShowScrollBottleneckRects:
return emptyVal, nil
case CommandOverlaySetShowHitTestBorders:
return emptyVal, nil
case CommandOverlaySetShowViewportSizeOnResize:
return emptyVal, nil
case EventOverlayInspectNodeRequested:
v = new(overlay.EventInspectNodeRequested)
case EventOverlayNodeHighlightRequested:
v = new(overlay.EventNodeHighlightRequested)
case EventOverlayScreenshotRequested:
v = new(overlay.EventScreenshotRequested)
case EventOverlayInspectModeCanceled:
v = new(overlay.EventInspectModeCanceled)
case CommandPageAddScriptToEvaluateOnNewDocument:
v = new(page.AddScriptToEvaluateOnNewDocumentReturns)
case CommandPageBringToFront:
return emptyVal, nil
case CommandPageCaptureScreenshot:
v = new(page.CaptureScreenshotReturns)
case CommandPageCaptureSnapshot:
v = new(page.CaptureSnapshotReturns)
case CommandPageCreateIsolatedWorld:
v = new(page.CreateIsolatedWorldReturns)
case CommandPageDisable:
return emptyVal, nil
case CommandPageEnable:
return emptyVal, nil
case CommandPageGetAppManifest:
v = new(page.GetAppManifestReturns)
case CommandPageGetInstallabilityErrors:
v = new(page.GetInstallabilityErrorsReturns)
case CommandPageGetFrameTree:
v = new(page.GetFrameTreeReturns)
case CommandPageGetLayoutMetrics:
v = new(page.GetLayoutMetricsReturns)
case CommandPageGetNavigationHistory:
v = new(page.GetNavigationHistoryReturns)
case CommandPageResetNavigationHistory:
return emptyVal, nil
case CommandPageGetResourceContent:
v = new(page.GetResourceContentReturns)
case CommandPageGetResourceTree:
v = new(page.GetResourceTreeReturns)
case CommandPageHandleJavaScriptDialog:
return emptyVal, nil
case CommandPageNavigate:
v = new(page.NavigateReturns)
case CommandPageNavigateToHistoryEntry:
return emptyVal, nil
case CommandPagePrintToPDF:
v = new(page.PrintToPDFReturns)
case CommandPageReload:
return emptyVal, nil
case CommandPageRemoveScriptToEvaluateOnNewDocument:
return emptyVal, nil
case CommandPageScreencastFrameAck:
return emptyVal, nil
case CommandPageSearchInResource:
v = new(page.SearchInResourceReturns)
case CommandPageSetAdBlockingEnabled:
return emptyVal, nil
case CommandPageSetBypassCSP:
return emptyVal, nil
case CommandPageSetFontFamilies:
return emptyVal, nil
case CommandPageSetFontSizes:
return emptyVal, nil
case CommandPageSetDocumentContent:
return emptyVal, nil
case CommandPageSetDownloadBehavior:
return emptyVal, nil
case CommandPageSetLifecycleEventsEnabled:
return emptyVal, nil
case CommandPageStartScreencast:
return emptyVal, nil
case CommandPageStopLoading:
return emptyVal, nil
case CommandPageCrash:
return emptyVal, nil
case CommandPageClose:
return emptyVal, nil
case CommandPageSetWebLifecycleState:
return emptyVal, nil
case CommandPageStopScreencast:
return emptyVal, nil
case CommandPageSetProduceCompilationCache:
return emptyVal, nil
case CommandPageAddCompilationCache:
return emptyVal, nil
case CommandPageClearCompilationCache:
return emptyVal, nil
case CommandPageGenerateTestReport:
return emptyVal, nil
case CommandPageWaitForDebugger:
return emptyVal, nil
case EventPageDomContentEventFired:
v = new(page.EventDomContentEventFired)
case EventPageFrameAttached:
v = new(page.EventFrameAttached)
case EventPageFrameDetached:
v = new(page.EventFrameDetached)
case EventPageFrameNavigated:
v = new(page.EventFrameNavigated)
case EventPageFrameResized:
v = new(page.EventFrameResized)
case EventPageFrameRequestedNavigation:
v = new(page.EventFrameRequestedNavigation)
case EventPageFrameStartedLoading:
v = new(page.EventFrameStartedLoading)
case EventPageFrameStoppedLoading:
v = new(page.EventFrameStoppedLoading)
case EventPageDownloadWillBegin:
v = new(page.EventDownloadWillBegin)
case EventPageInterstitialHidden:
v = new(page.EventInterstitialHidden)
case EventPageInterstitialShown:
v = new(page.EventInterstitialShown)
case EventPageJavascriptDialogClosed:
v = new(page.EventJavascriptDialogClosed)
case EventPageJavascriptDialogOpening:
v = new(page.EventJavascriptDialogOpening)
case EventPageLifecycleEvent:
v = new(page.EventLifecycleEvent)
case EventPageLoadEventFired:
v = new(page.EventLoadEventFired)
case EventPageNavigatedWithinDocument:
v = new(page.EventNavigatedWithinDocument)
case EventPageScreencastFrame:
v = new(page.EventScreencastFrame)
case EventPageScreencastVisibilityChanged:
v = new(page.EventScreencastVisibilityChanged)
case EventPageWindowOpen:
v = new(page.EventWindowOpen)
case EventPageCompilationCacheProduced:
v = new(page.EventCompilationCacheProduced)
case CommandPerformanceDisable:
return emptyVal, nil
case CommandPerformanceEnable:
return emptyVal, nil
case CommandPerformanceSetTimeDomain:
return emptyVal, nil
case CommandPerformanceGetMetrics:
v = new(performance.GetMetricsReturns)
case EventPerformanceMetrics:
v = new(performance.EventMetrics)
case CommandProfilerDisable:
return emptyVal, nil
case CommandProfilerEnable:
return emptyVal, nil
case CommandProfilerGetBestEffortCoverage:
v = new(profiler.GetBestEffortCoverageReturns)
case CommandProfilerSetSamplingInterval:
return emptyVal, nil
case CommandProfilerStart:
return emptyVal, nil
case CommandProfilerStartPreciseCoverage:
return emptyVal, nil
case CommandProfilerStartTypeProfile:
return emptyVal, nil
case CommandProfilerStop:
v = new(profiler.StopReturns)
case CommandProfilerStopPreciseCoverage:
return emptyVal, nil
case CommandProfilerStopTypeProfile:
return emptyVal, nil
case CommandProfilerTakePreciseCoverage:
v = new(profiler.TakePreciseCoverageReturns)
case CommandProfilerTakeTypeProfile:
v = new(profiler.TakeTypeProfileReturns)
case EventProfilerConsoleProfileFinished:
v = new(profiler.EventConsoleProfileFinished)
case EventProfilerConsoleProfileStarted:
v = new(profiler.EventConsoleProfileStarted)
case CommandRuntimeAwaitPromise:
v = new(runtime.AwaitPromiseReturns)
case CommandRuntimeCallFunctionOn:
v = new(runtime.CallFunctionOnReturns)
case CommandRuntimeCompileScript:
v = new(runtime.CompileScriptReturns)
case CommandRuntimeDisable:
return emptyVal, nil
case CommandRuntimeDiscardConsoleEntries:
return emptyVal, nil
case CommandRuntimeEnable:
return emptyVal, nil
case CommandRuntimeEvaluate:
v = new(runtime.EvaluateReturns)
case CommandRuntimeGetIsolateID:
v = new(runtime.GetIsolateIDReturns)
case CommandRuntimeGetHeapUsage:
v = new(runtime.GetHeapUsageReturns)
case CommandRuntimeGetProperties:
v = new(runtime.GetPropertiesReturns)
case CommandRuntimeGlobalLexicalScopeNames:
v = new(runtime.GlobalLexicalScopeNamesReturns)
case CommandRuntimeQueryObjects:
v = new(runtime.QueryObjectsReturns)
case CommandRuntimeReleaseObject:
return emptyVal, nil
case CommandRuntimeReleaseObjectGroup:
return emptyVal, nil
case CommandRuntimeRunIfWaitingForDebugger:
return emptyVal, nil
case CommandRuntimeRunScript:
v = new(runtime.RunScriptReturns)
case CommandRuntimeSetCustomObjectFormatterEnabled:
return emptyVal, nil
case CommandRuntimeSetMaxCallStackSizeToCapture:
return emptyVal, nil
case CommandRuntimeTerminateExecution:
return emptyVal, nil
case CommandRuntimeAddBinding:
return emptyVal, nil
case CommandRuntimeRemoveBinding:
return emptyVal, nil
case EventRuntimeBindingCalled:
v = new(runtime.EventBindingCalled)
case EventRuntimeConsoleAPICalled:
v = new(runtime.EventConsoleAPICalled)
case EventRuntimeExceptionRevoked:
v = new(runtime.EventExceptionRevoked)
case EventRuntimeExceptionThrown:
v = new(runtime.EventExceptionThrown)
case EventRuntimeExecutionContextCreated:
v = new(runtime.EventExecutionContextCreated)
case EventRuntimeExecutionContextDestroyed:
v = new(runtime.EventExecutionContextDestroyed)
case EventRuntimeExecutionContextsCleared:
v = new(runtime.EventExecutionContextsCleared)
case EventRuntimeInspectRequested:
v = new(runtime.EventInspectRequested)
case CommandSecurityDisable:
return emptyVal, nil
case CommandSecurityEnable:
return emptyVal, nil
case CommandSecuritySetIgnoreCertificateErrors:
return emptyVal, nil
case EventSecuritySecurityStateChanged:
v = new(security.EventSecurityStateChanged)
case CommandServiceWorkerDeliverPushMessage:
return emptyVal, nil
case CommandServiceWorkerDisable:
return emptyVal, nil
case CommandServiceWorkerDispatchSyncEvent:
return emptyVal, nil
case CommandServiceWorkerEnable:
return emptyVal, nil
case CommandServiceWorkerInspectWorker:
return emptyVal, nil
case CommandServiceWorkerSetForceUpdateOnPageLoad:
return emptyVal, nil
case CommandServiceWorkerSkipWaiting:
return emptyVal, nil
case CommandServiceWorkerStartWorker:
return emptyVal, nil
case CommandServiceWorkerStopAllWorkers:
return emptyVal, nil
case CommandServiceWorkerStopWorker:
return emptyVal, nil
case CommandServiceWorkerUnregister:
return emptyVal, nil
case CommandServiceWorkerUpdateRegistration:
return emptyVal, nil
case EventServiceWorkerWorkerErrorReported:
v = new(serviceworker.EventWorkerErrorReported)
case EventServiceWorkerWorkerRegistrationUpdated:
v = new(serviceworker.EventWorkerRegistrationUpdated)
case EventServiceWorkerWorkerVersionUpdated:
v = new(serviceworker.EventWorkerVersionUpdated)
case CommandStorageClearDataForOrigin:
return emptyVal, nil
case CommandStorageGetUsageAndQuota:
v = new(storage.GetUsageAndQuotaReturns)
case CommandStorageTrackCacheStorageForOrigin:
return emptyVal, nil
case CommandStorageTrackIndexedDBForOrigin:
return emptyVal, nil
case CommandStorageUntrackCacheStorageForOrigin:
return emptyVal, nil
case CommandStorageUntrackIndexedDBForOrigin:
return emptyVal, nil
case EventStorageCacheStorageContentUpdated:
v = new(storage.EventCacheStorageContentUpdated)
case EventStorageCacheStorageListUpdated:
v = new(storage.EventCacheStorageListUpdated)
case EventStorageIndexedDBContentUpdated:
v = new(storage.EventIndexedDBContentUpdated)
case EventStorageIndexedDBListUpdated:
v = new(storage.EventIndexedDBListUpdated)
case CommandSystemInfoGetInfo:
v = new(systeminfo.GetInfoReturns)
case CommandSystemInfoGetProcessInfo:
v = new(systeminfo.GetProcessInfoReturns)
case CommandTargetActivateTarget:
return emptyVal, nil
case CommandTargetAttachToTarget:
v = new(target.AttachToTargetReturns)
case CommandTargetAttachToBrowserTarget:
v = new(target.AttachToBrowserTargetReturns)
case CommandTargetCloseTarget:
v = new(target.CloseTargetReturns)
case CommandTargetExposeDevToolsProtocol:
return emptyVal, nil
case CommandTargetCreateBrowserContext:
v = new(target.CreateBrowserContextReturns)
case CommandTargetGetBrowserContexts:
v = new(target.GetBrowserContextsReturns)
case CommandTargetCreateTarget:
v = new(target.CreateTargetReturns)
case CommandTargetDetachFromTarget:
return emptyVal, nil
case CommandTargetDisposeBrowserContext:
return emptyVal, nil
case CommandTargetGetTargetInfo:
v = new(target.GetTargetInfoReturns)
case CommandTargetGetTargets:
v = new(target.GetTargetsReturns)
case CommandTargetSendMessageToTarget:
return emptyVal, nil
case CommandTargetSetAutoAttach:
return emptyVal, nil
case CommandTargetSetDiscoverTargets:
return emptyVal, nil
case CommandTargetSetRemoteLocations:
return emptyVal, nil
case EventTargetAttachedToTarget:
v = new(target.EventAttachedToTarget)
case EventTargetDetachedFromTarget:
v = new(target.EventDetachedFromTarget)
case EventTargetReceivedMessageFromTarget:
v = new(target.EventReceivedMessageFromTarget)
case EventTargetTargetCreated:
v = new(target.EventTargetCreated)
case EventTargetTargetDestroyed:
v = new(target.EventTargetDestroyed)
case EventTargetTargetCrashed:
v = new(target.EventTargetCrashed)
case EventTargetTargetInfoChanged:
v = new(target.EventTargetInfoChanged)
case CommandTetheringBind:
return emptyVal, nil
case CommandTetheringUnbind:
return emptyVal, nil
case EventTetheringAccepted:
v = new(tethering.EventAccepted)
case CommandTracingEnd:
return emptyVal, nil
case CommandTracingGetCategories:
v = new(tracing.GetCategoriesReturns)
case CommandTracingRecordClockSyncMarker:
return emptyVal, nil
case CommandTracingRequestMemoryDump:
v = new(tracing.RequestMemoryDumpReturns)
case CommandTracingStart:
return emptyVal, nil
case EventTracingBufferUsage:
v = new(tracing.EventBufferUsage)
case EventTracingDataCollected:
v = new(tracing.EventDataCollected)
case EventTracingTracingComplete:
v = new(tracing.EventTracingComplete)
case CommandWebAudioEnable:
return emptyVal, nil
case CommandWebAudioDisable:
return emptyVal, nil
case CommandWebAudioGetRealtimeData:
v = new(webaudio.GetRealtimeDataReturns)
case EventWebAudioContextCreated:
v = new(webaudio.EventContextCreated)
case EventWebAudioContextDestroyed:
v = new(webaudio.EventContextDestroyed)
case EventWebAudioContextChanged:
v = new(webaudio.EventContextChanged)
default:
return nil, cdp.ErrUnknownCommandOrEvent(msg.Method)
}
var buf easyjson.RawMessage
switch {
case msg.Params != nil:
buf = msg.Params
case msg.Result != nil:
buf = msg.Result
default:
return nil, cdp.ErrMsgMissingParamsOrResult
}
err := easyjson.Unmarshal(buf, v)
if err != nil {
return nil, err
}
return v, nil
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/db.go#L456-L477
|
func (db *DB) getMemTables() ([]*skl.Skiplist, func()) {
db.RLock()
defer db.RUnlock()
tables := make([]*skl.Skiplist, len(db.imm)+1)
// Get mutable memtable.
tables[0] = db.mt
tables[0].IncrRef()
// Get immutable memtables.
last := len(db.imm) - 1
for i := range db.imm {
tables[i+1] = db.imm[last-i]
tables[i+1].IncrRef()
}
return tables, func() {
for _, tbl := range tables {
tbl.DecrRef()
}
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/browser.go#L422-L424
|
func (p *SetDockTileParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDockTile, p, nil)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/assets/assets.go#L1539-L1544
|
func WriteGoogleAssets(encoder Encoder, opts *AssetOpts, bucket string, cred string, volumeSize int) error {
if err := WriteAssets(encoder, opts, googleBackend, googleBackend, volumeSize, ""); err != nil {
return err
}
return WriteSecret(encoder, GoogleSecret(bucket, cred), opts)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/cov/merge.go#L34-L68
|
func MergeProfiles(a []*cover.Profile, b []*cover.Profile) ([]*cover.Profile, error) {
var result []*cover.Profile
files := make(map[string]*cover.Profile, len(a))
for _, profile := range a {
np := deepCopyProfile(*profile)
result = append(result, &np)
files[np.FileName] = &np
}
needsSort := false
// Now merge b into the result
for _, profile := range b {
dest, ok := files[profile.FileName]
if ok {
if err := ensureProfilesMatch(profile, dest); err != nil {
return nil, fmt.Errorf("error merging %s: %v", profile.FileName, err)
}
for i, block := range profile.Blocks {
db := &dest.Blocks[i]
db.Count += block.Count
}
} else {
// If we get some file we haven't seen before, we just append it.
// We need to sort this later to ensure the resulting profile is still correctly sorted.
np := deepCopyProfile(*profile)
files[np.FileName] = &np
result = append(result, &np)
needsSort = true
}
}
if needsSort {
sort.Slice(result, func(i, j int) bool { return result[i].FileName < result[j].FileName })
}
return result, nil
}
|
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L949-L951
|
func Println(val ...interface{}) error {
return glg.out(PRINT, blankFormat(len(val)), val...)
}
|
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/account.go#L35-L37
|
func (dom *Domain) Account(name string) *Account {
return &Account{Domain: dom, Name: name}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/memory/easyjson.go#L1373-L1377
|
func (v ForciblyPurgeJavaScriptMemoryParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoMemory16(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/logexporter/cmd/main.go#L157-L194
|
func prepareLogfiles(logDir string) {
glog.Info("Preparing logfiles relevant to this node")
logfiles := nodeLogs[:]
switch *cloudProvider {
case "gce", "gke":
logfiles = append(logfiles, gceLogs...)
case "aws":
logfiles = append(logfiles, awsLogs...)
default:
glog.Errorf("Unknown cloud provider '%v' provided, skipping any provider specific logs", *cloudProvider)
}
// Grab kubemark logs too, if asked for.
if *enableHollowNodeLogs {
logfiles = append(logfiles, kubemarkLogs...)
}
// Select system/service specific logs.
if _, err := os.Stat("/workspace/etc/systemd/journald.conf"); err == nil {
glog.Info("Journalctl found on host. Collecting systemd logs")
createSystemdLogfiles(logDir)
} else {
glog.Infof("Journalctl not found on host (%v). Collecting supervisord logs instead", err)
logfiles = append(logfiles, kernelLog)
logfiles = append(logfiles, initdLogs...)
logfiles = append(logfiles, supervisordLogs...)
}
// Copy all the logfiles that exist, to logDir.
for _, logfile := range logfiles {
logfileFullPath := filepath.Join(localLogPath, logfile+".log*") // Append .log* to copy rotated logs too.
cmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("cp %v %v", logfileFullPath, logDir))
if err := cmd.Run(); err != nil {
glog.Warningf("Failed to copy any logfiles with pattern '%v': %v", logfileFullPath, err)
}
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L33-L35
|
func (p *ClearBrowserCacheParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClearBrowserCache, nil, nil)
}
|
https://github.com/tendermint/go-amino/blob/dc14acf9ef15f85828bfbc561ed9dd9d2a284885/decoder.go#L200-L225
|
func DecodeTime(bz []byte) (t time.Time, n int, err error) {
// Defensively set default to to zeroTime (1970, not 0001)
t = zeroTime
// Read sec and nanosec.
var sec int64
var nsec int32
if len(bz) > 0 {
sec, n, err = decodeSeconds(&bz)
if err != nil {
return
}
}
if len(bz) > 0 {
nsec, err = decodeNanos(&bz, &n)
if err != nil {
return
}
}
// Construct time.
t = time.Unix(sec, int64(nsec))
// Strip timezone and monotonic for deep equality.
t = t.UTC().Truncate(0)
return
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/config.go#L6-L8
|
func (n *NodeTx) Config() (map[string]string, error) {
return query.SelectConfig(n.tx, "config", "")
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/client.go#L94-L126
|
func NewClient(ch *tchannel.Channel, config Configuration, opts *ClientOptions) (*Client, error) {
client := &Client{tchan: ch, quit: make(chan struct{})}
if opts != nil {
client.opts = *opts
}
if client.opts.Timeout == 0 {
client.opts.Timeout = 3 * time.Second
}
if client.opts.TimeoutPerAttempt == 0 {
client.opts.TimeoutPerAttempt = time.Second
}
if client.opts.Handler == nil {
client.opts.Handler = nullHandler{}
}
if client.opts.TimeSleep == nil {
client.opts.TimeSleep = time.Sleep
}
if err := parseConfig(&config); err != nil {
return nil, err
}
// Add the given initial nodes as peers.
for _, node := range config.InitialNodes {
addPeer(ch, node)
}
client.jsonClient = tjson.NewClient(ch, hyperbahnServiceName, nil)
thriftClient := tthrift.NewClient(ch, hyperbahnServiceName, nil)
client.hyperbahnClient = htypes.NewTChanHyperbahnClient(thriftClient)
return client, nil
}
|
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/highgui.go#L390-L403
|
func SaveImage(filename string, image *IplImage, params []int) int {
name_c := C.CString(filename)
defer C.free(unsafe.Pointer(name_c))
var firstParam *C.int
if len(params) > 0 {
var params_c []C.int
for _, param := range params {
params_c = append(params_c, C.int(param))
}
firstParam = ¶ms_c[0]
}
rv := C.cvSaveImage(name_c, unsafe.Pointer(image), firstParam)
return int(rv)
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/leasehttp/http.go#L146-L190
|
func RenewHTTP(ctx context.Context, id lease.LeaseID, url string, rt http.RoundTripper) (int64, error) {
// will post lreq protobuf to leader
lreq, err := (&pb.LeaseKeepAliveRequest{ID: int64(id)}).Marshal()
if err != nil {
return -1, err
}
cc := &http.Client{Transport: rt}
req, err := http.NewRequest("POST", url, bytes.NewReader(lreq))
if err != nil {
return -1, err
}
req.Header.Set("Content-Type", "application/protobuf")
req.Cancel = ctx.Done()
resp, err := cc.Do(req)
if err != nil {
return -1, err
}
b, err := readResponse(resp)
if err != nil {
return -1, err
}
if resp.StatusCode == http.StatusRequestTimeout {
return -1, ErrLeaseHTTPTimeout
}
if resp.StatusCode == http.StatusNotFound {
return -1, lease.ErrLeaseNotFound
}
if resp.StatusCode != http.StatusOK {
return -1, fmt.Errorf("lease: unknown error(%s)", string(b))
}
lresp := &pb.LeaseKeepAliveResponse{}
if err := lresp.Unmarshal(b); err != nil {
return -1, fmt.Errorf(`lease: %v. data = "%s"`, err, string(b))
}
if lresp.ID != int64(id) {
return -1, fmt.Errorf("lease: renew id mismatch")
}
return lresp.TTL, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/input/types.go#L57-L69
|
func (t *GestureType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch GestureType(in.String()) {
case GestureDefault:
*t = GestureDefault
case GestureTouch:
*t = GestureTouch
case GestureMouse:
*t = GestureMouse
default:
in.AddError(errors.New("unknown GestureType value"))
}
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L200-L203
|
func escapeBackticks(d string) string {
elems := strings.Split(d, "`")
return strings.Join(elems, "` + `")
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/namespace/watch.go#L36-L38
|
func NewWatcher(w clientv3.Watcher, prefix string) clientv3.Watcher {
return &watcherPrefix{Watcher: w, pfx: prefix, stopc: make(chan struct{})}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/emulation.go#L37-L46
|
func (p *CanEmulateParams) Do(ctx context.Context) (result bool, err error) {
// execute
var res CanEmulateReturns
err = cdp.Execute(ctx, CommandCanEmulate, nil, &res)
if err != nil {
return false, err
}
return res.Result, nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_containers.go#L1560-L1562
|
func (r *ProtocolLXD) CreateContainerTemplateFile(containerName string, templateName string, content io.ReadSeeker) error {
return r.setContainerTemplateFile(containerName, templateName, content, "POST")
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/performance/easyjson.go#L81-L85
|
func (v *SetTimeDomainParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPerformance(&r, v)
return r.Error()
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L13033-L13040
|
func (r *Session) Locator(api *API) *SessionLocator {
for _, l := range r.Links {
if l["rel"] == "self" {
return api.SessionLocator(l["href"])
}
}
return nil
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/transports/transports.go#L76-L90
|
func ListNames() []string {
kt.mu.Lock()
defer kt.mu.Unlock()
deprecated := map[string]bool{
"atomic": true,
}
var names []string
for _, transport := range kt.transports {
if !deprecated[transport.Name()] {
names = append(names, transport.Name())
}
}
sort.Strings(names)
return names
}
|
https://github.com/bluekeyes/hatpear/blob/ffb42d5bb417aa8e12b3b7ff73d028b915dafa10/hatpear.go#L96-L110
|
func Recover() Middleware {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if v := recover(); v != nil {
Store(r, PanicError{
value: v,
stack: stack(1),
})
}
}()
next.ServeHTTP(w, r)
})
}
}
|
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/exp/cpp/export/export.go#L611-L630
|
func FindSequenceOnDiskPad(pattern *C.char, padStyle C.int) (FileSeqId, Error) {
str := C.GoString(pattern)
// Caller is responsible for freeing error string
if str == "" {
return 0, C.CString("empty pattern")
}
fs, err := fileseq.FindSequenceOnDiskPad(str, fileseq.PadStyle(padStyle))
if err != nil {
return 0, C.CString(err.Error())
}
// No Match
if fs == nil {
return 0, nil
}
id := sFileSeqs.Add(fs)
return id, nil
}
|
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/network.go#L331-L347
|
func (v *VM) totalNetworkAdapters(vmx map[string]string) int {
var total int
prefix := "ethernet"
for key := range vmx {
if strings.HasPrefix(key, prefix) {
ethN := strings.Split(key, ".")[0]
number, _ := strconv.Atoi(strings.Split(ethN, prefix)[1])
if number > total {
total = number
}
}
}
return total
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/fetch.go#L168-L171
|
func (p ContinueRequestParams) WithURL(url string) *ContinueRequestParams {
p.URL = url
return &p
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/team_token.go#L193-L231
|
func tokenDelete(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
tokenID := r.URL.Query().Get(":token_id")
teamToken, err := servicemanager.TeamToken.FindByTokenID(tokenID)
if err != nil {
if err == authTypes.ErrTeamTokenNotFound {
return &errors.HTTP{
Code: http.StatusNotFound,
Message: err.Error(),
}
}
return err
}
teamName := teamToken.Team
allowed := permission.Check(t, permission.PermTeamTokenDelete,
permission.Context(permTypes.CtxTeam, teamName),
)
if !allowed {
return permission.ErrUnauthorized
}
evt, err := event.New(&event.Opts{
Target: teamTarget(teamName),
Kind: permission.PermTeamTokenDelete,
Owner: t,
CustomData: event.FormToCustomData(InputFields(r)),
Allowed: event.Allowed(permission.PermTeamReadEvents, permission.Context(permTypes.CtxTeam, teamName)),
})
if err != nil {
return err
}
defer func() { evt.Done(err) }()
err = servicemanager.TeamToken.Delete(tokenID)
if err == authTypes.ErrTeamTokenNotFound {
return &errors.HTTP{
Code: http.StatusNotFound,
Message: err.Error(),
}
}
return err
}
|
https://github.com/mikespook/possum/blob/56d7ebb6470b670001632b11be7fc089038f4dd7/view/static.go#L11-L18
|
func StaticFile(filename string, contentType string) staticFile {
if contentType == "" {
contentType = mime.TypeByExtension(path.Ext(filename))
}
header := make(http.Header)
header.Set("Content-Type", contentType)
return staticFile{filename, header}
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/dry_run_client.go#L177-L179
|
func (c *dryRunProwJobClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *prowapi.ProwJob, err error) {
return nil, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/tracing/easyjson.go#L1009-L1013
|
func (v EventDataCollected) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoTracing9(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/gossip.go#L242-L251
|
func (gs *gossipSenders) Sender(channelName string, makeGossipSender func(sender protocolSender, stop <-chan struct{}) *gossipSender) *gossipSender {
gs.Lock()
defer gs.Unlock()
s, found := gs.senders[channelName]
if !found {
s = makeGossipSender(gs.sender, gs.stop)
gs.senders[channelName] = s
}
return s
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/lenses/lenses.go#L96-L112
|
func RegisterLens(lens Lens) error {
config := lens.Config()
_, ok := lensReg[config.Name]
if ok {
return fmt.Errorf("viewer already registered with name %s", config.Name)
}
if config.Title == "" {
return errors.New("empty title field in view metadata")
}
if config.Priority < 0 {
return errors.New("priority must be >=0")
}
lensReg[config.Name] = lens
logrus.Infof("Spyglass registered viewer %s with title %s.", config.Name, config.Title)
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/easyjson.go#L1524-L1528
|
func (v *ContinueRequestParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoFetch13(&r, v)
return r.Error()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/profiler/easyjson.go#L2418-L2422
|
func (v EventConsoleProfileFinished) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler23(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/signals/signals.go#L79-L111
|
func (h *Handler) Register() {
go func() {
h.timer = time.NewTimer(time.Duration(h.timeoutSeconds) * time.Second)
for {
select {
case s := <-h.signals:
switch {
case s == os.Interrupt:
if h.signalReceived == 0 {
h.signalReceived = 1
logger.Debug("SIGINT Received")
continue
}
h.signalReceived = signalTerminate
debug.PrintStack()
os.Exit(130)
break
case s == syscall.SIGQUIT:
h.signalReceived = signalAbort
break
case s == syscall.SIGTERM:
h.signalReceived = signalTerminate
os.Exit(3)
break
}
case <-h.timer.C:
os.Exit(4)
break
}
}
}()
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L232-L270
|
func MergeCommands(root *cobra.Command, children []*cobra.Command) {
// Implement our own 'find' function because Command.Find is not reliable?
findCommand := func(parent *cobra.Command, name string) *cobra.Command {
for _, cmd := range parent.Commands() {
if cmd.Name() == name {
return cmd
}
}
return nil
}
// Sort children by max nesting depth - this will put 'docs' commands first,
// so they are not overwritten by logical commands added by aliases.
var depth func(*cobra.Command) int
depth = func(cmd *cobra.Command) int {
maxDepth := 0
for _, subcmd := range cmd.Commands() {
subcmdDepth := depth(subcmd)
if subcmdDepth > maxDepth {
maxDepth = subcmdDepth
}
}
return maxDepth + 1
}
sort.Slice(children, func(i, j int) bool {
return depth(children[i]) < depth(children[j])
})
// Move each child command over to the main command tree recursively
for _, cmd := range children {
parent := findCommand(root, cmd.Name())
if parent == nil {
root.AddCommand(cmd)
} else {
MergeCommands(parent, cmd.Commands())
}
}
}
|
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/identity.go#L35-L38
|
func (id *Identity) Issue(opts ...Option) *Identity {
opts = append(opts, Issuer(id))
return New(opts...)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gcsupload/options.go#L96-L106
|
func (o *Options) AddFlags(fs *flag.FlagSet) {
fs.StringVar(&o.SubDir, "sub-dir", "", "Optional sub-directory of the job's path to which artifacts are uploaded")
fs.StringVar(&o.PathStrategy, "path-strategy", prowapi.PathStrategyExplicit, "how to encode org and repo into GCS paths")
fs.StringVar(&o.DefaultOrg, "default-org", "", "optional default org for GCS path encoding")
fs.StringVar(&o.DefaultRepo, "default-repo", "", "optional default repo for GCS path encoding")
fs.Var(&o.gcsPath, "gcs-path", "GCS path to upload into")
fs.StringVar(&o.GcsCredentialsFile, "gcs-credentials-file", "", "file where Google Cloud authentication credentials are stored")
fs.BoolVar(&o.DryRun, "dry-run", true, "do not interact with GCS")
}
|
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/swedish/step3.go#L16-L42
|
func step3(w *snowballword.SnowballWord) bool {
// Possible sufficies for this step, longest first.
suffix, suffixRunes := w.FirstSuffixIn(w.R1start, len(w.RS),
"fullt", "löst", "lig", "els", "ig",
)
// If it is not in R1, do nothing
if suffix == "" || len(suffixRunes) > len(w.RS)-w.R1start {
return false
}
// Handle a suffix that was found, which is going
// to be replaced with a different suffix.
//
var repl string
switch suffix {
case "fullt":
repl = "full"
case "löst":
repl = "lös"
case "lig", "ig", "els":
repl = ""
}
w.ReplaceSuffixRunes(suffixRunes, []rune(repl), true)
return true
}
|
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/stats.go#L79-L85
|
func (s *Stats) AddUint64(src *uint64, val uint64) {
if s.isLocal {
*src += val
} else {
atomic.AddUint64(src, val)
}
}
|
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L659-L669
|
func (r *Rule) AttrString(key string) string {
attr, ok := r.attrs[key]
if !ok {
return ""
}
str, ok := attr.RHS.(*bzl.StringExpr)
if !ok {
return ""
}
return str.Value
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L178-L191
|
func (m SetFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if !isFlagValid(xdr.AccountFlags(m)) {
return errors.New("Unknown flag in SetFlag mutator")
}
var val xdr.Uint32
if o.SetFlags == nil {
val = xdr.Uint32(m)
} else {
val = xdr.Uint32(m) | *o.SetFlags
}
o.SetFlags = &val
return
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L255-L301
|
func PrintDetailedDatumInfo(w io.Writer, datumInfo *ppsclient.DatumInfo) {
fmt.Fprintf(w, "ID\t%s\n", datumInfo.Datum.ID)
fmt.Fprintf(w, "Job ID\t%s\n", datumInfo.Datum.Job.ID)
fmt.Fprintf(w, "State\t%s\n", datumInfo.State)
fmt.Fprintf(w, "Data Downloaded\t%s\n", pretty.Size(datumInfo.Stats.DownloadBytes))
fmt.Fprintf(w, "Data Uploaded\t%s\n", pretty.Size(datumInfo.Stats.UploadBytes))
totalTime := client.GetDatumTotalTime(datumInfo.Stats).String()
fmt.Fprintf(w, "Total Time\t%s\n", totalTime)
var downloadTime string
dl, err := types.DurationFromProto(datumInfo.Stats.DownloadTime)
if err != nil {
downloadTime = err.Error()
}
downloadTime = dl.String()
fmt.Fprintf(w, "Download Time\t%s\n", downloadTime)
var procTime string
proc, err := types.DurationFromProto(datumInfo.Stats.ProcessTime)
if err != nil {
procTime = err.Error()
}
procTime = proc.String()
fmt.Fprintf(w, "Process Time\t%s\n", procTime)
var uploadTime string
ul, err := types.DurationFromProto(datumInfo.Stats.UploadTime)
if err != nil {
uploadTime = err.Error()
}
uploadTime = ul.String()
fmt.Fprintf(w, "Upload Time\t%s\n", uploadTime)
fmt.Fprintf(w, "PFS State:\n")
tw := ansiterm.NewTabWriter(w, 10, 1, 3, ' ', 0)
PrintFileHeader(tw)
PrintFile(tw, datumInfo.PfsState)
tw.Flush()
fmt.Fprintf(w, "Inputs:\n")
tw = ansiterm.NewTabWriter(w, 10, 1, 3, ' ', 0)
PrintFileHeader(tw)
for _, d := range datumInfo.Data {
PrintFile(tw, d.File)
}
tw.Flush()
}
|
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/pad.go#L181-L192
|
func zfillString(src string, z int) string {
size := len(src)
if size >= z {
return src
}
fill := strings.Repeat("0", z-size)
if strings.HasPrefix(src, "-") {
return fmt.Sprintf("-%s%s", fill, src[1:])
}
return fmt.Sprintf("%s%s", fill, src)
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/docker_image_dest.go#L222-L265
|
func (d *dockerImageDestination) mountBlob(ctx context.Context, srcRepo reference.Named, srcDigest digest.Digest, extraScope *authScope) error {
u := url.URL{
Path: fmt.Sprintf(blobUploadPath, reference.Path(d.ref.ref)),
RawQuery: url.Values{
"mount": {srcDigest.String()},
"from": {reference.Path(srcRepo)},
}.Encode(),
}
mountPath := u.String()
logrus.Debugf("Trying to mount %s", mountPath)
res, err := d.c.makeRequest(ctx, "POST", mountPath, nil, nil, v2Auth, extraScope)
if err != nil {
return err
}
defer res.Body.Close()
switch res.StatusCode {
case http.StatusCreated:
logrus.Debugf("... mount OK")
return nil
case http.StatusAccepted:
// Oops, the mount was ignored - either the registry does not support that yet, or the blob does not exist; the registry has started an ordinary upload process.
// Abort, and let the ultimate caller do an upload when its ready, instead.
// NOTE: This does not really work in docker/distribution servers, which incorrectly require the "delete" action in the token's scope, and is thus entirely untested.
uploadLocation, err := res.Location()
if err != nil {
return errors.Wrap(err, "Error determining upload URL after a mount attempt")
}
logrus.Debugf("... started an upload instead of mounting, trying to cancel at %s", uploadLocation.String())
res2, err := d.c.makeRequestToResolvedURL(ctx, "DELETE", uploadLocation.String(), nil, nil, -1, v2Auth, extraScope)
if err != nil {
logrus.Debugf("Error trying to cancel an inadvertent upload: %s", err)
} else {
defer res2.Body.Close()
if res2.StatusCode != http.StatusNoContent {
logrus.Debugf("Error trying to cancel an inadvertent upload, status %s", http.StatusText(res.StatusCode))
}
}
// Anyway, if canceling the upload fails, ignore it and return the more important error:
return fmt.Errorf("Mounting %s from %s to %s started an upload instead", srcDigest, srcRepo.Name(), d.ref.ref.Name())
default:
logrus.Debugf("Error mounting, response %#v", *res)
return errors.Wrapf(client.HandleErrorResponse(res), "Error mounting %s from %s to %s", srcDigest, srcRepo.Name(), d.ref.ref.Name())
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/storage/storage.go#L125-L127
|
func (p *TrackIndexedDBForOriginParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandTrackIndexedDBForOrigin, p, nil)
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.