_id
stringlengths 86
170
| text
stringlengths 54
39.3k
|
|---|---|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L5204-L5208
|
func (v GetComputedStyleForNodeReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss45(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/log_windows.go#L99-L102
|
func setConsoleTextAttribute(f file, attribute uint16) bool {
ok, _, _ := setConsoleTextAttributeProc.Call(f.Fd(), uintptr(attribute), 0)
return ok != 0
}
|
https://github.com/reiver/go-telnet/blob/9ff0b2ab096ebe42bf8e2ffd1366e7ed2223b04c/conn.go#L121-L123
|
func (clientConn *Conn) Read(p []byte) (n int, err error) {
return clientConn.dataReader.Read(p)
}
|
https://github.com/go-bongo/bongo/blob/761759e31d8fed917377aa7085db01d218ce50d8/collection.go#L212-L225
|
func (c *Collection) Find(query interface{}) *ResultSet {
col := c.Collection()
// Count for testing
q := col.Find(query)
resultset := new(ResultSet)
resultset.Query = q
resultset.Params = query
resultset.Collection = c
return resultset
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/typed/buffer.go#L142-L145
|
func (r *ReadBuffer) ReadLen8String() string {
n := r.ReadSingleByte()
return r.ReadString(int(n))
}
|
https://github.com/fhs/go-netrc/blob/4ffed54ee5c32ebfb1b8c7c72fc90bb08dc3ff43/netrc/netrc.go#L80-L82
|
func (e *Error) Error() string {
return fmt.Sprintf("%s:%d: %s", e.Filename, e.LineNum, e.Msg)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/error.go#L18-L28
|
func Code(err error) ErrCode {
if err == nil {
return OK
}
hte, ok := err.(*hashTreeError)
if !ok {
return Unknown
}
return hte.code
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L770-L773
|
func (e TrustLineFlags) ValidEnum(v int32) bool {
_, ok := trustLineFlagsMap[v]
return ok
}
|
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/inmem_store.go#L79-L96
|
func (i *InmemStore) DeleteRange(min, max uint64) error {
i.l.Lock()
defer i.l.Unlock()
for j := min; j <= max; j++ {
delete(i.logs, j)
}
if min <= i.lowIndex {
i.lowIndex = max + 1
}
if max >= i.highIndex {
i.highIndex = min - 1
}
if i.lowIndex > i.highIndex {
i.lowIndex = 0
i.highIndex = 0
}
return nil
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/cmd/saml.go#L66-L70
|
func samlRequestTimeout(schemeData map[string]string) int {
p := schemeData["request_timeout"]
timeout, _ := strconv.Atoi(p)
return timeout
}
|
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L303-L309
|
func (api *TelegramBotAPI) NewInlineQueryAnswer(queryID string, results []InlineQueryResult) *InlineQueryAnswer {
return &InlineQueryAnswer{
api: api,
QueryID: queryID,
Results: results,
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/easyjson.go#L249-L253
|
func (v *RequestPattern) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoFetch2(&r, v)
return r.Error()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/easyjson.go#L1290-L1294
|
func (v *SetDefaultBackgroundColorOverrideParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoEmulation13(&r, v)
return r.Error()
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L130-L135
|
func (r Ref) Required() []string {
if refIF, ok := r["required"]; ok {
return refIF.([]string)
}
return []string{}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/runtime.go#L722-L725
|
func (p RunScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *RunScriptParams {
p.ExecutionContextID = executionContextID
return &p
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L128-L131
|
func RegisterGenericCommentHandler(name string, fn GenericCommentHandler, help HelpProvider) {
pluginHelp[name] = help
genericCommentHandlers[name] = fn
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L6187-L6191
|
func (v EventResourceChangedPriority) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork49(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/dsl/mock_service.go#L92-L114
|
func (m *MockService) WritePact() error {
log.Println("[DEBUG] mock service write pact")
if m.Consumer == "" || m.Provider == "" {
return errors.New("Consumer and Provider name need to be provided")
}
if m.PactFileWriteMode == "" {
m.PactFileWriteMode = "overwrite"
}
pact := map[string]interface{}{
"consumer": map[string]string{
"name": m.Consumer,
},
"provider": map[string]string{
"name": m.Provider,
},
"pactFileWriteMode": m.PactFileWriteMode,
}
url := fmt.Sprintf("%s/pact", m.BaseURL)
return m.call("POST", url, pact)
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L677-L727
|
func (loc *ApplicationLocator) Launch(options rsapi.APIParams) error {
var params rsapi.APIParams
var p rsapi.APIParams
p = rsapi.APIParams{}
var deferLaunchOpt = options["defer_launch"]
if deferLaunchOpt != nil {
p["defer_launch"] = deferLaunchOpt
}
var descriptionOpt = options["description"]
if descriptionOpt != nil {
p["description"] = descriptionOpt
}
var endDateOpt = options["end_date"]
if endDateOpt != nil {
p["end_date"] = endDateOpt
}
var nameOpt = options["name"]
if nameOpt != nil {
p["name"] = nameOpt
}
var options_Opt = options["options"]
if options_Opt != nil {
p["options"] = options_Opt
}
var scheduleNameOpt = options["schedule_name"]
if scheduleNameOpt != nil {
p["schedule_name"] = scheduleNameOpt
}
uri, err := loc.ActionPath("Application", "launch")
if err != nil {
return err
}
req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
if err != nil {
return err
}
resp, err := loc.api.PerformRequest(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
respBody, _ := ioutil.ReadAll(resp.Body)
sr := string(respBody)
if sr != "" {
sr = ": " + sr
}
return fmt.Errorf("invalid response %s%s", resp.Status, sr)
}
return nil
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/admin/server/convert1_7.go#L303-L308
|
func clean1_7HashtreePath(p string) string {
if !strings.HasPrefix(p, "/") {
p = "/" + p
}
return default1_7HashtreeRoot(pathlib.Clean(p))
}
|
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/streambuffer/streambuffer.go#L131-L201
|
func (s *Stream) Run() (err error) {
s.mu.RLock()
defer s.mu.RUnlock()
defer func() {
if err != nil {
if grpc.Code(err) == codes.Canceled {
s.log.Debug("streambuffer: context canceled")
err = context.Canceled
return
}
if grpc.Code(err) == codes.DeadlineExceeded {
s.log.Debug("streambuffer: context deadline exceeded")
err = context.DeadlineExceeded
return
}
}
}()
stream, err := s.setupFunc()
if err != nil {
s.log.WithError(err).Debug("streambuffer: setup returned error")
return err
}
recvErr := make(chan error)
defer func() {
go func() { // empty the recvErr channel on return
<-recvErr
}()
}()
go func() {
for {
var r interface{}
if s.recvFunc != nil {
r = s.recvFunc()
} else {
r = new(empty.Empty) // Generic proto message if not interested in received values
}
err := stream.RecvMsg(r)
if err != nil {
s.log.WithError(err).Debug("streambuffer: error from stream.RecvMsg")
recvErr <- err
close(recvErr)
return
}
if s.recvFunc != nil {
s.recvMsg(r)
}
}
}()
defer stream.CloseSend()
for {
select {
case err := <-recvErr:
return err
case <-stream.Context().Done():
s.log.WithError(stream.Context().Err()).Debug("streambuffer: context done")
return stream.Context().Err()
case msg := <-s.sendBuffer:
if err = stream.SendMsg(msg); err != nil {
s.log.WithError(err).Debug("streambuffer: error from stream.SendMsg")
return err
}
atomic.AddUint64(&s.sent, 1)
}
}
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/node.go#L169-L210
|
func removeNodeHandler(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
address := r.URL.Query().Get(":address")
if address == "" {
return errors.Errorf("Node address is required.")
}
_, n, err := node.FindNode(address)
if err != nil {
if err == provision.ErrNodeNotFound {
return &tsuruErrors.HTTP{
Code: http.StatusNotFound,
Message: err.Error(),
}
}
return err
}
pool := n.Pool()
allowedNodeRemove := permission.Check(t, permission.PermNodeDelete,
permission.Context(permTypes.CtxPool, pool),
)
if !allowedNodeRemove {
return permission.ErrUnauthorized
}
evt, err := event.New(&event.Opts{
Target: event.Target{Type: event.TargetTypeNode, Value: n.Address()},
Kind: permission.PermNodeDelete,
Owner: t,
CustomData: event.FormToCustomData(InputFields(r)),
Allowed: event.Allowed(permission.PermPoolReadEvents, permission.Context(permTypes.CtxPool, pool)),
})
if err != nil {
return err
}
defer func() { evt.Done(err) }()
noRebalance, _ := strconv.ParseBool(r.URL.Query().Get("no-rebalance"))
removeIaaS, _ := strconv.ParseBool(r.URL.Query().Get("remove-iaas"))
return node.RemoveNode(node.RemoveNodeArgs{
Node: n,
Rebalance: !noRebalance,
Writer: w,
RemoveIaaS: removeIaaS,
})
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/iaas.go#L62-L91
|
func machineDestroy(w http.ResponseWriter, r *http.Request, token auth.Token) (err error) {
machineID := r.URL.Query().Get(":machine_id")
if machineID == "" {
return &errors.HTTP{Code: http.StatusBadRequest, Message: "machine id is required"}
}
m, err := iaas.FindMachineById(machineID)
if err != nil {
if err == iaas.ErrMachineNotFound {
return &errors.HTTP{Code: http.StatusNotFound, Message: "machine not found"}
}
return err
}
iaasCtx := permission.Context(permTypes.CtxIaaS, m.Iaas)
allowed := permission.Check(token, permission.PermMachineDelete, iaasCtx)
if !allowed {
return permission.ErrUnauthorized
}
evt, err := event.New(&event.Opts{
Target: event.Target{Type: event.TargetTypeIaas, Value: m.Iaas},
Kind: permission.PermMachineDelete,
Owner: token,
CustomData: event.FormToCustomData(InputFields(r)),
Allowed: event.Allowed(permission.PermMachineReadEvents, iaasCtx),
})
if err != nil {
return err
}
defer func() { evt.Done(err) }()
return m.Destroy()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L164-L167
|
func (p DeleteCookiesParams) WithURL(url string) *DeleteCookiesParams {
p.URL = url
return &p
}
|
https://github.com/aphistic/gomol/blob/1546845ba714699f76f484ad3af64cf0503064d1/default.go#L211-L213
|
func Fatalm(m *Attrs, msg string, a ...interface{}) error {
return curDefault.Fatalm(m, msg, a...)
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/iterator.go#L74-L95
|
func (itr *blockIterator) Seek(key []byte, whence int) {
itr.err = nil
switch whence {
case origin:
itr.Reset()
case current:
}
var done bool
for itr.Init(); itr.Valid(); itr.Next() {
k := itr.Key()
if y.CompareKeys(k, key) >= 0 {
// We are done as k is >= key.
done = true
break
}
}
if !done {
itr.err = io.EOF
}
}
|
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/builder.go#L203-L235
|
func (b *Builder) Finish() []byte {
bf := bbloom.New(float64(b.keyCount), 0.01)
var klen [2]byte
key := make([]byte, 1024)
for {
if _, err := b.keyBuf.Read(klen[:]); err == io.EOF {
break
} else if err != nil {
y.Check(err)
}
kl := int(binary.BigEndian.Uint16(klen[:]))
if cap(key) < kl {
key = make([]byte, 2*int(kl)) // 2 * uint16 will overflow
}
key = key[:kl]
y.Check2(b.keyBuf.Read(key))
bf.Add(key)
}
b.finishBlock() // This will never start a new block.
index := b.blockIndex()
b.buf.Write(index)
// Write bloom filter.
bdata := bf.JSONMarshal()
n, err := b.buf.Write(bdata)
y.Check(err)
var buf [4]byte
binary.BigEndian.PutUint32(buf[:], uint32(n))
b.buf.Write(buf[:])
return b.buf.Bytes()
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/client/client.go#L542-L559
|
func isDialErrorRetriable(err error) bool {
opErr, isOpErr := err.(*net.OpError)
if !isOpErr {
return false
}
if opErr.Timeout() || opErr.Temporary() {
return true
}
sysErr, isSysErr := opErr.Err.(*os.SyscallError)
if !isSysErr {
return false
}
switch sysErr.Err {
case syscall.ECONNREFUSED, syscall.ECONNRESET:
return true
}
return false
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/openshift/openshift-copies.go#L969-L986
|
func loadTLSFiles(c *restConfig) error {
var err error
c.CAData, err = dataFromSliceOrFile(c.CAData, c.CAFile)
if err != nil {
return err
}
c.CertData, err = dataFromSliceOrFile(c.CertData, c.CertFile)
if err != nil {
return err
}
c.KeyData, err = dataFromSliceOrFile(c.KeyData, c.KeyFile)
if err != nil {
return err
}
return nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L48-L64
|
func (r *ProtocolLXD) DeleteClusterMember(name string, force bool) error {
if !r.HasExtension("clustering") {
return fmt.Errorf("The server is missing the required \"clustering\" API extension")
}
params := ""
if force {
params += "?force=1"
}
_, err := r.queryStruct("DELETE", fmt.Sprintf("/cluster/members/%s%s", name, params), nil, "", nil)
if err != nil {
return err
}
return nil
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ca/cac/codegen_client.go#L3585-L3587
|
func (api *API) TempInstancePriceLocator(href string) *TempInstancePriceLocator {
return &TempInstancePriceLocator{Href(href), api}
}
|
https://github.com/geoffgarside/ber/blob/27a1aff36ce64dbe5d93c08cc5f161983134ddc5/ber.go#L307-L316
|
func parseIA5String(bytes []byte) (ret string, err error) {
for _, b := range bytes {
if b >= utf8.RuneSelf {
err = asn1.SyntaxError{Msg: "IA5String contains invalid character"}
return
}
}
ret = string(bytes)
return
}
|
https://github.com/olorin/nagiosplugin/blob/893f9702af4ea1e2dc4cd6528cbdcdb3dc7ca064/check.go#L15-L18
|
func Exit(status Status, message string) {
fmt.Printf("%v: %s\n", status, message)
os.Exit(int(status))
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/log.go#L279-L281
|
func (l *raftLog) isUpToDate(lasti, term uint64) bool {
return term > l.lastTerm() || (term == l.lastTerm() && lasti >= l.lastIndex())
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/samples.go#L18-L24
|
func Output(name, ext string) string {
var root string
if ext == "pdf" || ext == "svg" {
root = "../"
}
return fmt.Sprintf("%soutput/samples/%s.%s", root, name, ext)
}
|
https://github.com/delicb/gstring/blob/77637d5e476b8e22d81f6a7bc5311a836dceb1c2/gstring.go#L130-L133
|
func Sprintm(format string, args map[string]interface{}) string {
f, a := gformat(format, args)
return fmt.Sprintf(f, a...)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/cluster.go#L75-L88
|
func GetProwJobClient(masterURL, kubeConfig string) (prowjobclientset.Interface, error) {
config, err := loadClusterConfig(masterURL, kubeConfig)
if err != nil {
return nil, err
}
prowjobClient, err := prowjobclientset.NewForConfig(config)
if err != nil {
return nil, err
}
logrus.Info("Successfully constructed k8s client")
return prowjobClient, nil
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L8328-L8375
|
func (loc *RepositoryLocator) CookbookImport(assetHrefs []string, options rsapi.APIParams) error {
if len(assetHrefs) == 0 {
return fmt.Errorf("assetHrefs is required")
}
var params rsapi.APIParams
var p rsapi.APIParams
p = rsapi.APIParams{
"asset_hrefs": assetHrefs,
}
var followOpt = options["follow"]
if followOpt != nil {
p["follow"] = followOpt
}
var namespaceOpt = options["namespace"]
if namespaceOpt != nil {
p["namespace"] = namespaceOpt
}
var repositoryCommitReferenceOpt = options["repository_commit_reference"]
if repositoryCommitReferenceOpt != nil {
p["repository_commit_reference"] = repositoryCommitReferenceOpt
}
var withDependenciesOpt = options["with_dependencies"]
if withDependenciesOpt != nil {
p["with_dependencies"] = withDependenciesOpt
}
uri, err := loc.ActionPath("Repository", "cookbook_import")
if err != nil {
return err
}
req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
if err != nil {
return err
}
resp, err := loc.api.PerformRequest(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
respBody, _ := ioutil.ReadAll(resp.Body)
sr := string(respBody)
if sr != "" {
sr = ": " + sr
}
return fmt.Errorf("invalid response %s%s", resp.Status, sr)
}
return nil
}
|
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/protocol.go#L217-L226
|
func filterV1Features(intro map[string]string) map[string]string {
safe := make(map[string]string)
for _, k := range protocolV1Features {
if val, ok := intro[k]; ok {
safe[k] = val
}
}
return safe
}
|
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L708-L710
|
func (g *Glg) Logf(format string, val ...interface{}) error {
return g.out(LOG, format, val...)
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L297-L323
|
func (subChMap *subChannelMap) IntrospectState(opts *IntrospectionOptions) map[string]SubChannelRuntimeState {
m := make(map[string]SubChannelRuntimeState)
subChMap.RLock()
for k, sc := range subChMap.subchannels {
state := SubChannelRuntimeState{
Service: k,
Isolated: sc.Isolated(),
}
if state.Isolated {
state.IsolatedPeers = sc.Peers().IntrospectList(opts)
}
if hmap, ok := sc.handler.(*handlerMap); ok {
state.Handler.Type = methodHandler
methods := make([]string, 0, len(hmap.handlers))
for k := range hmap.handlers {
methods = append(methods, k)
}
sort.Strings(methods)
state.Handler.Methods = methods
} else {
state.Handler.Type = overrideHandler
}
m[k] = state
}
subChMap.RUnlock()
return m
}
|
https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/offsets.go#L27-L37
|
func (s *OffsetStash) MarkPartitionOffset(topic string, partition int32, offset int64, metadata string) {
s.mu.Lock()
defer s.mu.Unlock()
key := topicPartition{Topic: topic, Partition: partition}
if info := s.offsets[key]; offset >= info.Offset {
info.Offset = offset
info.Metadata = metadata
s.offsets[key] = info
}
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L7459-L7463
|
func (v *AppManifestError) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage82(&r, v)
return r.Error()
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/har/easyjson.go#L1021-L1025
|
func (v Param) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoHar4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L132-L134
|
func (w *SnowballWord) FitsInR2(x int) bool {
return w.R2start <= len(w.RS)-x
}
|
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/xmpp/xmpp.go#L145-L163
|
func (p *Presence) Send(c context.Context) error {
req := &pb.XmppSendPresenceRequest{
Jid: &p.To,
}
if p.State != "" {
req.Show = &p.State
}
if p.Type != "" {
req.Type = &p.Type
}
if p.Sender != "" {
req.FromJid = &p.Sender
}
if p.Status != "" {
req.Status = &p.Status
}
res := &pb.XmppSendPresenceResponse{}
return internal.Call(c, "xmpp", "SendPresence", req, res)
}
|
https://github.com/pandemicsyn/oort/blob/fca1d3baddc1d944387cc8bbe8b21f911ec9091b/oort/config.go#L19-L24
|
func FExists(name string) bool {
if _, err := os.Stat(name); os.IsNotExist(err) {
return false
}
return true
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/json/handler.go#L43-L75
|
func verifyHandler(t reflect.Type) error {
if t.NumIn() != 2 || t.NumOut() != 2 {
return fmt.Errorf("handler should be of format func(json.Context, *ArgType) (*ResType, error)")
}
isStructPtr := func(t reflect.Type) bool {
return t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct
}
isMap := func(t reflect.Type) bool {
return t.Kind() == reflect.Map && t.Key().Kind() == reflect.String
}
validateArgRes := func(t reflect.Type, name string) error {
if !isStructPtr(t) && !isMap(t) {
return fmt.Errorf("%v should be a pointer to a struct, or a map[string]interface{}", name)
}
return nil
}
if t.In(0) != typeOfContext {
return fmt.Errorf("arg0 should be of type json.Context")
}
if err := validateArgRes(t.In(1), "second argument"); err != nil {
return err
}
if err := validateArgRes(t.Out(0), "first return value"); err != nil {
return err
}
if !t.Out(1).AssignableTo(typeOfError) {
return fmt.Errorf("second return value should be an error")
}
return nil
}
|
https://github.com/apuigsech/seekret/blob/9b1f7ea1b3fd5bd29d93cf62102cb66e54428a49/seekret.go#L164-L166
|
func (s *Seekret) EnableRuleByRegexp(name string) int {
return setRuleEnabledByRegexp(s.ruleList, name, true)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pps/pretty/pretty.go#L127-L179
|
func PrintDetailedJobInfo(jobInfo *PrintableJobInfo) error {
template, err := template.New("JobInfo").Funcs(funcMap).Parse(
`ID: {{.Job.ID}} {{if .Pipeline}}
Pipeline: {{.Pipeline.Name}} {{end}} {{if .ParentJob}}
Parent: {{.ParentJob.ID}} {{end}}{{if .FullTimestamps}}
Started: {{.Started}}{{else}}
Started: {{prettyAgo .Started}} {{end}}{{if .Finished}}
Duration: {{prettyTimeDifference .Started .Finished}} {{end}}
State: {{jobState .State}}
Reason: {{.Reason}}
Processed: {{.DataProcessed}}
Failed: {{.DataFailed}}
Skipped: {{.DataSkipped}}
Recovered: {{.DataRecovered}}
Total: {{.DataTotal}}
Data Downloaded: {{prettySize .Stats.DownloadBytes}}
Data Uploaded: {{prettySize .Stats.UploadBytes}}
Download Time: {{prettyDuration .Stats.DownloadTime}}
Process Time: {{prettyDuration .Stats.ProcessTime}}
Upload Time: {{prettyDuration .Stats.UploadTime}}
Datum Timeout: {{.DatumTimeout}}
Job Timeout: {{.JobTimeout}}
Worker Status:
{{workerStatus .}}Restarts: {{.Restart}}
ParallelismSpec: {{.ParallelismSpec}}
{{ if .ResourceRequests }}ResourceRequests:
CPU: {{ .ResourceRequests.Cpu }}
Memory: {{ .ResourceRequests.Memory }} {{end}}
{{ if .ResourceLimits }}ResourceLimits:
CPU: {{ .ResourceLimits.Cpu }}
Memory: {{ .ResourceLimits.Memory }}
{{ if .ResourceLimits.Gpu }}GPU:
Type: {{ .ResourceLimits.Gpu.Type }}
Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}
{{ if .Service }}Service:
{{ if .Service.InternalPort }}InternalPort: {{ .Service.InternalPort }} {{end}}
{{ if .Service.ExternalPort }}ExternalPort: {{ .Service.ExternalPort }} {{end}} {{end}}Input:
{{jobInput .}}
Transform:
{{prettyTransform .Transform}} {{if .OutputCommit}}
Output Commit: {{.OutputCommit.ID}} {{end}} {{ if .StatsCommit }}
Stats Commit: {{.StatsCommit.ID}} {{end}} {{ if .Egress }}
Egress: {{.Egress.URL}} {{end}}
`)
if err != nil {
return err
}
err = template.Execute(os.Stdout, jobInfo)
if err != nil {
return err
}
return nil
}
|
https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L793-L808
|
func (c *Consumer) leaveGroup() error {
broker, err := c.client.Coordinator(c.groupID)
if err != nil {
c.closeCoordinator(broker, err)
return err
}
memberID, _ := c.membership()
if _, err = broker.LeaveGroup(&sarama.LeaveGroupRequest{
GroupId: c.groupID,
MemberId: memberID,
}); err != nil {
c.closeCoordinator(broker, err)
}
return err
}
|
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/repo/remote.go#L433-L449
|
func (m *remoteCacheMap) ensure(key string, load func() (interface{}, error)) (interface{}, error) {
m.mu.Lock()
e, ok := m.cache[key]
if !ok {
e = &remoteCacheEntry{ready: make(chan struct{})}
m.cache[key] = e
m.mu.Unlock()
e.value, e.err = load()
close(e.ready)
} else {
m.mu.Unlock()
if e.ready != nil {
<-e.ready
}
}
return e.value, e.err
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L316-L322
|
func (a *ArrayDataType) IsEquivalent(other DataType) bool {
t, ok := other.(*ArrayDataType)
if !ok {
return false
}
return a.ElemType.IsEquivalent(t.ElemType)
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L100-L106
|
func IsUnixSocket(path string) bool {
stat, err := os.Stat(path)
if err != nil {
return false
}
return (stat.Mode() & os.ModeSocket) == os.ModeSocket
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L390-L398
|
func (f *FakeClient) IsCollaborator(org, repo, login string) (bool, error) {
normed := github.NormLogin(login)
for _, collab := range f.Collaborators {
if github.NormLogin(collab) == normed {
return true, nil
}
}
return false, nil
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/oci/layout/oci_src.go#L128-L130
|
func (s *ociImageSource) GetSignatures(ctx context.Context, instanceDigest *digest.Digest) ([][]byte, error) {
return [][]byte{}, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/debugger.go#L424-L433
|
func (p *RestartFrameParams) Do(ctx context.Context) (callFrames []*CallFrame, asyncStackTrace *runtime.StackTrace, asyncStackTraceID *runtime.StackTraceID, err error) {
// execute
var res RestartFrameReturns
err = cdp.Execute(ctx, CommandRestartFrame, p, &res)
if err != nil {
return nil, nil, nil, err
}
return res.CallFrames, res.AsyncStackTrace, res.AsyncStackTraceID, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/easyjson.go#L1457-L1461
|
func (v DispatchSyncEventParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoServiceworker15(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/gocv/gocv_core.go#L65-L77
|
func Mat64ToGcvMat(mat *mat64.Dense) GcvMat {
row, col := mat.Dims()
rawData := NewGcvFloat64Vector(int64(row * col))
for i := 0; i < row; i++ {
for j := 0; j < col; j++ {
rawData.Set(i*col+j, mat.At(i, j))
}
}
return Mat64ToGcvMat_(row, col, rawData)
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dsvg/gc.go#L125-L134
|
func (gc *GraphicContext) DrawImage(image image.Image) {
bounds := image.Bounds()
svgImage := &Image{Href: imageToSvgHref(image)}
svgImage.X = float64(bounds.Min.X)
svgImage.Y = float64(bounds.Min.Y)
svgImage.Width = toSvgLength(float64(bounds.Max.X - bounds.Min.X))
svgImage.Height = toSvgLength(float64(bounds.Max.Y - bounds.Min.Y))
gc.newGroup(0).Image = svgImage
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/sql/sql.go#L28-L55
|
func (r *PGDumpReader) ReadRow() ([]byte, error) {
if len(r.Header) == 0 {
err := r.readHeader()
if err != nil {
return nil, err
}
}
endLine := "\\.\n" // Trailing '\.' denotes the end of the row inserts
row, err := r.rd.ReadBytes('\n')
if err != nil && err != io.EOF {
return nil, fmt.Errorf("error reading pgdump row: %v", err)
}
// corner case: some pgdump files separate lines with \r\n (even on linux),
// so clean this case up so all handling below is unified
if len(row) >= 2 && row[len(row)-2] == '\r' {
row[len(row)-2] = '\n'
row = row[:len(row)-1]
}
if string(row) == endLine {
r.Footer = append(r.Footer, row...)
err = r.readFooter()
row = nil // The endline is part of the footer
}
if err == io.EOF && len(r.Footer) == 0 {
return nil, fmt.Errorf("invalid pgdump - missing footer")
}
return row, err
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L54-L59
|
func ErrorAndExit(format string, args ...interface{}) {
if errString := strings.TrimSpace(fmt.Sprintf(format, args...)); errString != "" {
fmt.Fprintf(os.Stderr, "%s\n", errString)
}
os.Exit(1)
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/storage/storage_image.go#L556-L573
|
func (s *storageImageDestination) getConfigBlob(info types.BlobInfo) ([]byte, error) {
if info.Digest == "" {
return nil, errors.Errorf(`no digest supplied when reading blob`)
}
if err := info.Digest.Validate(); err != nil {
return nil, errors.Wrapf(err, `invalid digest supplied when reading blob`)
}
// Assume it's a file, since we're only calling this from a place that expects to read files.
if filename, ok := s.filenames[info.Digest]; ok {
contents, err2 := ioutil.ReadFile(filename)
if err2 != nil {
return nil, errors.Wrapf(err2, `error reading blob from file %q`, filename)
}
return contents, nil
}
// If it's not a file, it's a bug, because we're not expecting to be asked for a layer.
return nil, errors.New("blob not found")
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L4768-L4772
|
func (v FontFamilies) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage49(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/lease/lessor.go#L504-L520
|
func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {
le.mu.Lock()
defer le.mu.Unlock()
l := le.leaseMap[id]
if l == nil {
return ErrLeaseNotFound
}
l.mu.Lock()
for _, it := range items {
l.itemSet[it] = struct{}{}
le.itemMap[it] = id
}
l.mu.Unlock()
return nil
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/external-plugins/cherrypicker/server.go#L426-L442
|
func (s *Server) ensureForkExists(org, repo string) error {
s.repoLock.Lock()
defer s.repoLock.Unlock()
// Fork repo if it doesn't exist.
fork := s.botName + "/" + repo
if !repoExists(fork, s.repos) {
if err := s.ghc.CreateFork(org, repo); err != nil {
return fmt.Errorf("cannot fork %s/%s: %v", org, repo, err)
}
if err := waitForRepo(s.botName, repo, s.ghc); err != nil {
return fmt.Errorf("fork of %s/%s cannot show up on GitHub: %v", org, repo, err)
}
s.repos = append(s.repos, github.Repo{FullName: fork, Fork: true})
}
return nil
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/exec/exec.go#L161-L168
|
func CommandContext(ctx context.Context, name string, arg ...string) *Cmd {
if ctx == nil {
panic("nil Context")
}
cmd := Command(name, arg...)
cmd.ctx = ctx
return cmd
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L590-L592
|
func (api *API) AlertSpecLocator(href string) *AlertSpecLocator {
return &AlertSpecLocator{Href(href), api}
}
|
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/snapshot/v3_snapshot.go#L239-L309
|
func (s *v3Manager) Restore(cfg RestoreConfig) error {
pURLs, err := types.NewURLs(cfg.PeerURLs)
if err != nil {
return err
}
var ics types.URLsMap
ics, err = types.NewURLsMap(cfg.InitialCluster)
if err != nil {
return err
}
srv := etcdserver.ServerConfig{
Logger: s.lg,
Name: cfg.Name,
PeerURLs: pURLs,
InitialPeerURLsMap: ics,
InitialClusterToken: cfg.InitialClusterToken,
}
if err = srv.VerifyBootstrap(); err != nil {
return err
}
s.cl, err = membership.NewClusterFromURLsMap(s.lg, cfg.InitialClusterToken, ics)
if err != nil {
return err
}
dataDir := cfg.OutputDataDir
if dataDir == "" {
dataDir = cfg.Name + ".etcd"
}
if fileutil.Exist(dataDir) {
return fmt.Errorf("data-dir %q exists", dataDir)
}
walDir := cfg.OutputWALDir
if walDir == "" {
walDir = filepath.Join(dataDir, "member", "wal")
} else if fileutil.Exist(walDir) {
return fmt.Errorf("wal-dir %q exists", walDir)
}
s.name = cfg.Name
s.dbPath = cfg.SnapshotPath
s.walDir = walDir
s.snapDir = filepath.Join(dataDir, "member", "snap")
s.skipHashCheck = cfg.SkipHashCheck
s.lg.Info(
"restoring snapshot",
zap.String("path", s.dbPath),
zap.String("wal-dir", s.walDir),
zap.String("data-dir", dataDir),
zap.String("snap-dir", s.snapDir),
)
if err = s.saveDB(); err != nil {
return err
}
if err = s.saveWALAndSnap(); err != nil {
return err
}
s.lg.Info(
"restored snapshot",
zap.String("path", s.dbPath),
zap.String("wal-dir", s.walDir),
zap.String("data-dir", dataDir),
zap.String("snap-dir", s.snapDir),
)
return nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L914-L929
|
func (c *Cluster) StoragePoolVolumeRename(project, oldVolumeName string, newVolumeName string, volumeType int, poolID int64) error {
volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, oldVolumeName, volumeType, poolID)
if err != nil {
return err
}
err = c.Transaction(func(tx *ClusterTx) error {
err := storagePoolVolumeReplicateIfCeph(tx.tx, volumeID, project, oldVolumeName, volumeType, poolID, func(volumeID int64) error {
_, err := tx.tx.Exec("UPDATE storage_volumes SET name=? WHERE id=? AND type=?", newVolumeName, volumeID, volumeType)
return err
})
return err
})
return err
}
|
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/service.go#L184-L216
|
func serviceDelete(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
s, err := getService(r.URL.Query().Get(":name"))
if err != nil {
return err
}
allowed := permission.Check(t, permission.PermServiceDelete,
contextsForServiceProvision(&s)...,
)
if !allowed {
return permission.ErrUnauthorized
}
evt, err := event.New(&event.Opts{
Target: serviceTarget(s.Name),
Kind: permission.PermServiceDelete,
Owner: t,
CustomData: event.FormToCustomData(InputFields(r)),
Allowed: event.Allowed(permission.PermServiceReadEvents, contextsForServiceProvision(&s)...),
})
if err != nil {
return err
}
defer func() { evt.Done(err) }()
instances, err := service.GetServiceInstancesByServices([]service.Service{s})
if err != nil {
return err
}
if len(instances) > 0 {
msg := "This service cannot be removed because it has instances.\n"
msg += "Please remove these instances before removing the service."
return &errors.HTTP{Code: http.StatusForbidden, Message: msg}
}
return service.Delete(s)
}
|
https://github.com/pivotal-pez/pezdispenser/blob/768e2777520868857916b66cfd4cfb7149383ca5/fakes/fake.go#L334-L345
|
func NewFakeCollection(updated int) *FakeCollection {
fakeCol := new(FakeCollection)
if updated == -1 {
fakeCol.FakeChangeInfo = nil
} else {
fakeCol.FakeChangeInfo = &mgo.ChangeInfo{
Updated: updated,
}
}
return fakeCol
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/easyjson.go#L1590-L1594
|
func (v GetHighlightObjectForTestReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoOverlay15(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/metadata/resource.go#L51-L58
|
func (r *Resource) GetAction(name string) *Action {
for _, a := range r.Actions {
if a.Name == name {
return a
}
}
return nil
}
|
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/line/line.go#L17-L31
|
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
gc.SetFillRule(draw2d.FillRuleWinding)
gc.Clear()
// Draw the line
for x := 5.0; x < 297; x += 10 {
Draw(gc, x, 0, x, 210)
}
gc.ClearRect(100, 75, 197, 135)
draw2dkit.Ellipse(gc, 148.5, 105, 35, 25)
gc.SetFillColor(color.RGBA{0xff, 0xff, 0x44, 0xff})
gc.FillStroke()
// Return the output filename
return samples.Output("line", ext), nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_containers.go#L1423-L1457
|
func (r *ProtocolLXD) GetContainerLogfile(name string, filename string) (io.ReadCloser, error) {
// Prepare the HTTP request
url := fmt.Sprintf("%s/1.0/containers/%s/logs/%s", r.httpHost, url.QueryEscape(name), url.QueryEscape(filename))
url, err := r.setQueryAttributes(url)
if err != nil {
return nil, err
}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
// Set the user agent
if r.httpUserAgent != "" {
req.Header.Set("User-Agent", r.httpUserAgent)
}
// Send the request
resp, err := r.do(req)
if err != nil {
return nil, err
}
// Check the return value for a cleaner error
if resp.StatusCode != http.StatusOK {
_, _, err := lxdParseResponse(resp)
if err != nil {
return nil, err
}
}
return resp.Body, err
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/image/docker_list.go#L83-L94
|
func ChooseManifestInstanceFromManifestList(ctx context.Context, sys *types.SystemContext, src types.UnparsedImage) (digest.Digest, error) {
// For now this only handles manifest.DockerV2ListMediaType; we can generalize it later,
// probably along with manifest list editing.
blob, mt, err := src.Manifest(ctx)
if err != nil {
return "", err
}
if mt != manifest.DockerV2ListMediaType {
return "", fmt.Errorf("Internal error: Trying to select an image from a non-manifest-list manifest type %s", mt)
}
return chooseDigestFromManifestList(sys, blob)
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L145-L163
|
func (a *PodLogArtifact) ReadTail(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log tail: %v", err)
}
size := int64(len(logs))
var off int64
if n > size {
off = 0
} else {
off = size - n
}
p := make([]byte, n)
readBytes, err := bytes.NewReader(logs).ReadAt(p, off)
if err != nil && err != io.EOF {
return nil, fmt.Errorf("error reading pod log tail: %v", err)
}
return p[:readBytes], nil
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L673-L688
|
func (c *ClusterTx) ProfileRename(project string, name string, to string) error {
stmt := c.stmt(profileRename)
result, err := stmt.Exec(to, project, name)
if err != nil {
return errors.Wrap(err, "Rename profile")
}
n, err := result.RowsAffected()
if err != nil {
return errors.Wrap(err, "Fetch affected rows")
}
if n != 1 {
return fmt.Errorf("Query affected %d rows instead of 1", n)
}
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/applicationcache/easyjson.go#L1040-L1044
|
func (v ApplicationCache) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoApplicationcache11(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
|
https://github.com/giantswarm/certctl/blob/2a6615f61499cd09a8d5ced9a5fade322d2de254/service/cert-signer/cert_signer.go#L24-L38
|
func DefaultConfig() Config {
newClientConfig := vaultclient.DefaultConfig()
newClientConfig.Address = "http://127.0.0.1:8200"
newVaultClient, err := vaultclient.NewClient(newClientConfig)
if err != nil {
panic(err)
}
newConfig := Config{
// Dependencies.
VaultClient: newVaultClient,
}
return newConfig
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/overlay.go#L221-L224
|
func (p HighlightQuadParams) WithOutlineColor(outlineColor *cdp.RGBA) *HighlightQuadParams {
p.OutlineColor = outlineColor
return &p
}
|
https://github.com/rlmcpherson/s3gof3r/blob/864ae0bf7cf2e20c0002b7ea17f4d84fec1abc14/putter.go#L399-L401
|
func growPartSize(partIndex int, partSize, putsz int64) bool {
return (maxObjSize-putsz)/(maxNPart-int64(partIndex)) > partSize
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/runtime.go#L674-L676
|
func (p *ReleaseObjectGroupParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandReleaseObjectGroup, p, nil)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/cast/easyjson.go#L223-L227
|
func (v *SetSinkToUseParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoCast2(&r, v)
return r.Error()
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/profiles.go#L41-L81
|
func profilesGet(d *Daemon, r *http.Request) Response {
project := projectParam(r)
recursion := util.IsRecursionRequest(r)
var result interface{}
err := d.cluster.Transaction(func(tx *db.ClusterTx) error {
hasProfiles, err := tx.ProjectHasProfiles(project)
if err != nil {
return errors.Wrap(err, "Check project features")
}
if !hasProfiles {
project = "default"
}
filter := db.ProfileFilter{
Project: project,
}
if recursion {
profiles, err := tx.ProfileList(filter)
if err != nil {
return err
}
apiProfiles := make([]*api.Profile, len(profiles))
for i, profile := range profiles {
apiProfiles[i] = db.ProfileToAPI(&profile)
}
result = apiProfiles
} else {
result, err = tx.ProfileURIs(filter)
}
return err
})
if err != nil {
return SmartError(err)
}
return SyncResponse(true, result)
}
|
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/pfs.go#L130-L135
|
func IsCommitFinishedErr(err error) bool {
if err == nil {
return false
}
return commitFinishedRe.MatchString(grpcutil.ScrubGRPC(err).Error())
}
|
https://github.com/mattn/go-xmpp/blob/6093f50721ed2204a87a81109ca5a466a5bec6c1/xmpp_muc.go#L132-L135
|
func (c *Client) LeaveMUC(jid string) (n int, err error) {
return fmt.Fprintf(c.conn, "<presence from='%s' to='%s' type='unavailable' />",
c.jid, xmlEscape(jid))
}
|
https://github.com/piotrkowalczuk/mnemosyne/blob/66d59c3c5b886e8e869915bb76257bcba4a47250/internal/storage/storagemock/instrumented_storage.go#L114-L134
|
func (_m *InstrumentedStorage) List(_a0 context.Context, _a1 int64, _a2 int64, _a3 *time.Time, _a4 *time.Time) ([]*mnemosynerpc.Session, error) {
ret := _m.Called(_a0, _a1, _a2, _a3, _a4)
var r0 []*mnemosynerpc.Session
if rf, ok := ret.Get(0).(func(context.Context, int64, int64, *time.Time, *time.Time) []*mnemosynerpc.Session); ok {
r0 = rf(_a0, _a1, _a2, _a3, _a4)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*mnemosynerpc.Session)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, int64, int64, *time.Time, *time.Time) error); ok {
r1 = rf(_a0, _a1, _a2, _a3, _a4)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
|
https://github.com/libp2p/go-libp2p-pubsub/blob/9db3dbdde90f44d1c420192c5cefd60682fbdbb9/pubsub.go#L272-L277
|
func WithBlacklist(b Blacklist) Option {
return func(p *PubSub) error {
p.blacklist = b
return nil
}
}
|
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/functions_client.go#L125-L136
|
func (c *Functions) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
c.Apps.SetTransport(transport)
c.Routes.SetTransport(transport)
c.Tasks.SetTransport(transport)
c.Version.SetTransport(transport)
}
|
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_containers.go#L42-L52
|
func (r *ProtocolLXD) GetContainers() ([]api.Container, error) {
containers := []api.Container{}
// Fetch the raw value
_, err := r.queryStruct("GET", "/containers?recursion=1", nil, "", &containers)
if err != nil {
return nil, err
}
return containers, nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/target/easyjson.go#L2220-L2224
|
func (v *CreateBrowserContextParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget25(&r, v)
return r.Error()
}
|
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/hyperbahn/utils.go#L31-L38
|
func intToIP4(ip uint32) net.IP {
return net.IP{
byte(ip >> 24 & 0xff),
byte(ip >> 16 & 0xff),
byte(ip >> 8 & 0xff),
byte(ip & 0xff),
}
}
|
https://github.com/onsi/gomega/blob/f0e010e04c08c48a875f83d17df37b04eb3a985b/ghttp/handlers.go#L134-L141
|
func VerifyJSONRepresenting(object interface{}) http.HandlerFunc {
data, err := json.Marshal(object)
Expect(err).ShouldNot(HaveOccurred())
return CombineHandlers(
VerifyContentType("application/json"),
VerifyJSON(string(data)),
)
}
|
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/ostree/ostree_transport.go#L185-L197
|
func (ref ostreeReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
var tmpDir string
if sys == nil || sys.OSTreeTmpDirPath == "" {
tmpDir = os.TempDir()
} else {
tmpDir = sys.OSTreeTmpDirPath
}
src, err := newImageSource(tmpDir, ref)
if err != nil {
return nil, err
}
return image.FromSource(ctx, sys, src)
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L5903-L5907
|
func (v *EventFrameResized) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage62(&r, v)
return r.Error()
}
|
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/dry_run_client.go#L80-L84
|
func (c *dryRunProwJobClient) List(opts metav1.ListOptions) (*prowapi.ProwJobList, error) {
var jl prowapi.ProwJobList
err := c.request("/prowjobs.js", map[string]string{"labelSelector": opts.LabelSelector}, &jl)
return &jl, err
}
|
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/asset.go#L93-L145
|
func (a Asset) Extract(typ interface{}, code interface{}, issuer interface{}) error {
switch typ := typ.(type) {
case *AssetType:
*typ = a.Type
case *string:
switch a.Type {
case AssetTypeAssetTypeNative:
*typ = "native"
case AssetTypeAssetTypeCreditAlphanum4:
*typ = "credit_alphanum4"
case AssetTypeAssetTypeCreditAlphanum12:
*typ = "credit_alphanum12"
}
default:
return errors.New("can't extract type")
}
if code != nil {
switch code := code.(type) {
case *string:
switch a.Type {
case AssetTypeAssetTypeCreditAlphanum4:
an := a.MustAlphaNum4()
*code = strings.TrimRight(string(an.AssetCode[:]), "\x00")
case AssetTypeAssetTypeCreditAlphanum12:
an := a.MustAlphaNum12()
*code = strings.TrimRight(string(an.AssetCode[:]), "\x00")
}
default:
return errors.New("can't extract code")
}
}
if issuer != nil {
switch issuer := issuer.(type) {
case *string:
switch a.Type {
case AssetTypeAssetTypeCreditAlphanum4:
an := a.MustAlphaNum4()
raw := an.Issuer.MustEd25519()
*issuer = strkey.MustEncode(strkey.VersionByteAccountID, raw[:])
case AssetTypeAssetTypeCreditAlphanum12:
an := a.MustAlphaNum12()
raw := an.Issuer.MustEd25519()
*issuer = strkey.MustEncode(strkey.VersionByteAccountID, raw[:])
}
default:
return errors.New("can't extract issuer")
}
}
return nil
}
|
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L275-L278
|
func (p EnableParams) WithMaxPostDataSize(maxPostDataSize int64) *EnableParams {
p.MaxPostDataSize = maxPostDataSize
return &p
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.