_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/emulation.go#L169-L171
func (p *SetDefaultBackgroundColorOverrideParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetDefaultBackgroundColorOverride, p, nil) }
https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/datasource/mongo/config.go#L66-L71
func GetMongo(source interface{}, environment string) (mongo Config, err error) { var env Environment i, err := config.Get(source, environment, &env) mongo = i.(Config) return }
https://github.com/fcavani/text/blob/023e76809b57fc8cfc80c855ba59537720821cb5/validation.go#L84-L94
func CheckPassword(pass string, min, max int) error { if len(pass) < min || len(pass) > max { return e.New(ErrInvalidPassLength) } for _, r := range pass { if !unicode.IsGraphic(r) { return e.New(ErrInvalidPassChar) } } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L3848-L3852
func (v *EventConsoleAPICalled) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime35(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/page.go#L1168-L1170
func (p *StartScreencastParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandStartScreencast, p, nil) }
https://github.com/blacklabeldata/namedtuple/blob/c341f1db44f30b8164294aa8605ede42be604aba/schema/lexer.go#L234-L288
func lexText(l *Lexer) stateFn { OUTER: for { l.skipWhitespace() remaining := l.remaining() if strings.HasPrefix(remaining, comment) { // Start comment // state function which lexes a comment return lexComment } else if strings.HasPrefix(remaining, pkg) { // Start package decl // state function which lexes a package decl return lexPackage } else if strings.HasPrefix(remaining, from) { // Start from decl // state function which lexes a from decl return lexFrom } else if strings.HasPrefix(remaining, typeDef) { // Start type def // state function which lexes a type return lexTypeDef } else if strings.HasPrefix(remaining, version) { // Start version // state function which lexes a version return lexVersion } else if strings.HasPrefix(remaining, required) { // Start required field // state function which lexes a field l.Pos += len(required) l.emit(TokenRequired) l.skipWhitespace() return lexType } else if strings.HasPrefix(remaining, optional) { // Start optional field // state function which lexes a field l.Pos += len(optional) l.emit(TokenOptional) l.skipWhitespace() return lexType } else if strings.HasPrefix(remaining, openScope) { // Open scope l.Pos += len(openScope) l.emit(TokenOpenCurlyBracket) } else if strings.HasPrefix(remaining, closeScope) { // Close scope l.Pos += len(closeScope) l.emit(TokenCloseCurlyBracket) } else { switch r := l.next(); { case r == eof: // reached EOF? l.emit(TokenEOF) break OUTER default: l.errorf("unknown token: %#v", string(r)) } } } // Stops the run loop return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/op.go#L220-L228
func OpGet(key string, opts ...OpOption) Op { // WithPrefix and WithFromKey are not supported together if isWithPrefix(opts) && isWithFromKey(opts) { panic("`WithPrefix` and `WithFromKey` cannot be set at the same time, choose one") } ret := Op{t: tRange, key: []byte(key)} ret.applyOpts(opts) return ret }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/tethering/easyjson.go#L81-L85
func (v *UnbindParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoTethering(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L2639-L2643
func (v *RuleMatch) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss24(&r, v) return r.Error() }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/watch.go#L960-L972
func (wr *watchRequest) toPB() *pb.WatchRequest { req := &pb.WatchCreateRequest{ StartRevision: wr.rev, Key: []byte(wr.key), RangeEnd: []byte(wr.end), ProgressNotify: wr.progressNotify, Filters: wr.filters, PrevKv: wr.prevKV, Fragment: wr.fragment, } cr := &pb.WatchRequest_CreateRequest{CreateRequest: req} return &pb.WatchRequest{RequestUnion: cr} }
https://github.com/google/subcommands/blob/d47216cd17848d55a33e6f651cbe408243ed55b8/subcommands.go#L378-L384
func dealias(cmd Command) Command { if alias, ok := cmd.(*aliaser); ok { return dealias(alias.Command) } return cmd }
https://github.com/mgutz/str/blob/968bf66e3da857419e4f6e71b2d5c9ae95682dc4/funcsAO.go#L191-L195
func EnsurePrefixF(prefix string) func(string) string { return func(s string) string { return EnsurePrefix(s, prefix) } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/client.go#L2508-L2523
func (c *Client) ClearMilestone(org, repo string, num int) error { c.log("ClearMilestone", org, repo, num) issue := &struct { // Clearing the milestone requires providing a null value, and // interface{} will serialize to null. Milestone interface{} `json:"milestone"` }{} _, err := c.request(&request{ method: http.MethodPatch, path: fmt.Sprintf("/repos/%v/%v/issues/%d", org, repo, num), requestBody: &issue, exitCodes: []int{200}, }, nil) return err }
https://github.com/VividCortex/ewma/blob/43880d236f695d39c62cf7aa4ebd4508c258e6c0/ewma.go#L96-L108
func (e *VariableEWMA) Add(value float64) { switch { case e.count < WARMUP_SAMPLES: e.count++ e.value += value case e.count == WARMUP_SAMPLES: e.count++ e.value = e.value / float64(WARMUP_SAMPLES) e.value = (value * e.decay) + (e.value * (1 - e.decay)) default: e.value = (value * e.decay) + (e.value * (1 - e.decay)) } }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxtype.go#L889-L896
func (s Scalar) Val() [4]float64 { return [4]float64{ float64(s.val[0]), float64(s.val[1]), float64(s.val[2]), float64(s.val[3]), } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/auth_command.go#L84-L97
func authDisableCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 0 { ExitWithError(ExitBadArgs, fmt.Errorf("auth disable command does not accept any arguments")) } ctx, cancel := commandCtx(cmd) _, err := mustClientFromCmd(cmd).Auth.AuthDisable(ctx) cancel() if err != nil { ExitWithError(ExitError, err) } fmt.Println("Authentication Disabled") }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/connect.go#L40-L55
func ConnectIfContainerIsRemote(cluster *db.Cluster, project, name string, cert *shared.CertInfo) (lxd.ContainerServer, error) { var address string // Node address err := cluster.Transaction(func(tx *db.ClusterTx) error { var err error address, err = tx.ContainerNodeAddress(project, name) return err }) if err != nil { return nil, err } if address == "" { // The container is running right on this node, no need to connect. return nil, nil } return Connect(address, cert, false) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L4479-L4483
func (v *GetRequestPostDataParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork33(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/debugger.go#L46-L48
func (p *ContinueToLocationParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandContinueToLocation, p, nil) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/systeminfo/easyjson.go#L729-L733
func (v GPUDevice) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoSysteminfo6(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cache/server/server.go#L26-L35
func NewCacheServer(router shard.Router, shards uint64) CacheServer { server := &groupCacheServer{ Logger: log.NewLogger("CacheServer"), router: router, localShards: make(map[uint64]bool), shards: shards, } groupcache.RegisterPeerPicker(func() groupcache.PeerPicker { return server }) return server }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/networks.go#L491-L516
func (c *Cluster) NetworkUpdate(name, description string, config map[string]string) error { id, _, err := c.NetworkGet(name) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error { err = NetworkUpdateDescription(tx.tx, id, description) if err != nil { return err } err = NetworkConfigClear(tx.tx, id, c.nodeID) if err != nil { return err } err = networkConfigAdd(tx.tx, id, c.nodeID, config) if err != nil { return err } return nil }) return err }
https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L596-L630
func (c *Consumer) subscribe(tomb *loopTomb, subs map[string][]int32) error { // fetch offsets offsets, err := c.fetchOffsets(subs) if err != nil { _ = c.leaveGroup() return err } // create consumers in parallel var mu sync.Mutex var wg sync.WaitGroup for topic, partitions := range subs { for _, partition := range partitions { wg.Add(1) info := offsets[topic][partition] go func(topic string, partition int32) { if e := c.createConsumer(tomb, topic, partition, info); e != nil { mu.Lock() err = e mu.Unlock() } wg.Done() }(topic, partition) } } wg.Wait() if err != nil { _ = c.release() _ = c.leaveGroup() } return err }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/user/user_vm.go#L17-L31
func Current(c context.Context) *User { h := internal.IncomingHeaders(c) u := &User{ Email: h.Get("X-AppEngine-User-Email"), AuthDomain: h.Get("X-AppEngine-Auth-Domain"), ID: h.Get("X-AppEngine-User-Id"), Admin: h.Get("X-AppEngine-User-Is-Admin") == "1", FederatedIdentity: h.Get("X-AppEngine-Federated-Identity"), FederatedProvider: h.Get("X-AppEngine-Federated-Provider"), } if u.Email == "" && u.FederatedIdentity == "" { return nil } return u }
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/part.go#L47-L52
func NewPart(contentType string) *Part { return &Part{ Header: make(textproto.MIMEHeader), ContentType: contentType, } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/report/report.go#L131-L190
func Report(ghc GitHubClient, reportTemplate *template.Template, pj prowapi.ProwJob, validTypes []prowapi.ProwJobType) error { if ghc == nil { return fmt.Errorf("trying to report pj %s, but found empty github client", pj.ObjectMeta.Name) } if !ShouldReport(pj, validTypes) { return nil } refs := pj.Spec.Refs // we are not reporting for batch jobs, we can consider support that in the future if len(refs.Pulls) > 1 { return nil } if err := reportStatus(ghc, pj); err != nil { return fmt.Errorf("error setting status: %v", err) } // Report manually aborted Jenkins jobs and jobs with invalid pod specs alongside // test successes/failures. if !pj.Complete() { return nil } if len(refs.Pulls) == 0 { return nil } ics, err := ghc.ListIssueComments(refs.Org, refs.Repo, refs.Pulls[0].Number) if err != nil { return fmt.Errorf("error listing comments: %v", err) } botName, err := ghc.BotName() if err != nil { return fmt.Errorf("error getting bot name: %v", err) } deletes, entries, updateID := parseIssueComments(pj, botName, ics) for _, delete := range deletes { if err := ghc.DeleteComment(refs.Org, refs.Repo, delete); err != nil { return fmt.Errorf("error deleting comment: %v", err) } } if len(entries) > 0 { comment, err := createComment(reportTemplate, pj, entries) if err != nil { return fmt.Errorf("generating comment: %v", err) } if updateID == 0 { if err := ghc.CreateComment(refs.Org, refs.Repo, refs.Pulls[0].Number, comment); err != nil { return fmt.Errorf("error creating comment: %v", err) } } else { if err := ghc.EditComment(refs.Org, refs.Repo, updateID, comment); err != nil { return fmt.Errorf("error updating comment: %v", err) } } } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/easyjson.go#L6367-L6371
func (v DescribeNodeReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom72(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/har/easyjson.go#L2500-L2504
func (v Cache) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoHar15(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L13666-L13668
func (api *API) TagLocator(href string) *TagLocator { return &TagLocator{Href(href), api} }
https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/lyra2.go#L204-L228
func reducedSqueezeRow0(state []uint64, rowOut []uint64, nCols int) { ptr := (nCols - 1) * blockLenInt64 //M[row][C-1-col] = H.reduced_squeeze() for i := 0; i < nCols; i++ { ptrWord := rowOut[ptr:] //In Lyra2: pointer to M[0][C-1] ptrWord[0] = state[0] ptrWord[1] = state[1] ptrWord[2] = state[2] ptrWord[3] = state[3] ptrWord[4] = state[4] ptrWord[5] = state[5] ptrWord[6] = state[6] ptrWord[7] = state[7] ptrWord[8] = state[8] ptrWord[9] = state[9] ptrWord[10] = state[10] ptrWord[11] = state[11] //Goes to next block (column) that will receive the squeezed data ptr -= blockLenInt64 //Applies the reduced-round transformation f to the sponge's state reducedBlake2bLyra(state) } }
https://github.com/mgutz/str/blob/968bf66e3da857419e4f6e71b2d5c9ae95682dc4/funcsAO.go#L319-L322
func Lines(s string) []string { s = strings.Replace(s, "\r\n", "\n", -1) return strings.Split(s, "\n") }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/types.go#L126-L166
func (t *PermissionType) UnmarshalEasyJSON(in *jlexer.Lexer) { switch PermissionType(in.String()) { case PermissionTypeAccessibilityEvents: *t = PermissionTypeAccessibilityEvents case PermissionTypeAudioCapture: *t = PermissionTypeAudioCapture case PermissionTypeBackgroundSync: *t = PermissionTypeBackgroundSync case PermissionTypeBackgroundFetch: *t = PermissionTypeBackgroundFetch case PermissionTypeClipboardRead: *t = PermissionTypeClipboardRead case PermissionTypeClipboardWrite: *t = PermissionTypeClipboardWrite case PermissionTypeDurableStorage: *t = PermissionTypeDurableStorage case PermissionTypeFlash: *t = PermissionTypeFlash case PermissionTypeGeolocation: *t = PermissionTypeGeolocation case PermissionTypeMidi: *t = PermissionTypeMidi case PermissionTypeMidiSysex: *t = PermissionTypeMidiSysex case PermissionTypeNotifications: *t = PermissionTypeNotifications case PermissionTypePaymentHandler: *t = PermissionTypePaymentHandler case PermissionTypeProtectedMediaIdentifier: *t = PermissionTypeProtectedMediaIdentifier case PermissionTypeSensors: *t = PermissionTypeSensors case PermissionTypeVideoCapture: *t = PermissionTypeVideoCapture case PermissionTypeIdleDetection: *t = PermissionTypeIdleDetection default: in.AddError(errors.New("unknown PermissionType value")) } }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L2554-L2563
func NewCreateAccountResult(code CreateAccountResultCode, value interface{}) (result CreateAccountResult, err error) { result.Code = code switch CreateAccountResultCode(code) { case CreateAccountResultCodeCreateAccountSuccess: // void default: // void } return }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/txn.go#L419-L425
func (txn *Txn) Delete(key []byte) error { e := &Entry{ Key: key, meta: bitDelete, } return txn.modify(e) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/systeminfo/easyjson.go#L439-L443
func (v GetInfoParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoSysteminfo4(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L5819-L5827
func (u LedgerEntryChange) MustState() LedgerEntry { val, ok := u.GetState() if !ok { panic("arm State is not set") } return val }
https://github.com/ant0ine/go-json-rest/blob/ebb33769ae013bd5f518a8bac348c310dea768b8/rest/gzip.go#L103-L132
func (w *gzipResponseWriter) Write(b []byte) (int, error) { if !w.wroteHeader { w.WriteHeader(http.StatusOK) } writer := w.ResponseWriter.(http.ResponseWriter) if w.canGzip { // Write can be called multiple times for a given response. // (see the streaming example: // https://github.com/ant0ine/go-json-rest-examples/tree/master/streaming) // The gzipWriter is instantiated only once, and flushed after // each write. if w.gzipWriter == nil { w.gzipWriter = gzip.NewWriter(writer) } count, errW := w.gzipWriter.Write(b) errF := w.gzipWriter.Flush() if errW != nil { return count, errW } if errF != nil { return count, errF } return count, nil } return writer.Write(b) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/runtime.go#L337-L340
func (p EvaluateParams) WithSilent(silent bool) *EvaluateParams { p.Silent = silent return &p }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/provision/dockercommon/commands.go#L27-L32
func DeployCmds(app provision.App) []string { uaCmds := unitAgentCmds(app) uaCmds = append(uaCmds, "deploy-only") finalCmd := strings.Join(uaCmds, " ") return []string{"/bin/sh", "-lc", finalCmd} }
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/ranges/ranges.go#L79-L98
func (r *InclusiveRange) String() string { var buf strings.Builder // Always for a single value buf.WriteString(strconv.Itoa(r.Start())) // If we have a range, express the end value if r.End() != r.Start() { buf.WriteString(`-`) buf.WriteString(strconv.Itoa(r.End())) // Express the stepping, if its not 1 step := r.Step() if step > 1 || step < -1 { buf.WriteString(`x`) buf.WriteString(strconv.Itoa(r.Step())) } } return buf.String() }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/raft.go#L319-L420
func (r *Raft) runLeader() { r.logger.Info(fmt.Sprintf("%v entering Leader state", r)) metrics.IncrCounter([]string{"raft", "state", "leader"}, 1) // Notify that we are the leader asyncNotifyBool(r.leaderCh, true) // Push to the notify channel if given if notify := r.conf.NotifyCh; notify != nil { select { case notify <- true: case <-r.shutdownCh: } } // Setup leader state r.leaderState.commitCh = make(chan struct{}, 1) r.leaderState.commitment = newCommitment(r.leaderState.commitCh, r.configurations.latest, r.getLastIndex()+1 /* first index that may be committed in this term */) r.leaderState.inflight = list.New() r.leaderState.replState = make(map[ServerID]*followerReplication) r.leaderState.notify = make(map[*verifyFuture]struct{}) r.leaderState.stepDown = make(chan struct{}, 1) // Cleanup state on step down defer func() { // Since we were the leader previously, we update our // last contact time when we step down, so that we are not // reporting a last contact time from before we were the // leader. Otherwise, to a client it would seem our data // is extremely stale. r.setLastContact() // Stop replication for _, p := range r.leaderState.replState { close(p.stopCh) } // Respond to all inflight operations for e := r.leaderState.inflight.Front(); e != nil; e = e.Next() { e.Value.(*logFuture).respond(ErrLeadershipLost) } // Respond to any pending verify requests for future := range r.leaderState.notify { future.respond(ErrLeadershipLost) } // Clear all the state r.leaderState.commitCh = nil r.leaderState.commitment = nil r.leaderState.inflight = nil r.leaderState.replState = nil r.leaderState.notify = nil r.leaderState.stepDown = nil // If we are stepping down for some reason, no known leader. // We may have stepped down due to an RPC call, which would // provide the leader, so we cannot always blank this out. r.leaderLock.Lock() if r.leader == r.localAddr { r.leader = "" } r.leaderLock.Unlock() // Notify that we are not the leader asyncNotifyBool(r.leaderCh, false) // Push to the notify channel if given if notify := r.conf.NotifyCh; notify != nil { select { case notify <- false: case <-r.shutdownCh: // On shutdown, make a best effort but do not block select { case notify <- false: default: } } } }() // Start a replication routine for each peer r.startStopReplication() // Dispatch a no-op log entry first. This gets this leader up to the latest // possible commit index, even in the absence of client commands. This used // to append a configuration entry instead of a noop. However, that permits // an unbounded number of uncommitted configurations in the log. We now // maintain that there exists at most one uncommitted configuration entry in // any log, so we have to do proper no-ops here. noop := &logFuture{ log: Log{ Type: LogNoop, }, } r.dispatchLogs([]*logFuture{noop}) // Sit in the leader loop until we step down r.leaderLoop() }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_lxc.go#L8551-L8596
func (c *containerLXC) setNetworkPriority() error { // Check that the container is running if !c.IsRunning() { return fmt.Errorf("Can't set network priority on stopped container") } // Don't bother if the cgroup controller doesn't exist if !c.state.OS.CGroupNetPrioController { return nil } // Extract the current priority networkPriority := c.expandedConfig["limits.network.priority"] if networkPriority == "" { networkPriority = "0" } networkInt, err := strconv.Atoi(networkPriority) if err != nil { return err } // Get all the interfaces netifs, err := net.Interfaces() if err != nil { return err } // Check that we at least succeeded to set an entry success := false var last_error error for _, netif := range netifs { err = c.CGroupSet("net_prio.ifpriomap", fmt.Sprintf("%s %d", netif.Name, networkInt)) if err == nil { success = true } else { last_error = err } } if !success { return fmt.Errorf("Failed to set network device priority: %s", last_error) } return nil }
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/header.go#L486-L493
func rfc2047AttributeName(s string) string { if !strings.Contains(s, "?=") { return s } pair := strings.SplitAfter(s, "?=") pair[0] = decodeHeader(pair[0]) return strings.Join(pair, "") }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/context_header.go#L119-L121
func WithoutHeaders(ctx context.Context) context.Context { return context.WithValue(context.WithValue(ctx, contextKeyTChannel, nil), contextKeyHeaders, nil) }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/app/plan.go#L64-L66
func (s *planService) Remove(planName string) error { return s.storage.Delete(appTypes.Plan{Name: planName}) }
https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/normalize.go#L10-L27
func NormalizeMax(buf *audio.FloatBuffer) { if buf == nil { return } max := 0.0 for i := 0; i < len(buf.Data); i++ { if math.Abs(buf.Data[i]) > max { max = math.Abs(buf.Data[i]) } } if max != 0.0 { for i := 0; i < len(buf.Data); i++ { buf.Data[i] /= max } } }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/retry.go#L185-L200
func (rs *RequestState) AddSelectedPeer(hostPort string) { if rs == nil { return } host := getHost(hostPort) if rs.SelectedPeers == nil { rs.SelectedPeers = map[string]struct{}{ hostPort: {}, host: {}, } } else { rs.SelectedPeers[hostPort] = struct{}{} rs.SelectedPeers[host] = struct{}{} } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/emulation.go#L228-L231
func (p SetDeviceMetricsOverrideParams) WithScreenHeight(screenHeight int64) *SetDeviceMetricsOverrideParams { p.ScreenHeight = screenHeight return &p }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L202-L223
func LogoutCmd() *cobra.Command { logout := &cobra.Command{ Short: "Log out of Pachyderm by deleting your local credential", Long: "Log out of Pachyderm by deleting your local credential. Note that " + "it's not necessary to log out before logging in with another account " + "(simply run 'pachctl auth login' twice) but 'logout' can be useful on " + "shared workstations.", Run: cmdutil.Run(func([]string) error { cfg, err := config.Read() if err != nil { return fmt.Errorf("error reading Pachyderm config (for cluster "+ "address): %v", err) } if cfg.V1 == nil { return nil } cfg.V1.SessionToken = "" return cfg.Write() }), } return cmdutil.CreateAlias(logout, "auth logout") }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/language/go/config.go#L121-L132
func (gc *goConfig) setBuildTags(tags string) error { if tags == "" { return nil } for _, t := range strings.Split(tags, ",") { if strings.HasPrefix(t, "!") { return fmt.Errorf("build tags can't be negated: %s", t) } gc.genericTags[t] = true } return nil }
https://github.com/ip2location/ip2location-go/blob/a417f19539fd2a0eb0adf273b4190241cacc0499/ip2location.go#L218-L233
func readuint128(pos uint32) *big.Int { pos2 := int64(pos) retval := big.NewInt(0) data := make([]byte, 16) _, err := f.ReadAt(data, pos2 - 1) if err != nil { fmt.Println("File read failed:", err) } // little endian to big endian for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 { data[i], data[j] = data[j], data[i] } retval.SetBytes(data) return retval }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/archive/dest.go#L70-L72
func (d *archiveImageDestination) Commit(ctx context.Context) error { return d.Destination.Commit(ctx) }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/internal/version/version.go#L54-L72
func ParseVersion(vs string) (Version, error) { i := strings.IndexByte(vs, '-') if i >= 0 { vs = vs[:i] } cstrs := strings.Split(vs, ".") v := make(Version, len(cstrs)) for i, cstr := range cstrs { cn, err := strconv.Atoi(cstr) if err != nil { return nil, fmt.Errorf("could not parse version string: %q is not an integer", cstr) } if cn < 0 { return nil, fmt.Errorf("could not parse version string: %q is negative", cstr) } v[i] = cn } return v, nil }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/openshift/openshift-copies.go#L98-L112
func newOpenShiftClientConfigLoadingRules() *clientConfigLoadingRules { chain := []string{} envVarFile := os.Getenv("KUBECONFIG") if len(envVarFile) != 0 { chain = append(chain, filepath.SplitList(envVarFile)...) } else { chain = append(chain, recommendedHomeFile) } return &clientConfigLoadingRules{ Precedence: chain, // REMOVED: Migration support; run (oc login) to trigger migration } }
https://github.com/btcsuite/btclog/blob/84c8d2346e9fc8c7b947e243b9c24e6df9fd206a/log.go#L243-L259
func callsite(flag uint32) (string, int) { _, file, line, ok := runtime.Caller(calldepth) if !ok { return "???", 0 } if flag&Lshortfile != 0 { short := file for i := len(file) - 1; i > 0; i-- { if os.IsPathSeparator(file[i]) { short = file[i+1:] break } } file = short } return file, line }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/logging_conn.go#L71-L77
func (p *loggingPipe) serverConn() *loggingConn { return &loggingConn{ pipe: p, r: p.serverReader, w: p.clientWriter, } }
https://github.com/akutz/gotil/blob/6fa2e80bd3ac40f15788cfc3d12ebba49a0add92/gotil.go#L185-L188
func GetThisPathParts() (dirPath, fileName, absPath string) { exeFile, _ := osext.Executable() return GetPathParts(exeFile) }
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/protocol_crypto.go#L22-L24
func generateKeyPair() (publicKey, privateKey *[32]byte, err error) { return box.GenerateKey(rand.Reader) }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/oci/layout/oci_transport.go#L135-L149
func (ref ociReference) PolicyConfigurationNamespaces() []string { res := []string{} path := ref.resolvedDir for { lastSlash := strings.LastIndex(path, "/") // Note that we do not include "/"; it is redundant with the default "" global default, // and rejected by ociTransport.ValidatePolicyConfigurationScope above. if lastSlash == -1 || path == "/" { break } res = append(res, path) path = path[:lastSlash] } return res }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/apparmor.go#L517-L604
func getAAProfileContent(c container) string { profile := strings.TrimLeft(AA_PROFILE_BASE, "\n") // Apply new features if aaParserSupports("unix") { profile += ` ### Feature: unix # Allow receive via unix sockets from anywhere unix (receive), # Allow all unix in the container unix peer=(label=@{profile_name}), ` } // Apply cgns bits if shared.PathExists("/proc/self/ns/cgroup") { profile += "\n ### Feature: cgroup namespace\n" profile += " mount fstype=cgroup -> /sys/fs/cgroup/**,\n" profile += " mount fstype=cgroup2 -> /sys/fs/cgroup/**,\n" } state := c.DaemonState() if state.OS.AppArmorStacking && !state.OS.AppArmorStacked { profile += "\n ### Feature: apparmor stacking\n" profile += ` ### Configuration: apparmor profile loading (in namespace) deny /sys/k[^e]*{,/**} wklx, deny /sys/ke[^r]*{,/**} wklx, deny /sys/ker[^n]*{,/**} wklx, deny /sys/kern[^e]*{,/**} wklx, deny /sys/kerne[^l]*{,/**} wklx, deny /sys/kernel/[^s]*{,/**} wklx, deny /sys/kernel/s[^e]*{,/**} wklx, deny /sys/kernel/se[^c]*{,/**} wklx, deny /sys/kernel/sec[^u]*{,/**} wklx, deny /sys/kernel/secu[^r]*{,/**} wklx, deny /sys/kernel/secur[^i]*{,/**} wklx, deny /sys/kernel/securi[^t]*{,/**} wklx, deny /sys/kernel/securit[^y]*{,/**} wklx, deny /sys/kernel/security/[^a]*{,/**} wklx, deny /sys/kernel/security/a[^p]*{,/**} wklx, deny /sys/kernel/security/ap[^p]*{,/**} wklx, deny /sys/kernel/security/app[^a]*{,/**} wklx, deny /sys/kernel/security/appa[^r]*{,/**} wklx, deny /sys/kernel/security/appar[^m]*{,/**} wklx, deny /sys/kernel/security/apparm[^o]*{,/**} wklx, deny /sys/kernel/security/apparmo[^r]*{,/**} wklx, deny /sys/kernel/security/apparmor?*{,/**} wklx, deny /sys/kernel/security?*{,/**} wklx, deny /sys/kernel?*{,/**} wklx, ` profile += fmt.Sprintf(" change_profile -> \":%s:*\",\n", AANamespace(c)) profile += fmt.Sprintf(" change_profile -> \":%s://*\",\n", AANamespace(c)) } else { profile += "\n ### Feature: apparmor stacking (not present)\n" profile += " deny /sys/k*{,/**} wklx,\n" } if c.IsNesting() { // Apply nesting bits profile += "\n ### Configuration: nesting\n" profile += strings.TrimLeft(AA_PROFILE_NESTING, "\n") if !state.OS.AppArmorStacking || state.OS.AppArmorStacked { profile += fmt.Sprintf(" change_profile -> \"%s\",\n", AAProfileFull(c)) } } if !c.IsPrivileged() || state.OS.RunningInUserNS { // Apply unprivileged bits profile += "\n ### Configuration: unprivileged containers\n" profile += strings.TrimLeft(AA_PROFILE_UNPRIVILEGED, "\n") } // Append raw.apparmor rawApparmor, ok := c.ExpandedConfig()["raw.apparmor"] if ok { profile += "\n ### Configuration: raw.apparmor\n" for _, line := range strings.Split(strings.Trim(rawApparmor, "\n"), "\n") { profile += fmt.Sprintf(" %s\n", line) } } return fmt.Sprintf(`#include <tunables/global> profile "%s" flags=(attach_disconnected,mediate_deleted) { %s } `, AAProfileFull(c), strings.Trim(profile, "\n")) }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L231-L249
func FillStroke(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/210, height/215 gc.MoveTo(x+sx*113.0, y) gc.LineTo(x+sx*215.0, y+sy*215) rLineTo(gc, sx*-100, 0) gc.CubicCurveTo(x+sx*35, y+sy*215, x+sx*35, y+sy*113, x+sx*113.0, y+sy*113) gc.Close() gc.MoveTo(x+sx*50.0, y) rLineTo(gc, sx*51.2, sy*51.2) rLineTo(gc, sx*-51.2, sy*51.2) rLineTo(gc, sx*-51.2, sy*-51.2) gc.Close() gc.SetLineWidth(width / 20.0) gc.SetFillColor(color.NRGBA{0, 0, 0xFF, 0xFF}) gc.SetStrokeColor(image.Black) gc.FillStroke() }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/agent/handler.go#L694-L720
func (srv *Server) handle_SIGQUIT_ETCD_AND_REMOVE_DATA_AND_STOP_AGENT() (*rpcpb.Response, error) { err := srv.stopEtcd(syscall.SIGQUIT) if err != nil { return nil, err } if srv.etcdServer != nil { srv.etcdServer.GetLogger().Sync() } else { srv.etcdLogFile.Sync() srv.etcdLogFile.Close() } err = os.RemoveAll(srv.Member.BaseDir) if err != nil { return nil, err } srv.lg.Info("removed base directory", zap.String("dir", srv.Member.BaseDir)) // stop agent server srv.Stop() return &rpcpb.Response{ Success: true, Status: "destroyed etcd and agent", }, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/easyjson.go#L2267-L2271
func (v *PushNodesByBackendIdsToFrontendParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom24(&r, v) return r.Error() }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/rsapi.go#L44-L60
func New(host string, auth Authenticator) *API { client := httpclient.New() if strings.HasPrefix(host, "http://") { host = host[7:] } else if strings.HasPrefix(host, "https://") { host = host[8:] } a := &API{ Auth: auth, Host: host, Client: client, } if auth != nil { auth.SetHost(host) } return a }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/routes_linux.go#L160-L186
func getIfaceLink(idx uint32) (*syscall.NetlinkMessage, error) { dat, err := syscall.NetlinkRIB(syscall.RTM_GETLINK, syscall.AF_UNSPEC) if err != nil { return nil, err } msgs, msgErr := syscall.ParseNetlinkMessage(dat) if msgErr != nil { return nil, msgErr } ifinfomsg := syscall.IfInfomsg{} for _, m := range msgs { if m.Header.Type != syscall.RTM_NEWLINK { continue } buf := bytes.NewBuffer(m.Data[:syscall.SizeofIfInfomsg]) if rerr := binary.Read(buf, cpuutil.ByteOrder(), &ifinfomsg); rerr != nil { continue } if ifinfomsg.Index == int32(idx) { return &m, nil } } return nil, fmt.Errorf("could not find link for interface index %v", idx) }
https://github.com/mikespook/possum/blob/56d7ebb6470b670001632b11be7fc089038f4dd7/server.go#L53-L55
func (mux *ServerMux) HandleFunc(r router.Router, h HandlerFunc, v view.View) { mux.routers.Add(r, h, v) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/easyjson.go#L350-L354
func (v *UnregisterParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoServiceworker2(&r, v) return r.Error() }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay.go#L241-L299
func (r *Relayer) Receive(f *Frame, fType frameType) (sent bool, failureReason string) { id := f.Header.ID // If we receive a response frame, we expect to find that ID in our outbound. // If we receive a request frame, we expect to find that ID in our inbound. items := r.receiverItems(fType) item, ok := items.Get(id) if !ok { r.logger.WithFields( LogField{"id", id}, ).Warn("Received a frame without a RelayItem.") return false, _relayErrorNotFound } finished := finishesCall(f) if item.tomb { // Call timed out, ignore this frame. (We've already handled stats.) // TODO: metrics for late-arriving frames. return true, "" } // call res frames don't include the OK bit, so we can't wait until the last // frame of a relayed RPC to determine if the call succeeded. if fType == responseFrame { // If we've gotten a response frame, we're the originating relayer and // should handle stats. if succeeded, failMsg := determinesCallSuccess(f); succeeded { item.call.Succeeded() } else if len(failMsg) > 0 { item.call.Failed(failMsg) } } select { case r.conn.sendCh <- f: default: // Buffer is full, so drop this frame and cancel the call. r.logger.WithFields( LogField{"id", id}, ).Warn("Dropping call due to slow connection.") items := r.receiverItems(fType) err := _relayErrorDestConnSlow // If we're dealing with a response frame, then the client is slow. if fType == responseFrame { err = _relayErrorSourceConnSlow } r.failRelayItem(items, id, err) return false, err } if finished { r.finishRelayItem(items, id) } return true, "" }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_lxc.go#L113-L175
func lxcSetConfigItem(c *lxc.Container, key string, value string) error { if c == nil { return fmt.Errorf("Uninitialized go-lxc struct") } if !util.RuntimeLiblxcVersionAtLeast(2, 1, 0) { switch key { case "lxc.uts.name": key = "lxc.utsname" case "lxc.pty.max": key = "lxc.pts" case "lxc.tty.dir": key = "lxc.devttydir" case "lxc.tty.max": key = "lxc.tty" case "lxc.apparmor.profile": key = "lxc.aa_profile" case "lxc.apparmor.allow_incomplete": key = "lxc.aa_allow_incomplete" case "lxc.selinux.context": key = "lxc.se_context" case "lxc.mount.fstab": key = "lxc.mount" case "lxc.console.path": key = "lxc.console" case "lxc.seccomp.profile": key = "lxc.seccomp" case "lxc.signal.halt": key = "lxc.haltsignal" case "lxc.signal.reboot": key = "lxc.rebootsignal" case "lxc.signal.stop": key = "lxc.stopsignal" case "lxc.log.syslog": key = "lxc.syslog" case "lxc.log.level": key = "lxc.loglevel" case "lxc.log.file": key = "lxc.logfile" case "lxc.init.cmd": key = "lxc.init_cmd" case "lxc.init.uid": key = "lxc.init_uid" case "lxc.init.gid": key = "lxc.init_gid" case "lxc.idmap": key = "lxc.id_map" } } if strings.HasPrefix(key, "lxc.prlimit.") { if !util.RuntimeLiblxcVersionAtLeast(2, 1, 0) { return fmt.Errorf(`Process limits require liblxc >= 2.1`) } } err := c.SetConfigItem(key, value) if err != nil { return fmt.Errorf("Failed to set LXC config: %s=%s", key, value) } return nil }
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/job.go#L457-L464
func (r *jobImportResult) JobSummary() *JobSummary { return &JobSummary{ ID: r.ID, Name: r.Name, GroupName: r.GroupName, ProjectName: r.ProjectName, } }
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/parser/tterse/tterse.go#L45-L51
func NewReaderLexer(rdr io.Reader) *parser.Lexer { l := parser.NewReaderLexer(rdr, SymbolSet) l.SetTagStart("[%") l.SetTagEnd("%]") return l }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/volume.go#L156-L188
func volumeUpdate(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) { var inputVolume volume.Volume err = ParseInput(r, &inputVolume) if err != nil { return err } inputVolume.Plan.Opts = nil inputVolume.Status = "" inputVolume.Name = r.URL.Query().Get(":name") dbVolume, err := volume.Load(inputVolume.Name) if err != nil { if err == volume.ErrVolumeNotFound { return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()} } return err } canUpdate := permission.Check(t, permission.PermVolumeUpdate, contextsForVolume(dbVolume)...) if !canUpdate { return permission.ErrUnauthorized } evt, err := event.New(&event.Opts{ Target: event.Target{Type: event.TargetTypeVolume, Value: inputVolume.Name}, Kind: permission.PermVolumeUpdate, Owner: t, CustomData: event.FormToCustomData(InputFields(r)), Allowed: event.Allowed(permission.PermVolumeReadEvents, contextsForVolume(dbVolume)...), }) if err != nil { return err } defer func() { evt.Done(err) }() return inputVolume.Update() }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/minio_client.go#L50-L65
func newMinioWriter(ctx context.Context, client *minioClient, name string) *minioWriter { reader, writer := io.Pipe() w := &minioWriter{ ctx: ctx, errChan: make(chan error), pipe: writer, } go func() { _, err := client.PutObject(client.bucket, name, reader, "application/octet-stream") if err != nil { reader.CloseWithError(err) } w.errChan <- err }() return w }
https://github.com/tendermint/go-amino/blob/dc14acf9ef15f85828bfbc561ed9dd9d2a284885/deep_copy.go#L183-L217
func callAminoCopy(src, dst reflect.Value) bool { if src.Type() != dst.Type() { panic("should not happen") } if src.Kind() == reflect.Ptr { cpy := reflect.New(src.Type().Elem()) dst.Set(cpy) } else if src.CanAddr() { if !dst.CanAddr() { panic("should not happen") } src = src.Addr() dst = dst.Addr() } else { return false } if !canAminoCopy(src) { return false } cpy := reflect.New(src.Type().Elem()) dst.Set(cpy) ma := src.MethodByName("MarshalAmino") ua := dst.MethodByName("UnmarshalAmino") outs := ma.Call(nil) repr, err := outs[0], outs[1] if !err.IsNil() { panic(err.Interface()) } outs = ua.Call([]reflect.Value{repr}) err = outs[0] if !err.IsNil() { panic(err.Interface()) } return true }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/easyjson.go#L1303-L1307
func (v *ErrorMessage) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoServiceworker13(&r, v) return r.Error() }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/helpers.go#L17-L19
func E(format string, a ...interface{}) error { return Safe(fmt.Errorf(format, a...)) }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/account_id.go#L12-L26
func (aid *AccountId) Address() string { if aid == nil { return "" } switch aid.Type { case CryptoKeyTypeKeyTypeEd25519: ed := aid.MustEd25519() raw := make([]byte, 32) copy(raw, ed[:]) return strkey.MustEncode(strkey.VersionByteAccountID, raw) default: panic(fmt.Errorf("Unknown account id type: %v", aid.Type)) } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/types.go#L402-L410
func (t *CaptureSnapshotFormat) UnmarshalEasyJSON(in *jlexer.Lexer) { switch CaptureSnapshotFormat(in.String()) { case CaptureSnapshotFormatMhtml: *t = CaptureSnapshotFormatMhtml default: in.AddError(errors.New("unknown CaptureSnapshotFormat value")) } }
https://github.com/gchaincl/sqlhooks/blob/1932c8dd22f2283687586008bf2d58c2c5c014d0/sqlhooks.go#L321-L323
func Wrap(driver driver.Driver, hooks Hooks) driver.Driver { return &Driver{driver, hooks} }
https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/sessionauth/login.go#L56-L72
func SessionUser(newUser func() User) martini.Handler { return func(s sessions.Session, c martini.Context, l *log.Logger) { userId := s.Get(SessionKey) user := newUser() if userId != nil { err := user.GetById(userId) if err != nil { l.Printf("Login Error: %v\n", err) } else { user.Login() } } c.MapTo(user, (*User)(nil)) } }
https://github.com/imdario/mergo/blob/45df20b7fcedb0ff48e461334a1f0aafcc3892e3/merge.go#L230-L232
func MergeWithOverwrite(dst, src interface{}, opts ...func(*Config)) error { return merge(dst, src, append(opts, WithOverride)...) }
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/https_redirect.go#L52-L81
func (l TLSListener) Accept() (net.Conn, error) { c, err := l.AcceptTCP() if err != nil { return nil, err } c.SetKeepAlive(true) c.SetKeepAlivePeriod(3 * time.Minute) b := make([]byte, 1) _, err = c.Read(b) if err != nil { c.Close() if err != io.EOF { return nil, err } } con := &conn{ Conn: c, b: b[0], e: err, f: true, } if b[0] == 22 { return tls.Server(con, l.TLSConfig), nil } return con, nil }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/coal/helpers.go#L107-L120
func Unique(ids []bson.ObjectId) []bson.ObjectId { // prepare map m := make(map[bson.ObjectId]bool) l := make([]bson.ObjectId, 0, len(ids)) for _, id := range ids { if _, ok := m[id]; !ok { m[id] = true l = append(l, id) } } return l }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/advertise.go#L58-L60
func fuzzInterval(interval time.Duration) time.Duration { return time.Duration(rand.Int63n(int64(interval))) }
https://github.com/aphistic/gomol/blob/1546845ba714699f76f484ad3af64cf0503064d1/log_adapter.go#L113-L115
func (la *LogAdapter) Dbgm(m *Attrs, msg string, a ...interface{}) error { return la.Debugm(m, msg, a...) }
https://github.com/ipfs/go-ipfs-api/blob/a1b28da48b3763f67654ec4cfcba5fcbfb3dfb32/requestbuilder.go#L76-L82
func (r *RequestBuilder) Send(ctx context.Context) (*Response, error) { req := NewRequest(ctx, r.shell.url, r.command, r.args...) req.Opts = r.opts req.Headers = r.headers req.Body = r.body return req.Send(&r.shell.httpcli) }
https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L69-L71
func (pk *RsaPublicKey) Encrypt(b []byte) ([]byte, error) { return rsa.EncryptPKCS1v15(rand.Reader, pk.k, b) }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/angular.go#L34-L36
func (c *AngularWriter) WriteResource(resource *gen.Resource, w io.Writer) error { return c.angularTmpl.Execute(w, resource) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/grpcutil/server.go#L63-L127
func Serve( servers ...ServerOptions, ) (retErr error) { for _, server := range servers { if server.RegisterFunc == nil { return ErrMustSpecifyRegisterFunc } if server.Port == 0 { return ErrMustSpecifyPort } opts := []grpc.ServerOption{ grpc.MaxConcurrentStreams(math.MaxUint32), grpc.MaxRecvMsgSize(server.MaxMsgSize), grpc.MaxSendMsgSize(server.MaxMsgSize), grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ MinTime: 5 * time.Second, PermitWithoutStream: true, }), grpc.UnaryInterceptor(tracing.UnaryServerInterceptor()), grpc.StreamInterceptor(tracing.StreamServerInterceptor()), } if server.PublicPortTLSAllowed { // Validate environment certPath := path.Join(TLSVolumePath, TLSCertFile) keyPath := path.Join(TLSVolumePath, TLSKeyFile) _, certPathStatErr := os.Stat(certPath) _, keyPathStatErr := os.Stat(keyPath) if certPathStatErr != nil { log.Warnf("TLS disabled: could not stat public cert at %s: %v", certPath, certPathStatErr) } if keyPathStatErr != nil { log.Warnf("TLS disabled: could not stat private key at %s: %v", keyPath, keyPathStatErr) } if certPathStatErr == nil && keyPathStatErr == nil { // Read TLS cert and key transportCreds, err := credentials.NewServerTLSFromFile(certPath, keyPath) if err != nil { return fmt.Errorf("couldn't build transport creds: %v", err) } opts = append(opts, grpc.Creds(transportCreds)) } } grpcServer := grpc.NewServer(opts...) if err := server.RegisterFunc(grpcServer); err != nil { return err } listener, err := net.Listen("tcp", fmt.Sprintf(":%d", server.Port)) if err != nil { return err } if server.Cancel != nil { go func() { <-server.Cancel if err := listener.Close(); err != nil { fmt.Printf("listener.Close(): %v\n", err) } }() } if err := grpcServer.Serve(listener); err != nil { return err } } return nil }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/get_apps_app_routes_route_parameters.go#L126-L129
func (o *GetAppsAppRoutesRouteParams) WithRoute(route string) *GetAppsAppRoutesRouteParams { o.SetRoute(route) return o }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ca/cac/codegen_client.go#L628-L630
func (api *API) CloudBillLocator(href string) *CloudBillLocator { return &CloudBillLocator{Href(href), api} }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/quota.go#L39-L50
func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error { if qa.q.Available(r) { return nil } req := &pb.AlarmRequest{ MemberID: uint64(qa.id), Action: pb.AlarmRequest_ACTIVATE, Alarm: pb.AlarmType_NOSPACE, } qa.a.Alarm(ctx, req) return rpctypes.ErrGRPCNoSpace }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/easyjson.go#L637-L641
func (v FulfillRequestParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoFetch6(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/server.go#L167-L172
func (c *Client) DetachVolume(dcid, srvid, volid string) (*http.Header, error) { url := serverVolumePath(dcid, srvid, volid) ret := &http.Header{} err := c.client.Delete(url, ret, http.StatusAccepted) return ret, err }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L449-L452
func (mat *MatND) Release() { mat_c := (*C.CvMatND)(mat) C.cvReleaseMatND(&mat_c) }
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/http/http_client.go#L61-L121
func Transport(options *Options) *http.Transport { if options.Timeout == 0 { options.Timeout = 30 * time.Second } if options.KeepAlive == 0 { options.KeepAlive = 30 * time.Second } if options.TLSHandshakeTimeout == 0 { options.TLSHandshakeTimeout = 30 * time.Second } netDialFunc := (&net.Dialer{ Timeout: options.Timeout, KeepAlive: options.KeepAlive, }).Dial dialFunc := netDialFunc if options.RetryTimeMax > 0 { retrySleepBaseNano := options.RetrySleepBase.Nanoseconds() if retrySleepBaseNano == 0 { retrySleepBaseNano = defaultRetrySleepBaseNano } retrySleepMaxNano := options.RetrySleepMax.Nanoseconds() if retrySleepMaxNano == 0 { retrySleepMaxNano = defaultRetrySleepMaxNano } dialFunc = func(network, address string) (conn net.Conn, err error) { var k int64 = 1 sleepNano := retrySleepBaseNano start := time.Now() for time.Since(start.Add(-time.Duration(sleepNano))) < options.RetryTimeMax { conn, err = netDialFunc(network, address) if err != nil { sleepNano = retrySleepBaseNano * k if sleepNano <= 0 { break } time.Sleep(time.Duration(random.Int63n(func(x, y int64) int64 { if x < y { return x } return y }(retrySleepMaxNano, sleepNano)))) k = 2 * k continue } return } return } } transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: dialFunc, TLSHandshakeTimeout: options.TLSHandshakeTimeout, TLSClientConfig: &tls.Config{InsecureSkipVerify: options.TLSSkipVerify}, } http2.ConfigureTransport(transport) return transport }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/http.go#L26-L32
func (f *FileUpload) MarshalJSON() ([]byte, error) { b, err := ioutil.ReadAll(f.Reader) if err != nil { return nil, err } return json.Marshal(string(b)) }
https://github.com/alexflint/go-arg/blob/fb1ae1c3e0bd00d45333c3d51384afc05846f7a0/parse.go#L37-L56
func MustParse(dest ...interface{}) *Parser { p, err := NewParser(Config{}, dest...) if err != nil { fmt.Println(err) os.Exit(-1) } err = p.Parse(flags()) if err == ErrHelp { p.WriteHelp(os.Stdout) os.Exit(0) } if err == ErrVersion { fmt.Println(p.version) os.Exit(0) } if err != nil { p.Fail(err.Error()) } return p }
https://github.com/coryb/figtree/blob/e5fa026ccd54e0a6a99b6d81f73bfcc8e6fe6a6b/gen-rawoption.go#L43-L51
func (o *BoolOption) Set(s string) error { err := convertString(s, &o.Value) if err != nil { return err } o.Source = "override" o.Defined = true return nil }
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/dialect.go#L138-L140
func (d *MySQLDialect) Quote(s string) string { return fmt.Sprintf("`%s`", strings.Replace(s, "`", "``", -1)) }