query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Truth implements the starlark.Value.Truth() method.
func (s *Sub) Truth() starlark.Bool { return s == nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func truth(r reflect.Value) bool {\nout:\n\tswitch r.Kind() {\n\tcase reflect.Array, reflect.Slice:\n\t\treturn r.Len() > 0\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn r.Int() > 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\...
[ "0.630129", "0.60790426", "0.60114306", "0.58849615", "0.58371353", "0.580668", "0.577208", "0.57663786", "0.5739403", "0.5739189", "0.57298344", "0.5705361", "0.5696912", "0.56952465", "0.5692787", "0.56886774", "0.5669468", "0.56679356", "0.5640828", "0.56307244", "0.561750...
0.53146994
43
Hash32 implements the Arg.Hash32() method.
func (s *Sub) Hash32(h hash.Hash32) { h.Write([]byte(s.Format)) for _, sub := range s.Substitutions { h.Write([]byte(sub.Key)) sub.Value.Hash32(h) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p Path) Hash32(h hash.Hash32) { h.Write([]byte(p)) }", "func (t *Target) Hash32(h hash.Hash32) {\n\th.Write([]byte(t.Name))\n\th.Write([]byte(t.Builder))\n\tfor _, arg := range t.Args {\n\t\targ.Hash32(h)\n\t}\n\tfor _, env := range t.Env {\n\t\th.Write([]byte(env))\n\t}\n}", "func CalcHash32(data []byte...
[ "0.75116545", "0.74907047", "0.7268526", "0.7188452", "0.6985214", "0.673352", "0.6720558", "0.6719553", "0.6649225", "0.66212195", "0.6579969", "0.6577231", "0.65532845", "0.6546386", "0.6525872", "0.6499919", "0.64648885", "0.6464478", "0.64486724", "0.6393531", "0.6317038"...
0.68938047
5
Hash implements the starlark.Value.Hash() method.
func (s *Sub) Hash() (uint32, error) { h := adler32.New() s.Hash32(h) return h.Sum32(), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Hash(value int64) uint64 {\n\treturn FNVHash64(uint64(value))\n}", "func (n *SoupNode) Hash() (uint32, error) {\n\treturn hashString(fmt.Sprintf(\"%v\", *n)), nil\n}", "func (o *ObjectIndex) Hash() uint32 {\n\tvar h uint32 = 17\n\n\tvar str string\n\tstr += fmt.Sprintf(\"%08x\", o.machine)\n\tstr += fmt.S...
[ "0.7138284", "0.7119623", "0.7041903", "0.700204", "0.7000892", "0.69765645", "0.6946901", "0.69159335", "0.69111687", "0.6884624", "0.68813616", "0.6854573", "0.6839519", "0.68087643", "0.68017894", "0.6779525", "0.6749075", "0.67478395", "0.6744907", "0.6727617", "0.6685133...
0.6391269
69
Freeze implements the starlark.Value.Freeze() method.
func (s *Sub) Freeze() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (i *Index) Freeze() {\n\ti.frozen = true\n}", "func (p *Poly) freeze() {\n\tfor i := 0; i < n; i++ {\n\t\tp[i] = freeze(p[i])\n\t}\n}", "func freeze(o *goja.Object) {\n\tfor _, key := range o.Keys() {\n\t\to.DefineDataProperty(key, o.Get(key), goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_TRUE)\n\t}\n}", ...
[ "0.629121", "0.61709946", "0.6089411", "0.60298693", "0.59620976", "0.5877203", "0.58217835", "0.57199144", "0.5709729", "0.5635698", "0.5491367", "0.5444173", "0.5394565", "0.5366694", "0.53647643", "0.5217478", "0.5201497", "0.5199691", "0.5163645", "0.5118248", "0.5094646"...
0.536854
13
starlarkSub parses Starlark kw/args and returns a corresponding `Sub` wrapped in a `starlark.Value` interface. This is used in the `sub()` starlark predefined/builtin function.
func starlarkSub( args starlark.Tuple, kwargs []starlark.Tuple, ) (starlark.Value, error) { // Expect exactly one positional argument, which represents the format // string. if len(args) != 1 { return nil, errors.Errorf( "Expected 1 positional argument 'format'; found %d", len(args), ) } // Validate that the positional argument is a string. format, ok := args[0].(starlark.String) if !ok { return nil, errors.Errorf( "TypeError: Expected argument 'format' has type str; found %s", args[0].Type(), ) } // Treat the keyword arguments as substitutions, including parsing their // values into `Arg`s. substitutions := make([]Substitution, len(kwargs)) for i, kwarg := range kwargs { value, err := starlarkValueToArg(kwarg[1]) if err != nil { return nil, err } substitutions[i] = Substitution{ Key: string(kwarg[0].(starlark.String)), Value: value, } } // TODO: Error if there are substitution placeholders in the format string // (e.g., `${Foo}`) for which there are no corresponding substitutions. // This is particularly important since the placeholder syntax is valid // bash, for example, if the placeholder is `${PATH}`, it would resolve at // runtime to the PATH env var, which would be a different down-the-road // error if it errored at all. // Build and return the resulting `*Sub` structure. return &Sub{Format: string(format), Substitutions: substitutions}, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n Name) Sub(v string) Name {\n\treturn n.WithType(v)\n}", "func (p *Parser) sub() {\n\tp.primary()\n\tp.emitByte(OP_SUB)\n}", "func Sub(a, b Expr) Expr {\n\treturn &subOp{&simpleOperator{a, b, scanner.SUB}}\n}", "func TestSub(t *testing.T) {\n\tfmt.Println(Sub(2,1))\n}", "func Command_Sub(script *rex...
[ "0.6531688", "0.6498178", "0.64098775", "0.6193627", "0.6166976", "0.6087103", "0.6056032", "0.59578586", "0.595171", "0.5871515", "0.5805317", "0.57967633", "0.5778368", "0.5746251", "0.5745691", "0.56985414", "0.56848735", "0.5681427", "0.5592972", "0.55728865", "0.55671126...
0.8053445
0
Target Type implements the starlark.Value.Type() method.
func (t *Target) Type() string { return "Target" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (value *Value) Type() Type {\n\treturn value.valueType\n}", "func (v *Value) Type() kiwi.ValueType {\n\treturn Type\n}", "func Type(value r.Value) r.Type {\n\tif !value.IsValid() || value == None {\n\t\treturn nil\n\t}\n\treturn value.Type()\n}", "func (v Value) Type() Type {\n\treturn v.Typ\n}", "fun...
[ "0.73556316", "0.71396637", "0.7072174", "0.6967342", "0.6960471", "0.69291276", "0.6924051", "0.6897344", "0.68691295", "0.68479174", "0.6796867", "0.6757388", "0.67203116", "0.67153203", "0.6670047", "0.6608092", "0.65924406", "0.6568637", "0.6563142", "0.6554397", "0.65338...
0.65105665
22
Freeze implements the starlark.Value.Freeze() method.
func (t *Target) Freeze() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (i *Index) Freeze() {\n\ti.frozen = true\n}", "func (p *Poly) freeze() {\n\tfor i := 0; i < n; i++ {\n\t\tp[i] = freeze(p[i])\n\t}\n}", "func freeze(o *goja.Object) {\n\tfor _, key := range o.Keys() {\n\t\to.DefineDataProperty(key, o.Get(key), goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_TRUE)\n\t}\n}", ...
[ "0.629121", "0.61709946", "0.6089411", "0.60298693", "0.59620976", "0.58217835", "0.57199144", "0.5709729", "0.5635698", "0.5491367", "0.5444173", "0.5394565", "0.536854", "0.5366694", "0.53647643", "0.5217478", "0.5201497", "0.5199691", "0.5163645", "0.5118248", "0.5094646",...
0.5877203
5
Truth implements the starlark.Value.Truth() method.
func (t *Target) Truth() starlark.Bool { return starlark.Bool(t == nil) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func truth(r reflect.Value) bool {\nout:\n\tswitch r.Kind() {\n\tcase reflect.Array, reflect.Slice:\n\t\treturn r.Len() > 0\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn r.Int() > 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\...
[ "0.6302526", "0.6080101", "0.60129184", "0.58864635", "0.5808124", "0.57730013", "0.5767958", "0.5739565", "0.57394236", "0.57306063", "0.5705854", "0.569673", "0.5695482", "0.56939113", "0.5689309", "0.56702256", "0.5668591", "0.5640195", "0.5632629", "0.561903", "0.5585214"...
0.58375704
4
Hash32 implements the Arg.Hash32() method.
func (t *Target) Hash32(h hash.Hash32) { h.Write([]byte(t.Name)) h.Write([]byte(t.Builder)) for _, arg := range t.Args { arg.Hash32(h) } for _, env := range t.Env { h.Write([]byte(env)) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p Path) Hash32(h hash.Hash32) { h.Write([]byte(p)) }", "func CalcHash32(data []byte) Hash32 {\n\treturn hash.Sum(data)\n}", "func (s String) Hash32(h hash.Hash32) { h.Write([]byte(s)) }", "func HexToHash32(s string) Hash32 { return BytesToHash(util.FromHex(s)) }", "func (s *Sub) Hash32(h hash.Hash32)...
[ "0.7513112", "0.72715765", "0.7190082", "0.6986059", "0.68957806", "0.67351377", "0.67205036", "0.67193633", "0.6649574", "0.6621809", "0.65809476", "0.6579308", "0.65534127", "0.6548068", "0.65251803", "0.6501993", "0.64664733", "0.6466416", "0.64491963", "0.6394227", "0.631...
0.7491727
1
Hash implements the starlark.Value.Hash() method.
func (t *Target) Hash() (uint32, error) { h := adler32.New() t.Hash32(h) return h.Sum32(), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Hash(value int64) uint64 {\n\treturn FNVHash64(uint64(value))\n}", "func (n *SoupNode) Hash() (uint32, error) {\n\treturn hashString(fmt.Sprintf(\"%v\", *n)), nil\n}", "func (o *ObjectIndex) Hash() uint32 {\n\tvar h uint32 = 17\n\n\tvar str string\n\tstr += fmt.Sprintf(\"%08x\", o.machine)\n\tstr += fmt.S...
[ "0.71392304", "0.7118988", "0.70433563", "0.70033073", "0.7000457", "0.69771796", "0.6946999", "0.69167256", "0.6911272", "0.6885437", "0.6881275", "0.6854698", "0.6839323", "0.6808889", "0.6802325", "0.67797977", "0.6749414", "0.6748137", "0.6745063", "0.67278856", "0.668532...
0.0
-1
starlarkTarget parses Starlark kw/args and returns a corresponding `Target` wrapped in a `starlark.Value` interface. This is used in the `target()` starlark predefined/builtin function.
func starlarkTarget( args starlark.Tuple, kwargs []starlark.Tuple, ) (starlark.Value, error) { // For the sake of simpler parsing, we'll simply require that all args are // passed as kwargs (no positional args). if len(args) != 0 { return nil, errors.Errorf( "Expected 0 positional args; found %d", len(args), ) } // Make sure we have exactly the right number of keyword arguments. if len(kwargs) != 4 { found := make([]string, len(kwargs)) for i, kwarg := range kwargs { found[i] = string(kwarg[0].(starlark.String)) } return nil, errors.Errorf( "Expected kwargs {name, builder, args, env}; found {%s}", strings.Join(found, ", "), ) } // Iterate through the keyword arguments and grab the values for each // kwarg, putting them into the right `starlark.Value` variable. We'll // convert these to Go values for the `*Target` struct later. var nameKwarg, builderKwarg, argsKwarg, envKwarg starlark.Value for _, kwarg := range kwargs { switch key := kwarg[0].(starlark.String); key { case "name": if nameKwarg != nil { return nil, errors.Errorf("Duplicate argument 'name' found") } nameKwarg = kwarg[1] case "builder": if builderKwarg != nil { return nil, errors.Errorf("Duplicate argument 'builder' found") } builderKwarg = kwarg[1] case "args": if argsKwarg != nil { return nil, errors.Errorf("Duplicate argument 'args' found") } argsKwarg = kwarg[1] case "env": if envKwarg != nil { return nil, errors.Errorf("Duplicate argument 'env' found") } envKwarg = kwarg[1] default: return nil, errors.Errorf("Unexpected argument '%s' found", key) } } // Ok, now we've made sure we have values for the required keyword args and // that no additional arguments were passed. Next, we'll convert these // `starlark.Value`-typed variables into Go values for the output `*Target` // struct. // Validate that the `name` kwarg was a string. name, ok := nameKwarg.(starlark.String) if !ok { return nil, errors.Errorf( "TypeError: argument 'name': expected str, got %s", nameKwarg.Type(), ) } // Validate that the `builder` kwarg was a string. builder, ok := builderKwarg.(starlark.String) if !ok { return nil, errors.Errorf( "TypeError: argument 'builder': expected str, got %s", builderKwarg.Type(), ) } // Validate that the `args` kwarg was a list of `Arg`s, and convert it // into a `[]Arg` for the `Target.Args` field. argsSL, ok := argsKwarg.(*starlark.List) if !ok { return nil, errors.Errorf( "TypeError: argument 'args': expected list, got %s", argsKwarg.Type(), ) } args_ := make([]Arg, argsSL.Len()) for i := range args_ { arg, err := starlarkValueToArg(argsSL.Index(i)) if err != nil { return nil, errors.Wrapf(err, "Argument 'args[%d]'", i) } args_[i] = arg } // Validate that the `env` kwarg was a list of strings, and convert it into // a `[]string` for the `Target.Env` field. envSL, ok := envKwarg.(*starlark.List) if !ok { return nil, errors.Errorf( "TypeError: argument 'env': expected list, got %s", envKwarg.Type(), ) } env := make([]string, envSL.Len()) for i := range env { str, ok := envSL.Index(i).(starlark.String) if !ok { return nil, errors.Errorf( "TypeError: argument 'env[%d]': expected string; found %s", i, envSL.Index(i).Type(), ) } env[i] = string(str) } // By now, all of the fields have been validated, so build and return the // final `*Target`. return &Target{ Name: string(name), Builder: string(builder), Args: args_, Env: env, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewTarget(path string, kvstore store.Store, log *zap.Logger) *Target {\n\t// make sure we have a trailing slash for trimming future updates\n\tif !strings.HasSuffix(path, \"/\") {\n\t\tpath = path + \"/\"\n\t}\n\n\teventTypePathWatcher := NewWatcher(path+\"eventtypes\", kvstore, log)\n\tfunctionPathWatcher :=...
[ "0.5902927", "0.58842", "0.57345617", "0.57153326", "0.56635815", "0.55738866", "0.5407274", "0.538354", "0.5329738", "0.5271659", "0.524852", "0.5237572", "0.51851034", "0.51704633", "0.5164845", "0.513546", "0.5122503", "0.50363517", "0.5035169", "0.50017464", "0.49984995",...
0.78945357
0
Arg starlarkValueToArg takes a starlark value and parses it into an `Arg`.
func starlarkValueToArg(v starlark.Value) (Arg, error) { switch x := v.(type) { case Arg: return x, nil case starlark.String: return String(x), nil default: return nil, errors.Errorf( "Cannot convert %s into a target argument", v.Type(), ) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ToArg(name, value string) string {\n\treturn name + \"=\" + value\n}", "func FromArg(arg string) (key, value string) {\n\tparts := strings.Split(arg, \"=\")\n\tif len(parts) == 1 {\n\t\treturn parts[0], \"\"\n\t}\n\treturn parts[0], parts[1]\n}", "func decodeArg(b *hcl.Block) (*Arg, errors.Error) {\n\targ...
[ "0.67139906", "0.59568244", "0.5797127", "0.56927204", "0.54258233", "0.539884", "0.5369455", "0.5281497", "0.52350473", "0.5182523", "0.51327753", "0.51287955", "0.51077867", "0.5093113", "0.5079938", "0.50655216", "0.50646305", "0.5059002", "0.5046095", "0.5002434", "0.4975...
0.88156927
0
execFile builtinWrapper DRYs up the error handling boilerplate for a starlark builtin function.
func builtinWrapper( name string, f func(starlark.Tuple, []starlark.Tuple) (starlark.Value, error), ) *starlark.Builtin { return starlark.NewBuiltin( name, func( _ *starlark.Thread, builtin *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple, ) (starlark.Value, error) { v, err := f(args, kwargs) if err != nil { return nil, errors.Wrapf(err, "%s()", builtin.Name()) } return v, nil }, ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ExecWrapper(f func(ctx *cli.Context) (int, error)) func(*cli.Context) error {\n\treturn func(ctx *cli.Context) error {\n\t\treturn exit(f(ctx))\n\t}\n}", "func runWrapper(cf func(cCmd *cobra.Command, args []string) (exit int)) func(cCmd *cobra.Command, args []string) {\n\treturn func(cCmd *cobra.Command, ar...
[ "0.61863595", "0.5779893", "0.5621438", "0.5595492", "0.5352558", "0.5321938", "0.5251699", "0.5250164", "0.51723653", "0.5156635", "0.51070184", "0.49635878", "0.49388602", "0.49287337", "0.4891345", "0.48601392", "0.4854314", "0.48532167", "0.48241422", "0.4801963", "0.4800...
0.47201166
27
makeLoader makes a load function for a given workspace.
func makeLoader(root string, packages map[string]string) loadFunc { return makeLoaderHelper( root, packages, map[string]*cacheEntry{}, starlark.StringDict{ "target": builtinWrapper("target", starlarkTarget), "sub": builtinWrapper("sub", starlarkSub), "path": builtinWrapper("path", starlarkPath), "glob": builtinWrapper("glob", starlarkGlob), }, ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func makeLoad(workingDir string) func(thread *starlark.Thread, module string) (starlark.StringDict, error) {\n\tf := repl.MakeLoad()\n\n\treturn func(thread *starlark.Thread, module string) (starlark.StringDict, error) {\n\t\t// To ensure config generation is hermetic we require that all loads specify a module\n\t...
[ "0.69174427", "0.60957247", "0.59598404", "0.57971555", "0.57845634", "0.568306", "0.567531", "0.56747866", "0.55498624", "0.55395716", "0.5537143", "0.55357504", "0.5530393", "0.5469123", "0.5450717", "0.54438096", "0.5430167", "0.5402078", "0.5357989", "0.53470635", "0.5337...
0.71230793
0
execModule executes a module using a given load function and returns the global variables.
func execModule(module string, load loadFunc) (starlark.StringDict, error) { return load(&starlark.Thread{Name: module, Load: load}, module) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func load(thread *starlark.Thread, module string) (starlark.StringDict, error) {\n\tif module == \"assert.star\" {\n\t\treturn starlarktest.LoadAssertModule()\n\t}\n\tif module == \"json.star\" {\n\t\treturn starlark.StringDict{\"json\": json.Module}, nil\n\t}\n\tif module == \"time.star\" {\n\t\treturn starlark.S...
[ "0.6671755", "0.6127695", "0.5694249", "0.56766814", "0.5612139", "0.53410804", "0.53085107", "0.5287491", "0.52582955", "0.5238143", "0.5232927", "0.5205424", "0.520263", "0.520205", "0.51830554", "0.51718724", "0.51359785", "0.5128875", "0.51054287", "0.5056298", "0.5049403...
0.8102706
0
NewHelm creates a new helm.
func NewHelm(namespace, repoFile, repoCache string) (*Helm, error) { configFlags := genericclioptions.NewConfigFlags(true) configFlags.Namespace = commonutil.String(namespace) kubeClient := kube.New(configFlags) cfg := &action.Configuration{ KubeClient: kubeClient, Log: func(s string, i ...interface{}) { logrus.Debugf(s, i) }, RESTClientGetter: configFlags, } helmDriver := "" settings := cli.New() settings.Debug = true // set namespace namespacePtr := (*string)(unsafe.Pointer(settings)) *namespacePtr = namespace settings.RepositoryConfig = repoFile settings.RepositoryCache = repoCache // initializes the action configuration if err := cfg.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, func(format string, v ...interface{}) { logrus.Debugf(format, v) }); err != nil { return nil, errors.Wrap(err, "init config") } return &Helm{ cfg: cfg, settings: settings, namespace: namespace, repoFile: repoFile, repoCache: repoCache, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *FakeHelms) Create(helm *v1alpha1.Helm) (result *v1alpha1.Helm, err error) {\n\tobj, err := c.Fake.\n\t\tInvokes(testing.NewCreateAction(helmsResource, c.ns, helm), &v1alpha1.Helm{})\n\n\tif obj == nil {\n\t\treturn nil, err\n\t}\n\treturn obj.(*v1alpha1.Helm), err\n}", "func (f *factory) CreateHelm(verb...
[ "0.6999746", "0.6987181", "0.6503738", "0.6433711", "0.60241", "0.5954915", "0.5873086", "0.57610524", "0.57160705", "0.55597526", "0.54564774", "0.54285806", "0.536348", "0.52476436", "0.52340335", "0.52292144", "0.5156951", "0.51407623", "0.5129945", "0.5086342", "0.5061586...
0.739738
0
Load loads the chart from the repository.
func (h *Helm) Load(chart, version string) (string, error) { return h.locateChart(chart, version) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *Worker) loadChart(u string) (*chart.Chart, error) {\n\t// Rate limit requests to Github to avoid them being rejected\n\tif strings.HasPrefix(u, \"https://github.com\") {\n\t\t_ = w.rl.Wait(w.ctx)\n\t}\n\n\tresp, err := w.hg.Get(u)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\t...
[ "0.69401693", "0.67860025", "0.6667731", "0.6296958", "0.6224137", "0.6205097", "0.6203969", "0.60339326", "0.6005427", "0.5969782", "0.5926162", "0.59133786", "0.5887185", "0.58507466", "0.5789335", "0.5752358", "0.5750637", "0.57266945", "0.56851685", "0.56775224", "0.56714...
0.71347237
0
LocateChart looks for a chart directory in known places, and returns either the full path or an error.
func (c *ChartPathOptions) LocateChart(name, dest string, settings *cli.EnvSettings) (string, error) { name = strings.TrimSpace(name) version := strings.TrimSpace(c.Version) if _, err := os.Stat(name); err == nil { abs, err := filepath.Abs(name) if err != nil { return abs, err } if c.Verify { if _, err := downloader.VerifyChart(abs, c.Keyring); err != nil { return "", err } } return abs, nil } if filepath.IsAbs(name) || strings.HasPrefix(name, ".") { return name, errors.Errorf("path %q not found", name) } dl := downloader.ChartDownloader{ Out: os.Stdout, Keyring: c.Keyring, Getters: getter.All(settings), Options: []getter.Option{ getter.WithBasicAuth(c.Username, c.Password), getter.WithTLSClientConfig(c.CertFile, c.KeyFile, c.CaFile), getter.WithInsecureSkipVerifyTLS(c.InsecureSkipTLSverify), }, RepositoryConfig: settings.RepositoryConfig, RepositoryCache: settings.RepositoryCache, } if c.Verify { dl.Verify = downloader.VerifyAlways } if c.RepoURL != "" { chartURL, err := repo.FindChartInAuthAndTLSRepoURL(c.RepoURL, c.Username, c.Password, name, version, c.CertFile, c.KeyFile, c.CaFile, c.InsecureSkipTLSverify, getter.All(settings)) if err != nil { return "", err } name = chartURL } if err := os.MkdirAll(dest, 0755); err != nil { return "", err } filename, _, err := dl.DownloadTo(name, version, dest) if err == nil { lname, err := filepath.Abs(filename) if err != nil { return filename, err } return lname, nil } else if settings.Debug { return filename, err } atVersion := "" if version != "" { atVersion = fmt.Sprintf(" at version %q", version) } return filename, errors.Errorf("failed to download %q%s (hint: running `helm repo update` may help)", name, atVersion) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (string, error) {\n\tf, err := repo.LoadFile(settings.RepositoryConfig)\n\tif err != nil || len(f.Repositories) == 0 {\n\t\treturn \"\", errors.Wrap(err, \"no repositories exist, need to add repo first\")\n\t}\n\n\te := f.Get(name)\n\ti...
[ "0.70844996", "0.6769755", "0.6639266", "0.64382845", "0.57238185", "0.5674744", "0.5130903", "0.48895267", "0.47821742", "0.46471423", "0.45921183", "0.45472524", "0.4545822", "0.45397443", "0.4526204", "0.45089817", "0.44530502", "0.44410527", "0.44367608", "0.44095662", "0...
0.7282314
0
checkIfInstallable validates if a chart can be installed Application chart type is only installable
func checkIfInstallable(ch *chart.Chart) error { switch ch.Metadata.Type { case "", "application": return nil } return errors.Errorf("%s charts are not installable", ch.Metadata.Type) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckIfInstallable(chart *chart.Chart) error {\n\tswitch chart.Metadata.Type {\n\tcase \"\", \"application\":\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"chart %s is %s, which is not installable\", chart.Name(), chart.Metadata.Type)\n}", "func isChartInstallable(ch *chart.Chart) (bool, error) {\n\tswitch ch...
[ "0.8497044", "0.8475372", "0.84579355", "0.55881405", "0.55528826", "0.55100256", "0.538975", "0.5382915", "0.53009117", "0.5276605", "0.524784", "0.52017456", "0.5199999", "0.5159729", "0.5140767", "0.5136497", "0.5108067", "0.50813764", "0.50802505", "0.50696635", "0.506718...
0.8658139
1
Deprecated: Use ResponseListUnacceptedAgreements.ProtoReflect.Descriptor instead.
func (*ResponseListUnacceptedAgreements) Descriptor() ([]byte, []int) { return file_response_list_unaccepted_agreements_proto_rawDescGZIP(), []int{0} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (*RequestListUnacceptedAgreements) Descriptor() ([]byte, []int) {\n\treturn file_request_list_unaccepted_agreements_proto_rawDescGZIP(), []int{0}\n}", "func (*Deprecation) Descriptor() ([]byte, []int) {\n\treturn file_external_cfgmgmt_response_nodes_proto_rawDescGZIP(), []int{8}\n}", "func (*ListResponse)...
[ "0.7459947", "0.7196085", "0.6830965", "0.6802951", "0.67783093", "0.6766362", "0.6758622", "0.6717443", "0.67119855", "0.66959614", "0.6670385", "0.6667114", "0.6666535", "0.66533613", "0.66446245", "0.6638348", "0.6633417", "0.66304475", "0.66287714", "0.66228986", "0.66134...
0.75362694
0
Parse the given text into a Vault instance
func Parse(urlText string) (Vault, error) { result, ok := factory.Load(urlText) if ok { return result.(Vault), nil } u, err := url.Parse(urlText) if err != nil { return nil, err } if u.Scheme == "" { return nil, fmt.Errorf("url scheme is empty in secret.Parse(%q)", urlText) } switch u.Scheme { case "env": vault, newVaultErr := newEnvVault(u.Hostname()) if newVaultErr != nil { return nil, newVaultErr } factory.Store(urlText, vault) return vault, nil case "passwd": vault := &passPhraseVault{passPhrase: u.Hostname()} factory.Store(urlText, vault) return vault, nil case "plain": return plainTextVault, nil default: return nil, fmt.Errorf("Unable to handle unknown scheme %q in %q", u.Scheme, u.String()) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Parse(bytes []byte) (*List, error) {\n\tl := NewList(\"temp\")\n\terr := l.UnmarshalText(bytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable to read list from text\")\n\t}\n\treturn l, nil\n}", "func Parse(text string) (*Amount, error) {\n\treturn parse(text, \".\")\n}", "func VariantParse(vTyp...
[ "0.52708244", "0.50116503", "0.5001348", "0.4994934", "0.49171442", "0.48933622", "0.48533553", "0.48503506", "0.4802255", "0.47748065", "0.4770923", "0.47427726", "0.47423014", "0.47001228", "0.469821", "0.46816352", "0.46793777", "0.4670426", "0.46670052", "0.46667182", "0....
0.717636
0
EncryptText does not encrypt, just sends the text back as plaintext
func (v nullVault) EncryptText(text string) (string, error) { return text, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func EncryptText(c context.Context, api KMSEncryptAPI, input *kms.EncryptInput) (*kms.EncryptOutput, error) {\n\treturn api.Encrypt(c, input)\n}", "func (v envVault) EncryptText(text string) (string, error) {\n\treturn EncryptText(text, v.passPhrase)\n}", "func Encrypt(text string) (encryptedText string, err e...
[ "0.7409445", "0.73169905", "0.72339696", "0.71382487", "0.7052748", "0.7033361", "0.7011278", "0.7004154", "0.6990545", "0.6978515", "0.6925627", "0.68238705", "0.68125665", "0.6778617", "0.6762621", "0.6718451", "0.6631018", "0.65882", "0.65139467", "0.6424962", "0.63283706"...
0.7360929
1
EncryptText does not decrypt, just sends the text back as plaintext
func (v nullVault) DecryptText(text string) (string, error) { return text, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v nullVault) EncryptText(text string) (string, error) {\n\treturn text, nil\n}", "func (v envVault) EncryptText(text string) (string, error) {\n\treturn EncryptText(text, v.passPhrase)\n}", "func EncryptText(c context.Context, api KMSEncryptAPI, input *kms.EncryptInput) (*kms.EncryptOutput, error) {\n\tr...
[ "0.7439621", "0.7374936", "0.7347353", "0.7344689", "0.71919066", "0.7176597", "0.7122419", "0.70673406", "0.7063164", "0.7062144", "0.704849", "0.69698185", "0.68966174", "0.6873915", "0.6834967", "0.68082905", "0.6718215", "0.6620609", "0.65087587", "0.64910537", "0.6423967...
0.0
-1
String satisfies the stringer interface.
func (v nullVault) String() string { return "plain://text" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s simpleString) String() string { return string(s) }", "func (self StringEqualer) String() string {\n\treturn fmt.Sprintf(\"%s\", self.S)\n}", "func (e Str) String() string {\n\treturn fmt.Sprintf(\"%v\", e)\n}", "func (ms MyString) String() string {\n\treturn fmt.Sprintf(\"%s (%d)\", ms.str, ms.age)\n...
[ "0.785296", "0.77519125", "0.76875526", "0.7563841", "0.7521477", "0.75210935", "0.74137986", "0.7343098", "0.730117", "0.7157921", "0.71560234", "0.7147634", "0.7126233", "0.7075471", "0.70014644", "0.70014644", "0.6991334", "0.6963718", "0.694869", "0.69428533", "0.6929566"...
0.0
-1
EncryptText encrypts text using a passphrase given a specific the env variable
func (v envVault) EncryptText(text string) (string, error) { return EncryptText(text, v.passPhrase) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Encrypt(text string) (string, error) {\n\tencKey := os.Getenv(\"ENC_KEY\")\n\tencIv := os.Getenv(\"ENC_IV\")\n\tkey := []byte(encKey)\n\tiv := []byte(encIv)\n\tplainText := []byte(text)\n\tplainText, err := pad(plainText, aes.BlockSize)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(`plainText: \"%s\" has ...
[ "0.70665914", "0.70411", "0.68006337", "0.654031", "0.62680376", "0.6218339", "0.6185526", "0.6125841", "0.60952836", "0.6045394", "0.60277456", "0.59855455", "0.591568", "0.58814204", "0.5870277", "0.5868782", "0.5843934", "0.58263505", "0.5804144", "0.579921", "0.57987565",...
0.7965842
0
DecryptText decrypts text using a passphrase given a specific the env variable
func (v envVault) DecryptText(text string) (string, error) { return DecryptText(text, v.passPhrase) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v passPhraseVault) DecryptText(text string) (string, error) {\n\treturn DecryptText(text, v.passPhrase)\n}", "func (v nullVault) DecryptText(text string) (string, error) {\n\treturn text, nil\n}", "func Decrypt(encrypted string) (string, error) {\n\tencKey := os.Getenv(\"ENC_KEY\")\n\tencIv := os.Getenv(...
[ "0.7234699", "0.69137406", "0.6902549", "0.65387285", "0.6525023", "0.6429595", "0.640347", "0.63556576", "0.6336738", "0.63160604", "0.62811875", "0.6265322", "0.6233716", "0.6214538", "0.6213949", "0.6190842", "0.61730665", "0.6155986", "0.61488086", "0.61423695", "0.608133...
0.7994236
0
String satisfies the stringer interface.
func (v envVault) String() string { return fmt.Sprintf("env://%s", v.envVarName) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s simpleString) String() string { return string(s) }", "func (self StringEqualer) String() string {\n\treturn fmt.Sprintf(\"%s\", self.S)\n}", "func (e Str) String() string {\n\treturn fmt.Sprintf(\"%v\", e)\n}", "func (ms MyString) String() string {\n\treturn fmt.Sprintf(\"%s (%d)\", ms.str, ms.age)\n...
[ "0.785296", "0.77519125", "0.76875526", "0.7563841", "0.7521477", "0.75210935", "0.74137986", "0.7343098", "0.730117", "0.7157921", "0.71560234", "0.7147634", "0.7126233", "0.7075471", "0.70014644", "0.70014644", "0.6991334", "0.6963718", "0.694869", "0.69428533", "0.6929566"...
0.0
-1
EncryptText encrypts text using a literal passphrase
func (v passPhraseVault) EncryptText(text string) (string, error) { return EncryptText(text, v.passPhrase) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v envVault) EncryptText(text string) (string, error) {\n\treturn EncryptText(text, v.passPhrase)\n}", "func (v nullVault) EncryptText(text string) (string, error) {\n\treturn text, nil\n}", "func EncryptText(c context.Context, api KMSEncryptAPI, input *kms.EncryptInput) (*kms.EncryptOutput, error) {\n\tr...
[ "0.8163001", "0.7622799", "0.71502745", "0.6973949", "0.68114865", "0.6789495", "0.6755763", "0.66825014", "0.66511774", "0.66387105", "0.66051626", "0.6589693", "0.65370107", "0.6518219", "0.6508857", "0.65036595", "0.6472664", "0.6462584", "0.6461147", "0.6448013", "0.63628...
0.79978836
1
DecryptText decrypts text using a literal passphrase
func (v passPhraseVault) DecryptText(text string) (string, error) { return DecryptText(text, v.passPhrase) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v envVault) DecryptText(text string) (string, error) {\n\treturn DecryptText(text, v.passPhrase)\n}", "func (v nullVault) DecryptText(text string) (string, error) {\n\treturn text, nil\n}", "func Decrypt(key []byte, text string) string {\n\tblock, err := aes.NewCipher(key)\n\tif err != nil {\n\t\tpanic(e...
[ "0.8003317", "0.74388397", "0.6872239", "0.6839808", "0.6765011", "0.67559594", "0.6747878", "0.67446476", "0.67008907", "0.6616169", "0.655827", "0.6517725", "0.6478747", "0.6392757", "0.63903934", "0.6389611", "0.63863766", "0.63661957", "0.6324007", "0.6303194", "0.6302665...
0.79779905
1
String satisfies the stringer interface.
func (v passPhraseVault) String() string { return fmt.Sprintf("passwd://%s", v.passPhrase) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s simpleString) String() string { return string(s) }", "func (self StringEqualer) String() string {\n\treturn fmt.Sprintf(\"%s\", self.S)\n}", "func (e Str) String() string {\n\treturn fmt.Sprintf(\"%v\", e)\n}", "func (ms MyString) String() string {\n\treturn fmt.Sprintf(\"%s (%d)\", ms.str, ms.age)\n...
[ "0.7853726", "0.77518994", "0.7688146", "0.756382", "0.7521328", "0.7520502", "0.74145335", "0.73440784", "0.73014796", "0.71584713", "0.71556544", "0.7147776", "0.7126503", "0.70750916", "0.7000625", "0.7000625", "0.6992527", "0.69632035", "0.6949243", "0.6943282", "0.693027...
0.0
-1
GetChanHistory returns slice of messages
func GetChanHistory(tdlibClient *client.Client, chatID int64, fromMessageID int64, toMessageID int64) (messages []*client.Message) { var totalMessages int messagesSet := make(map[int]*client.Message) totalLimit := 99999999999 // Read first message (newest) separetely, because messageReading does not return exactly message - fromMessageId if fromMessageID != 0 { lastMessage, err := tdlibClient.GetMessage(&client.GetMessageRequest{ChatId: chatID, MessageId: fromMessageID}) checkError(err, "Getting chan history") messagesSet[int(lastMessage.Id)] = lastMessage } messageReading: for { fmt.Println("Retriving messages from ", fromMessageID, "..") chanHistory, err := tdlibClient.GetChatHistory(&client.GetChatHistoryRequest{ ChatId: chatID, Limit: 100, OnlyLocal: false, FromMessageId: fromMessageID, }) checkError(err, "Getting chan history") if chanHistory.TotalCount == 0 { break } for _, m := range chanHistory.Messages { if totalLimit > 0 && totalMessages >= totalLimit { break messageReading } // Read to needed MessageID if toMessageID == m.Id { break messageReading } totalMessages++ // Read next set of messages fromMessageID = m.Id messagesSet[int(m.Id)] = m } } messagesIDsSorted := make([]int, 0, len(messagesSet)) for k := range messagesSet { messagesIDsSorted = append(messagesIDsSorted, k) } sort.Ints(messagesIDsSorted) for _, i := range messagesIDsSorted { messages = append(messages, messagesSet[i]) } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func History(ctx context.Context, channelName string) ([]*types.Message, error) {\n\tchannel := getChannel(channelName)\n\tmessages := messagesFromHistory(channel.History)\n\n\treturn messages, nil\n}", "func (e *TarantoolEngine) history(chID ChannelID) (msgs []Message, err error) {\n\tconn, err := e.pool.get()\...
[ "0.7704789", "0.7430112", "0.68845767", "0.6797101", "0.67133385", "0.6681382", "0.6637313", "0.66343653", "0.6592949", "0.6514193", "0.65121716", "0.64886004", "0.64822644", "0.64815116", "0.64676267", "0.6462026", "0.64599144", "0.6439093", "0.6423534", "0.6383649", "0.6373...
0.79167515
0
NewBackend is the exported constructor by which the DEX will import the DCRBackend. The provided context.Context should be cancelled when the DEX application exits. If configPath is an empty string, the backend will attempt to read the settings directly from the dcrd config file in its default system location.
func NewBackend(ctx context.Context, configPath string, logger dex.Logger, network dex.Network) (*DCRBackend, error) { // loadConfig will set fields if defaults are used and set the chainParams // package variable. cfg, err := loadConfig(configPath, network) if err != nil { return nil, err } dcr := unconnectedDCR(ctx, logger) notifications := &rpcclient.NotificationHandlers{ OnBlockConnected: dcr.onBlockConnected, } // When the exported constructor is used, the node will be an // rpcclient.Client. dcr.client, err = connectNodeRPC(cfg.RPCListen, cfg.RPCUser, cfg.RPCPass, cfg.RPCCert, notifications) if err != nil { return nil, err } err = dcr.client.NotifyBlocks() if err != nil { return nil, fmt.Errorf("error registering for block notifications") } dcr.node = dcr.client // Prime the cache with the best block. bestHash, _, err := dcr.client.GetBestBlock() if err != nil { return nil, fmt.Errorf("error getting best block from dcrd: %v", err) } if bestHash != nil { _, err := dcr.getDcrBlock(bestHash) if err != nil { return nil, fmt.Errorf("error priming the cache: %v", err) } } return dcr, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewBackend(conf config.Config) (*Backend, error) {\n\tlog.WithFields(log.Fields{\n\t\t\"event_url\": conf.Backend.Concentratord.EventURL,\n\t\t\"command_url\": conf.Backend.Concentratord.CommandURL,\n\t}).Info(\"backend/concentratord: setting up backend\")\n\n\tb := Backend{\n\t\teventURL: conf.Backend.Co...
[ "0.61432004", "0.59374225", "0.58322126", "0.57158095", "0.5665095", "0.56398", "0.56123394", "0.56093603", "0.5591699", "0.55635166", "0.5289244", "0.5264355", "0.51071537", "0.5102433", "0.50990784", "0.5057625", "0.5029185", "0.50227", "0.5021972", "0.5018889", "0.49942282...
0.6348927
0
InitTxSize is an asset.DEXAsset method that must produce the max size of a standardized atomic swap initialization transaction.
func (btc *DCRBackend) InitTxSize() uint32 { return dexdcr.InitTxSize }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (eth *Backend) InitTxSize() uint32 {\n\treturn eth.initTxSize\n}", "func (eth *Backend) InitTxSizeBase() uint32 {\n\treturn eth.initTxSize\n}", "func BufferInitSize(size int) int {\n\tif size == 0 {\n\t\treturn globalPool.bufferInitSize\n\t}\n\told := globalPool.bufferInitSize\n\tglobalPool.bufferInitSize...
[ "0.74457175", "0.69137216", "0.60836506", "0.5974748", "0.595039", "0.55153656", "0.5464052", "0.5463583", "0.5366341", "0.53545606", "0.52635115", "0.5156961", "0.51507014", "0.5106845", "0.5040854", "0.501315", "0.4976237", "0.49615723", "0.49147668", "0.49116242", "0.48985...
0.73080486
1
BlockChannel creates and returns a new channel on which to receive block updates. If the returned channel is ever blocking, there will be no error logged from the dcr package. Part of the asset.DEXAsset interface.
func (dcr *DCRBackend) BlockChannel(size int) chan uint32 { c := make(chan uint32, size) dcr.signalMtx.Lock() defer dcr.signalMtx.Unlock() dcr.blockChans = append(dcr.blockChans, c) return c }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (eth *Backend) BlockChannel(size int) <-chan *asset.BlockUpdate {\n\tc := make(chan *asset.BlockUpdate, size)\n\teth.blockChansMtx.Lock()\n\tdefer eth.blockChansMtx.Unlock()\n\teth.blockChans[c] = struct{}{}\n\treturn c\n}", "func (p *Character) Block(playerChan PlayerChannel) {\n\tinput := actions.Action{}...
[ "0.75976044", "0.66064984", "0.6478585", "0.61242306", "0.59563893", "0.5938221", "0.57723457", "0.5512562", "0.5471527", "0.5458594", "0.5419612", "0.5396688", "0.53795546", "0.5379272", "0.53686017", "0.53604186", "0.5352809", "0.5346257", "0.5337584", "0.53247017", "0.5324...
0.72564316
1
Coin is part of the asset.DEXAsset interface, so returns the asset.Coin type. Only spendable utxos with known types of pubkey script will be successfully retrieved. A spendable utxo is one that can be spent in the next block. Every regulartree output from a noncoinbase transaction is spendable immediately. Coinbase and stake tree outputs are only spendable after CoinbaseMaturity confirmations. Pubkey scripts can be P2PKH or P2SH in either regular or staketree flavor. P2PKH supports two alternative signatures, Schnorr and Edwards. Multisig P2SH redeem scripts are supported as well.
func (dcr *DCRBackend) Coin(coinID []byte, redeemScript []byte) (asset.Coin, error) { txHash, vout, err := decodeCoinID(coinID) if err != nil { return nil, fmt.Errorf("error decoding coin ID %x: %v", coinID, err) } return dcr.utxo(txHash, vout, redeemScript) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (dcr *DCRBackend) utxo(txHash *chainhash.Hash, vout uint32, redeemScript []byte) (*UTXO, error) {\n\ttxOut, verboseTx, pkScript, err := dcr.getTxOutInfo(txHash, vout)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinputNfo, err := dexdcr.InputInfo(pkScript, redeemScript, chainParams)\n\tif err != nil {\n\t...
[ "0.61177963", "0.5832482", "0.57181966", "0.5706132", "0.5706132", "0.5706132", "0.5656647", "0.5644319", "0.5522349", "0.5500901", "0.54408896", "0.541953", "0.541953", "0.541953", "0.5394614", "0.53199697", "0.5279201", "0.51935375", "0.5188278", "0.5163428", "0.51587594", ...
0.5507271
9
CheckAddress checks that the given address is parseable.
func (dcr *DCRBackend) CheckAddress(addr string) bool { _, err := dcrutil.DecodeAddress(addr, chainParams) return err == nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Setting) CheckAddress(adr string, hasPort, isEmptyHost bool) error {\n\tif strings.HasSuffix(adr, \".onion\") {\n\t\tif s.UseTor {\n\t\t\treturn nil\n\t\t}\n\t\treturn ErrTorAddress\n\t}\n\th, p, err2 := net.SplitHostPort(adr)\n\tif err2 != nil && hasPort {\n\t\treturn err2\n\t}\n\tif err2 == nil && !hasP...
[ "0.77516484", "0.76057404", "0.7435058", "0.7387827", "0.7387773", "0.7380567", "0.73167384", "0.7311681", "0.72945404", "0.72831154", "0.72659653", "0.724591", "0.7228436", "0.7149688", "0.7028857", "0.69365233", "0.6846989", "0.6729899", "0.66766006", "0.6654117", "0.664111...
0.7527266
2
UnspentDetails gets the recipient address, value, and confs of an unspent P2PKH transaction output. If the utxo does not exist or has a pubkey script of the wrong type, an error will be returned.
func (dcr *DCRBackend) UnspentDetails(txid string, vout uint32) (string, uint64, int64, error) { txHash, err := chainhash.NewHashFromStr(txid) if err != nil { return "", 0, -1, fmt.Errorf("error decoding tx ID %s: %v", txid, err) } txOut, pkScript, err := dcr.getUnspentTxOut(txHash, vout) if err != nil { return "", 0, -1, err } scriptType := dexdcr.ParseScriptType(dexdcr.CurrentScriptVersion, pkScript, nil) if scriptType == dexdcr.ScriptUnsupported { return "", 0, -1, dex.UnsupportedScriptError } if !scriptType.IsP2PKH() { return "", 0, -1, dex.UnsupportedScriptError } scriptAddrs, err := dexdcr.ExtractScriptAddrs(pkScript, chainParams) if err != nil { return "", 0, -1, fmt.Errorf("error parsing utxo script addresses") } if scriptAddrs.NumPK != 0 { return "", 0, -1, fmt.Errorf("pubkey addresses not supported for P2PKHDetails") } if scriptAddrs.NumPKH != 1 { return "", 0, -1, fmt.Errorf("multi-sig not supported for P2PKHDetails") } return scriptAddrs.PkHashes[0].String(), toAtoms(txOut.Value), txOut.Confirmations, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ListUnspentInfo(rsp http.ResponseWriter, req *http.Request) {\r\n\terrcode := ListUnspentInfo_ErrorCode\r\n\tvars := mux.Vars(req)\r\n\tmh, err := gHandle.MongoHandle(vars[\"type\"])\r\n\tif err != nil {\r\n\t\trsp.Write(common.MakeResponseWithErr(errcode-1, err))\r\n\t\treturn\r\n\t}\r\n\tfragment := common....
[ "0.6387986", "0.6176418", "0.6135895", "0.5948216", "0.5899068", "0.5754163", "0.57466215", "0.57283604", "0.5720983", "0.5709999", "0.56540304", "0.563221", "0.56190515", "0.5578661", "0.5573336", "0.54913014", "0.5394845", "0.5393376", "0.537308", "0.5348343", "0.5340176", ...
0.7695191
0
Get the Tx. Transaction info is not cached, so every call will result in a GetRawTransactionVerbose RPC call.
func (dcr *DCRBackend) transaction(txHash *chainhash.Hash, verboseTx *chainjson.TxRawResult) (*Tx, error) { // Figure out if it's a stake transaction msgTx, err := msgTxFromHex(verboseTx.Hex) if err != nil { return nil, fmt.Errorf("failed to decode MsgTx from hex for transaction %s: %v", txHash, err) } isStake := stake.DetermineTxType(msgTx) != stake.TxTypeRegular // If it's not a mempool transaction, get and cache the block data. var blockHash *chainhash.Hash var lastLookup *chainhash.Hash if verboseTx.BlockHash == "" { tipHash := dcr.blockCache.tipHash() if tipHash != zeroHash { lastLookup = &tipHash } } else { blockHash, err = chainhash.NewHashFromStr(verboseTx.BlockHash) if err != nil { return nil, fmt.Errorf("error decoding block hash %s for tx %s: %v", verboseTx.BlockHash, txHash, err) } // Make sure the block info is cached. _, err := dcr.getDcrBlock(blockHash) if err != nil { return nil, fmt.Errorf("error caching the block data for transaction %s", txHash) } } var sumIn, sumOut uint64 // Parse inputs and outputs, grabbing only what's needed. inputs := make([]txIn, 0, len(verboseTx.Vin)) var isCoinbase bool for _, input := range verboseTx.Vin { isCoinbase = input.Coinbase != "" sumIn += toAtoms(input.AmountIn) hash, err := chainhash.NewHashFromStr(input.Txid) if err != nil { return nil, fmt.Errorf("error decoding previous tx hash %sfor tx %s: %v", input.Txid, txHash, err) } inputs = append(inputs, txIn{prevTx: *hash, vout: input.Vout}) } outputs := make([]txOut, 0, len(verboseTx.Vout)) for vout, output := range verboseTx.Vout { pkScript, err := hex.DecodeString(output.ScriptPubKey.Hex) if err != nil { return nil, fmt.Errorf("error decoding pubkey script from %s for transaction %d:%d: %v", output.ScriptPubKey.Hex, txHash, vout, err) } sumOut += toAtoms(output.Value) outputs = append(outputs, txOut{ value: toAtoms(output.Value), pkScript: pkScript, }) } feeRate := (sumIn - sumOut) / uint64(len(verboseTx.Hex)/2) if isCoinbase { feeRate = 0 } return newTransaction(dcr, txHash, blockHash, lastLookup, verboseTx.BlockHeight, isStake, inputs, outputs, feeRate), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Context) GetTx() interface{} {\n\treturn c.tx\n}", "func (b *Bitcoind) GetRawTransaction(txId string, verbose bool) (rawTx interface{}, err error) {\n\tr, err := b.client.call(\"getrawtransaction\", []interface{}{txId, verbose})\n\tif err = handleError(err, &r); err != nil {\n\t\treturn\n\t}\n\n\tif !ve...
[ "0.7263245", "0.7125597", "0.7077553", "0.7010044", "0.6990968", "0.6925502", "0.6921681", "0.6895602", "0.68765855", "0.68272394", "0.6819173", "0.6819173", "0.6819173", "0.67866963", "0.6745477", "0.67282116", "0.67034066", "0.66091406", "0.657348", "0.6562667", "0.6556184"...
0.0
-1
Shutdown down the rpcclient.Client.
func (dcr *DCRBackend) shutdown() { if dcr.client != nil { dcr.client.Shutdown() dcr.client.WaitForShutdown() } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Shutdown() {\n\tstdClient.Close()\n}", "func (gs *GRPCClient) Shutdown() error {\n\treturn nil\n}", "func (c *client) Shutdown(ctx context.Context) error {\n\t// The otlpmetric.Exporter synchronizes access to client methods and\n\t// ensures this is called only once. The only thing that needs to be done\n...
[ "0.73745936", "0.7225617", "0.6888644", "0.6780136", "0.6691157", "0.6640586", "0.65991086", "0.6483838", "0.6481786", "0.6470059", "0.64099854", "0.64051586", "0.631624", "0.630749", "0.62762594", "0.62662035", "0.62636566", "0.6249138", "0.6240536", "0.6239879", "0.6229705"...
0.6549619
7
unconnectedDCR returns a DCRBackend without a node. The node should be set before use.
func unconnectedDCR(ctx context.Context, logger dex.Logger) *DCRBackend { dcr := &DCRBackend{ ctx: ctx, blockChans: make([]chan uint32, 0), blockCache: newBlockCache(logger), anyQ: make(chan interface{}, 128), // way bigger than needed. log: logger, } go dcr.superQueue() return dcr }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewBackend(ctx context.Context, configPath string, logger dex.Logger, network dex.Network) (*DCRBackend, error) {\n\t// loadConfig will set fields if defaults are used and set the chainParams\n\t// package variable.\n\tcfg, err := loadConfig(configPath, network)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\...
[ "0.5675982", "0.5640991", "0.51489455", "0.51292884", "0.5072386", "0.5046968", "0.500194", "0.49414936", "0.49361655", "0.48363492", "0.47757965", "0.4749657", "0.47285357", "0.4643413", "0.46065003", "0.45487693", "0.454845", "0.45359945", "0.45248133", "0.4474854", "0.4473...
0.72031325
0
superQueue should be run as a goroutine. The dcrdregistered handlers should perform any necessary type conversion and then deposit the payload into the anyQ channel. superQueue processes the queue and monitors the application context.
func (dcr *DCRBackend) superQueue() { out: for { select { case rawMsg := <-dcr.anyQ: switch msg := rawMsg.(type) { case *chainhash.Hash: // This is a new block notification. blockHash := msg dcr.log.Debugf("superQueue: Processing new block %s", blockHash) blockVerbose, err := dcr.node.GetBlockVerbose(blockHash, false) if err != nil { dcr.log.Errorf("onBlockConnected error retrieving block %s: %v", blockHash, err) return } // Check if this forces a reorg. currentTip := int64(dcr.blockCache.tipHeight()) if blockVerbose.Height <= currentTip { dcr.blockCache.reorg(blockVerbose) } block, err := dcr.blockCache.add(blockVerbose) if err != nil { dcr.log.Errorf("error adding block to cache") } dcr.signalMtx.RLock() for _, c := range dcr.blockChans { select { case c <- block.height: default: dcr.log.Errorf("tried sending block update on blocking channel") } } dcr.signalMtx.RUnlock() default: dcr.log.Warn("unknown message type in superQueue: %T", rawMsg) } case <-dcr.ctx.Done(): dcr.shutdown() break out } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (pc *partitionConsumer) dispatcher() {\n\tdefer func() {\n\t\tpc.log.Debug(\"exiting dispatch loop\")\n\t}()\n\tvar messages []*message\n\tfor {\n\t\tvar queueCh chan []*message\n\t\tvar messageCh chan ConsumerMessage\n\t\tvar nextMessage ConsumerMessage\n\t\tvar nextMessageSize int\n\n\t\t// are there more m...
[ "0.5877041", "0.56457406", "0.554473", "0.55286443", "0.55269974", "0.5523805", "0.5509261", "0.5444356", "0.5442355", "0.5419388", "0.5393476", "0.53879136", "0.5319574", "0.53174067", "0.5294507", "0.5260795", "0.52532613", "0.5247482", "0.5225851", "0.5207091", "0.51990676...
0.74948037
0
A callback to be registered with dcrd. It is critical that no RPC calls are made from this method. Doing so will likely result in a deadlock, as per
func (dcr *DCRBackend) onBlockConnected(serializedHeader []byte, _ [][]byte) { blockHeader := new(wire.BlockHeader) err := blockHeader.FromBytes(serializedHeader) if err != nil { dcr.log.Errorf("error decoding serialized header: %v", err) return } h := blockHeader.BlockHash() dcr.anyQ <- &h }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RVExtensionRegisterCallback(cbptr unsafe.Pointer) {\n\tcb = C.callbackProc(cbptr)\n\n\tlog.Println(\"Calling callback function ……\")\n\tfunction := C.CString(\"registered\")\n\tdefer C.free(unsafe.Pointer(function))\n\tC.bridge_cb(cb, name, function, function)\n}", "func registeredCB(\n ptr unsafe.Pointe...
[ "0.60473645", "0.57003", "0.5675279", "0.5597069", "0.55876535", "0.5491899", "0.54417133", "0.5438028", "0.5405987", "0.53921646", "0.5382326", "0.53731453", "0.5370236", "0.5298568", "0.5271958", "0.5263506", "0.52496874", "0.5180834", "0.5145246", "0.5117063", "0.5112205",...
0.0
-1
Get the UTXO, populating the block data along the way.
func (dcr *DCRBackend) utxo(txHash *chainhash.Hash, vout uint32, redeemScript []byte) (*UTXO, error) { txOut, verboseTx, pkScript, err := dcr.getTxOutInfo(txHash, vout) if err != nil { return nil, err } inputNfo, err := dexdcr.InputInfo(pkScript, redeemScript, chainParams) if err != nil { return nil, err } scriptType := inputNfo.ScriptType // If it's a pay-to-script-hash, extract the script hash and check it against // the hash of the user-supplied redeem script. if scriptType.IsP2SH() { scriptHash, err := dexdcr.ExtractScriptHashByType(scriptType, pkScript) if err != nil { return nil, fmt.Errorf("utxo error: %v", err) } if !bytes.Equal(dcrutil.Hash160(redeemScript), scriptHash) { return nil, fmt.Errorf("script hash check failed for utxo %s,%d", txHash, vout) } } blockHeight := uint32(verboseTx.BlockHeight) var blockHash chainhash.Hash var lastLookup *chainhash.Hash // UTXO is assumed to be valid while in mempool, so skip the validity check. if txOut.Confirmations > 0 { if blockHeight == 0 { return nil, fmt.Errorf("no raw transaction result found for tx output with "+ "non-zero confirmation count (%s has %d confirmations)", txHash, txOut.Confirmations) } blk, err := dcr.getBlockInfo(verboseTx.BlockHash) if err != nil { return nil, err } blockHeight = blk.height blockHash = blk.hash } else { // Set the lastLookup to the current tip. tipHash := dcr.blockCache.tipHash() if tipHash != zeroHash { lastLookup = &tipHash } } // Coinbase, vote, and revocation transactions all must mature before // spending. var maturity int64 if scriptType.IsStake() || txOut.Coinbase { maturity = int64(chainParams.CoinbaseMaturity) } if txOut.Confirmations < maturity { return nil, immatureTransactionError } tx, err := dcr.transaction(txHash, verboseTx) if err != nil { return nil, fmt.Errorf("error fetching verbose transaction data: %v", err) } return &UTXO{ dcr: dcr, tx: tx, height: blockHeight, blockHash: blockHash, vout: vout, maturity: int32(maturity), scriptType: scriptType, pkScript: pkScript, redeemScript: redeemScript, numSigs: inputNfo.ScriptAddrs.NRequired, // The total size associated with the wire.TxIn. spendSize: inputNfo.SigScriptSize + dexdcr.TxInOverhead, value: toAtoms(txOut.Value), lastLookup: lastLookup, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *ChainIO) GetUtxo(op *wire.OutPoint, _ []byte,\n\theightHint uint32, _ <-chan struct{}) (*wire.TxOut, er.R) {\n\n\treturn nil, nil\n}", "func (client *Client) UTXO(address string) ([]btc.UTXO, error) {\n\tvar response []btc.UTXO\n\terrorResp := &errorResponse{}\n\n\tresp, err := client.client.Post(\"/btc...
[ "0.66983944", "0.6249604", "0.6107751", "0.5934837", "0.5719519", "0.5654994", "0.5438669", "0.5363453", "0.53402656", "0.5261809", "0.52601206", "0.5210465", "0.51998585", "0.516098", "0.5116228", "0.5115651", "0.5105289", "0.50466335", "0.50234085", "0.5023179", "0.5023124"...
0.55830336
6
MsgTxFromHex creates a wire.MsgTx by deserializing the hex transaction.
func msgTxFromHex(txhex string) (*wire.MsgTx, error) { msgTx := wire.NewMsgTx() if err := msgTx.Deserialize(hex.NewDecoder(strings.NewReader(txhex))); err != nil { return nil, err } return msgTx, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func msgTxFromHex(txHex string) (*wire.MsgTx, error) {\n\tmsgTx := wire.NewMsgTx()\n\tif err := msgTx.Deserialize(hex.NewDecoder(strings.NewReader(txHex))); err != nil {\n\t\treturn nil, err\n\t}\n\treturn msgTx, nil\n}", "func msgTxFromHex(txHex string) (*wire.MsgTx, error) {\n\tmsgTx := wire.NewMsgTx()\n\tif e...
[ "0.8518934", "0.8518934", "0.73555577", "0.69453025", "0.6560635", "0.634584", "0.633896", "0.6125906", "0.58159053", "0.5756418", "0.56160355", "0.55764073", "0.5564265", "0.5477612", "0.5360798", "0.535055", "0.535055", "0.535055", "0.53421056", "0.5327159", "0.5304798", ...
0.84708995
2
Get information for an unspent transaction output.
func (dcr *DCRBackend) getUnspentTxOut(txHash *chainhash.Hash, vout uint32) (*chainjson.GetTxOutResult, []byte, error) { txOut, err := dcr.node.GetTxOut(txHash, vout, true) if err != nil { return nil, nil, fmt.Errorf("GetTxOut error for output %s:%d: %v", txHash, vout, err) } if txOut == nil { return nil, nil, fmt.Errorf("UTXO - no unspent txout found for %s:%d", txHash, vout) } pkScript, err := hex.DecodeString(txOut.ScriptPubKey.Hex) if err != nil { return nil, nil, fmt.Errorf("failed to decode pubkey script from '%s' for output %s:%d", txOut.ScriptPubKey.Hex, txHash, vout) } return txOut, pkScript, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getUnspent(addr string, page int) (string, error) {\n\turl := bitcoinCashAPI + \"/address/\" + addr + \"/unspent?pagesize=\" +\n\t\tstrconv.Itoa(defaultPageSize) + \"&page=\" + strconv.Itoa(page)\n\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif res.StatusCode != 200 {\n\t\t...
[ "0.6752377", "0.6605516", "0.6585877", "0.64894044", "0.6480415", "0.64345783", "0.640135", "0.62939304", "0.6265471", "0.62504184", "0.6115074", "0.6064", "0.6021693", "0.60137016", "0.59046924", "0.5858868", "0.5823582", "0.5808432", "0.5782322", "0.5768871", "0.57429415", ...
0.6798082
0
Get information for an unspent transaction output, plus the verbose transaction.
func (dcr *DCRBackend) getTxOutInfo(txHash *chainhash.Hash, vout uint32) (*chainjson.GetTxOutResult, *chainjson.TxRawResult, []byte, error) { txOut, pkScript, err := dcr.getUnspentTxOut(txHash, vout) if err != nil { return nil, nil, nil, err } verboseTx, err := dcr.node.GetRawTransactionVerbose(txHash) if err != nil { return nil, nil, nil, fmt.Errorf("GetRawTransactionVerbose for txid %s: %v", txHash, err) } return txOut, verboseTx, pkScript, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (gw *Gateway) GetTransactionVerbose(txid cipher.SHA256) (*visor.Transaction, []visor.TransactionInput, error) {\n\tvar txn *visor.Transaction\n\tvar inputs []visor.TransactionInput\n\tvar err error\n\tgw.strand(\"GetTransactionVerbose\", func() {\n\t\ttxn, inputs, err = gw.v.GetTransactionWithInputs(txid)\n\t...
[ "0.6555233", "0.6028365", "0.5917241", "0.57880974", "0.57669044", "0.57227284", "0.559527", "0.55457896", "0.5459531", "0.53880763", "0.53746974", "0.53548783", "0.5329701", "0.5329196", "0.5325462", "0.5320571", "0.52972066", "0.529067", "0.526966", "0.5170877", "0.51221925...
0.55095285
8
Get the block information, checking the cache first. Same as getDcrBlock, but takes a string argument.
func (dcr *DCRBackend) getBlockInfo(blockid string) (*dcrBlock, error) { blockHash, err := chainhash.NewHashFromStr(blockid) if err != nil { return nil, fmt.Errorf("unable to decode block hash from %s", blockid) } return dcr.getDcrBlock(blockHash) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cache *BlockCache) Get(blockID BlockID) (string, error) {\n\tcache.mu.Lock()\n\tdefer cache.mu.Unlock()\n\tif entry, ok := cache.entries[blockID]; ok {\n\t\tcache.callCount++\n\t\tentry.lastUsed = cache.callCount\n\t\treturn entry.block, nil\n\t}\n\treturn \"\", errors.New(\"Block \" + string(blockID) + \" i...
[ "0.7433264", "0.7097633", "0.6854615", "0.68225086", "0.6701608", "0.6690817", "0.6671227", "0.66362625", "0.6624479", "0.6556569", "0.654426", "0.65282035", "0.6453793", "0.64411473", "0.64145565", "0.6384272", "0.6361632", "0.6350189", "0.6332914", "0.63143504", "0.63122755...
0.7098702
1
Get the block information, checking the cache first.
func (dcr *DCRBackend) getDcrBlock(blockHash *chainhash.Hash) (*dcrBlock, error) { cachedBlock, found := dcr.blockCache.block(blockHash) if found { return cachedBlock, nil } blockVerbose, err := dcr.node.GetBlockVerbose(blockHash, false) if err != nil { return nil, fmt.Errorf("error retrieving block %s: %v", blockHash, err) } return dcr.blockCache.add(blockVerbose) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cache *BlockCache) Get(blockID BlockID) (string, error) {\n\tcache.mu.Lock()\n\tdefer cache.mu.Unlock()\n\tif entry, ok := cache.entries[blockID]; ok {\n\t\tcache.callCount++\n\t\tentry.lastUsed = cache.callCount\n\t\treturn entry.block, nil\n\t}\n\treturn \"\", errors.New(\"Block \" + string(blockID) + \" i...
[ "0.72391343", "0.71786505", "0.69215024", "0.68150514", "0.6794233", "0.6659732", "0.6650571", "0.6641638", "0.6635547", "0.6619689", "0.65339595", "0.6444369", "0.63869846", "0.63625735", "0.6355086", "0.6317724", "0.629948", "0.6278502", "0.6261923", "0.62254", "0.6221095",...
0.571269
83
Get the mainchain block at the given height, checking the cache first.
func (dcr *DCRBackend) getMainchainDcrBlock(height uint32) (*dcrBlock, error) { cachedBlock, found := dcr.blockCache.atHeight(height) if found { return cachedBlock, nil } hash, err := dcr.node.GetBlockHash(int64(height)) if err != nil { // Likely not mined yet. Not an error. return nil, nil } return dcr.getDcrBlock(hash) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *BlockCache) Get(height int) *walletrpc.CompactBlock {\n\tc.mutex.RLock()\n\tdefer c.mutex.RUnlock()\n\n\tif height < c.firstBlock || height >= c.nextBlock {\n\t\treturn nil\n\t}\n\tblock := c.readBlock(height)\n\tif block == nil {\n\t\tgo func() {\n\t\t\t// We hold only the read lock, need the exclusive l...
[ "0.7413385", "0.7301125", "0.7272819", "0.6949788", "0.69334644", "0.6897508", "0.68157536", "0.6755423", "0.66290843", "0.66019964", "0.6551436", "0.64818543", "0.64643836", "0.64366305", "0.6436303", "0.6425219", "0.6414073", "0.6406841", "0.6400347", "0.6395481", "0.639258...
0.73146623
1
connectNodeRPC attempts to create a new websocket connection to a dcrd node with the given credentials and notification handlers.
func connectNodeRPC(host, user, pass, cert string, notifications *rpcclient.NotificationHandlers) (*rpcclient.Client, error) { dcrdCerts, err := ioutil.ReadFile(cert) if err != nil { return nil, fmt.Errorf("TLS certificate read error: %v", err) } config := &rpcclient.ConnConfig{ Host: host, Endpoint: "ws", // websocket User: user, Pass: pass, Certificates: dcrdCerts, } dcrdClient, err := rpcclient.New(config, notifications) if err != nil { return nil, fmt.Errorf("Failed to start dcrd RPC client: %v", err) } return dcrdClient, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *rpcWallet) Connect(ctx context.Context) error {\n\tw.rpcMtx.Lock()\n\tdefer w.rpcMtx.Unlock()\n\n\t// NOTE: rpcclient.(*Client).Disconnected() returns false prior to connect,\n\t// so we cannot block incorrect Connect calls on that basis. However, it is\n\t// always safe to call Shutdown, so do it just in...
[ "0.5678625", "0.5574681", "0.553442", "0.5318691", "0.5208728", "0.5197474", "0.5172092", "0.5171623", "0.5110479", "0.5089093", "0.5073526", "0.50589776", "0.50174344", "0.49976897", "0.4952915", "0.4912385", "0.48695475", "0.48659632", "0.48654136", "0.48596957", "0.4855707...
0.774264
0
decodeCoinID decodes the coin ID into a tx hash and a vout.
func decodeCoinID(coinID []byte) (*chainhash.Hash, uint32, error) { if len(coinID) != 36 { return nil, 0, fmt.Errorf("coin ID wrong length. expected 36, got %d", len(coinID)) } var txHash chainhash.Hash copy(txHash[:], coinID[:32]) return &txHash, binary.BigEndian.Uint32(coinID[32:]), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func decodeCoinID(coinID dex.Bytes) (*chainhash.Hash, uint32, error) {\n\tif len(coinID) != 36 {\n\t\treturn nil, 0, fmt.Errorf(\"coin ID wrong length. expected 36, got %d\", len(coinID))\n\t}\n\tvar txHash chainhash.Hash\n\tcopy(txHash[:], coinID[:32])\n\treturn &txHash, binary.BigEndian.Uint32(coinID[32:]), nil\...
[ "0.7952344", "0.7952344", "0.7952344", "0.73947984", "0.73801225", "0.7359979", "0.7359979", "0.7313785", "0.7311404", "0.70934844", "0.65640086", "0.6383265", "0.6383265", "0.6383265", "0.5988277", "0.56237215", "0.54667443", "0.5415308", "0.5366419", "0.5259613", "0.5194115...
0.7893231
3
toCoinID converts the outpoint to a coin ID.
func toCoinID(txHash *chainhash.Hash, vout uint32) []byte { hashLen := len(txHash) b := make([]byte, hashLen+4) copy(b[:hashLen], txHash[:]) binary.BigEndian.PutUint32(b[hashLen:], vout) return b }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func toCoinID(txHash *chainhash.Hash, vout uint32) []byte {\n\tcoinID := make([]byte, chainhash.HashSize+4)\n\tcopy(coinID[:chainhash.HashSize], txHash[:])\n\tbinary.BigEndian.PutUint32(coinID[chainhash.HashSize:], vout)\n\treturn coinID\n}", "func toCoinID(txHash *chainhash.Hash, vout uint32) []byte {\n\tcoinID...
[ "0.699069", "0.699069", "0.699069", "0.6849971", "0.6647042", "0.5780764", "0.5748355", "0.5586011", "0.5458626", "0.5452238", "0.5452238", "0.5444285", "0.5424757", "0.5423626", "0.5360309", "0.53461546", "0.5259709", "0.5259709", "0.5259709", "0.5242078", "0.5229691", "0....
0.69547534
3
Convert the DCR value to atoms.
func toAtoms(v float64) uint64 { return uint64(math.Round(v * 1e8)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func toAtoms(v float64) uint64 {\n\treturn uint64(math.Round(v * conventionalConversionFactor))\n}", "func PropValAtoms(xu *xgbutil.XUtil, reply *xproto.GetPropertyReply,\n\terr error) ([]string, error) {\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif reply.Format != 32 {\n\t\treturn nil, fmt.Errorf(\"Prop...
[ "0.56985295", "0.5318303", "0.49374065", "0.4737565", "0.47363374", "0.46584833", "0.46391574", "0.46391574", "0.4609804", "0.46034306", "0.45536092", "0.44392696", "0.43683672", "0.43274194", "0.4296113", "0.4273294", "0.4257204", "0.42343932", "0.42323673", "0.42308548", "0...
0.5402026
2
NewHuffmanEncoder creates an encoder from the input io.ReadSeeker and prepares it for writing to output io.Writer. It calculates the dictionary by doing frequency counting on the input bytes.
func NewHuffmanEncoder(inp io.ReadSeeker, wc io.Writer) *HuffmanEncoder { he := new(HuffmanEncoder) freq := make(map[byte]int) var b [1]byte // using the reader, count the frequency of bytes for { _, err := inp.Read(b[:]) if err != nil { if err == io.EOF { break } panic(err) } _, ok := freq[b[0]] if !ok { freq[b[0]] = 0 } freq[b[0]]++ } _, err := inp.Seek(0, io.SeekStart) if err != nil { panic(err) } pQ := make(PriorityQueue, len(freq)) i := 0 for v, f := range freq { pQ[i] = NewHNode(v, f) i++ } heap.Init(&pQ) for pQ.Len() > 1 { zero := pQ.Pop() l := zero.(Item) one := pQ.Pop() r := one.(Item) ht := NewHTree(l, r) heap.Push(&pQ, ht) } htree := pQ.Pop() root, ok := htree.(*HTree) if !ok { panic("Huffman Tree") } he.root = root he.dict = make(map[byte]Huffcode) filldict(he.root, "", he.dict) he.bw = bs.NewWriter(wc) return he }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Encode(in, out *os.File) {\n\tcounts := count(in)\n\tp := makePQ(counts)\n\th := makeHuffman(p)\n\tm := make(map[byte]string)\n\tfillMap(h, m, \"\")\n\tfor k, v := range m {\n\t\tfmt.Printf(\"k: %c, v: %s\\n\", k, v)\n\t}\n}", "func createFrequencyTable(bytes *vector.Vector) *dictionary.Dictionary {\n\tdict...
[ "0.63321435", "0.56082517", "0.54519534", "0.5308969", "0.5214941", "0.51323193", "0.5113666", "0.49791935", "0.4955239", "0.49260506", "0.47540465", "0.47011536", "0.46830842", "0.46463782", "0.4641212", "0.46109676", "0.46104366", "0.4607955", "0.45618033", "0.4559878", "0....
0.74129003
0
NewHuffmanEncoder creates a new encoder given an existing dictionary. It prepares the encoder to write to the io.Writer that is provided. The order of the dictionary slice determines its priority.
func NewHuffmanEncoderWithDict(wc io.Writer, dict []byte) *HuffmanEncoder { he := new(HuffmanEncoder) pQ := make(PriorityQueue, len(dict)) MaxPri := len(dict) for i, v := range dict { pQ[i] = NewHNode(v, MaxPri - i) // prioritize in order of dict } heap.Init(&pQ) for pQ.Len() > 1 { zero := pQ.Pop() l := zero.(Item) one := pQ.Pop() r := one.(Item) ht := NewHTree(l, r) heap.Push(&pQ, ht) } htree := pQ.Pop() root, ok := htree.(*HTree) if !ok { panic("Huffman Tree") } he.root = root he.dict = make(map[byte]Huffcode) filldict(he.root, "", he.dict) he.bw = bs.NewWriter(wc) return he }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewHuffmanEncoder(inp io.ReadSeeker, wc io.Writer) *HuffmanEncoder {\n\the := new(HuffmanEncoder)\n\tfreq := make(map[byte]int)\n\n\tvar b [1]byte\n\t// using the reader, count the frequency of bytes\n\tfor {\n\t\t_, err := inp.Read(b[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\...
[ "0.68187904", "0.5415419", "0.53564626", "0.5354171", "0.52567977", "0.5114436", "0.51006263", "0.5085648", "0.5083247", "0.50649095", "0.50164247", "0.5015503", "0.49872044", "0.49753368", "0.4959254", "0.4930867", "0.4922031", "0.49132106", "0.49132106", "0.49132106", "0.49...
0.6864214
0
Writes the Huffman tree that will be used for decoding XXX should probably save the uncompressed file size (in bytes) in the header; this would allow the reader to know how big the file should be. It might make sense to also have the compressed size as well, to be able to perform a sanity check that junk isn't being added to the end of the file somehow.
func (enc *HuffmanEncoder) WriteHeader() error { // for iterative tree walking use savedict // for recursive, use rsavedict // if err := savedict(enc.bw, enc.root); err != nil { if err := rsavedict(enc.bw, enc.root); err != nil { // recursive version return err } return enc.bw.WriteBit(bs.Zero) // end of dictionary indicator }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (head *Node) WriteHeader(w *bitio.Writer, freq map[uint8]uint) (err error) {\n\tvar nEncoded uint32\n\tfor _, v := range freq {\n\t\tnEncoded += uint32(v)\n\t}\n\n\t// Write total number of encoded symbols\n\tw.TryWriteBitsUnsafe(uint64(nEncoded), 32)\n\n\t// Write total number of symbols in graph\n\tw.TryWri...
[ "0.6329973", "0.6045846", "0.6032457", "0.5782994", "0.55037165", "0.5465604", "0.5369017", "0.53598994", "0.5286722", "0.527717", "0.52457976", "0.5237702", "0.5197437", "0.5150963", "0.51408374", "0.51348996", "0.5115096", "0.50463367", "0.50451905", "0.5043282", "0.5008207...
0.6471056
0
Satisfies the io.Writer interface
func (enc *HuffmanEncoder) Write(p []byte) (n int, err error) { for _, v := range p { code, ok := enc.dict[v] if !ok { panic(errors.New("non-existant uncompressed code " + string(v))) } err = enc.bw.WriteBits(code.hcode, code.nbits) if err != nil { return 0, err } } return len(p), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *Writer) Close() error {}", "func (w *Writer) Write(wr io.Writer, data interface{}) (err error) {\n\tw.w = wr\n\t_, err = w.encode(data)\n\n\treturn\n}", "func (w *writerWrapper) Write(buf []byte) (int, error) {\n\tif !w.wroteHeader {\n\t\tw.WriteHeader(http.StatusOK)\n\t}\n\tn, err := w.ResponseWriter...
[ "0.69155353", "0.6802392", "0.6716041", "0.6650596", "0.65909255", "0.65705055", "0.6569131", "0.6567318", "0.6500117", "0.64540964", "0.64366436", "0.6431016", "0.64201397", "0.6398738", "0.6394778", "0.6392109", "0.6363929", "0.6343151", "0.6339702", "0.6329556", "0.6314478...
0.0
-1
Flushes incomplete bytes to output
func (enc *HuffmanEncoder) Flush() error { return enc.bw.Flush(bs.Zero) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *Writer) Flush() error {\n\tif w.count != 8 {\n\t\t_, err := w.w.Write(w.b[:])\n\t\treturn err\n\t}\n\treturn nil\n}", "func (z *bufioEncWriter) flushErr() (err error) {\n\tn, err := z.w.Write(z.buf[:z.n])\n\tz.n -= n\n\tif z.n > 0 && err == nil {\n\t\terr = io.ErrShortWrite\n\t}\n\tif n > 0 && z.n > 0 {...
[ "0.65437937", "0.6193655", "0.6111782", "0.5985848", "0.5838739", "0.57894355", "0.57892287", "0.5777491", "0.57667696", "0.57257664", "0.56634104", "0.5662461", "0.56282485", "0.5565944", "0.5565778", "0.55408823", "0.55345553", "0.55337304", "0.55255216", "0.5509925", "0.55...
0.517923
49
Print the constructed Huffman tree
func (enc *HuffmanEncoder) ShowHuffTree() { traverse(enc.root, "") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n *Node) print() string {\n\n\th := n.height()\n\tprintMap = make(map[int][]int, h)\n\tfor i := 1; i <= h; i++ {\n\t\tn.printByLevel(i)\n\t}\n\tfor key := h; key > 0; key-- {\n\t\tfor j := h; j > key; j-- {\n\t\t\tfor _, k := range printMap[j] {\n\t\t\t\tif arrayutils.InInt(printMap[key], k) {\n\t\t\t\t\tpri...
[ "0.67556983", "0.65548545", "0.64473444", "0.6355353", "0.63495487", "0.63421017", "0.62907606", "0.62621576", "0.6245571", "0.6230869", "0.6198465", "0.6188055", "0.6176889", "0.61548245", "0.6044016", "0.59704137", "0.59682196", "0.5926465", "0.59260035", "0.59055454", "0.5...
0.69969803
0
GenerateRequestToken generates a token for a check request
func GenerateRequestToken(proxy, uid, checkid int) (string, error) { claims := struct { Proxy int `json:"proxy"` ID int `json:"id"` CheckID int `json:"checkid"` jwt.StandardClaims }{ proxy, uid, checkid, jwt.StandardClaims{ ExpiresAt: time.Now().Add(time.Minute * 10).Unix(), Issuer: "Server", }, } token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) return token.SignedString([]byte(os.Getenv("JWTSecret"))) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RequestToken(w http.ResponseWriter, r *http.Request) {\n\t// get the token from the body\n\tvar requestData requestTokenRequest\n\terr := json.NewDecoder(r.Body).Decode(&requestData)\n\tif err != nil {\n\t\ttemplates.JSONError(w, err)\n\t\treturn\n\t}\n\n\t// read and validate the token\n\ttoken, err := jwt.P...
[ "0.66232103", "0.6417559", "0.6399479", "0.6377574", "0.63117445", "0.6259131", "0.62589234", "0.62516654", "0.62364393", "0.62357354", "0.621038", "0.6146838", "0.6140899", "0.61170757", "0.6101631", "0.6076743", "0.6036621", "0.6035912", "0.6035874", "0.60315853", "0.602582...
0.8204228
0
DecodeRequestToken decodes a token for a check request
func DecodeRequestToken(ptoken string) (int, int, int, error) { // TODO: Return Values to Struct! token, err := jwt.Parse(ptoken, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) } return []byte(os.Getenv("JWTSecret")), nil }) if err == nil { if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid { return int(claims["proxy"].(float64)), int(claims["id"].(float64)), int(claims["checkid"].(float64)), nil } } return 0, 0, 0, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func decodeVerifyRequest(_ context.Context, r interface{}) (interface{}, error) {\n\trq := r.(*pb.VerifyRequest)\n\n\treturn endpoint.VerifyRequest{\n\t\tToken: rq.Token,\n\t\tType: rq.Type,\n\t\tCode: rq.Code,\n\t}, nil\n}", "func (t *ExpireDelegationTokenRequest) Decode(d *Decoder, version int16) error {\n\t...
[ "0.68870664", "0.66117424", "0.6522489", "0.6479375", "0.6381417", "0.62694895", "0.62654114", "0.62093854", "0.6146002", "0.6115867", "0.6093569", "0.6093476", "0.6093476", "0.60903925", "0.6080506", "0.59667265", "0.5951391", "0.5901449", "0.58642566", "0.58464855", "0.5814...
0.72312915
0
GetItem returns an item based on the provided ID value
func (i *itemsService) GetItem(itemID string)(*domain.Item, *utils.ApplicationError){ return nil, &utils.ApplicationError { Message: "not implemented", StatusCode: http.StatusBadRequest, Code: "bad_request", } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (i Inventory) GetItemById(id int) (Item, *ErrHandler) {\n var item Item\n err := i.Db.GetItemById(id,&item)\n return item, err\n}", "func GetItem(c Context) {\n\tidentifer, err := strconv.Atoi(c.Param(\"id\"))\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tre...
[ "0.7705056", "0.73141557", "0.71873814", "0.7183088", "0.71113724", "0.6930943", "0.6901362", "0.6844753", "0.6808142", "0.6802855", "0.6713457", "0.6691677", "0.6685008", "0.6648123", "0.6610974", "0.6517523", "0.649654", "0.64963335", "0.6476716", "0.6416178", "0.6402383", ...
0.6235808
27
LoadOffset loads the last offset associated with the given source application key sk. ak is the 'owner' application key. If there is no offset associated with the given source application key, the offset is returned as zero and error as nil.
func (driver) LoadOffset( ctx context.Context, db *sql.DB, ak, sk string, ) (uint64, error) { row := db.QueryRowContext( ctx, `SELECT next_offset FROM stream_offset WHERE app_key = ? AND source_app_key = ?`, ak, sk, ) var o uint64 err := row.Scan(&o) if err == sql.ErrNoRows { err = nil } return o, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func recoveredDataOffset(chunkFetchOffset uint64, rs modules.ErasureCoder) uint64 {\n\t// If partialDecoding is not available we downloaded the whole sector and\n\t// recovered the whole chunk which means the offset and length are actually\n\t// equal to the chunkFetchOffset and chunkFetchLength.\n\tif !rs.Support...
[ "0.50615436", "0.49211717", "0.48032776", "0.47755668", "0.47425985", "0.47088978", "0.4707543", "0.46445605", "0.46122235", "0.45880616", "0.45770794", "0.45286804", "0.449994", "0.44305518", "0.4426901", "0.4385762", "0.43705243", "0.43544406", "0.43517968", "0.4343254", "0...
0.7397653
0
InsertOffset inserts a new offset associated with the given source application key sk. ak is the 'owner' application key. It returns false if the row already exists.
func (driver) InsertOffset( ctx context.Context, tx *sql.Tx, ak, sk string, n uint64, ) (_ bool, err error) { defer sqlx.Recover(&err) return sqlx.TryExecRow( ctx, tx, `INSERT INTO stream_offset SET app_key = ?, source_app_key = ?, next_offset = ? ON DUPLICATE KEY UPDATE app_key = app_key`, // do nothing ak, sk, n, ), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (driver) UpdateOffset(\n\tctx context.Context,\n\ttx *sql.Tx,\n\tak, sk string,\n\tc, n uint64,\n) (_ bool, err error) {\n\tdefer sqlx.Recover(&err)\n\n\treturn sqlx.TryExecRow(\n\t\tctx,\n\t\ttx,\n\t\t`UPDATE stream_offset SET\n\t\t\tnext_offset = ?\n\t\tWHERE app_key = ?\n\t\tAND source_app_key = ?\n\t\tAND...
[ "0.53806126", "0.49017456", "0.45575985", "0.45187888", "0.4372562", "0.43215376", "0.42887828", "0.42844123", "0.42801693", "0.42686084", "0.4265812", "0.42324173", "0.41944718", "0.4174271", "0.4151377", "0.41212583", "0.41108283", "0.41079918", "0.40762496", "0.40593997", ...
0.7343345
0
UpdateOffset updates the offset associated with the given source application key sk. ak is the 'owner' application key. It returns false if the row does not exist or c is not the current offset associated with the given application key.
func (driver) UpdateOffset( ctx context.Context, tx *sql.Tx, ak, sk string, c, n uint64, ) (_ bool, err error) { defer sqlx.Recover(&err) return sqlx.TryExecRow( ctx, tx, `UPDATE stream_offset SET next_offset = ? WHERE app_key = ? AND source_app_key = ? AND next_offset = ?`, n, ak, sk, c, ), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (driver) InsertOffset(\n\tctx context.Context,\n\ttx *sql.Tx,\n\tak, sk string,\n\tn uint64,\n) (_ bool, err error) {\n\tdefer sqlx.Recover(&err)\n\n\treturn sqlx.TryExecRow(\n\t\tctx,\n\t\ttx,\n\t\t`INSERT INTO stream_offset SET\n\t\t\tapp_key = ?,\n\t\t\tsource_app_key = ?,\n\t\t\tnext_offset = ?\n\t\tON DU...
[ "0.5265997", "0.5001188", "0.4997778", "0.4948661", "0.47325367", "0.46862262", "0.4617137", "0.4422344", "0.4403765", "0.43536887", "0.4332005", "0.42700264", "0.42593765", "0.42416778", "0.42387107", "0.42280987", "0.42227277", "0.42138276", "0.4205628", "0.41990882", "0.41...
0.6796423
0
createOffsetSchema creates the schema elements for stream offsets.
func createOffsetSchema(ctx context.Context, db *sql.DB) { sqlx.Exec( ctx, db, `CREATE TABLE IF NOT EXISTS stream_offset ( app_key VARBINARY(255) NOT NULL, source_app_key VARBINARY(255) NOT NULL, next_offset BIGINT NOT NULL, PRIMARY KEY (app_key, source_app_key) ) ENGINE=InnoDB`, ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func dropOffsetSchema(ctx context.Context, db *sql.DB) {\n\tsqlx.Exec(ctx, db, `DROP TABLE IF EXISTS stream_offset`)\n}", "func (w *windowTransformation2) createSchema(cols []flux.ColMeta) []flux.ColMeta {\n\tncols := len(cols)\n\tif execute.ColIdx(w.startCol, cols) < 0 {\n\t\tncols++\n\t}\n\tif execute.ColIdx(w...
[ "0.6668258", "0.59531236", "0.4917406", "0.4842255", "0.48148918", "0.48063517", "0.48004463", "0.47688976", "0.47340184", "0.46674427", "0.46646196", "0.46415585", "0.46394846", "0.46318924", "0.46213883", "0.4616732", "0.4608155", "0.4595821", "0.45910755", "0.45858547", "0...
0.8171505
0
dropOffsetSchema drops the schema elements for stream offsets.
func dropOffsetSchema(ctx context.Context, db *sql.DB) { sqlx.Exec(ctx, db, `DROP TABLE IF EXISTS stream_offset`) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *Telly) DropOffsets() error {\n\t_, err := t.metaTable().Get(t.offsetKey()).Delete().RunWrite(t.Executor())\n\treturn err\n}", "func createOffsetSchema(ctx context.Context, db *sql.DB) {\n\tsqlx.Exec(\n\t\tctx,\n\t\tdb,\n\t\t`CREATE TABLE IF NOT EXISTS stream_offset (\n\t\t\tapp_key VARBINARY(255) NOT NU...
[ "0.65431356", "0.5897997", "0.5540047", "0.5491531", "0.5133063", "0.51117074", "0.5074445", "0.4885307", "0.48411688", "0.4840852", "0.48365957", "0.4804482", "0.47582945", "0.47399566", "0.47135127", "0.47126", "0.46876818", "0.4677966", "0.4677966", "0.4677966", "0.4677966...
0.836623
0
Deprecated: Use SumSaleValuesRequest.ProtoReflect.Descriptor instead.
func (*SumSaleValuesRequest) Descriptor() ([]byte, []int) { return file_sale_proto_rawDescGZIP(), []int{0} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (*SumSaleValuesResponse) Descriptor() ([]byte, []int) {\n\treturn file_sale_proto_rawDescGZIP(), []int{1}\n}", "func (*SumRequest) Descriptor() ([]byte, []int) {\n\treturn file_calculatorpb_calculator_proto_rawDescGZIP(), []int{0}\n}", "func (*GetSaleOrderRequest) Descriptor() ([]byte, []int) {\n\treturn ...
[ "0.6645216", "0.600242", "0.5958504", "0.5919472", "0.5913957", "0.5890063", "0.5843352", "0.58195996", "0.57833153", "0.5769982", "0.57416576", "0.57240784", "0.57084304", "0.569001", "0.56584746", "0.5644444", "0.5638984", "0.5627937", "0.56184053", "0.56153077", "0.5594644...
0.7417047
0
Deprecated: Use SumSaleValuesResponse.ProtoReflect.Descriptor instead.
func (*SumSaleValuesResponse) Descriptor() ([]byte, []int) { return file_sale_proto_rawDescGZIP(), []int{1} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (*SumSaleValuesRequest) Descriptor() ([]byte, []int) {\n\treturn file_sale_proto_rawDescGZIP(), []int{0}\n}", "func (x *fastReflection_MsgCommunityPoolSpendResponse) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgCommunityPoolSpendResponse\n}", "func (*GetSaleOrderResponse) Descriptor() ([]...
[ "0.6912668", "0.6350167", "0.60535", "0.60375196", "0.60186344", "0.5939751", "0.5939521", "0.592548", "0.5924573", "0.58735955", "0.586989", "0.58384675", "0.5834551", "0.58245265", "0.5817466", "0.5816653", "0.5816067", "0.58092535", "0.58035386", "0.57850885", "0.5753539",...
0.71831435
0
RandInt generates random int between min and max
func RandInt(min int, max int) int { r := rand.New(rand.NewSource(time.Now().UnixNano())) return r.Intn(max-min) + min }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RandInt(min, max int) int {\n\treturn rand.Intn(max-min+1) + min\n}", "func RandInt(min, max int) int {\n\treturn min + rand.Intn(max-min)\n}", "func randomInt(min, max int) int {\n\treturn min + rand.Intn(max-min)\n}", "func randomInt(min, max int) int {\n\treturn min + rand.Intn(max-min)\n}", "func ...
[ "0.86780375", "0.86658245", "0.8523402", "0.8523402", "0.8523402", "0.8523402", "0.8523402", "0.85209435", "0.8520326", "0.8512728", "0.85012895", "0.8499019", "0.84947085", "0.8456424", "0.84359443", "0.84217656", "0.8410235", "0.83798057", "0.83246094", "0.82986814", "0.829...
0.8335904
18
Send sends the webpush request with the push subscription.
func (c *PushServiceClient) Send(subscription *pb.PushSubscription, request *pb.WebpushRequest) (*WebpushResponse, error) { content, err := c.encrypt(subscription, request) if err != nil { return nil, err } req, err := http.NewRequest("POST", subscription.Endpoint, bytes.NewReader(content)) if err != nil { return nil, err } req.Header.Add("TTL", "30") req.Header.Add("Content-Encoding", "aes128gcm") subject := "mailto:nokamoto.engr@gmail.com" expiry := time.Now().Add(12 * time.Hour).Unix() addAuthorizationHeader(req, subscription.Endpoint, subject, expiry, c.KeyPair) res, err := c.Client.Do(req) if err != nil { return nil, err } defer res.Body.Close() b, err := ioutil.ReadAll(res.Body) if err != nil { return nil, err } retryAfter, err := parseRetryAfter(time.Now(), &res.Header) if err != nil { // todo } wr := &WebpushResponse{ Status: res.Status, StatusCode: res.StatusCode, Text: string(b), RetryAfter: retryAfter, } return wr, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func PushToWeb(req PushNotification) bool {\n\tLogAccess.Debug(\"Start push notification for Web\")\n\n\tvar retryCount = 0\n\tvar maxRetry = PushConf.Web.MaxRetry\n\n\tif req.Retry > 0 && req.Retry < maxRetry {\n\t\tmaxRetry = req.Retry\n\t}\n\n\t// check message\n\terr := CheckMessage(req)\n\n\tif err != nil {\n...
[ "0.63720524", "0.6312198", "0.5907286", "0.5889171", "0.5805053", "0.578413", "0.5753914", "0.5698604", "0.56712", "0.56687117", "0.5664942", "0.56114054", "0.56007963", "0.55908614", "0.5588826", "0.5577937", "0.5551254", "0.55230355", "0.5501611", "0.54977125", "0.54580736"...
0.71577096
0
Panic function adalah function yg bisa kita gunakan untuk menghentikan program Panic function biasanya dipanggil ketika terjadi error pada saat program kita berjalan Saat panic function dipanggil, program akan terhenti, namun defer function tetap akan dieksekusi
func endApp() { fmt.Println("end app") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func deferFunc() {\r\n\tfmt.Println(\"Aplicaation Ended\")\r\n\tmessage := recover() // menangkap eror dan di tampilkan dalam pesan\r\n\tif message != nil {\r\n\t\tfmt.Println(\"eror with message :\", message)\r\n\t}\r\n\r\n}", "func ejemploPanic() {\n\ta := 1\n\tif a == 1 {\n\t\tpanic(\"Se encontró el valor de ...
[ "0.70140356", "0.6781659", "0.6739621", "0.6613491", "0.6540914", "0.65387857", "0.62417805", "0.6232773", "0.61581886", "0.61510843", "0.6136249", "0.61278147", "0.60755974", "0.6065634", "0.6065634", "0.6056639", "0.60053545", "0.5977083", "0.59546065", "0.59313726", "0.592...
0.0
-1
TODO Check Admin Login
func (action ReportAction) GetNon2StepVerifiedUsers() error { report, err := action.report.Get2StepVerifiedStatusReport() if err != nil { return err } if len(report.UsageReports) == 0 { return errors.New("No Report Available") } var paramIndex int fmt.Println("Latest Report: " + report.UsageReports[0].Date) for i, param := range report.UsageReports[0].Parameters { // https://developers.google.com/admin-sdk/reports/v1/guides/manage-usage-users // Parameters: https://developers.google.com/admin-sdk/reports/v1/reference/usage-ref-appendix-a/users-accounts if param.Name == "accounts:is_2sv_enrolled" { paramIndex = i break } } for _, r := range report.UsageReports { if !r.Parameters[paramIndex].BoolValue { fmt.Println(r.Entity.UserEmail) } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func isAdmin(res http.ResponseWriter, req *http.Request) bool {\n\tmyUser := getUser(res, req)\n\treturn myUser.Username == \"admin\"\n}", "func AdminLogin(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminLogin, w, data)\n}", "func AdminLogin(w http.ResponseWriter, data *AdminLoginData) {\n\trender(...
[ "0.665762", "0.66363335", "0.6522691", "0.63126487", "0.6307976", "0.63048774", "0.62177783", "0.61199987", "0.611319", "0.60783297", "0.6050973", "0.6044232", "0.59962004", "0.5980784", "0.59500855", "0.5914631", "0.59073484", "0.58528674", "0.5847329", "0.58470595", "0.5845...
0.0
-1
GetIllegalLoginUsersAndIp Main purpose is to detect employees who have not logged in from office for 30days
func (action ReportAction) GetIllegalLoginUsersAndIp(activities []*admin.Activity, officeIPs []string) error { data := make(map[string]*LoginInformation) for _, activity := range activities { email := activity.Actor.Email ip := activity.IpAddress if value, ok := data[email]; ok { if !value.OfficeLogin { // If an user has logged in from not verified IP so far // then check if new IP is the one from office or not. value.OfficeLogin = containIP(officeIPs, ip) } value.LoginIPs = append(value.LoginIPs, ip) } else { data[email] = &LoginInformation{ email, containIP(officeIPs, ip), []string{ip}} } } for key, value := range data { if !value.OfficeLogin { fmt.Println(key) fmt.Print(" IP: ") fmt.Println(value.LoginIPs) } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsLimitedAccess(ipaddr string, ref db.DBClient) bool {\n\tresults, err := ref.Fetch(ipaddr)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tjst, _ := time.LoadLocation(\"Asia/Tokyo\")\n\tnow := time.Now().In(jst)\n\tisLimited := false\n\tfor _, r := range results {\n\t\tvar u User\n\t\tif err := r.Unmarsha...
[ "0.55618083", "0.53362024", "0.52133155", "0.504922", "0.5025185", "0.5021805", "0.49990374", "0.49925345", "0.4975953", "0.49752885", "0.49593654", "0.49559018", "0.49486402", "0.49274644", "0.49150744", "0.4891709", "0.48823234", "0.4870131", "0.48608845", "0.48539826", "0....
0.79552656
0
ConvertManifest changes application/octetstream to schema2 config media type if need. NOTE: 1. original manifest will be deleted by next gc round. 2. don't cover manifest list.
func ConvertManifest(ctx context.Context, store content.Store, desc ocispec.Descriptor) (ocispec.Descriptor, error) { if !(desc.MediaType == images.MediaTypeDockerSchema2Manifest || desc.MediaType == ocispec.MediaTypeImageManifest) { log.G(ctx).Warnf("do nothing for media type: %s", desc.MediaType) return desc, nil } // read manifest data mb, err := content.ReadBlob(ctx, store, desc) if err != nil { return ocispec.Descriptor{}, fmt.Errorf("failed to read index data: %w", err) } var manifest ocispec.Manifest if err := json.Unmarshal(mb, &manifest); err != nil { return ocispec.Descriptor{}, fmt.Errorf("failed to unmarshal data into manifest: %w", err) } // check config media type if manifest.Config.MediaType != LegacyConfigMediaType { return desc, nil } manifest.Config.MediaType = images.MediaTypeDockerSchema2Config data, err := json.MarshalIndent(manifest, "", " ") if err != nil { return ocispec.Descriptor{}, fmt.Errorf("failed to marshal manifest: %w", err) } // update manifest with gc labels desc.Digest = digest.Canonical.FromBytes(data) desc.Size = int64(len(data)) labels := map[string]string{} for i, c := range append([]ocispec.Descriptor{manifest.Config}, manifest.Layers...) { labels[fmt.Sprintf("containerd.io/gc.ref.content.%d", i)] = c.Digest.String() } ref := remotes.MakeRefKey(ctx, desc) if err := content.WriteBlob(ctx, store, ref, bytes.NewReader(data), desc, content.WithLabels(labels)); err != nil { return ocispec.Descriptor{}, fmt.Errorf("failed to update content: %w", err) } return desc, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GenerateManifestObj(manifestBytes []byte, manifestType string, osFilterList, archFilterList []string,\n\ti *ImageSource, parent *manifest.Schema2List) (interface{}, []byte, []*ManifestInfo, error) {\n\n\tswitch manifestType {\n\tcase manifest.DockerV2Schema2MediaType:\n\t\tmanifestObj, err := manifest.Schema2...
[ "0.6272285", "0.61268884", "0.6069464", "0.56475556", "0.5595849", "0.5593677", "0.5557736", "0.54702747", "0.54667705", "0.5381301", "0.53493315", "0.53375196", "0.5332968", "0.52484876", "0.52468956", "0.51982343", "0.51681316", "0.5150227", "0.5135461", "0.50848836", "0.50...
0.7655116
0
NewCloudManager creates a cloud manager.
func NewCloudManager(dataStore *store.DataStore) (CloudManager, error) { if dataStore == nil { return nil, fmt.Errorf("Fail to new cloud manager as data store is nil.") } return &cloudManager{dataStore}, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewManager(system Resumer, name string, kubeClient kubernetes.Interface) *Manager {\n\treturn &Manager{\n\t\tstop: make(chan struct{}),\n\t\tsystem: system,\n\t\tname: name,\n\t\tkubeClient: kubeClient,\n\t}\n}", "func NewManager(c config.StorageService, serviceName, restoreFolder, binLog st...
[ "0.67431074", "0.6529142", "0.6522321", "0.651553", "0.6362552", "0.6357567", "0.6357567", "0.6337562", "0.6315729", "0.6300832", "0.6300793", "0.6259243", "0.62556833", "0.62087953", "0.6195508", "0.6164765", "0.6161856", "0.6116793", "0.6110162", "0.6089127", "0.60886985", ...
0.7256937
0
CreateCloud creates a cloud.
func (m *cloudManager) CreateCloud(c *api.Cloud) (*api.Cloud, error) { cloudName := c.Name if _, err := m.ds.FindCloudByName(cloudName); err == nil { return nil, httperror.ErrorAlreadyExist.Format(cloudName) } // check auth info cp, err := cloud.NewCloudProvider(c) if err != nil { return nil, httperror.ErrorValidationFailed.Format("cloud body", err) } err = cp.Ping() if err != nil { return nil, httperror.ErrorValidationFailed.Format("cloud body", err) } if err := m.ds.InsertCloud(c); err != nil { return nil, err } return c, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Create(ip string, user string, name string) (*Cloud, error) {\n\tkey, err := sshkey()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tport := sshport()\n\tsshClient := ssh.New(ip).WithUser(user).WithKey(key).WithPort(port)\n\treturn &Cloud{\n\t\tIP: ip,\n\t\tUser: user,\n\t\tName: name,\n\t\tType: types.Clo...
[ "0.6834125", "0.6702865", "0.6396245", "0.6335121", "0.61975646", "0.6191873", "0.6094794", "0.60791254", "0.59872746", "0.5945341", "0.5944723", "0.59052587", "0.58329237", "0.58106196", "0.58104384", "0.5789175", "0.5764127", "0.5731699", "0.57309675", "0.5705416", "0.56902...
0.7975238
0
ListClouds lists all clouds.
func (m *cloudManager) ListClouds() ([]api.Cloud, error) { return m.ds.FindAllClouds() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *CloudsService) ListAll(ctx context.Context, org string) ([]*Cloud, *http.Response, error) {\n\tif org == \"\" {\n\t\treturn nil, nil, errors.New(\"org name must be non-empty\")\n\t}\n\toc := fmt.Sprintf(\"%v/clouds\", org)\n\n\treq, err := s.client.NewRequest(\"GET\", oc, nil)\n\tif err != nil {\n\t\tretu...
[ "0.75105655", "0.73811686", "0.6556542", "0.634234", "0.6327636", "0.60169786", "0.60099643", "0.5958216", "0.5926719", "0.5926633", "0.58319795", "0.58097786", "0.5730285", "0.5722008", "0.57091457", "0.5642574", "0.5606681", "0.55926037", "0.5588285", "0.55673075", "0.55298...
0.8236685
0
DeleteCloud deletes the cloud.
func (m *cloudManager) DeleteCloud(name string) error { return m.ds.DeleteCloudByName(name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cc *Controller) DeleteCloud(name string) {\n\tdelete(cc.Clouds, name)\n}", "func (dc Datacenter) Delete(client MetalCloudClient) error {\n\treturn nil\n}", "func (client StorageGatewayClient) DeleteCloudSync(ctx context.Context, request DeleteCloudSyncRequest) (response DeleteCloudSyncResponse, err error...
[ "0.78004485", "0.6621369", "0.6118169", "0.59255344", "0.58194435", "0.57293665", "0.5630269", "0.55803317", "0.55161494", "0.54982334", "0.5486809", "0.5447681", "0.5434831", "0.54257137", "0.5424664", "0.54219127", "0.54157925", "0.5395865", "0.53480345", "0.5310983", "0.52...
0.7406859
1
PingCloud pings the cloud to check its health.
func (m *cloudManager) PingCloud(name string) error { c, err := m.ds.FindCloudByName(name) if err != nil { return httperror.ErrorContentNotFound.Format(name) } cp, err := cloud.NewCloudProvider(c) if err != nil { return err } return cp.Ping() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cloud *K8SCloud) Ping() error {\n\t_, err := cloud.client.CoreV1().Pods(cloud.namespace).List(meta_v1.ListOptions{})\n\treturn err\n}", "func (client *activeClient) Ping(c *ishell.Context) error {\n\treturn client.RPC.Call(\"API.Ping\", void, &void)\n}", "func (c Client) Ping() (err error) {\n\tvar pr Pi...
[ "0.75410986", "0.64162904", "0.64137214", "0.6380477", "0.63345695", "0.6272254", "0.61578655", "0.6141015", "0.61374366", "0.6125822", "0.61245215", "0.6115694", "0.6099986", "0.6089753", "0.60880244", "0.6048584", "0.60376966", "0.6032353", "0.6032326", "0.60194355", "0.598...
0.75496507
0
ListWorkers lists all workers.
func (m *cloudManager) ListWorkers(name string, extendInfo string) ([]api.WorkerInstance, error) { c, err := m.ds.FindCloudByName(name) if err != nil { return nil, httperror.ErrorContentNotFound.Format(name) } if c.Type == api.CloudTypeKubernetes && extendInfo == "" { err := fmt.Errorf("query parameter namespace can not be empty because cloud type is %v.", api.CloudTypeKubernetes) return nil, err } if c.Kubernetes != nil { if c.Kubernetes.InCluster { // default cluster, get default namespace. c.Kubernetes.Namespace = cloud.DefaultNamespace } else { c.Kubernetes.Namespace = extendInfo } } cp, err := cloud.NewCloudProvider(c) if err != nil { return nil, httperror.ErrorUnknownInternal.Format(err) } return cp.ListWorkers() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (db *Postgres) ListWorkers() ([]Worker, error) {\n\tvar workers []Worker\n\n\trows, err := db.db.Query(`SELECT id, queue, max_job_count, attributes FROM junction.workers`)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tvar worker Worker\n\t\tvar attributes hstor...
[ "0.75559056", "0.7226931", "0.6998144", "0.6618659", "0.6598629", "0.63565457", "0.6347319", "0.6347319", "0.6347319", "0.6322651", "0.6317281", "0.63114697", "0.63114697", "0.63114697", "0.63114697", "0.63114697", "0.63114697", "0.63114697", "0.63114697", "0.63114697", "0.63...
0.7243635
1
NewSummary creates a new tracing summary that can be passed to component constructors for adding traces.
func NewSummary() *Summary { return &Summary{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewSummary(namespace, subsystem, name, help string, labelMap map[string]string, objectives map[float64]float64) prometheus.Summary {\n\treturn prometheus.NewSummary(prometheus.SummaryOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: subsystem,\n\t\tName: name,\n\t\tHelp: help,\n\t\tConstLabel...
[ "0.7158956", "0.69201916", "0.6612985", "0.6554421", "0.64981747", "0.6230694", "0.6007244", "0.5971761", "0.5917504", "0.5917504", "0.5913954", "0.56070757", "0.55766994", "0.5560569", "0.55142343", "0.5509913", "0.5428008", "0.5411781", "0.54017174", "0.5389909", "0.5364322...
0.752358
0
InputEvents returns a map of input labels to events traced during the execution of a stream pipeline.
func (s *Summary) InputEvents() map[string][]NodeEvent { m := map[string][]NodeEvent{} s.inputEvents.Range(func(key, value any) bool { m[key.(string)] = value.(*events).Extract() return true }) return m }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Engine) EventsInput() chan<- *InEvent {\n\treturn e.inEvents\n}", "func (linux *linuxSystemObject) GetInputEvents() ([]gin.OsEvent, int64) {\n\tvar first_event *C.GlopKeyEvent\n\tcp := (*unsafe.Pointer)(unsafe.Pointer(&first_event))\n\tvar length C.int\n\tvar horizon C.longlong\n\tC.GlopGetInputEvents(c...
[ "0.6246226", "0.5906484", "0.5672509", "0.56447995", "0.5487946", "0.5245688", "0.51941764", "0.50537294", "0.50033385", "0.49476933", "0.49463183", "0.49331596", "0.49174765", "0.48466128", "0.48196077", "0.47845575", "0.47838122", "0.47791883", "0.47675776", "0.47577938", "...
0.76808536
0
ProcessorEvents returns a map of processor labels to events traced during the execution of a stream pipeline.
func (s *Summary) ProcessorEvents() map[string][]NodeEvent { m := map[string][]NodeEvent{} s.processorEvents.Range(func(key, value any) bool { m[key.(string)] = value.(*events).Extract() return true }) return m }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Summary) InputEvents() map[string][]NodeEvent {\n\tm := map[string][]NodeEvent{}\n\ts.inputEvents.Range(func(key, value any) bool {\n\t\tm[key.(string)] = value.(*events).Extract()\n\t\treturn true\n\t})\n\treturn m\n}", "func eventMapping(info []*haproxy.Stat, r mb.ReporterV2) {\n\tfor _, evt := range ...
[ "0.5846361", "0.5748836", "0.5595276", "0.5388502", "0.5340182", "0.52838385", "0.52438504", "0.521005", "0.51795727", "0.5043579", "0.5035017", "0.49828053", "0.48539478", "0.4847942", "0.4814291", "0.47924703", "0.47880173", "0.47581965", "0.47513494", "0.47508985", "0.4747...
0.7830062
0
OutputEvents returns a map of output labels to events traced during the execution of a stream pipeline.
func (s *Summary) OutputEvents() map[string][]NodeEvent { m := map[string][]NodeEvent{} s.outputEvents.Range(func(key, value any) bool { m[key.(string)] = value.(*events).Extract() return true }) return m }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Engine) EventsOutput() <-chan *OutEvent {\n\treturn e.outEvents\n}", "func (o RegistryTaskSourceTriggerOutput) Events() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v RegistryTaskSourceTrigger) []string { return v.Events }).(pulumi.StringArrayOutput)\n}", "func (o IntentOutput) Events() pulumi.S...
[ "0.6442742", "0.5828244", "0.5757043", "0.5582252", "0.5567077", "0.5526591", "0.54130644", "0.5261317", "0.5246309", "0.5207136", "0.51714545", "0.5166471", "0.5164374", "0.5153409", "0.51349187", "0.5131234", "0.5125875", "0.512276", "0.5085051", "0.50706756", "0.49821892",...
0.76933664
0
preConfigureUI preconfigures UI based on information about user terminal
func preConfigureUI() { term := os.Getenv("TERM") fmtc.DisableColors = true if term != "" { switch { case strings.Contains(term, "xterm"), strings.Contains(term, "color"), term == "screen": fmtc.DisableColors = false } } if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { fmtc.DisableColors = true } if os.Getenv("NO_COLOR") != "" { fmtc.DisableColors = true } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func configureUI() {\n\tterminal.Prompt = \"› \"\n\tterminal.TitleColorTag = \"{s}\"\n\n\tif options.GetB(OPT_NO_COLOR) {\n\t\tfmtc.DisableColors = true\n\t}\n\n\tswitch {\n\tcase fmtc.IsTrueColorSupported():\n\t\tcolorTagApp, colorTagVer = \"{#CC1E2C}\", \"{#CC1E2C}\"\n\tcase fmtc.Is256ColorsSupported():\n\t\tcol...
[ "0.7180504", "0.6304459", "0.6287592", "0.57763785", "0.5560957", "0.5547894", "0.55220366", "0.5466867", "0.5362588", "0.5326284", "0.53178704", "0.52990276", "0.52901006", "0.5235003", "0.52211857", "0.51834905", "0.5153998", "0.514636", "0.5114229", "0.51125467", "0.508741...
0.7603863
1
configureUI configures user interface
func configureUI() { terminal.Prompt = "› " terminal.TitleColorTag = "{s}" if options.GetB(OPT_NO_COLOR) { fmtc.DisableColors = true } switch { case fmtc.IsTrueColorSupported(): colorTagApp, colorTagVer = "{#CC1E2C}", "{#CC1E2C}" case fmtc.Is256ColorsSupported(): colorTagApp, colorTagVer = "{#160}", "{#160}" default: colorTagApp, colorTagVer = "{r}", "{r}" } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func configureUI() {\n\tif options.GetB(OPT_NO_COLOR) {\n\t\tfmtc.DisableColors = true\n\t}\n\n\tswitch {\n\tcase fmtc.IsTrueColorSupported():\n\t\tcolorTagApp, colorTagVer = \"{#BCCF00}\", \"{#BCCF00}\"\n\tcase fmtc.Is256ColorsSupported():\n\t\tcolorTagApp, colorTagVer = \"{#148}\", \"{#148}\"\n\tdefault:\n\t\tco...
[ "0.6933391", "0.6699711", "0.66008276", "0.6512188", "0.6487177", "0.64852494", "0.64819866", "0.6439937", "0.63235915", "0.6273671", "0.6092615", "0.6066454", "0.60654086", "0.6037525", "0.595742", "0.5934977", "0.5905563", "0.57556975", "0.57553554", "0.574902", "0.5715195"...
0.7271574
0
checkArguments checks command line arguments
func checkArguments(url, dir string) { if !httputil.IsURL(url) { printErrorAndExit("Url %s doesn't look like valid url", url) } if !fsutil.IsExist(dir) { printErrorAndExit("Directory %s does not exist", dir) } if !fsutil.IsDir(dir) { printErrorAndExit("Target %s is not a directory", dir) } if !fsutil.IsReadable(dir) { printErrorAndExit("Directory %s is not readable", dir) } if !fsutil.IsExecutable(dir) { printErrorAndExit("Directory %s is not executable", dir) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func validateArguments(args ...string) error {\n\tif args == nil {\n\t\treturn errors.New(\"No command line args were specified\")\n\t}\n\tfor _, arg := range args {\n\t\tif arg == \"\" {\n\t\t\treturn errors.New(\"Unspecified required command line args\")\n\t\t}\n\t}\n\treturn nil\n}", "func CheckArguments(argu...
[ "0.7524863", "0.7486469", "0.73417056", "0.7286023", "0.72810936", "0.72313786", "0.71089345", "0.71022826", "0.70681334", "0.7038693", "0.697468", "0.67858285", "0.6767945", "0.6748791", "0.6740648", "0.6659914", "0.66559744", "0.6644422", "0.6632238", "0.65664023", "0.65651...
0.7053545
9
cloneRepository start repository clone process
func cloneRepository(url, dir string) { fmtc.Printf("Fetching index from {*}%s{!}…\n", url) i, err := fetchIndex(url) if err != nil { printErrorAndExit(err.Error()) } if i.Meta.Items == 0 { printErrorAndExit("Repository is empty") } printRepositoryInfo(i) uuid := getCurrentIndexUUID(dir) if uuid == i.UUID { fmtc.Println("{g}Looks like you already have the same set of data{!}") return } if !options.GetB(OPT_YES) { ok, err := terminal.ReadAnswer("Clone this repository?", "N") fmtc.NewLine() if !ok || err != nil { os.Exit(0) } } downloadRepositoryData(i, url, dir) saveIndex(i, dir) fmtc.NewLine() fmtc.Printf("{g}Repository successfully cloned to {g*}%s{!}\n", dir) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func cloneRepo(URI string, destdir string, conf *Configuration) error {\n\t// NOTE: cloneRepo changes the working directory to the cloned repository\n\t// See: https://github.com/G-Node/gin-cli/issues/225\n\t// This will need to change when that issue is fixed\n\torigdir, err := os.Getwd()\n\tif err != nil {\n\t\t...
[ "0.72494453", "0.6982261", "0.6927834", "0.6857167", "0.68381953", "0.67713535", "0.6685741", "0.6608449", "0.655927", "0.655684", "0.6525246", "0.6483348", "0.6481677", "0.6461571", "0.6418866", "0.641031", "0.63933265", "0.6387039", "0.6345549", "0.63412005", "0.63314986", ...
0.72198164
1
printRepositoryInfo prints basic info about repository data
func printRepositoryInfo(i *index.Index) { fmtutil.Separator(false, "REPOSITORY INFO") updated := timeutil.Format(time.Unix(i.Meta.Created, 0), "%Y/%m/%d %H:%M:%S") fmtc.Printf(" {*}UUID{!}: %s\n", i.UUID) fmtc.Printf(" {*}Updated{!}: %s\n\n", updated) for _, distName := range i.Data.Keys() { size, items := int64(0), 0 for archName, arch := range i.Data[distName] { for _, category := range arch { for _, version := range category { size += version.Size items++ if len(version.Variations) != 0 { for _, variation := range version.Variations { items++ size += variation.Size } } } } fmtc.Printf( " {c*}%s{!}{c}/%s:{!} %3s {s-}|{!} %s\n", distName, archName, fmtutil.PrettyNum(items), fmtutil.PrettySize(size, " "), ) } } fmtc.NewLine() fmtc.Printf( " {*}Total:{!} %s {s-}|{!} %s\n", fmtutil.PrettyNum(i.Meta.Items), fmtutil.PrettySize(i.Meta.Size, " "), ) fmtutil.Separator(false) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *GitRegistry) Info(ct *out.Container) {\n\tct.Add(out.NewValue(\"Repository\", r.Repository))\n}", "func (r repo) print(verbose bool) {\n\tif verbose {\n\t\tfmt.Printf(\"%s (%s)\\n\\t%s\\n\\t%s\\n\", r.Name, r.Desc, r.HTTP, r.SSH)\n\t\treturn\n\t}\n\tfmt.Println(r.SSH)\n}", "func (g *GitLocal) Info(dir...
[ "0.67226356", "0.65493935", "0.65447277", "0.62965417", "0.62847465", "0.62759304", "0.61552596", "0.61120737", "0.61120594", "0.5942547", "0.58970207", "0.58383435", "0.5824784", "0.5769643", "0.57650363", "0.57432973", "0.5742977", "0.57110584", "0.57110584", "0.5686988", "...
0.80205846
0
fetchIndex downloads remote repository index
func fetchIndex(url string) (*index.Index, error) { resp, err := req.Request{URL: url + "/" + INDEX_NAME}.Get() if err != nil { return nil, fmtc.Errorf("Can't fetch repository index: %v", err) } if resp.StatusCode != 200 { return nil, fmtc.Errorf("Can't fetch repository index: server return status code %d", resp.StatusCode) } repoIndex := &index.Index{} err = resp.JSON(repoIndex) if err != nil { return nil, fmtc.Errorf("Can't decode repository index: %v", err) } return repoIndex, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func fetchRepoIndex(netClient *HTTPClient, repoURL string, authHeader string) (*repo.IndexFile, error) {\n\treq, err := getReq(repoURL, authHeader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres, err := (*netClient).Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdata, err := readResponseBody(res)\n...
[ "0.79848945", "0.69114137", "0.684012", "0.67962646", "0.67911434", "0.6659791", "0.65676916", "0.62828726", "0.62654114", "0.6249647", "0.62363887", "0.6105302", "0.6061409", "0.6012638", "0.600222", "0.5990207", "0.59626997", "0.5819786", "0.5818868", "0.5790951", "0.578559...
0.78158385
1
downloadRepositoryData downloads all files from repository
func downloadRepositoryData(i *index.Index, url, dir string) { items := getItems(i, url) pb := progress.New(int64(len(items)), "Starting…") pbs := progress.DefaultSettings pbs.IsSize = false pbs.ShowSpeed = false pbs.ShowRemaining = false pbs.ShowName = false pbs.NameColorTag = "{*}" pbs.BarFgColorTag = colorTagApp pbs.PercentColorTag = "" pbs.RemainingColorTag = "{s}" pb.UpdateSettings(pbs) pb.Start() fmtc.Printf( "Downloading %s %s from remote repository…\n", fmtutil.PrettyNum(len(items)), pluralize.Pluralize(len(items), "file", "files"), ) for _, item := range items { fileDir := path.Join(dir, item.OS, item.Arch) filePath := path.Join(dir, item.OS, item.Arch, item.File) if !fsutil.IsExist(fileDir) { err := os.MkdirAll(fileDir, 0755) if err != nil { pb.Finish() fmtc.NewLine() printErrorAndExit("Can't create directory %s: %v", fileDir, err) } } if fsutil.IsExist(filePath) { fileSize := fsutil.GetSize(filePath) if fileSize == item.Size { pb.Add(1) continue } } err := downloadFile(item.URL, filePath) if err != nil { pb.Finish() fmtc.NewLine() printErrorAndExit("%v", err) } pb.Add(1) } pb.Finish() fmtc.Printf("\n{g}Repository successfully cloned into %s{!}\n") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (repo *RemoteRepo) Download(d utils.Downloader, db database.Storage, packageRepo *Repository) error {\n\tlist := NewPackageList()\n\n\t// Download and parse all Release files\n\tfor _, component := range repo.Components {\n\t\tfor _, architecture := range repo.Architectures {\n\t\t\tpackagesReader, packagesFi...
[ "0.6849753", "0.652801", "0.64715755", "0.6380562", "0.6337232", "0.62812746", "0.6122708", "0.6094378", "0.60897374", "0.6086116", "0.6058918", "0.59934855", "0.58915913", "0.58904564", "0.5856266", "0.584288", "0.58072853", "0.57997537", "0.57943255", "0.57816243", "0.57566...
0.7770635
0
getItems returns slice with info about items in repository
func getItems(repoIndex *index.Index, url string) []FileInfo { var items []FileInfo for _, os := range repoIndex.Data.Keys() { for _, arch := range repoIndex.Data[os].Keys() { for _, category := range repoIndex.Data[os][arch].Keys() { for _, version := range repoIndex.Data[os][arch][category] { items = append(items, FileInfo{ File: version.File, URL: url + "/" + version.Path + "/" + version.File, OS: os, Arch: arch, Size: version.Size, }) if len(version.Variations) != 0 { for _, subVersion := range version.Variations { items = append(items, FileInfo{ File: subVersion.File, URL: url + "/" + subVersion.Path + "/" + subVersion.File, OS: os, Arch: arch, Size: subVersion.Size, }) } } } } } } return items }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (is *ItemServices) Items(ctx context.Context, limit, offset int) ([]entity.Item, []error) {\n\titms, errs := is.itemRepo.Items(ctx, limit, offset)\n\tif len(errs) > 0 {\n\t\treturn nil, errs\n\t}\n\treturn itms, errs\n}", "func (c *container) Items(prefix, cursor string, count int) ([]stow.Item, string, err...
[ "0.64373845", "0.6281059", "0.6268589", "0.61503065", "0.60985714", "0.6079799", "0.6058126", "0.60465604", "0.59909725", "0.5920822", "0.5885976", "0.5869522", "0.581138", "0.5810596", "0.5780842", "0.57463956", "0.573643", "0.57293844", "0.56773424", "0.5636208", "0.5576961...
0.676599
0
downloadFile downloads and saves remote file
func downloadFile(url, output string) error { if fsutil.IsExist(output) { os.Remove(output) } fd, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0644) if err != nil { return fmtc.Errorf("Can't create file: %v", err) } defer fd.Close() resp, err := req.Request{URL: url}.Get() if err != nil { return fmtc.Errorf("Can't download file: %v", err) } if resp.StatusCode != 200 { return fmtc.Errorf("Can't download file: server return status code %d", resp.StatusCode) } w := bufio.NewWriter(fd) _, err = io.Copy(w, resp.Body) w.Flush() if err != nil { return fmtc.Errorf("Can't write file: %v", err) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func downloadFile(filename, url string) error {\n\t// Try to create the file with the given filename.\n\tfile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\t// Get the response from the given url.\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\...
[ "0.78253835", "0.7821619", "0.78051573", "0.78037894", "0.7765332", "0.7765332", "0.7757129", "0.765652", "0.7597339", "0.7491274", "0.7459667", "0.742792", "0.7427161", "0.7413067", "0.7369334", "0.7362799", "0.73234963", "0.7300355", "0.7300355", "0.7300355", "0.7300355", ...
0.7467502
10
saveIndex encodes index to JSON format and saves it into the file
func saveIndex(repoIndex *index.Index, dir string) { indexPath := path.Join(dir, INDEX_NAME) fmtc.Printf("Saving index… ") err := jsonutil.Write(indexPath, repoIndex) if err != nil { fmtc.Println("{r}ERROR{!}") printErrorAndExit("Can't save index as %s: %v", indexPath, err) } fmtc.Println("{g}DONE{!}") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func SaveIndex(target string, source QueryList, verbose bool) {\n\tlogm(\"INFO\", fmt.Sprintf(\"saving index to %s...\", target), verbose)\n\tfile, err := os.Create(target)\n\tcheckResult(err)\n\tdefer file.Close()\n\n\tgr := gzip.NewWriter(file)\n\tdefer gr.Close()\n\n\tencoder := gob.NewEncoder(gr)\n\n\terr = en...
[ "0.7623538", "0.7393146", "0.7294664", "0.7245271", "0.72254014", "0.6892107", "0.686368", "0.6761404", "0.6594129", "0.65816647", "0.6541175", "0.6535057", "0.65122896", "0.6489205", "0.6458479", "0.64109933", "0.64108104", "0.63792455", "0.6146911", "0.6144461", "0.609384",...
0.8331292
0
getCurrentIndexUUID returns current index UUID (if exist)
func getCurrentIndexUUID(dir string) string { indexFile := path.Join(dir, INDEX_NAME) if !fsutil.IsExist(indexFile) { return "" } i := &index.Index{} if jsonutil.Read(indexFile, i) != nil { return "" } return i.UUID }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getCBGTIndexUUID(manager *cbgt.Manager, indexName string) (exists bool, previousUUID string, err error) {\n\n\t_, indexDefsMap, err := manager.GetIndexDefs(true)\n\tif err != nil {\n\t\treturn false, \"\", errors.Wrapf(err, \"Error calling CBGT GetIndexDefs() on index: %s\", indexName)\n\t}\n\n\tindexDef, ok ...
[ "0.7144685", "0.5786462", "0.57137805", "0.56747085", "0.5615748", "0.5600664", "0.5521853", "0.5507938", "0.5505144", "0.5474473", "0.54624945", "0.54579675", "0.54390085", "0.54054946", "0.5388893", "0.53199935", "0.53090554", "0.52770084", "0.5256892", "0.5210128", "0.5189...
0.8477617
0
////////////////////////////////////////////////////////////////////////////////// // printCompletion prints completion for given shell
func printCompletion() int { info := genUsage() switch options.GetS(OPT_COMPLETION) { case "bash": fmt.Printf(bash.Generate(info, "rbinstall-clone")) case "fish": fmt.Printf(fish.Generate(info, "rbinstall-clone")) case "zsh": fmt.Printf(zsh.Generate(info, optMap, "rbinstall-clone")) default: return 1 } return 0 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func printCompletion() int {\n\tinfo := genUsage()\n\n\tswitch options.GetS(OPT_COMPLETION) {\n\tcase \"bash\":\n\t\tfmt.Printf(bash.Generate(info, \"init-exporter\"))\n\tcase \"fish\":\n\t\tfmt.Printf(fish.Generate(info, \"init-exporter\"))\n\tcase \"zsh\":\n\t\tfmt.Printf(zsh.Generate(info, optMap, \"init-export...
[ "0.7543102", "0.6336671", "0.63106585", "0.610397", "0.60926086", "0.6042343", "0.5869837", "0.58365184", "0.5782093", "0.56852394", "0.5645756", "0.5562036", "0.553493", "0.5518101", "0.5499502", "0.54641956", "0.5390887", "0.53255993", "0.5296073", "0.52767366", "0.5222355"...
0.76840794
0
printMan prints man page
func printMan() { fmt.Println( man.Generate( genUsage(), genAbout(""), ), ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func printHelp(h helper, pp parentParser) {\n\thelpWriter.Write([]byte(h.help(pp)))\n}", "func showManual(manual string) error {\n\tmanBinary, err := exec.LookPath(\"man\")\n\tif err != nil {\n\t\tif errors.Is(err, exec.ErrNotFound) {\n\t\t\tfmt.Printf(\"toolbox - Tool for containerized command line environments...
[ "0.643233", "0.6397411", "0.6154959", "0.60716003", "0.60066336", "0.5985333", "0.59567195", "0.5945319", "0.592143", "0.59141445", "0.58520895", "0.57988304", "0.57733864", "0.5760647", "0.5757078", "0.5738855", "0.56932425", "0.56881464", "0.56636477", "0.56211007", "0.5620...
0.80187
1
genUsage generates usage info
func genUsage() *usage.Info { info := usage.NewInfo("", "url", "path") info.AppNameColorTag = "{*}" + colorTagApp info.AddOption(OPT_YES, `Answer "yes" to all questions`) info.AddOption(OPT_NO_COLOR, "Disable colors in output") info.AddOption(OPT_HELP, "Show this help message") info.AddOption(OPT_VER, "Show version") info.AddExample( "https://rbinstall.kaos.st /path/to/clone", "Clone EK repository to /path/to/clone", ) return info }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func genUsage(w io.Writer, cmdName string) error {\n\t// Capture output from running:\n\t// foo -help\n\tbuf := new(bytes.Buffer)\n\tcmd := exec.Command(cmdName, \"-help\")\n\tcmd.Stderr = buf\n\tcmd.Run()\n\n\t// Add DO NOT EDIT notice.\n\tout := new(bytes.Buffer)\n\tfmt.Fprintf(out, \"// Generated by `usagen ...
[ "0.79965514", "0.78128314", "0.7793384", "0.7136047", "0.7110214", "0.7013749", "0.64894265", "0.6456141", "0.635502", "0.62977207", "0.62948483", "0.6276718", "0.6258758", "0.6257365", "0.625348", "0.6252613", "0.62342244", "0.6221245", "0.6178919", "0.61595225", "0.6082342"...
0.7992258
1
genAbout generates info about version
func genAbout(gitRev string) *usage.About { about := &usage.About{ App: APP, Version: VER, Desc: DESC, Year: 2006, Owner: "ESSENTIAL KAOS", License: "Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>", AppNameColorTag: "{*}" + colorTagApp, VersionColorTag: colorTagVer, } if gitRev != "" { about.Build = "git:" + gitRev } return about }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func genAbout(gitRev string) *usage.About {\n\tabout := &usage.About{\n\t\tApp: APP,\n\t\tVersion: VER,\n\t\tDesc: DESC,\n\t\tYear: 2006,\n\t\tOwner: \"FunBox\",\n\t\tLicense: \"MIT License\",\n\t\tUpdateChecker: usage.UpdateChecker{\"funbox/init-exporter\", update.G...
[ "0.8218457", "0.6725305", "0.6665721", "0.6322846", "0.62238806", "0.61022305", "0.6076054", "0.6026096", "0.6021514", "0.6009816", "0.5996698", "0.59879005", "0.59854835", "0.587912", "0.5858202", "0.584068", "0.5830515", "0.5756458", "0.57129806", "0.5682438", "0.5669994", ...
0.8162136
1