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 |
|---|---|---|---|---|---|---|
Validate returns an error if key is empty | func (kv BatchKeyRotateKV) Validate() error {
if kv.Key == "" {
return errInvalidArgument
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func validateKey(key *types.MapValue) error {\n\tif key == nil {\n\t\treturn nosqlerr.NewIllegalArgument(\"Key must be non-nil\")\n\t}\n\n\tif key.Len() == 0 {\n\t\treturn nosqlerr.NewIllegalArgument(\"Key must be non-empty\")\n\t}\n\n\treturn nil\n}",
"func (e EmptyValidationError) Key() bool { return e.key }",... | [
"0.75002897",
"0.69816774",
"0.690423",
"0.6776137",
"0.6737957",
"0.662673",
"0.65838337",
"0.6549191",
"0.64973724",
"0.64879715",
"0.6456016",
"0.6449215",
"0.64477557",
"0.6446813",
"0.64176035",
"0.6412607",
"0.63904417",
"0.63821954",
"0.63796514",
"0.6375793",
"0.63753... | 0.693187 | 2 |
Empty indicates if kv is not set | func (kv BatchKeyRotateKV) Empty() bool {
return kv.Key == "" && kv.Value == ""
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func hasNonEmptyKV(kvMap map[string]string) bool {\n\tfor k, v := range kvMap {\n\t\tif strings.TrimSpace(k) == \"\" && strings.TrimSpace(v) == \"\" {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}",
"func equalNilAndEmpty(key, value string, params Parameter) bool {\n if v, ok := params[key]; ok {\n ... | [
"0.6333462",
"0.6198159",
"0.61713",
"0.6114734",
"0.59245336",
"0.5807965",
"0.5784596",
"0.55849326",
"0.55599976",
"0.5501188",
"0.5485564",
"0.54497916",
"0.54161036",
"0.5416033",
"0.537964",
"0.53667325",
"0.53588593",
"0.53375435",
"0.53161156",
"0.52891976",
"0.528753... | 0.65100455 | 0 |
Match matches input kv with kv, value will be wildcard matched depending on the user input | func (kv BatchKeyRotateKV) Match(ikv BatchKeyRotateKV) bool {
if kv.Empty() {
return true
}
if strings.EqualFold(kv.Key, ikv.Key) {
return wildcard.Match(kv.Value, ikv.Value)
}
return false
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Match(goos, kv, key string) (value string, ok bool) {\n\tif len(kv) <= len(key) || kv[len(key)] != '=' {\n\t\treturn \"\", false\n\t}\n\n\tif goos == \"windows\" {\n\t\t// Case insensitive.\n\t\tif !strings.EqualFold(kv[:len(key)], key) {\n\t\t\treturn \"\", false\n\t\t}\n\t} else {\n\t\t// Case sensitive.\n\... | [
"0.7097848",
"0.69746256",
"0.6162469",
"0.6156034",
"0.60447186",
"0.599638",
"0.5879797",
"0.5872499",
"0.5860298",
"0.58108395",
"0.57897544",
"0.57737875",
"0.5747656",
"0.5741802",
"0.56776214",
"0.5676985",
"0.5634095",
"0.56085414",
"0.5597004",
"0.5589954",
"0.557177"... | 0.71222144 | 0 |
Validate validates input replicate retries. | func (r BatchKeyRotateRetry) Validate() error {
if r.Attempts < 0 {
return errInvalidArgument
}
if r.Delay < 0 {
return errInvalidArgument
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (r BatchReplicateRetry) Validate() error {\n\tif r.Attempts < 0 {\n\t\treturn errInvalidArgument\n\t}\n\n\tif r.Delay < 0 {\n\t\treturn errInvalidArgument\n\t}\n\n\treturn nil\n}",
"func (r *BatchJobReplicateV1) Validate(ctx context.Context, job BatchJobRequest, o ObjectLayer) error {\n\tif r == nil {\n\t\t... | [
"0.74960744",
"0.57643306",
"0.5702115",
"0.55220336",
"0.5487586",
"0.5443635",
"0.52778167",
"0.5185343",
"0.51229566",
"0.5120975",
"0.5108453",
"0.5068902",
"0.50688136",
"0.50606054",
"0.50606054",
"0.5039195",
"0.50262135",
"0.5020048",
"0.49768957",
"0.49728695",
"0.49... | 0.6482321 | 1 |
Validate validates input key rotation encryption options. | func (e BatchJobKeyRotateEncryption) Validate() error {
if e.Type != sses3 && e.Type != ssekms {
return errInvalidArgument
}
spaces := strings.HasPrefix(e.Key, " ") || strings.HasSuffix(e.Key, " ")
if e.Type == ssekms && spaces {
return crypto.ErrInvalidEncryptionKeyID
}
if e.Type == ssekms && GlobalKMS != nil {
ctx := kms.Context{}
if e.Context != "" {
b, err := base64.StdEncoding.DecodeString(e.Context)
if err != nil {
return err
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal(b, &ctx); err != nil {
return err
}
}
e.kmsContext = kms.Context{}
for k, v := range ctx {
e.kmsContext[k] = v
}
ctx["MinIO batch API"] = "batchrotate" // Context for a test key operation
if _, err := GlobalKMS.GenerateKey(GlobalContext, e.Key, ctx); err != nil {
return err
}
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (kv BatchKeyRotateKV) Validate() error {\n\tif kv.Key == \"\" {\n\t\treturn errInvalidArgument\n\t}\n\treturn nil\n}",
"func (e RotationValidationError) Key() bool { return e.key }",
"func (r *BatchJobKeyRotateV1) Validate(ctx context.Context, job BatchJobRequest, o ObjectLayer) error {\n\tif r == nil {\n... | [
"0.6198566",
"0.5907458",
"0.5780951",
"0.56250936",
"0.55951184",
"0.5560013",
"0.5555904",
"0.54674876",
"0.5467326",
"0.54615873",
"0.5447552",
"0.54134583",
"0.5411202",
"0.5406471",
"0.5354693",
"0.5336632",
"0.53256315",
"0.53087765",
"0.52998185",
"0.52895993",
"0.5269... | 0.6515647 | 0 |
Notify notifies notification endpoint if configured regarding job failure or success. | func (r BatchJobKeyRotateV1) Notify(ctx context.Context, body io.Reader) error {
if r.Flags.Notify.Endpoint == "" {
return nil
}
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, r.Flags.Notify.Endpoint, body)
if err != nil {
return err
}
if r.Flags.Notify.Token != "" {
req.Header.Set("Authorization", r.Flags.Notify.Token)
}
clnt := http.Client{Transport: getRemoteInstanceTransport}
resp, err := clnt.Do(req)
if err != nil {
return err
}
xhttp.DrainBody(resp.Body)
if resp.StatusCode != http.StatusOK {
return errors.New(resp.Status)
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func notify(job jobConfig, result runResult) error {\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tclient := &http.Client{\n\t\tTimeout: time.Second * 10,\n\t}\n\n\tnotifyPayload := jobNotify{\n\t\tRunID: job.ID,\n\t\tSuccess: result.Success,\n\t\tOutput: result.Output,\n\t\... | [
"0.67180604",
"0.655542",
"0.6183939",
"0.6133323",
"0.60512966",
"0.58008385",
"0.5772567",
"0.5686183",
"0.5661964",
"0.565898",
"0.5417281",
"0.541208",
"0.5409103",
"0.5391522",
"0.5385122",
"0.537624",
"0.5346147",
"0.5321421",
"0.53012604",
"0.52782583",
"0.5277206",
... | 0.5461978 | 10 |
KeyRotate rotates encryption key of an object | func (r *BatchJobKeyRotateV1) KeyRotate(ctx context.Context, api ObjectLayer, objInfo ObjectInfo) error {
srcBucket := r.Bucket
srcObject := objInfo.Name
if objInfo.DeleteMarker || !objInfo.VersionPurgeStatus.Empty() {
return nil
}
sseKMS := crypto.S3KMS.IsEncrypted(objInfo.UserDefined)
sseS3 := crypto.S3.IsEncrypted(objInfo.UserDefined)
if !sseKMS && !sseS3 { // neither sse-s3 nor sse-kms disallowed
return errInvalidEncryptionParameters
}
if sseKMS && r.Encryption.Type == sses3 { // previously encrypted with sse-kms, now sse-s3 disallowed
return errInvalidEncryptionParameters
}
versioned := globalBucketVersioningSys.PrefixEnabled(srcBucket, srcObject)
versionSuspended := globalBucketVersioningSys.PrefixSuspended(srcBucket, srcObject)
lock := api.NewNSLock(r.Bucket, objInfo.Name)
lkctx, err := lock.GetLock(ctx, globalOperationTimeout)
if err != nil {
return err
}
ctx = lkctx.Context()
defer lock.Unlock(lkctx)
opts := ObjectOptions{
VersionID: objInfo.VersionID,
Versioned: versioned,
VersionSuspended: versionSuspended,
NoLock: true,
}
obj, err := api.GetObjectInfo(ctx, r.Bucket, objInfo.Name, opts)
if err != nil {
return err
}
oi := obj.Clone()
var (
newKeyID string
newKeyContext kms.Context
)
encMetadata := make(map[string]string)
for k, v := range oi.UserDefined {
if strings.HasPrefix(strings.ToLower(k), ReservedMetadataPrefixLower) {
encMetadata[k] = v
}
}
if (sseKMS || sseS3) && r.Encryption.Type == ssekms {
if err = r.Encryption.Validate(); err != nil {
return err
}
newKeyID = strings.TrimPrefix(r.Encryption.Key, crypto.ARNPrefix)
newKeyContext = r.Encryption.kmsContext
}
if err = rotateKey(ctx, []byte{}, newKeyID, []byte{}, r.Bucket, oi.Name, encMetadata, newKeyContext); err != nil {
return err
}
// Since we are rotating the keys, make sure to update the metadata.
oi.metadataOnly = true
oi.keyRotation = true
for k, v := range encMetadata {
oi.UserDefined[k] = v
}
if _, err := api.CopyObject(ctx, r.Bucket, oi.Name, r.Bucket, oi.Name, oi, ObjectOptions{
VersionID: oi.VersionID,
}, ObjectOptions{
VersionID: oi.VersionID,
NoLock: true,
}); err != nil {
return err
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func rotateKey(oldKey []byte, newKey []byte, metadata map[string]string) error {\n\tdelete(metadata, SSECustomerKey) // make sure we do not save the key by accident\n\n\tif metadata[ServerSideEncryptionSealAlgorithm] != SSESealAlgorithmDareSha256 { // currently DARE-SHA256 is the only option\n\t\treturn errObjectT... | [
"0.68230635",
"0.66989833",
"0.66093475",
"0.647618",
"0.6370345",
"0.6170176",
"0.60946894",
"0.6072444",
"0.5827766",
"0.5811087",
"0.5599854",
"0.5597232",
"0.55714077",
"0.55631316",
"0.55575067",
"0.55345094",
"0.55277187",
"0.549797",
"0.5486713",
"0.545797",
"0.5429036... | 0.7712946 | 0 |
Start the batch key rottion job, resumes if there was a pending job via "job.ID" | func (r *BatchJobKeyRotateV1) Start(ctx context.Context, api ObjectLayer, job BatchJobRequest) error {
ri := &batchJobInfo{
JobID: job.ID,
JobType: string(job.Type()),
StartTime: job.Started,
}
if err := ri.load(ctx, api, job); err != nil {
return err
}
globalBatchJobsMetrics.save(job.ID, ri)
lastObject := ri.Object
delay := job.KeyRotate.Flags.Retry.Delay
if delay == 0 {
delay = batchKeyRotateJobDefaultRetryDelay
}
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
skip := func(info FileInfo) (ok bool) {
if r.Flags.Filter.OlderThan > 0 && time.Since(info.ModTime) < r.Flags.Filter.OlderThan {
// skip all objects that are newer than specified older duration
return false
}
if r.Flags.Filter.NewerThan > 0 && time.Since(info.ModTime) >= r.Flags.Filter.NewerThan {
// skip all objects that are older than specified newer duration
return false
}
if !r.Flags.Filter.CreatedAfter.IsZero() && r.Flags.Filter.CreatedAfter.Before(info.ModTime) {
// skip all objects that are created before the specified time.
return false
}
if !r.Flags.Filter.CreatedBefore.IsZero() && r.Flags.Filter.CreatedBefore.After(info.ModTime) {
// skip all objects that are created after the specified time.
return false
}
if len(r.Flags.Filter.Tags) > 0 {
// Only parse object tags if tags filter is specified.
tagMap := map[string]string{}
tagStr := info.Metadata[xhttp.AmzObjectTagging]
if len(tagStr) != 0 {
t, err := tags.ParseObjectTags(tagStr)
if err != nil {
return false
}
tagMap = t.ToMap()
}
for _, kv := range r.Flags.Filter.Tags {
for t, v := range tagMap {
if kv.Match(BatchKeyRotateKV{Key: t, Value: v}) {
return true
}
}
}
// None of the provided tags filter match skip the object
return false
}
if len(r.Flags.Filter.Metadata) > 0 {
for _, kv := range r.Flags.Filter.Metadata {
for k, v := range info.Metadata {
if !strings.HasPrefix(strings.ToLower(k), "x-amz-meta-") && !isStandardHeader(k) {
continue
}
// We only need to match x-amz-meta or standardHeaders
if kv.Match(BatchKeyRotateKV{Key: k, Value: v}) {
return true
}
}
}
// None of the provided metadata filters match skip the object.
return false
}
if r.Flags.Filter.KMSKeyID != "" {
if v, ok := info.Metadata[xhttp.AmzServerSideEncryptionKmsID]; ok && strings.TrimPrefix(v, crypto.ARNPrefix) != r.Flags.Filter.KMSKeyID {
return false
}
}
return true
}
workerSize, err := strconv.Atoi(env.Get("_MINIO_BATCH_KEYROTATION_WORKERS", strconv.Itoa(runtime.GOMAXPROCS(0)/2)))
if err != nil {
return err
}
wk, err := workers.New(workerSize)
if err != nil {
// invalid worker size.
return err
}
retryAttempts := ri.RetryAttempts
ctx, cancel := context.WithCancel(ctx)
results := make(chan ObjectInfo, 100)
if err := api.Walk(ctx, r.Bucket, r.Prefix, results, ObjectOptions{
WalkMarker: lastObject,
WalkFilter: skip,
}); err != nil {
cancel()
// Do not need to retry if we can't list objects on source.
return err
}
for result := range results {
result := result
sseKMS := crypto.S3KMS.IsEncrypted(result.UserDefined)
sseS3 := crypto.S3.IsEncrypted(result.UserDefined)
if !sseKMS && !sseS3 { // neither sse-s3 nor sse-kms disallowed
continue
}
wk.Take()
go func() {
defer wk.Give()
for attempts := 1; attempts <= retryAttempts; attempts++ {
attempts := attempts
stopFn := globalBatchJobsMetrics.trace(batchKeyRotationMetricObject, job.ID, attempts, result)
success := true
if err := r.KeyRotate(ctx, api, result); err != nil {
stopFn(err)
logger.LogIf(ctx, err)
success = false
} else {
stopFn(nil)
}
ri.trackCurrentBucketObject(r.Bucket, result, success)
ri.RetryAttempts = attempts
globalBatchJobsMetrics.save(job.ID, ri)
// persist in-memory state to disk after every 10secs.
logger.LogIf(ctx, ri.updateAfter(ctx, api, 10*time.Second, job))
if success {
break
}
}
}()
}
wk.Wait()
ri.Complete = ri.ObjectsFailed == 0
ri.Failed = ri.ObjectsFailed > 0
globalBatchJobsMetrics.save(job.ID, ri)
// persist in-memory state to disk.
logger.LogIf(ctx, ri.updateAfter(ctx, api, 0, job))
buf, _ := json.Marshal(ri)
if err := r.Notify(ctx, bytes.NewReader(buf)); err != nil {
logger.LogIf(ctx, fmt.Errorf("unable to notify %v", err))
}
cancel()
if ri.Failed {
ri.ObjectsFailed = 0
ri.Bucket = ""
ri.Object = ""
ri.Objects = 0
time.Sleep(delay + time.Duration(rnd.Float64()*float64(delay)))
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (a adminAPIHandlers) StartBatchJob(w http.ResponseWriter, r *http.Request) {\n\tctx := newContext(r, w, \"StartBatchJob\")\n\n\tdefer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))\n\n\tobjectAPI, creds := validateAdminReq(ctx, w, r, iampolicy.StartBatchJobAction)\n\tif objectAPI == nil {\n\t\treturn\n... | [
"0.63678306",
"0.60703164",
"0.5710661",
"0.56723154",
"0.5664913",
"0.5619767",
"0.55071634",
"0.5507015",
"0.5505586",
"0.54581165",
"0.54401153",
"0.54312783",
"0.5407354",
"0.5398783",
"0.5394899",
"0.53920925",
"0.539137",
"0.538903",
"0.5365163",
"0.53522587",
"0.533672... | 0.608413 | 1 |
Validate validates the job definition input | func (r *BatchJobKeyRotateV1) Validate(ctx context.Context, job BatchJobRequest, o ObjectLayer) error {
if r == nil {
return nil
}
if r.APIVersion != batchKeyRotateAPIVersion {
return errInvalidArgument
}
if r.Bucket == "" {
return errInvalidArgument
}
if _, err := o.GetBucketInfo(ctx, r.Bucket, BucketOptions{}); err != nil {
if isErrBucketNotFound(err) {
return batchKeyRotationJobError{
Code: "NoSuchSourceBucket",
Description: "The specified source bucket does not exist",
HTTPStatusCode: http.StatusNotFound,
}
}
return err
}
if GlobalKMS == nil {
return errKMSNotConfigured
}
if err := r.Encryption.Validate(); err != nil {
return err
}
for _, tag := range r.Flags.Filter.Tags {
if err := tag.Validate(); err != nil {
return err
}
}
for _, meta := range r.Flags.Filter.Metadata {
if err := meta.Validate(); err != nil {
return err
}
}
if err := r.Flags.Retry.Validate(); err != nil {
return err
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s ScheduledJob) validate() error {\n\tvar err error\n\tif err = s.ScheduledJobConfig.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = s.Workload.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = validateContainerDeps(validateDependenciesOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t\timageCon... | [
"0.71353847",
"0.70872307",
"0.7057234",
"0.70403004",
"0.7038734",
"0.6985453",
"0.6956082",
"0.6955184",
"0.6812868",
"0.6765313",
"0.6757547",
"0.675049",
"0.6660855",
"0.6626627",
"0.65732706",
"0.6557419",
"0.65209156",
"0.6478754",
"0.6438617",
"0.631663",
"0.6313686",
... | 0.58256733 | 42 |
toGA is an utility method to return the baseInstance data as a GA Instance object | func (bi *baseInstance) toGA() *ga.Instance {
inst := &ga.Instance{Name: bi.name, Zone: bi.zone, NetworkInterfaces: []*ga.NetworkInterface{{}}}
if bi.aliasRange != "" {
inst.NetworkInterfaces[0].AliasIpRanges = []*ga.AliasIpRange{
{IpCidrRange: bi.aliasRange, SubnetworkRangeName: util.TestSecondaryRangeName},
}
}
return inst
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (bi *baseInstance) toBeta() *beta.Instance {\n\tinst := &beta.Instance{Name: bi.name, Zone: bi.zone, NetworkInterfaces: []*beta.NetworkInterface{{}}}\n\tif bi.aliasRange != \"\" {\n\t\tinst.NetworkInterfaces[0].AliasIpRanges = []*beta.AliasIpRange{\n\t\t\t{IpCidrRange: bi.aliasRange, SubnetworkRangeName: util... | [
"0.58498",
"0.55195946",
"0.5480924",
"0.5227962",
"0.50450355",
"0.4820873",
"0.48025364",
"0.47862035",
"0.4779465",
"0.47661734",
"0.47625732",
"0.4697985",
"0.46975428",
"0.46894577",
"0.46771544",
"0.46434072",
"0.46340284",
"0.46209815",
"0.46189263",
"0.46185815",
"0.4... | 0.8056762 | 0 |
toGA is an utility method to return the baseInstance data as a beta Instance object | func (bi *baseInstance) toBeta() *beta.Instance {
inst := &beta.Instance{Name: bi.name, Zone: bi.zone, NetworkInterfaces: []*beta.NetworkInterface{{}}}
if bi.aliasRange != "" {
inst.NetworkInterfaces[0].AliasIpRanges = []*beta.AliasIpRange{
{IpCidrRange: bi.aliasRange, SubnetworkRangeName: util.TestSecondaryRangeName},
}
}
return inst
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (bi *baseInstance) toGA() *ga.Instance {\n\tinst := &ga.Instance{Name: bi.name, Zone: bi.zone, NetworkInterfaces: []*ga.NetworkInterface{{}}}\n\tif bi.aliasRange != \"\" {\n\t\tinst.NetworkInterfaces[0].AliasIpRanges = []*ga.AliasIpRange{\n\t\t\t{IpCidrRange: bi.aliasRange, SubnetworkRangeName: util.TestSecon... | [
"0.772265",
"0.55584383",
"0.54472685",
"0.5152903",
"0.5063716",
"0.4974295",
"0.49704218",
"0.496328",
"0.48645544",
"0.48514754",
"0.4848639",
"0.48257947",
"0.48195985",
"0.48057404",
"0.47782093",
"0.47607097",
"0.4754396",
"0.47254223",
"0.47182488",
"0.47182488",
"0.47... | 0.688688 | 1 |
newBaseInstanceList is the baseInstanceList constructor | func newBaseInstanceList(allocateCIDR bool, clusterCIDR *net.IPNet, subnetMaskSize int) *baseInstanceList {
cidrSet, _ := cidrset.NewCIDRSet(clusterCIDR, subnetMaskSize)
return &baseInstanceList{
allocateCIDR: allocateCIDR,
clusterCIDR: clusterCIDR,
subnetMaskSize: subnetMaskSize,
cidrSet: cidrSet,
instances: make(map[meta.Key]*baseInstance),
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func newBase() *base {\n\treturn &base{shared.NewUUID(), time.Now().UTC(), time.Now().UTC(), false/*, shared.NewUUID()*/}\n}",
"func newSubInstance(parent *BaseInstance, name string) *BaseInstance {\n\tsi := parent.module.subinstance\n\tif si == nil {\n\t\tsi = make(map[string][]*BaseInstance)\n\t\tparent.module... | [
"0.6095147",
"0.6051629",
"0.60512936",
"0.60462177",
"0.6043791",
"0.5972696",
"0.58985627",
"0.5896269",
"0.58636135",
"0.5861767",
"0.57537234",
"0.573758",
"0.5711063",
"0.5693298",
"0.5691532",
"0.5683488",
"0.5661154",
"0.5661154",
"0.5643412",
"0.56272656",
"0.5625379"... | 0.8217321 | 0 |
getOrCreateBaseInstance lazily creates a new base instance, assigning if allocateCIDR is true | func (bil *baseInstanceList) getOrCreateBaseInstance(key *meta.Key) *baseInstance {
bil.lock.Lock()
defer bil.lock.Unlock()
inst, found := bil.instances[*key]
if !found {
inst = &baseInstance{name: key.Name, zone: key.Zone}
if bil.allocateCIDR {
nextRange, _ := bil.cidrSet.AllocateNext()
inst.aliasRange = nextRange.String()
}
bil.instances[*key] = inst
}
return inst
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func newBaseInstanceList(allocateCIDR bool, clusterCIDR *net.IPNet, subnetMaskSize int) *baseInstanceList {\n\tcidrSet, _ := cidrset.NewCIDRSet(clusterCIDR, subnetMaskSize)\n\treturn &baseInstanceList{\n\t\tallocateCIDR: allocateCIDR,\n\t\tclusterCIDR: clusterCIDR,\n\t\tsubnetMaskSize: subnetMaskSize,\n\t\tci... | [
"0.5949005",
"0.5725722",
"0.5369504",
"0.5214787",
"0.5149179",
"0.5123685",
"0.5117184",
"0.5099963",
"0.5049843",
"0.5029948",
"0.50290453",
"0.50138724",
"0.49412763",
"0.49271756",
"0.48621428",
"0.48538187",
"0.47791496",
"0.47764036",
"0.47500402",
"0.47404003",
"0.473... | 0.72381115 | 0 |
newGAGetHook creates a new closure with the current baseInstanceList to be used as a MockInstances.GetHook | func (bil *baseInstanceList) newGAGetHook() func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {
return func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {
m.Lock.Lock()
defer m.Lock.Unlock()
if _, found := m.Objects[*key]; !found {
m.Objects[*key] = &cloud.MockInstancesObj{Obj: bil.getOrCreateBaseInstance(key).toGA()}
}
return false, nil, nil
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (bil *baseInstanceList) newBetaGetHook() func(ctx context.Context, key *meta.Key, m *cloud.MockBetaInstances) (bool, *beta.Instance, error) {\n\treturn func(ctx context.Context, key *meta.Key, m *cloud.MockBetaInstances) (bool, *beta.Instance, error) {\n\t\tm.Lock.Lock()\n\t\tdefer m.Lock.Unlock()\n\n\t\tif _... | [
"0.73362684",
"0.55606365",
"0.5346862",
"0.53349245",
"0.51018983",
"0.50766736",
"0.50756764",
"0.5031727",
"0.49362725",
"0.49105883",
"0.48886675",
"0.48711956",
"0.48659244",
"0.4857758",
"0.4857758",
"0.4845478",
"0.4821866",
"0.47960016",
"0.47906336",
"0.4775277",
"0.... | 0.88796777 | 0 |
newBetaGetHook creates a new closure with the current baseInstanceList to be used as a MockBetaInstances.GetHook | func (bil *baseInstanceList) newBetaGetHook() func(ctx context.Context, key *meta.Key, m *cloud.MockBetaInstances) (bool, *beta.Instance, error) {
return func(ctx context.Context, key *meta.Key, m *cloud.MockBetaInstances) (bool, *beta.Instance, error) {
m.Lock.Lock()
defer m.Lock.Unlock()
if _, found := m.Objects[*key]; !found {
m.Objects[*key] = &cloud.MockInstancesObj{Obj: bil.getOrCreateBaseInstance(key).toBeta()}
}
return false, nil, nil
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (bil *baseInstanceList) newGAGetHook() func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {\n\treturn func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {\n\t\tm.Lock.Lock()\n\t\tdefer m.Lock.Unlock()\n\n\t\tif _, found := m.O... | [
"0.75942796",
"0.5408831",
"0.5109261",
"0.49638084",
"0.4917815",
"0.4800882",
"0.47378483",
"0.46847326",
"0.46703503",
"0.46522126",
"0.46307093",
"0.45831934",
"0.45636097",
"0.45611542",
"0.45577788",
"0.45528764",
"0.45515147",
"0.4545838",
"0.4534998",
"0.4518134",
"0.... | 0.87772727 | 0 |
newMockCloud returns a mock GCE instance with the appropriate handlers hooks | func (bil *baseInstanceList) newMockCloud() cloud.Cloud {
c := cloud.NewMockGCE(nil)
// insert hooks to lazy create a instance when needed
c.MockInstances.GetHook = bil.newGAGetHook()
c.MockBetaInstances.GetHook = bil.newBetaGetHook()
return c
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func NewCloudMock() *CloudMock {\n\taddress, grpcServer, mockTrace := startMockServer()\n\n\tconn, err := grpc.Dial(address, grpc.WithInsecure())\n\tif err != nil {\n\t\tlog.Fatalf(\"did not connect: %s\", err)\n\t}\n\n\ttraceClient := cloudtrace.NewTraceServiceClient(conn)\n\tmetricClient := monitoring.NewMetricS... | [
"0.74995255",
"0.69299114",
"0.69029814",
"0.6815023",
"0.6562258",
"0.6515134",
"0.6346468",
"0.62458694",
"0.6240434",
"0.6203039",
"0.61380965",
"0.60854924",
"0.6003493",
"0.59790623",
"0.5966205",
"0.59641105",
"0.5882635",
"0.5866135",
"0.5820343",
"0.58198625",
"0.5764... | 0.7895326 | 0 |
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded. | func Asset(name string) ([]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
}
return a.bytes, nil
}
return nil, fmt.Errorf("Asset %s not found", name)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Asset(name string) ([]byte, error) {\n cannonicalName := strings.Replace(name, \"\\\\\", \"/\", -1)\n if f, ok := _bindata[cannonicalName]; ok {\n a, err := f()\n if err != nil {\n return nil, fmt.Errorf(\"Asset %s can't read by error: %v\", name, err)\n }\n return a.bytes, nil\n }\n retu... | [
"0.7346324",
"0.7267003",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.7103171",
"0.70684695",
... | 0.7093733 | 71 |
AssetString returns the asset contents as a string (instead of a []byte). | func AssetString(name string) (string, error) {
data, err := Asset(name)
return string(data), err
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s GetAssetOutput) String() string {\n\treturn awsutil.Prettify(s)\n}",
"func (s GetAssetOutput) String() string {\n\treturn awsutil.Prettify(s)\n}",
"func String() string {\n\tbuffer := bytes.Buffer{}\n\tfor _, name := range AssetNames() {\n\t\tbytes := MustAsset(name)\n\t\tbuffer.Write(bytes)\n\n\t\tif ... | [
"0.74635357",
"0.74635357",
"0.74050194",
"0.71176565",
"0.69487256",
"0.68454397",
"0.68166065",
"0.68166065",
"0.678136",
"0.66660875",
"0.662912",
"0.662912",
"0.65534294",
"0.64794993",
"0.643966",
"0.63937074",
"0.6383043",
"0.63824075",
"0.62887394",
"0.6259392",
"0.623... | 0.0 | -1 |
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables. | func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func MustAsset(name string) []byte {\n\ta, err := Asset(name)\n\tif (err != nil) {\n\t\tpanic(\"asset: Asset(\" + name + \"): \" + err.Error())\n\t}\n\n\treturn a\n}",
"func MustAsset(name string) []byte {\n\ta, err := Asset(name)\n\tif (err != nil) {\n\t\tpanic(\"asset: Asset(\" + name + \"): \" + err.Error())\... | [
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"0.7499818",
"... | 0.0 | -1 |
MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables. | func MustAssetString(name string) string {
return string(MustAsset(name))
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func AssetString(name string) (string, error) {\n\tdata, err := Asset(name)\n\treturn string(data), err\n}",
"func AssetString(name string) (string, error) {\n\tdata, err := Asset(name)\n\treturn string(data), err\n}",
"func AssetString(name string) (string, error) {\n\tdata, err := Asset(name)\n\treturn strin... | [
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"0.6235313",
"... | 0.7863556 | 49 |
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded. | func AssetInfo(name string) (os.FileInfo, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
}
return a.info, nil
}
return nil, fmt.Errorf("AssetInfo %s not found", name)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func AssetInfo(name string) (os.FileInfo, error) {\n\tcannonicalName := strings.Replace(name, \"\\\\\", \"/\", -1)\n\tif f, ok := _bindata[cannonicalName]; ok {\n\t\ta, err := f()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"AssetInfo %s can't read by error: %v\", name, err)\n\t\t}\n\t\treturn a.info, nil\... | [
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"0.8059118",
"... | 0.81341106 | 52 |
AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded. | func AssetDigest(name string) ([sha256.Size]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err)
}
return a.digest, nil
}
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (a *Asset) Hash(hashType string) (string, error) {\n\tvar hashEncodedLen int\n\tvar hash string\n\n\t// We read the actual asset content\n\tbytes, err := os.ReadFile(a.path)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(bytes) == 0 {\n\t\treturn \"\", fmt.Errorf(\"Empty asset file at %s\", a.path)... | [
"0.56964684",
"0.5555062",
"0.5486972",
"0.53367144",
"0.53113675",
"0.5301951",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
"0.525409",
... | 0.7696742 | 49 |
Digests returns a map of all known files and their checksums. | func Digests() (map[string][sha256.Size]byte, error) {
mp := make(map[string][sha256.Size]byte, len(_bindata))
for name := range _bindata {
a, err := _bindata[name]()
if err != nil {
return nil, err
}
mp[name] = a.digest
}
return mp, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func filesDigest(fs afero.Fs, paths []string) []*PackageFilesDigest {\n\treturn mapPaths(fs, paths, pathToOperator)\n}",
"func Md5All(root string) (map[string][md5.Size]byte, error) {\n\tdone := make(chan struct{})\n\tdefer close(done)\n\n\tpaths, errc := walkFiles(done, root)\n\n\t// Starts a fixed number of go... | [
"0.6962257",
"0.6857267",
"0.6500901",
"0.64340717",
"0.6351849",
"0.6168927",
"0.6060193",
"0.6027875",
"0.5841485",
"0.58326197",
"0.5764696",
"0.57436156",
"0.5716916",
"0.5619292",
"0.5611238",
"0.56094915",
"0.55823195",
"0.5540355",
"0.5539558",
"0.55263436",
"0.5470863... | 0.69082654 | 50 |
AssetNames returns the names of the assets. | func AssetNames() []string {
names := make([]string, 0, len(_bindata))
for name := range _bindata {
names = append(names, name)
}
return names
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [] | [] | 0.0 | -1 |
RestoreAsset restores an asset under the given directory. | func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func RestoreAsset(dir, name string) error {\n\tdata, err := Asset(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\tinfo, err := AssetInfo(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = os.MkdirAll(_filePath(dir, path.Dir(name)), os.FileMode(0755))\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.Wri... | [
"0.7935779",
"0.7935779",
"0.7935779",
"0.7935779",
"0.79253083",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
"0.7924187",
... | 0.0 | -1 |
RestoreAssets restores an asset under the given directory recursively. | func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func RestoreAssets(dir, name string) error {\n\tchildren, err := AssetDir(name)\n\tif err != nil { // File\n\t\treturn RestoreAsset(dir, name)\n\t} else { // Dir\n\t\tfor _, child := range children {\n\t\t\terr = RestoreAssets(dir, path.Join(name, child))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\... | [
"0.78780913",
"0.78780913",
"0.78780913",
"0.78780913"
] | 0.0 | -1 |
GetTask returns a new task for the action | func GetTask(name, action string, conf *config.MountConfig) (iface.Task, error) {
switch action {
case "", "create":
return NewCreateTask(name, conf), nil
case "remove", "rm":
return NewRemoveTask(name, conf), nil
default:
return nil, fmt.Errorf("Invalid mount action %q for task %q", action, name)
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func GetTask(r *http.Request) *task.Task {\n\tif rv := r.Context().Value(model.ApiTaskKey); rv != nil {\n\t\tif t, ok := rv.(*task.Task); ok {\n\t\t\treturn t\n\t\t}\n\t}\n\treturn nil\n}",
"func (*FakeReconcilerClient) GetTask(string) (swarm.Task, error) {\n\treturn swarm.Task{}, FakeUnimplemented\n}",
"func ... | [
"0.7213508",
"0.71484256",
"0.7080093",
"0.7022939",
"0.70011353",
"0.68791914",
"0.6873889",
"0.68579173",
"0.68332416",
"0.6799068",
"0.67832404",
"0.6742814",
"0.6718434",
"0.670646",
"0.6698478",
"0.6695807",
"0.6687799",
"0.665799",
"0.6657192",
"0.6641929",
"0.6606461",... | 0.7655484 | 0 |
NewCommonTime returns a simple 4/4 meter at the specified tempo | func NewCommonTime(bpm float64) *Meter {
return &Meter{
BeatsPerMinute: bpm,
BeatsPerBar: 4,
BeatValue: notes.Quarter,
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (t Time) Nanosecond() int {}",
"func New(h, m int) Clock {\n\tminutes := h*60 + m\n\tminutes %= 1440\n\tif minutes < 0 {\n\t\tminutes += 1440\n\t}\n\n\treturn Clock{minutes}\n}",
"func (t Time) Minute() int {}",
"func newFakeTime() {\n\tfakeCurrentTime = fakeTime().Add(time.Hour * 24 * 2)\n}",
"func N... | [
"0.53669107",
"0.5306059",
"0.52969766",
"0.5279843",
"0.5251734",
"0.52410793",
"0.5239546",
"0.522227",
"0.51717865",
"0.5143131",
"0.51333964",
"0.5087262",
"0.5053068",
"0.5053068",
"0.5053068",
"0.5053068",
"0.50448024",
"0.50265586",
"0.50222766",
"0.50056636",
"0.49707... | 0.6473046 | 0 |
New returns a new meter with the specified parameters | func New(bpm, beatsPerBar float64, beatValue notes.Duration) *Meter {
return &Meter{
BeatsPerMinute: bpm,
BeatsPerBar: beatsPerBar,
BeatValue: beatValue,
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func NewMeter(name string, options ...Option) Meter {\n\treturn newMeter(name, options...)\n}",
"func NewMeter(client Client, name string, tagOptions ...TagOption) (*Meter, error) {\n\tif err := validateMetricName(name); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Meter{\n\t\tclient: client,\n\t\tname: ... | [
"0.6899709",
"0.6802081",
"0.6737444",
"0.66954213",
"0.6548257",
"0.6525749",
"0.6503611",
"0.64407635",
"0.63265437",
"0.612432",
"0.5977774",
"0.59515846",
"0.59335434",
"0.5911891",
"0.5897539",
"0.5890825",
"0.5890561",
"0.58305466",
"0.58248305",
"0.5815958",
"0.5770586... | 0.71873426 | 0 |
NoteToTime converts a notes.Duration to a time.Duration based on the meter | func (m Meter) NoteToTime(noteVal notes.Duration) time.Duration {
return time.Duration((float64(noteVal/m.BeatValue) / m.BeatsPerMinute) * float64(time.Minute))
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func minutesToDuration(n uint8) Duration {\n\treturn Duration(time.Duration(n) * time.Minute)\n}",
"func (e *Exact) convertToDuration() time.Duration {\n\tif isValidUnitOfTime(e.Unit) {\n\t\treturn convertTimeToDuration(e.Quantity, e.Unit)\n\t}\n\tpanic(\"'unit' is not a valid unit of time\")\n}",
"func (r Res... | [
"0.6077799",
"0.5801322",
"0.5798061",
"0.5757803",
"0.5740865",
"0.57225984",
"0.5601669",
"0.5556431",
"0.54757607",
"0.5466047",
"0.54560196",
"0.54490495",
"0.5432458",
"0.5383502",
"0.53819966",
"0.5361781",
"0.53517246",
"0.53364056",
"0.5326453",
"0.5320531",
"0.531519... | 0.8580701 | 0 |
NoteToFreq converts a notes.Duration into a frequency with period equal to that note length | func (m Meter) NoteToFreq(noteVal notes.Duration) float64 {
duration := m.NoteToTime(noteVal)
return 1 / float64(duration.Seconds())
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func toFreq(s semi, tonic freq) freq {\n\treturn tonic * freq(math.Pow(root12, float64(s)))\n}",
"func (c *Config) FrequencyDur() time.Duration {\n\tconfigLock.RLock()\n\tdefer configLock.RUnlock()\n\n\tif c.Frequency == 0 {\n\t\treturn callhomeCycleDefault\n\t}\n\n\treturn c.Frequency\n}",
"func (m Meter) Not... | [
"0.6109282",
"0.56692827",
"0.5592371",
"0.54737693",
"0.5341398",
"0.5270148",
"0.52006036",
"0.5196711",
"0.50826305",
"0.5026439",
"0.5008344",
"0.50019354",
"0.49847287",
"0.4954853",
"0.4947973",
"0.4922762",
"0.49062866",
"0.48975572",
"0.48922068",
"0.48828414",
"0.488... | 0.82673764 | 0 |
/ A tuple is a finite sorted list of elements. It is a data structure that groups data. Tuples are typically immutable sequential collections. The element has related fields of different datatypes. The only way to modify a tuple is to change the fields. Operators such as + and can be applied to tuples. A database record is referred to as a tuple. In the following example, power series of integers are calculated and the square and cube of the integer is returned as a tuple: importing fmt package gets the power series of integer a and returns tuple of square of a and cube of a | func powerSeries(a int) (int, int) {
return a * a, a * a * a
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Multiply(t Tuplelike, n float64) Tuplelike {\n\tresult := []float64{}\n\n\tfor _, value := range t.Values() {\n\t\tresult = append(result, value*n)\n\t}\n\n\treturn Tuple(result)\n}",
"func Tuple(argv []TermT) TermT {\n\tcount := C.uint32_t(len(argv))\n\t//iam: FIXME need to unify the yices errors and the g... | [
"0.64886904",
"0.6247497",
"0.61603564",
"0.610934",
"0.6033286",
"0.5953124",
"0.5881533",
"0.58625937",
"0.5833882",
"0.5820546",
"0.57736194",
"0.57283825",
"0.56730825",
"0.56594837",
"0.55717015",
"0.55475885",
"0.55184346",
"0.54951537",
"0.54623514",
"0.54509795",
"0.5... | 0.5276199 | 33 |
GenerateJWTToken generates a JWT token with the username and singed by the given secret key | func GenerateJWTToken(userName, jwtAccSecretKey string) (string, error) {
claims := jwt.MapClaims{
"username": userName,
"ExpiresAt": jwt.TimeFunc().Add(1 * time.Minute).Unix(),
"IssuedAt": jwt.TimeFunc().Unix(),
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return token.SignedString([]byte(jwtAccSecretKey))
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func GenerateJWTToken(username string) (string, error) {\n\t// Create token\n\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{\n\t\t\"username\": username,\n\t\t\"exp\": time.Now().Add(time.Minute * 5).Unix(),\n\t})\n\n\tt, err := token.SignedString([]byte(jwtsecret))\n\tif err != nil {\n\t\... | [
"0.8215574",
"0.78082126",
"0.7724785",
"0.77192235",
"0.771866",
"0.7673677",
"0.7650788",
"0.7650347",
"0.76278704",
"0.7624205",
"0.761858",
"0.76141596",
"0.76023495",
"0.7587422",
"0.7586905",
"0.7568152",
"0.75659156",
"0.75551575",
"0.75548047",
"0.7543786",
"0.7528981... | 0.8048552 | 1 |
ValidateJWTToken validates a JWT token with the given key | func ValidateJWTToken(jwtKey, tokenString string) (*Claims, error) {
clms := &Claims{}
tkn, err := jwt.ParseWithClaims(tokenString, clms, 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(jwtKey), nil
})
if err != nil {
if err == jwt.ErrSignatureInvalid {
return nil, errors.WithMessage(err, "Invalid Signature")
}
return nil, errors.WithMessage(err, "Access Denied-Please check the access token")
}
if !tkn.Valid {
return nil, errors.WithMessage(err, "Invalid Token")
}
return clms, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func ValidateJWT(next echo.HandlerFunc) echo.HandlerFunc {\n\treturn func(c echo.Context) error {\n\t\tvar tokenString string\n\t\ttokenString, err := getTokenFromAuthorizationHeader(c.Request())\n\t\tif err != nil {\n\t\t\ttokenString, err = getTokenFromURLParams(c.Request())\n\t\t\tif err != nil {\n\t\t\t\tretur... | [
"0.7699664",
"0.75941306",
"0.7513526",
"0.7442866",
"0.7334197",
"0.7312587",
"0.729662",
"0.7211861",
"0.7191269",
"0.7175674",
"0.7171228",
"0.7161451",
"0.7157099",
"0.7146733",
"0.71361905",
"0.7088462",
"0.708682",
"0.70732176",
"0.7066534",
"0.7061922",
"0.7060058",
... | 0.7437225 | 4 |
WriteCloserWithContext converts ContextCloser to io.Closer, whenever new Close method will be called, the ctx will be passed to it | func WriteCloserWithContext(ctx context.Context, closer WriteContextCloser) io.WriteCloser {
return &closerWithContext{
WriteContextCloser: closer,
ctx: ctx,
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (c *closerWithContext) Close() error {\n\treturn c.WriteContextCloser.Close(c.ctx)\n}",
"func (c *Context) Close() error {\n\treturn c.writer.Close()\n}",
"func (fw *FileWriter) CloseWithContext(ctx context.Context, opts ...FlushRowGroupOption) error {\n\tif fw.schemaWriter.rowGroupNumRecords() > 0 {\n\t\... | [
"0.7478201",
"0.59653234",
"0.59053546",
"0.5853121",
"0.5791737",
"0.57658553",
"0.57110214",
"0.5644903",
"0.5617057",
"0.55500585",
"0.54606736",
"0.5370619",
"0.52994496",
"0.5261682",
"0.5238762",
"0.5207119",
"0.52057135",
"0.5195372",
"0.51947",
"0.5191003",
"0.5137905... | 0.7699851 | 0 |
Close closes all resources and returns the result | func (c *closerWithContext) Close() error {
return c.WriteContextCloser.Close(c.ctx)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (c FinalOutput) Close() {}",
"func (cr *callResult) Close() error { return nil }",
"func (r *result) Close() error {\n\treturn r.reader.Close()\n}",
"func (r *Result) Close() error {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.close(true)\n}",
"func (fr *FakeResult) Close() {\n}",
"func (i *It... | [
"0.68667895",
"0.6778104",
"0.67122173",
"0.6589011",
"0.6545102",
"0.6529692",
"0.6523978",
"0.6461263",
"0.63559073",
"0.6354894",
"0.63269347",
"0.63106054",
"0.6306415",
"0.63030994",
"0.627391",
"0.6237731",
"0.61970115",
"0.6179155",
"0.616494",
"0.61487216",
"0.6143402... | 0.0 | -1 |
NilCloser returns closer if it's not nil otherwise returns a nop closer | func NilCloser(r io.Closer) io.Closer {
if r == nil {
return &nilCloser{}
}
return r
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (nopCloser) Close() error { return nil }",
"func (n *nilCloser) Close() error {\n\t// works even if n is nil\n\treturn nil\n}",
"func NopCloser() error { return nil }",
"func NoCloser(in io.Reader) io.Reader {\n\tif in == nil {\n\t\treturn in\n\t}\n\t// if in doesn't implement io.Closer, just return it\... | [
"0.7222569",
"0.69184256",
"0.68131655",
"0.65612435",
"0.65169245",
"0.608959",
"0.59361756",
"0.59183574",
"0.5906258",
"0.5872431",
"0.57893544",
"0.57882726",
"0.5740676",
"0.5678546",
"0.56239897",
"0.5589913",
"0.55773497",
"0.5547098",
"0.54516846",
"0.54490966",
"0.54... | 0.7534535 | 0 |
NopWriteCloser returns a WriteCloser with a noop Close method wrapping the provided Writer w | func NopWriteCloser(r io.Writer) io.WriteCloser {
return nopWriteCloser{r}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func NopWriteCloser(w io.Writer) io.WriteCloser {\n\treturn &nopWriteCloser{w}\n}",
"func NopWriteCloser(w io.Writer) io.WriteCloser {\n\treturn errWriteCloser{Writer: w, CloseErr: nil}\n}",
"func NopCloser() error { return nil }",
"func NopCloser() io.Closer {\r\n\treturn &nopCloser{}\r\n}",
"func NopFlus... | [
"0.83569413",
"0.8011272",
"0.71590877",
"0.6870779",
"0.67140406",
"0.67096657",
"0.6687032",
"0.6371078",
"0.6286475",
"0.6217874",
"0.6208649",
"0.61860895",
"0.61359453",
"0.61247253",
"0.607347",
"0.6037165",
"0.5976911",
"0.5891818",
"0.58669317",
"0.57316923",
"0.57210... | 0.82828856 | 1 |
NewTracer returns a new tracer | func NewTracer(description string) *Tracer {
return &Tracer{Started: time.Now().UTC(), Description: description}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func NewTracer(name string) *Tracer {\n\tname = fmt.Sprintf(namePattern, name)\n\treturn &Tracer{\n\t\tname: name,\n\t}\n}",
"func NewTracer(parent *Logger, prefix string) *Logger {\n\treturn &Logger{parent: parent, prefix: prefix, tracer: true}\n}",
"func NewTracer(name string, w io.Writer, m Memory) Memory {... | [
"0.8209218",
"0.8077655",
"0.79836166",
"0.79239917",
"0.7877002",
"0.78683406",
"0.7835157",
"0.779283",
"0.7783801",
"0.7783801",
"0.7783801",
"0.7775605",
"0.7605881",
"0.76013285",
"0.7595682",
"0.7517959",
"0.7459979",
"0.7405851",
"0.7405851",
"0.7370349",
"0.7234734",
... | 0.8393048 | 0 |
Start logs start of the trace | func (t *Tracer) Start() *Tracer {
log.Debugf("Tracer started %v.", t.Description)
return t
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func LogStart(version string, env string) {\n\tlog.Println(\"Start\")\n\tlog.Printf(\"Version: %s\", version)\n\tlog.Printf(\"Environment: %s\", env)\n\tlog.Printf(\"Go version: %s\", runtime.Version())\n\tlog.Printf(\"Go max procs: %d\", runtime.GOMAXPROCS(0))\n}",
"func init() {\n\tlog.SetPrefix(\"TRACE: \")\n... | [
"0.70481753",
"0.67946726",
"0.6792258",
"0.6780392",
"0.6672557",
"0.65980446",
"0.6561377",
"0.65486723",
"0.64368075",
"0.6423788",
"0.6393507",
"0.638214",
"0.6349291",
"0.62269604",
"0.6202975",
"0.62012595",
"0.6176968",
"0.6169051",
"0.61496973",
"0.61337566",
"0.61204... | 0.6492113 | 8 |
Stop logs stop of the trace | func (t *Tracer) Stop() *Tracer {
log.Debugf("Tracer completed %v in %v.", t.Description, time.Since(t.Started))
return t
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (t *Tracer) Stop() {}",
"func Stop() {\n\tinternal.SetGlobalTracer(&internal.NoopTracer{})\n\tlog.Flush()\n}",
"func (o *influxDBLogger) stop() error {\n\treturn nil\n}",
"func (t *Tracer) Stop() {\n\tt.close()\n}",
"func (t *Tracer) Stop() {\n\tt.close()\n}",
"func (t *tracer) Stop() {\n\tt.stopOnc... | [
"0.79674745",
"0.71204233",
"0.69399786",
"0.69265217",
"0.69265217",
"0.6831262",
"0.68158007",
"0.6786613",
"0.6785409",
"0.6773118",
"0.67459726",
"0.6679901",
"0.6633648",
"0.6599372",
"0.6574594",
"0.65598506",
"0.65119165",
"0.6508982",
"0.6487301",
"0.6478834",
"0.6415... | 0.6180919 | 28 |
ThisFunction returns calling function name | func ThisFunction() string {
var pc [32]uintptr
runtime.Callers(2, pc[:])
return runtime.FuncForPC(pc[0]).Name()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func CurrentFunctionName() string {\n\tpc, _, _, _ := runtime.Caller(1)\n\tfuncname := path.Base(runtime.FuncForPC(pc).Name())\n\treturn funcname\n}",
"func funcName() string {\n\tpc, _, _, _ := runtime.Caller(1)\n\treturn runtime.FuncForPC(pc).Name()\n}",
"func ThisFunc() *runtime.Func {\n\tpc, _, _, _ := run... | [
"0.7722278",
"0.766978",
"0.76039034",
"0.7582178",
"0.7449456",
"0.7403062",
"0.70837003",
"0.7075239",
"0.6886995",
"0.68866515",
"0.68251276",
"0.68018013",
"0.6781213",
"0.6740152",
"0.67332137",
"0.66841245",
"0.66416866",
"0.66173244",
"0.6587148",
"0.65851456",
"0.6574... | 0.84559995 | 0 |
Value returns value of the string | func (s *SyncString) Value() string {
s.Lock()
defer s.Unlock()
return s.string
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s *String) GetValue() string {\n\treturn s.value\n}",
"func (sval *ScalarValue) Value() string {\n\tswitch {\n\tcase strings.HasPrefix(sval.Raw, `\"\"\"`):\n\t\treturn parseBlockString(sval.Raw)\n\tcase strings.HasPrefix(sval.Raw, `\"`):\n\t\treturn parseString(sval.Raw)\n\tdefault:\n\t\treturn sval.Raw\n\... | [
"0.75110775",
"0.74706155",
"0.74118876",
"0.73986423",
"0.73799694",
"0.7359382",
"0.72732645",
"0.72452945",
"0.7236553",
"0.7220005",
"0.72173685",
"0.71555114",
"0.71239245",
"0.71044296",
"0.7084027",
"0.70409364",
"0.70191246",
"0.70084894",
"0.6993719",
"0.6992071",
"0... | 0.75706613 | 0 |
Set sets the value of the string | func (s *SyncString) Set(v string) {
s.Lock()
defer s.Unlock()
s.string = v
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (sf *String) Set(x string) error {\n\tsf.Value = x\n\tsf.set = true\n\treturn nil\n}",
"func (s *String) Set(str string) {\n\ts.Value = []byte(str)\n\ts.Length = int32(len(s.Value))\n}",
"func (l *settableString) Set(s string) error {\n\tl.s = s\n\tl.isSet = true\n\treturn nil\n}",
"func (a *Mpflt) SetS... | [
"0.79293394",
"0.7827096",
"0.7804932",
"0.7693435",
"0.7640353",
"0.75797755",
"0.7420005",
"0.73857605",
"0.7376449",
"0.73744327",
"0.73223305",
"0.73069286",
"0.7282563",
"0.72566503",
"0.72496474",
"0.7207861",
"0.7196015",
"0.7186725",
"0.7183804",
"0.7176873",
"0.71364... | 0.7578262 | 6 |
ClickableURL fixes address in url to make sure it's clickable, e.g. it replaces "undefined" address like 0.0.0.0 used in network listeners format with loopback 127.0.0.1 | func ClickableURL(in string) string {
out, err := url.Parse(in)
if err != nil {
return in
}
host, port, err := net.SplitHostPort(out.Host)
if err != nil {
return in
}
ip := net.ParseIP(host)
// if address is not an IP, unspecified, e.g. all interfaces 0.0.0.0 or multicast,
// replace with localhost that is clickable
if len(ip) == 0 || ip.IsUnspecified() || ip.IsMulticast() {
out.Host = fmt.Sprintf("127.0.0.1:%v", port)
return out.String()
}
return out.String()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func SanitizeURL(in string) string {\n\treturn sanitizeURLWithFlags(in, purell.FlagsSafe|purell.FlagRemoveTrailingSlash|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator)\n}",
"func fixImgurLink(link string) string {\n\torigina... | [
"0.52412796",
"0.5147074",
"0.50879025",
"0.5021607",
"0.49071804",
"0.48897803",
"0.48651856",
"0.4834832",
"0.48083636",
"0.48071218",
"0.4795265",
"0.47837985",
"0.47502625",
"0.47394225",
"0.4733341",
"0.47310492",
"0.47305945",
"0.47228217",
"0.4715572",
"0.47154",
"0.47... | 0.802518 | 0 |
AsBool converts string to bool, in case of the value is empty or unknown, defaults to false | func AsBool(v string) bool {
if v == "" {
return false
}
out, _ := apiutils.ParseBool(v)
return out
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s *Value) asBool() (bool, error) {\n\t// A missing value is considered false\n\tif s == nil {\n\t\treturn false, nil\n\t}\n\tswitch s.Name {\n\tcase \"true\":\n\t\treturn true, nil\n\tcase \"false\":\n\t\treturn false, nil\n\tdefault:\n\t\treturn false, fmt.Errorf(\"invalid boolean: %s\", s.Name)\n\t}\n}",
... | [
"0.76321614",
"0.7480224",
"0.7370424",
"0.7344179",
"0.729552",
"0.7221894",
"0.7180088",
"0.7171699",
"0.71345377",
"0.7087665",
"0.70560706",
"0.70353085",
"0.7016963",
"0.7016963",
"0.69989306",
"0.6966437",
"0.6965041",
"0.6953353",
"0.69252783",
"0.6895328",
"0.68600845... | 0.8361102 | 0 |
ParseAdvertiseAddr validates advertise address, makes sure it's not an unreachable or multicast address returns address split into host and port, port could be empty if not specified | func ParseAdvertiseAddr(advertiseIP string) (string, string, error) {
advertiseIP = strings.TrimSpace(advertiseIP)
host := advertiseIP
port := ""
if len(net.ParseIP(host)) == 0 && strings.Contains(advertiseIP, ":") {
var err error
host, port, err = net.SplitHostPort(advertiseIP)
if err != nil {
return "", "", trace.BadParameter("failed to parse address %q", advertiseIP)
}
if _, err := strconv.Atoi(port); err != nil {
return "", "", trace.BadParameter("bad port %q, expected integer", port)
}
if host == "" {
return "", "", trace.BadParameter("missing host parameter")
}
}
ip := net.ParseIP(host)
if len(ip) != 0 {
if ip.IsUnspecified() || ip.IsMulticast() {
return "", "", trace.BadParameter("unreachable advertise IP: %v", advertiseIP)
}
}
return host, port, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func parseAdvertiseAddr(advAddr string, port int) (string, int) {\n\treturn advAddr, port\n\n\t// bug: if use domain, always return empty host\n\t/*m, e := regexp.Match(ipv4Pattern, []byte(advAddr))\n\t// if parse error, use serve port and parsed ip address\n\tif e != nil {\n\t\treturn \"\", port\n\t}\n\tif m {\n\... | [
"0.8340167",
"0.8205273",
"0.7002564",
"0.638477",
"0.6307578",
"0.6307132",
"0.6303563",
"0.6131761",
"0.61101985",
"0.6086822",
"0.6052451",
"0.60465807",
"0.5911784",
"0.5911784",
"0.59074295",
"0.5907354",
"0.58481467",
"0.575326",
"0.57085407",
"0.5657779",
"0.5657514",
... | 0.84405524 | 0 |
StringsSliceFromSet returns a sorted strings slice from set | func StringsSliceFromSet(in map[string]struct{}) []string {
if in == nil {
return nil
}
out := make([]string, 0, len(in))
for key := range in {
out = append(out, key)
}
sort.Strings(out)
return out
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func StrSliceSet(slice []string) []string {\n\tset := make([]string, 0)\n\ttempMap := make(map[string]bool, len(slice))\n\tfor _, v := range slice {\n\t\tif !tempMap[v] {\n\t\t\tset = append(set, v)\n\t\t\ttempMap[v] = true\n\t\t}\n\t}\n\n\treturn set\n}",
"func (set StringSet) ToSlice() []string {\n\tif n := se... | [
"0.7395667",
"0.70148724",
"0.6999877",
"0.69945043",
"0.69452065",
"0.6828592",
"0.6691718",
"0.669042",
"0.6537828",
"0.64243567",
"0.641947",
"0.63832146",
"0.6322088",
"0.62684745",
"0.62402517",
"0.62099415",
"0.6133305",
"0.60791206",
"0.6033735",
"0.6019684",
"0.601857... | 0.81835073 | 0 |
ParseOnOff parses whether value is "on" or "off", parameterName is passed for error reporting purposes, defaultValue is returned when no value is set | func ParseOnOff(parameterName, val string, defaultValue bool) (bool, error) {
switch val {
case teleport.On:
return true, nil
case teleport.Off:
return false, nil
case "":
return defaultValue, nil
default:
return false, trace.BadParameter("bad %q parameter value: %q, supported values are on or off", parameterName, val)
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (dps *domainParser) di2OnOff() {\n\tdps.defaultValue = dps.onOffDefaultValue\n\tdps.customParseID = dps.onOffCustomParseID\n\tdps.checkEndedCorrect = dps.onOffCheckEndedCorrect\n\tdps.appendQP = dps.onOffAppendQp\n}",
"func ParseBool(str string) (bool, error) {\n\tif str == \"on\" {\n\t\treturn true, nil\n\... | [
"0.56482726",
"0.5562257",
"0.5544399",
"0.5209864",
"0.5193872",
"0.5183491",
"0.51610637",
"0.51105624",
"0.5067777",
"0.50530106",
"0.5005197",
"0.4955115",
"0.49473256",
"0.49443442",
"0.4923302",
"0.49199948",
"0.49097046",
"0.48919663",
"0.48528236",
"0.4831881",
"0.476... | 0.87817115 | 0 |
IsGroupMember returns whether currently logged user is a member of a group | func IsGroupMember(gid int) (bool, error) {
groups, err := os.Getgroups()
if err != nil {
return false, trace.ConvertSystemError(err)
}
for _, group := range groups {
if group == gid {
return true, nil
}
}
return false, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s *GroupService) isGroupMember(groupId, userId string) (bool, error) {\n\tvar condition = map[string]interface{}{\n\t\t\"groupId\": groupId,\n\t\t\"userId\": userId,\n\t}\n\tmemberProfile, err := groupRepo.FindOneMember(condition)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn memberProfile == nil... | [
"0.76126474",
"0.7386575",
"0.73728687",
"0.7257297",
"0.7106678",
"0.6925676",
"0.6812919",
"0.67271173",
"0.67248964",
"0.66902804",
"0.6681328",
"0.6652703",
"0.6634036",
"0.6619776",
"0.657318",
"0.64903814",
"0.64772445",
"0.64528537",
"0.63925785",
"0.6369088",
"0.63597... | 0.7899438 | 0 |
DNSName extracts DNS name from host:port string. | func DNSName(hostport string) (string, error) {
host, err := Host(hostport)
if err != nil {
return "", trace.Wrap(err)
}
if ip := net.ParseIP(host); len(ip) != 0 {
return "", trace.BadParameter("%v is an IP address", host)
}
return host, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func GetHostName(hostAddr string) string {\n\treturn strings.Split(hostAddr, base.UrlPortNumberDelimiter)[0]\n}",
"func GetHostname(addr string) string {\n\treturn strings.Split(addr, \":\")[0]\n}",
"func hostname(hostport string) (string, error) {\n\thost, _, err := net.SplitHostPort(hostport)\n\treturn host,... | [
"0.6603416",
"0.6248293",
"0.61732805",
"0.61518425",
"0.60280794",
"0.59298724",
"0.5926241",
"0.5838026",
"0.5804168",
"0.57999206",
"0.57859087",
"0.5661244",
"0.56175256",
"0.559655",
"0.5595708",
"0.5587074",
"0.5566612",
"0.55407655",
"0.55281454",
"0.5504938",
"0.55014... | 0.7793767 | 0 |
Host extracts host from host:port string | func Host(hostname string) (string, error) {
if hostname == "" {
return "", trace.BadParameter("missing parameter hostname")
}
// if this is IPv4 or V6, return as is
if ip := net.ParseIP(hostname); len(ip) != 0 {
return hostname, nil
}
// has no indication of port, return, note that
// it will not break ipv6 as it always has at least one colon
if !strings.Contains(hostname, ":") {
return hostname, nil
}
host, _, err := SplitHostPort(hostname)
if err != nil {
return "", trace.Wrap(err)
}
return host, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func parseHost(host string) string {\n\trealHost, _, _ := net.SplitHostPort(host)\n\tif realHost != \"\" {\n\t\treturn realHost\n\t}\n\treturn host\n}",
"func parseHostPort(str string) (string, string) {\n\tvar (\n\t\thost string\n\t\tport string\n\n\t\ti = strings.Index(str, \":\")\n\t)\n\tif i == -1 {\n\t\tret... | [
"0.7416197",
"0.7274514",
"0.7265152",
"0.72162014",
"0.7179156",
"0.7138976",
"0.7102227",
"0.70657533",
"0.70626915",
"0.7054715",
"0.70489645",
"0.7039764",
"0.7039558",
"0.70273805",
"0.67160875",
"0.6699287",
"0.6681174",
"0.6674688",
"0.65914196",
"0.65827954",
"0.65790... | 0.7172603 | 5 |
SplitHostPort splits host and port and checks that host is not empty | func SplitHostPort(hostname string) (string, string, error) {
host, port, err := net.SplitHostPort(hostname)
if err != nil {
return "", "", trace.Wrap(err)
}
if host == "" {
return "", "", trace.BadParameter("empty hostname")
}
return host, port, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func SplitHostPort(hostport string) (host, port string, err error) {\n\taddrErr := func(addr, why string) (host, port string, err error) {\n\t\treturn \"\", \"\", &net.AddrError{Err: why, Addr: addr}\n\t}\n\n\thoststart, hostend := 0, 0\n\tportstart := len(hostport)\n\tif len(hostport) >= 1 && hostport[0] == '[' {... | [
"0.7563116",
"0.74220127",
"0.73175776",
"0.72000736",
"0.717764",
"0.70948535",
"0.68692344",
"0.6828243",
"0.6814598",
"0.66328686",
"0.66094387",
"0.6568446",
"0.6309145",
"0.62275636",
"0.62050116",
"0.6202007",
"0.6161781",
"0.6160127",
"0.61394835",
"0.61028975",
"0.607... | 0.71889913 | 4 |
IsValidHostname checks if a string represents a valid hostname. | func IsValidHostname(hostname string) bool {
for _, label := range strings.Split(hostname, ".") {
if len(validation.IsDNS1035Label(label)) > 0 {
return false
}
}
return true
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (p *Parser) validateHostname(host string) bool {\n\t// Lazy regexp init\n\tif p.hostValidate == nil {\n\t\tconst r string = `(?i)^((-?)(xn--|_)?[a-z0-9-_]{0,61}[a-z0-9-_]\\.)*(xn--)?([a-z0-9][a-z0-9\\-]{0,60}|[a-z0-9-]{1,30}\\.[a-z]{2,})$`\n\t\t// @link: https://stackoverflow.com/a/26987741\n\t\tp.hostValidat... | [
"0.79797286",
"0.77808625",
"0.77077204",
"0.7385047",
"0.73775864",
"0.7297476",
"0.6890047",
"0.66355765",
"0.6396525",
"0.6324849",
"0.62274617",
"0.61423105",
"0.6126824",
"0.60815984",
"0.6032941",
"0.59857845",
"0.59436375",
"0.59223866",
"0.58482933",
"0.58423096",
"0.... | 0.7682102 | 3 |
ReadPath reads file contents | func ReadPath(path string) ([]byte, error) {
if path == "" {
return nil, trace.NotFound("empty path")
}
s, err := filepath.Abs(path)
if err != nil {
return nil, trace.ConvertSystemError(err)
}
abs, err := filepath.EvalSymlinks(s)
if err != nil {
if errors.Is(err, fs.ErrPermission) {
//do not convert to system error as this loses the ability to compare that it is a permission error
return nil, err
}
return nil, trace.ConvertSystemError(err)
}
bytes, err := os.ReadFile(abs)
if err != nil {
if errors.Is(err, fs.ErrPermission) {
//do not convert to system error as this loses the ability to compare that it is a permission error
return nil, err
}
return nil, trace.ConvertSystemError(err)
}
return bytes, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func ReadFilePath(path string) ([]byte, error) {\n\tfileData, err := os.Open(path)\n\tdefer fileData.Close()\n\tdata, err := ioutil.ReadAll(fileData)\n\treturn data, err\n}",
"func ReadPath(ctx context.Context, readBucket ReadBucket, path string) (_ []byte, retErr error) {\n\treadObject, err := readBucket.Get(ct... | [
"0.69383174",
"0.68287534",
"0.6815623",
"0.6785166",
"0.6754481",
"0.6678411",
"0.6626459",
"0.6582085",
"0.65602815",
"0.65602815",
"0.6546036",
"0.6472949",
"0.6459003",
"0.6405429",
"0.6402996",
"0.63998675",
"0.63586974",
"0.62960666",
"0.62625414",
"0.625736",
"0.622878... | 0.6771913 | 4 |
MultiCloser implements io.Close, it sequentially calls Close() on each object | func MultiCloser(closers ...io.Closer) io.Closer {
return &multiCloser{
closers: closers,
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (mc *MultiCloser) Close() error {\n\tmc.mu.Lock()\n\tdefer mc.mu.Unlock()\n\tresult := &multierror.Error{ErrorFormat: utils.SingleLineErrorFormatter}\n\n\tfor _, closer := range mc.closers {\n\t\tif err := closer.Close(); err != nil {\n\t\t\tresult = multierror.Append(result, err)\n\t\t}\n\t}\n\n\tmc.closers ... | [
"0.7285341",
"0.69266",
"0.68220395",
"0.6799848",
"0.6782212",
"0.676067",
"0.67010254",
"0.6576231",
"0.6567459",
"0.65182304",
"0.6500774",
"0.64879596",
"0.645716",
"0.6314351",
"0.62897563",
"0.62881887",
"0.62770766",
"0.62508285",
"0.62197375",
"0.62140936",
"0.6165004... | 0.74036545 | 0 |
OpaqueAccessDenied returns a generic NotFound instead of AccessDenied so as to avoid leaking the existence of secret resources. | func OpaqueAccessDenied(err error) error {
if trace.IsAccessDenied(err) {
return trace.NotFound("not found")
}
return trace.Wrap(err)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (ctx *ShowSecretsContext) NotFound() error {\n\tctx.ResponseData.WriteHeader(404)\n\treturn nil\n}",
"func ErrAccessDenied(w http.ResponseWriter, r *http.Request) {\n\tAccessDeniedWithErr(w, r, errors.New(\"Forbidden\"))\n}",
"func (aee *ActiveEndpointsError) Forbidden() {}",
"func Forbidden(msg string)... | [
"0.6432331",
"0.60147",
"0.588723",
"0.5819935",
"0.5743779",
"0.5713874",
"0.5659095",
"0.5598807",
"0.5597008",
"0.5592161",
"0.5579683",
"0.5568134",
"0.5550085",
"0.55464023",
"0.55464023",
"0.5545322",
"0.5542302",
"0.55259365",
"0.5513903",
"0.5513903",
"0.55054015",
... | 0.7602695 | 0 |
Pop returns a value from the list, it panics if the value is not there | func (p *PortList) Pop() string {
p.Lock()
defer p.Unlock()
if len(p.ports) == 0 {
panic("list is empty")
}
val := p.ports[len(p.ports)-1]
p.ports = p.ports[:len(p.ports)-1]
return val
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (l *List) Pop() (v Value, err error) {\n\tif l.tail == nil {\n\t\terr = errEmpty\n\t} else {\n\t\tv = l.tail.Value\n\t\tl.tail = l.tail.prev\n\t\tif l.tail == nil {\n\t\t\tl.head = nil\n\t\t}\n\t}\n\treturn v, err\n}",
"func (l *pqList) Pop() interface{} {\n\treturn l.Remove(len(l.Slice) - 1)\n}",
"func (... | [
"0.7859467",
"0.7850854",
"0.76105386",
"0.7610248",
"0.7603819",
"0.7530249",
"0.7521987",
"0.7520093",
"0.74930227",
"0.74818516",
"0.73888147",
"0.7387611",
"0.73734367",
"0.7354793",
"0.7348931",
"0.7323641",
"0.7319464",
"0.7305898",
"0.7296203",
"0.72842634",
"0.7268814... | 0.71927667 | 34 |
PopInt returns a value from the list, it panics if not enough values were allocated | func (p *PortList) PopInt() int {
i, err := strconv.Atoi(p.Pop())
if err != nil {
panic(err)
}
return i
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s *SliceOfInt) Pop() int {\n\tpoppedItem := s.items[len(s.items)-1]\n\ts.items = s.items[:len(s.items)-1]\n\treturn poppedItem\n}",
"func (p *IntVector) Pop() int\t{ return p.Vector.Pop().(int) }",
"func (s *SliceOfInt32) Pop() int32 {\n\tpoppedItem := s.items[len(s.items)-1]\n\ts.items = s.items[:len(s.... | [
"0.75718653",
"0.72919536",
"0.7277665",
"0.724577",
"0.71927625",
"0.71801865",
"0.713347",
"0.70770997",
"0.70427364",
"0.69788194",
"0.6975585",
"0.6890257",
"0.6820779",
"0.6796666",
"0.6782513",
"0.6761821",
"0.673664",
"0.6729056",
"0.67286617",
"0.67235994",
"0.6723054... | 0.7560944 | 1 |
GetFreeTCPPorts returns n ports starting from port 20000. | func GetFreeTCPPorts(n int, offset ...int) (PortList, error) {
list := make([]string, 0, n)
start := PortStartingNumber
if len(offset) != 0 {
start = offset[0]
}
for i := start; i < start+n; i++ {
list = append(list, strconv.Itoa(i))
}
return PortList{ports: list}, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Take(n int) (ports []int, err error) {\n\tif n <= 0 {\n\t\treturn nil, fmt.Errorf(\"freeport: cannot take %d ports\", n)\n\t}\n\n\tmu.Lock()\n\tdefer mu.Unlock()\n\n\t// Reserve a port block\n\tonce.Do(initialize)\n\n\tif n > total {\n\t\treturn nil, fmt.Errorf(\"freeport: block size too small\")\n\t}\n\n\tfo... | [
"0.6888929",
"0.67983717",
"0.66069543",
"0.65850073",
"0.6558296",
"0.6558296",
"0.65428734",
"0.6534923",
"0.6523196",
"0.65159756",
"0.65052295",
"0.64984024",
"0.6488279",
"0.6486295",
"0.6423216",
"0.64032197",
"0.6374218",
"0.63717896",
"0.6371297",
"0.63018143",
"0.629... | 0.8380831 | 0 |
HostUUIDExistsLocally checks if dataDir/host_uuid file exists in local storage. | func HostUUIDExistsLocally(dataDir string) bool {
_, err := ReadHostUUID(dataDir)
return err == nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (r *Release) localExist() error {\n\tvar (\n\t\tversion string = fmt.Sprintf(\"terraform-%s.zip\", r.Version)\n\t\terr error\n\t)\n\n\tif _, err = os.Stat(filepath.Join(r.Home, PathTmp.toString(), version)); !os.IsNotExist(err) {\n\t\tfmt.Println(\"Already in cache ...\")\n\t\treturn err\n\t}\n\n\treturn ... | [
"0.6837421",
"0.6144338",
"0.61178225",
"0.6017075",
"0.59379965",
"0.59195673",
"0.5889505",
"0.5859016",
"0.58369076",
"0.5826344",
"0.5795487",
"0.57538235",
"0.57405114",
"0.5738003",
"0.57183146",
"0.57179755",
"0.5670447",
"0.56537825",
"0.56479305",
"0.564708",
"0.5640... | 0.8382169 | 0 |
ReadHostUUID reads host UUID from the file in the data dir | func ReadHostUUID(dataDir string) (string, error) {
out, err := ReadPath(filepath.Join(dataDir, HostUUIDFile))
if err != nil {
if errors.Is(err, fs.ErrPermission) {
//do not convert to system error as this loses the ability to compare that it is a permission error
return "", err
}
return "", trace.ConvertSystemError(err)
}
id := strings.TrimSpace(string(out))
if id == "" {
return "", trace.NotFound("host uuid is empty")
}
return id, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func ReadOrMakeHostUUID(dataDir string) (string, error) {\n\tid, err := ReadHostUUID(dataDir)\n\tif err == nil {\n\t\treturn id, nil\n\t}\n\tif !trace.IsNotFound(err) {\n\t\treturn \"\", trace.Wrap(err)\n\t}\n\t// Checking error instead of the usual uuid.New() in case uuid generation\n\t// fails due to not enough ... | [
"0.69632655",
"0.6446444",
"0.60150903",
"0.59953517",
"0.5983552",
"0.59579515",
"0.58662516",
"0.5794862",
"0.5774995",
"0.57337934",
"0.57194346",
"0.56959444",
"0.5645361",
"0.5586416",
"0.554383",
"0.55005544",
"0.53939855",
"0.53913856",
"0.5279676",
"0.5251984",
"0.518... | 0.8575717 | 0 |
WriteHostUUID writes host UUID into a file | func WriteHostUUID(dataDir string, id string) error {
err := os.WriteFile(filepath.Join(dataDir, HostUUIDFile), []byte(id), os.ModeExclusive|0400)
if err != nil {
if errors.Is(err, fs.ErrPermission) {
//do not convert to system error as this loses the ability to compare that it is a permission error
return err
}
return trace.ConvertSystemError(err)
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func WriteUUID(buffer []byte, offset int, value UUID) {\n bytes, _ := value.MarshalBinary()\n WriteBytes(buffer, offset, bytes)\n}",
"func (this *Actions) generateUid(config *Config, hostname string) string{\n uuidNew := uuid.NewV5(uuid.NewV1(), hostname).String()\n uuid_path := config.GetValue(\"bas... | [
"0.64471084",
"0.6248215",
"0.5742111",
"0.55889857",
"0.54731405",
"0.54549134",
"0.53703684",
"0.5361488",
"0.5359973",
"0.5352255",
"0.5332432",
"0.5296048",
"0.52657807",
"0.5221564",
"0.5199073",
"0.518144",
"0.5132775",
"0.5102348",
"0.50953376",
"0.5062497",
"0.5041759... | 0.8289592 | 0 |
ReadOrMakeHostUUID looks for a hostid file in the data dir. If present, returns the UUID from it, otherwise generates one | func ReadOrMakeHostUUID(dataDir string) (string, error) {
id, err := ReadHostUUID(dataDir)
if err == nil {
return id, nil
}
if !trace.IsNotFound(err) {
return "", trace.Wrap(err)
}
// Checking error instead of the usual uuid.New() in case uuid generation
// fails due to not enough randomness. It's been known to happen happen when
// Teleport starts very early in the node initialization cycle and /dev/urandom
// isn't ready yet.
rawID, err := uuid.NewRandom()
if err != nil {
return "", trace.BadParameter("" +
"Teleport failed to generate host UUID. " +
"This may happen if randomness source is not fully initialized when the node is starting up. " +
"Please try restarting Teleport again.")
}
id = rawID.String()
if err = WriteHostUUID(dataDir, id); err != nil {
return "", trace.Wrap(err)
}
return id, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func ReadHostUUID(dataDir string) (string, error) {\n\tout, err := ReadPath(filepath.Join(dataDir, HostUUIDFile))\n\tif err != nil {\n\t\tif errors.Is(err, fs.ErrPermission) {\n\t\t\t//do not convert to system error as this loses the ability to compare that it is a permission error\n\t\t\treturn \"\", err\n\t\t}\n... | [
"0.77543086",
"0.6042349",
"0.588953",
"0.5722182",
"0.5662293",
"0.5657924",
"0.56159735",
"0.5602016",
"0.55612344",
"0.5539282",
"0.5483126",
"0.5434467",
"0.53669393",
"0.5341538",
"0.5333852",
"0.5304593",
"0.5253771",
"0.5247491",
"0.52331644",
"0.5198665",
"0.5154344",... | 0.8242125 | 0 |
StringSliceSubset returns true if b is a subset of a. | func StringSliceSubset(a []string, b []string) error {
aset := make(map[string]bool)
for _, v := range a {
aset[v] = true
}
for _, v := range b {
_, ok := aset[v]
if !ok {
return trace.BadParameter("%v not in set", v)
}
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (s String) IsSubset(other String) bool {\n\tif len(s) > len(other) {\n\t\treturn false\n\t}\n\n\tfor k := range s {\n\t\tif _, ok := other[k]; !ok {\n\t\t\treturn false\n\t\t}\n\n\t}\n\treturn true\n}",
"func StringsSliceContains(a []string, b string) bool {\n\tif !sort.StringsAreSorted(a) {\n\t\tsort.Strin... | [
"0.72063106",
"0.6842188",
"0.6821371",
"0.6786121",
"0.6751392",
"0.67450565",
"0.6714515",
"0.6702434",
"0.66884464",
"0.6672785",
"0.66710854",
"0.6625813",
"0.6613793",
"0.66135323",
"0.6598829",
"0.65849054",
"0.6550833",
"0.6545979",
"0.6528951",
"0.65145385",
"0.650531... | 0.8096038 | 0 |
UintSliceSubset returns true if b is a subset of a. | func UintSliceSubset(a []uint16, b []uint16) error {
aset := make(map[uint16]bool)
for _, v := range a {
aset[v] = true
}
for _, v := range b {
_, ok := aset[v]
if !ok {
return trace.BadParameter("%v not in set", v)
}
}
return nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func StringSliceSubset(a []string, b []string) error {\n\taset := make(map[string]bool)\n\tfor _, v := range a {\n\t\taset[v] = true\n\t}\n\n\tfor _, v := range b {\n\t\t_, ok := aset[v]\n\t\tif !ok {\n\t\t\treturn trace.BadParameter(\"%v not in set\", v)\n\t\t}\n\n\t}\n\treturn nil\n}",
"func SliceSubset(slice1... | [
"0.6548862",
"0.63709605",
"0.6341045",
"0.6319706",
"0.6259678",
"0.6141531",
"0.61243564",
"0.61081415",
"0.6035182",
"0.5946461",
"0.59458554",
"0.59438497",
"0.59422666",
"0.59412664",
"0.59306276",
"0.59273285",
"0.59237146",
"0.5862433",
"0.58578426",
"0.58344585",
"0.5... | 0.76196134 | 0 |
RemoveFromSlice makes a copy of the slice and removes the passed in values from the copy. | func RemoveFromSlice(slice []string, values ...string) []string {
output := make([]string, 0, len(slice))
remove := make(map[string]bool)
for _, value := range values {
remove[value] = true
}
for _, s := range slice {
_, ok := remove[s]
if ok {
continue
}
output = append(output, s)
}
return output
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func RemoveFromSlice(slice []int, s int) []int {\n\treturn append(slice[:s], slice[s+1:]...)\n}",
"func RemoveFromSlice(slice []string, item string) []string {\n\tfor i, value := range slice {\n\t\tif value == item {\n\t\t\treturn append(slice[:i], slice[i+1:]...)\n\t\t}\n\t}\n\treturn slice\n}",
"func RemoveF... | [
"0.72074586",
"0.716618",
"0.7101833",
"0.7082994",
"0.70630497",
"0.6932562",
"0.6897101",
"0.68811226",
"0.6855913",
"0.6505445",
"0.63579625",
"0.63161755",
"0.6234457",
"0.62126327",
"0.61018604",
"0.59863406",
"0.59863406",
"0.59863025",
"0.5968467",
"0.5968467",
"0.5958... | 0.76177776 | 0 |
ChooseRandomString returns a random string from the given slice. | func ChooseRandomString(slice []string) string {
switch len(slice) {
case 0:
return ""
case 1:
return slice[0]
default:
return slice[rand.Intn(len(slice))]
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func ChooseString(l []string) string {\n\tif len(l) == 0 {\n\t\treturn \"\"\n\t}\n\trand.Seed(time.Now().UnixNano())\n\treturn l[rand.Intn(len(l))]\n}",
"func (h *Random) StringFromSlice(in []string) string {\n\trandomIndex := rand.Intn(len(in))\n\treturn in[randomIndex]\n}",
"func RandomString(values ...strin... | [
"0.7593272",
"0.68603545",
"0.6819849",
"0.6768189",
"0.6673112",
"0.6672849",
"0.665283",
"0.6644218",
"0.6626326",
"0.66243505",
"0.6619441",
"0.6537378",
"0.6531689",
"0.64609605",
"0.6444482",
"0.6438242",
"0.6422548",
"0.64116293",
"0.6404121",
"0.6369966",
"0.6364124",
... | 0.86567205 | 0 |
CheckCertificateFormatFlag checks if the certificate format is valid. | func CheckCertificateFormatFlag(s string) (string, error) {
switch s {
case constants.CertificateFormatStandard, teleport.CertificateFormatOldSSH, teleport.CertificateFormatUnspecified:
return s, nil
default:
return "", trace.BadParameter("invalid certificate format parameter: %q", s)
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (da *DefaultAuth) CheckFormat() error {\n\treturn nil\n}",
"func (dd *AccountDoc) IsValidFormat() bool {\n\tif dd.Created == 0 || dd.GetType() != int(AccountDIDType) {\n\t\treturn false\n\t}\n\treturn true\n}",
"func CheckCertificate(crt string) {\n\t// Read and parse the PEM certificate file\n\tpemData, ... | [
"0.6173354",
"0.6016101",
"0.5732977",
"0.55939424",
"0.5554805",
"0.5551032",
"0.55084914",
"0.54934126",
"0.53708816",
"0.5328171",
"0.52916765",
"0.5222796",
"0.5215715",
"0.52015436",
"0.5192821",
"0.5157193",
"0.50885516",
"0.50314575",
"0.502443",
"0.50205916",
"0.50175... | 0.8533605 | 0 |
AddrsFromStrings returns strings list converted to address list | func AddrsFromStrings(s apiutils.Strings, defaultPort int) ([]NetAddr, error) {
addrs := make([]NetAddr, len(s))
for i, val := range s {
addr, err := ParseHostPortAddr(val, defaultPort)
if err != nil {
return nil, trace.Wrap(err)
}
addrs[i] = *addr
}
return addrs, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func parseAddressesFromStr(s string) ([]cipher.Address, error) {\n\taddrsStr := splitCommaString(s)\n\n\tvar addrs []cipher.Address\n\tfor _, s := range addrsStr {\n\t\ta, err := cipher.DecodeBase58Address(s)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\taddrs = append(addrs, a)\n\t}\n\n\treturn addrs,... | [
"0.71821207",
"0.7044454",
"0.6832384",
"0.6765927",
"0.6733926",
"0.66150105",
"0.6613743",
"0.6550636",
"0.6482139",
"0.6216898",
"0.6203558",
"0.6178492",
"0.6171338",
"0.6144829",
"0.60689884",
"0.6033101",
"0.59134465",
"0.5852022",
"0.58166736",
"0.5807565",
"0.57831806... | 0.69718254 | 2 |
FileExists checks whether a file exists at a given path | func FileExists(fp string) bool {
_, err := os.Stat(fp)
if err != nil && os.IsNotExist(err) {
return false
}
return true
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func fileExists(path string) bool {\n _, err := os.Stat(path)\n return err == nil\n}",
"func exists(filePath string) (exists bool) {\n _,err := os.Stat(filePath)\n if err != nil {\n exists = false\n } else {\n exists = true\n }\n return\n}",
"func fileExists(path string) bool... | [
"0.78745645",
"0.7857279",
"0.7842963",
"0.7828053",
"0.7789463",
"0.7785036",
"0.7785036",
"0.7785036",
"0.7785036",
"0.77773625",
"0.777536",
"0.77659947",
"0.7732012",
"0.7717755",
"0.7694575",
"0.7674762",
"0.7639756",
"0.7639756",
"0.7629891",
"0.76086295",
"0.76050866",... | 0.0 | -1 |
ReadAtMost reads up to limit bytes from r, and reports an error when limit bytes are read. | func ReadAtMost(r io.Reader, limit int64) ([]byte, error) {
limitedReader := &io.LimitedReader{R: r, N: limit}
data, err := io.ReadAll(limitedReader)
if err != nil {
return data, err
}
if limitedReader.N <= 0 {
return data, ErrLimitReached
}
return data, nil
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (c Conn) LimitedRead(b []byte) (int, error) {\n\tr := io.LimitReader(c.Conn, c.maxReadBuffer)\n\treturn r.Read(b)\n}",
"func (rr *Reader) ReadSizeWithLimit(limit uint32) int {\n\tif rr.Err != nil {\n\t\treturn 0\n\t}\n\tvar size32 uint32\n\tsize32, rr.Err = size32Decode(func() (byte, error) {\n\t\treturn rr... | [
"0.6698476",
"0.592675",
"0.5846762",
"0.58344626",
"0.57960194",
"0.5787837",
"0.5778206",
"0.5766628",
"0.57591337",
"0.5743206",
"0.5741069",
"0.57359076",
"0.5708238",
"0.56657344",
"0.56469196",
"0.56459975",
"0.56374776",
"0.56374776",
"0.5634473",
"0.56332356",
"0.5598... | 0.81593716 | 0 |
HasPrefixAny determines if any of the string values have the given prefix. | func HasPrefixAny(prefix string, values []string) bool {
for _, val := range values {
if strings.HasPrefix(val, prefix) {
return true
}
}
return false
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func StartsWithAny(str string, prefixes ...string) bool {\n\tfor _, prefix := range prefixes {\n\t\tif internalStartsWith(str, (string)(prefix), false) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}",
"func HasAnyPrefix(s string, prefixList []string) bool {\n\tfor _, prefix := range prefixList {\n\t\tif str... | [
"0.8174585",
"0.79133207",
"0.7500345",
"0.738086",
"0.71756464",
"0.6655777",
"0.659458",
"0.6593437",
"0.6548416",
"0.6371666",
"0.63586235",
"0.6307001",
"0.6305777",
"0.6094398",
"0.60713154",
"0.59563047",
"0.5929936",
"0.5913401",
"0.58664",
"0.58584625",
"0.58547485",
... | 0.8484297 | 0 |
ByteCount converts a size in bytes to a humanreadable string. | func ByteCount(b int64) string {
const unit = 1000
if b < unit {
return fmt.Sprintf("%d B", b)
}
div, exp := int64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB",
float64(b)/float64(div), "kMGTPE"[exp])
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Size(size int64) string {\n\tif size < 1024 {\n\t\treturn fmt.Sprintf(\"%d byte\", size)\n\t}\n\tif size < 1024*1024 {\n\t\treturn fmt.Sprintf(\"%d kB\", size/1024)\n\t}\n\tif size < 1024*1024*1024 {\n\t\treturn fmt.Sprintf(\"%d MB\", size/1024/1024)\n\t}\n\treturn fmt.Sprintf(\"%d GB\", size/1024/1024/1024)\... | [
"0.7148524",
"0.69198364",
"0.671273",
"0.67092806",
"0.6649801",
"0.6649801",
"0.66310406",
"0.66257006",
"0.66198426",
"0.6602792",
"0.64785177",
"0.64743775",
"0.64439887",
"0.64107174",
"0.6199427",
"0.6164231",
"0.61463237",
"0.6094446",
"0.60875374",
"0.6059895",
"0.604... | 0.5518703 | 44 |
Equals checks two matches for equality | func (m *Match) Equals(other *Match) bool {
if m == nil && other == nil {
return true
} else if m == nil {
return false
} else if other == nil {
return false
}
return m.PC == other.PC &&
m.StartLine == other.StartLine &&
m.StartColumn == other.StartColumn &&
m.EndLine == other.EndLine &&
m.EndColumn == other.EndColumn &&
bytes.Equal(m.Bytes, other.Bytes)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func TestEquals(t *testing.T) {\n\tt.Parallel()\n\tfor ti, tt := range []struct {\n\t\tm1, m2 MatrixExp\n\t\teq bool\n\t}{\n\t\t{\n\t\t\tm1: GeneralZeros(1, 1),\n\t\t\tm2: GeneralZeros(1, 1),\n\t\t\teq: true,\n\t\t},\n\t\t{\n\t\t\tm1: GeneralZeros(1, 1),\n\t\t\tm2: GeneralZeros(1, 10),\n\t\t\teq: false,\n\t\t}... | [
"0.6665299",
"0.6641414",
"0.6626935",
"0.6626935",
"0.6571231",
"0.642829",
"0.6321033",
"0.6263613",
"0.6251727",
"0.6233622",
"0.62238616",
"0.6217805",
"0.614363",
"0.6140861",
"0.6139372",
"0.612923",
"0.61276424",
"0.6115138",
"0.6110481",
"0.6083133",
"0.60731983",
"... | 0.6786418 | 0 |
String formats the match for humans | func (m Match) String() string {
return fmt.Sprintf("<Match %d %d (%d, %d)-(%d, %d) '%v'>", m.PC, m.TC, m.StartLine, m.StartColumn, m.EndLine, m.EndColumn, string(m.Bytes))
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (m match) String() string {\n\treturn fmt.Sprintf(\"M{%d,%d}\", m.distance, m.n)\n}",
"func (node *MatchExpr) Format(buf *TrackedBuffer) {\n\tbuf.astPrintf(node, \"match(%v) against (%v%s)\", node.Columns, node.Expr, node.Option.ToString())\n}",
"func (s Match) String() string {\n\treturn awsutil.Prettify... | [
"0.61389",
"0.5814977",
"0.5773067",
"0.5701211",
"0.5525912",
"0.54897654",
"0.5479896",
"0.543582",
"0.5378268",
"0.5328926",
"0.5307862",
"0.5284562",
"0.52692956",
"0.52632475",
"0.52471685",
"0.52363086",
"0.52283716",
"0.521719",
"0.518946",
"0.5162455",
"0.5155652",
... | 0.55583423 | 4 |
LexerEngine does the actual tokenization of the byte slice text using the NFA bytecode in program. If the lexing process fails the Scanner will return an UnconsumedInput error. | func LexerEngine(program inst.Slice, text []byte) Scanner {
done := false
matchPC := -1
matchTC := -1
prevTC := 0
line := 1
col := 1
var scan Scanner
var cqueue, nqueue *queue.Queue = queue.New(len(program)), queue.New(len(program))
scan = func(tc int) (int, *Match, error, Scanner) {
if done && tc == len(text) {
return tc, nil, nil, nil
}
startTC := tc
if tc < matchTC {
// we back-tracked so reset the last matchTC
matchTC = -1
} else if tc == matchTC {
// the caller did not reset the tc, we are where we left
} else if matchTC != -1 && tc > matchTC {
// we skipped text
matchTC = tc
}
cqueue.Clear()
nqueue.Clear()
cqueue.Push(0)
for ; tc <= len(text); tc++ {
if cqueue.Empty() {
break
}
for !cqueue.Empty() {
pc := cqueue.Pop()
i := program[pc]
switch i.Op {
case inst.CHAR:
x := byte(i.X)
y := byte(i.Y)
if tc < len(text) && x <= text[tc] && text[tc] <= y {
nqueue.Push(pc + 1)
}
case inst.MATCH:
if matchTC < tc {
matchPC = int(pc)
matchTC = tc
} else if matchPC > int(pc) {
matchPC = int(pc)
matchTC = tc
}
case inst.JMP:
cqueue.Push(i.X)
case inst.SPLIT:
cqueue.Push(i.X)
cqueue.Push(i.Y)
default:
panic(fmt.Errorf("unexpected instruction %v", i))
}
}
cqueue, nqueue = nqueue, cqueue
if cqueue.Empty() && matchPC > -1 {
line, col = computeLineCol(text, prevTC, startTC, line, col)
eLine, eCol := computeLineCol(text, startTC, matchTC-1, line, col)
match := &Match{
PC: matchPC,
TC: startTC,
StartLine: line,
StartColumn: col,
EndLine: eLine,
EndColumn: eCol,
Bytes: text[startTC:matchTC],
}
prevTC = startTC
matchPC = -1
return tc, match, nil, scan
}
}
if matchTC != len(text) && startTC >= len(text) {
// the user has moved us farther than the text. Assume that was
// the intent and return EOF.
return tc, nil, nil, nil
} else if matchTC != len(text) {
done = true
if matchTC == -1 {
matchTC = 0
}
sline, scol := computeLineCol(text, 0, startTC, 1, 1)
fline, fcol := computeLineCol(text, 0, tc, 1, 1)
err := &UnconsumedInput{
StartTC: startTC,
FailTC: tc,
StartLine: sline,
StartColumn: scol,
FailLine: fline,
FailColumn: fcol,
Text: text,
}
return tc, nil, err, scan
} else {
return tc, nil, nil, nil
}
}
return scan
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func newLexerWithInit(in io.Reader, initFun func(*lexer)) *lexer {\n type dfa struct {\n acc []bool // Accepting states.\n f []func(rune) int // Transitions.\n startf, endf []int // Transitions at start and end of input.\n nest []dfa\n }\n yylex := new(lexer)\n if initFun != nil {\n initFun(y... | [
"0.58732367",
"0.5784889",
"0.5703706",
"0.55805975",
"0.5456216",
"0.53958595",
"0.538605",
"0.53396213",
"0.53048724",
"0.5303696",
"0.52453625",
"0.52387947",
"0.5211122",
"0.520678",
"0.51975566",
"0.5183511",
"0.5175322",
"0.51680154",
"0.51622397",
"0.5149477",
"0.51469... | 0.69410497 | 0 |
Test_Add_Read adds random entries to a testdb then tries to read those entries | func Test_Add_Read(t *testing.T) {
var test_shorthand = make([]byte, 20)
var test_fullpath = make([]byte, 20)
prio := -1
rand.Read(test_shorthand)
rand.Read(test_fullpath)
short := make_printable(test_shorthand)
full := make_printable(test_fullpath)
e := Entry{
shorthand: short,
full_path: full,
prio: prio,
extra: "TESTING",
}
AddEntry(&e)
res := GetShort(short)
if len(res) < 1{
t.Fail()
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func readTestData(t *testing.T, r FileSetReader, shard uint32, timestamp time.Time, entries []testEntry) {\n\tfor _, underTest := range readTestTypes {\n\t\terr := r.Open(testNs1ID, 0, timestamp)\n\t\trequire.NoError(t, err)\n\n\t\trequire.Equal(t, len(entries), r.Entries())\n\t\trequire.Equal(t, 0, r.EntriesRead(... | [
"0.65255356",
"0.62917155",
"0.59972405",
"0.5882072",
"0.5842434",
"0.5656843",
"0.56230897",
"0.551995",
"0.55115515",
"0.5494585",
"0.54865044",
"0.54829204",
"0.5474204",
"0.54673815",
"0.5457889",
"0.5437312",
"0.5421605",
"0.54197836",
"0.5406034",
"0.5395217",
"0.53695... | 0.69003636 | 0 |
GetUsersHandler lista todos los usuarios | func GetUsersHandler(w http.ResponseWriter, r *http.Request) {
var users []User
for _, v := range Listusers {
users = append(users, v)
}
w.Header().Set("Content-Type", "application/json")
j, err := json.Marshal(users)
if err != nil {
panic(err)
}
w.WriteHeader(http.StatusOK)
w.Write(j)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func getUsersHandler(c *gin.Context) {\n\tuser, _ := c.Get(JwtIdentityKey)\n\n\t// Role check.\n\tif !isAdmin(user) {\n\t\tc.JSON(http.StatusUnauthorized, gin.H{\"message\": \"unauthorized\"})\n\t\treturn\n\t}\n\n\tpage := c.DefaultQuery(\"page\", \"1\")\n\tcount := c.DefaultQuery(\"count\", \"10\")\n\tpageInt, _ ... | [
"0.77413064",
"0.76049715",
"0.75767225",
"0.7560748",
"0.7475642",
"0.74546",
"0.74237984",
"0.73957825",
"0.7393577",
"0.73627543",
"0.73378384",
"0.72897553",
"0.72844577",
"0.7261622",
"0.72614956",
"0.7254002",
"0.72333294",
"0.7209193",
"0.7197647",
"0.71920323",
"0.713... | 0.77894056 | 0 |
PostUserHandler crea un usuario en la base de datos | func PostUserHandler(w http.ResponseWriter, r *http.Request) {
var user User
err := json.NewDecoder(r.Body).Decode(&user)
if err != nil {
panic(err)
}
user.CreateAt = time.Now()
id++
k := strconv.Itoa(id)
Listusers[k] = user
w.Header().Set("Content-Type", "application/json")
j, err := json.Marshal(user)
if err != nil {
panic(err)
}
w.WriteHeader(http.StatusCreated)
w.Write(j)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func PostUserHandler(w http.ResponseWriter, r *http.Request) {\n\tvar user models.User\n\terr := json.NewDecoder(r.Body).Decode(&user)\n\tif err != nil {\n\t\tlog.Println(\"Error al parsear usuario\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\... | [
"0.78383803",
"0.7456648",
"0.74130136",
"0.73975974",
"0.7373872",
"0.73664296",
"0.73215455",
"0.7290208",
"0.728816",
"0.7268887",
"0.7192617",
"0.71799153",
"0.71711975",
"0.71696395",
"0.71660227",
"0.7104086",
"0.710336",
"0.7103203",
"0.7039367",
"0.7038086",
"0.703103... | 0.75723433 | 1 |
PutUserHandler Actualiza un usuario en base al id | func PutUserHandler(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
k := params["id"]
var userupdate User
err := json.NewDecoder(r.Body).Decode(&userupdate)
if err != nil {
panic(err)
}
if user, ok := Listusers[k]; ok {
userupdate.CreateAt = user.CreateAt
delete(Listusers, k)
Listusers[k] = userupdate
} else {
log.Printf("No encontramos el id %s", k)
}
w.WriteHeader(http.StatusNoContent)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func PutUserHandler(w http.ResponseWriter, r *http.Request) {\n\tid := mux.Vars(r)[\"id\"]\n\tvar userUpdate models.User\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\terr := json.NewDecoder(r.Body).Decode(&userUpdate)\n\tif err != nil {\n\t\tlog.Printf(\"Error al parsear usuario con el id %s\", id... | [
"0.7637592",
"0.7349026",
"0.676662",
"0.6664704",
"0.64797777",
"0.64533484",
"0.6371254",
"0.6328185",
"0.62599856",
"0.62352246",
"0.62276334",
"0.6226214",
"0.6223639",
"0.62121433",
"0.6204188",
"0.6164084",
"0.6130815",
"0.6123331",
"0.6111087",
"0.61034936",
"0.6097477... | 0.7697687 | 0 |
DeleteUserHandler elimina un usuario en base al id | func DeleteUserHandler(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
k := params["id"]
if _, ok := Listusers[k]; ok {
delete(Listusers, k)
} else {
log.Printf("No encontramos el id %s", k)
}
w.WriteHeader(http.StatusNoContent)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func DeleteUserHandler(connection *sql.DB, cnf config.Config) negroni.HandlerFunc {\n\treturn negroni.HandlerFunc(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\t\tvar queryToken = r.URL.Query().Get(\"token\")\n\n\t\tif len(queryToken) < 1 {\n\t\t\tqueryToken = r.Header.Get(\"token\")\n\t\... | [
"0.7829194",
"0.75990427",
"0.758616",
"0.7584279",
"0.75630176",
"0.7557841",
"0.7556832",
"0.75329816",
"0.75098014",
"0.7507609",
"0.750512",
"0.74947095",
"0.7493544",
"0.7471709",
"0.7445412",
"0.74386734",
"0.7437152",
"0.74366146",
"0.7431234",
"0.73927724",
"0.7389141... | 0.77397424 | 1 |
MarshalJSON supports json.Marshaler interface | func (v UnloadCheckResponse) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson6a975c40EncodeJsonBenchmark(&w, v)
return w.Buffer.BuildBytes(), w.Error
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Marshal(v Marshaler) ([]byte, error) {\n\tw := jwriter.Writer{}\n\tv.MarshalEasyJSON(&w)\n\treturn w.BuildBytes()\n}",
"func Marshal(v interface{}) ([]byte, error) {\n\tif ImplementsPreJSONMarshaler(v) {\n\t\terr := v.(PreJSONMarshaler).PreMarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t... | [
"0.75134",
"0.7502133",
"0.7500753",
"0.74823195",
"0.7446766",
"0.7371689",
"0.73370403",
"0.7304601",
"0.72591853",
"0.72539127",
"0.72181046",
"0.717537",
"0.7162588",
"0.7161582",
"0.71608186",
"0.7072197",
"0.70587647",
"0.7044735",
"0.7022404",
"0.6973228",
"0.6963657",... | 0.0 | -1 |
MarshalEasyJSON supports easyjson.Marshaler interface | func (v UnloadCheckResponse) MarshalEasyJSON(w *jwriter.Writer) {
easyjson6a975c40EncodeJsonBenchmark(w, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v item) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeGithubComZhekabyGoGeneratorMongoRequestwrapperTests(w, v)\n}",
"func (v Fruit) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeBackendInternalModels11(w, v)\n}",
"func (v BlitzedItemResponse) MarshalEasyJSON(w *jwriter.Wr... | [
"0.77204984",
"0.7672636",
"0.7653424",
"0.7591104",
"0.7549626",
"0.7543635",
"0.7506079",
"0.74917865",
"0.74814856",
"0.747845",
"0.74776804",
"0.7472024",
"0.74326074",
"0.74075466",
"0.74005824",
"0.7393129",
"0.7387327",
"0.7384699",
"0.7380124",
"0.7379066",
"0.7372010... | 0.0 | -1 |
UnmarshalJSON supports json.Unmarshaler interface | func (v *UnloadCheckResponse) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson6a975c40DecodeJsonBenchmark(&r, v)
return r.Error()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (j *jsonNative) UnmarshalJSON(input []byte) error {\n\tfs := fflib.NewFFLexer(input)\n\treturn j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)\n}",
"func unmarshalJSON(j extv1.JSON, output *any) error {\n\tif len(j.Raw) == 0 {\n\t\treturn nil\n\t}\n\treturn json.Unmarshal(j.Raw, output)\n}",
"func (j ... | [
"0.70113605",
"0.698139",
"0.6947301",
"0.6867781",
"0.68005323",
"0.67680764",
"0.6741481",
"0.67051035",
"0.6688701",
"0.66797084",
"0.6676911",
"0.6669605",
"0.6661001",
"0.66579056",
"0.6652777",
"0.66498846",
"0.6632663",
"0.663189",
"0.6627629",
"0.66243863",
"0.6612909... | 0.6318712 | 62 |
UnmarshalEasyJSON supports easyjson.Unmarshaler interface | func (v *UnloadCheckResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson6a975c40DecodeJsonBenchmark(l, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v *BlitzedItemResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson6a975c40DecodeJsonBenchmark4(l, v)\n}",
"func (v *Fruit) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjsonD2b7633eDecodeBackendInternalModels11(l, v)\n}",
"func (v *Boo) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson42239ddeDecodeMs... | [
"0.73436594",
"0.73405373",
"0.72584677",
"0.72040373",
"0.71776104",
"0.71510446",
"0.7143438",
"0.71413064",
"0.71286225",
"0.7112999",
"0.7103849",
"0.71005577",
"0.7097653",
"0.7085183",
"0.70850646",
"0.7081146",
"0.7077145",
"0.70403785",
"0.70357895",
"0.7030433",
"0.7... | 0.6772522 | 78 |
MarshalJSON supports json.Marshaler interface | func (v OrderCheckResponse) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson6a975c40EncodeJsonBenchmark1(&w, v)
return w.Buffer.BuildBytes(), w.Error
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Marshal(v Marshaler) ([]byte, error) {\n\tw := jwriter.Writer{}\n\tv.MarshalEasyJSON(&w)\n\treturn w.BuildBytes()\n}",
"func Marshal(v interface{}) ([]byte, error) {\n\tif ImplementsPreJSONMarshaler(v) {\n\t\terr := v.(PreJSONMarshaler).PreMarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t... | [
"0.75134",
"0.7502133",
"0.7500753",
"0.74823195",
"0.7446766",
"0.7371689",
"0.73370403",
"0.7304601",
"0.72591853",
"0.72539127",
"0.72181046",
"0.717537",
"0.7162588",
"0.7161582",
"0.71608186",
"0.7072197",
"0.70587647",
"0.7044735",
"0.7022404",
"0.6973228",
"0.6963657",... | 0.0 | -1 |
MarshalEasyJSON supports easyjson.Marshaler interface | func (v OrderCheckResponse) MarshalEasyJSON(w *jwriter.Writer) {
easyjson6a975c40EncodeJsonBenchmark1(w, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v item) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeGithubComZhekabyGoGeneratorMongoRequestwrapperTests(w, v)\n}",
"func (v Fruit) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeBackendInternalModels11(w, v)\n}",
"func (v BlitzedItemResponse) MarshalEasyJSON(w *jwriter.Wr... | [
"0.77204984",
"0.7672636",
"0.7653424",
"0.7591104",
"0.7549626",
"0.7543635",
"0.7506079",
"0.74917865",
"0.74814856",
"0.747845",
"0.74776804",
"0.7472024",
"0.74326074",
"0.74075466",
"0.74005824",
"0.7393129",
"0.7387327",
"0.7384699",
"0.7380124",
"0.7379066",
"0.7372010... | 0.73029035 | 30 |
UnmarshalJSON supports json.Unmarshaler interface | func (v *OrderCheckResponse) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson6a975c40DecodeJsonBenchmark1(&r, v)
return r.Error()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (j *jsonNative) UnmarshalJSON(input []byte) error {\n\tfs := fflib.NewFFLexer(input)\n\treturn j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)\n}",
"func unmarshalJSON(j extv1.JSON, output *any) error {\n\tif len(j.Raw) == 0 {\n\t\treturn nil\n\t}\n\treturn json.Unmarshal(j.Raw, output)\n}",
"func (j ... | [
"0.70113605",
"0.698139",
"0.6947301",
"0.6867781",
"0.68005323",
"0.67680764",
"0.6741481",
"0.67051035",
"0.6688701",
"0.66797084",
"0.6676911",
"0.6669605",
"0.6661001",
"0.66579056",
"0.6652777",
"0.66498846",
"0.6632663",
"0.663189",
"0.6627629",
"0.66243863",
"0.6612909... | 0.0 | -1 |
UnmarshalEasyJSON supports easyjson.Unmarshaler interface | func (v *OrderCheckResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson6a975c40DecodeJsonBenchmark1(l, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v *BlitzedItemResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson6a975c40DecodeJsonBenchmark4(l, v)\n}",
"func (v *Fruit) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjsonD2b7633eDecodeBackendInternalModels11(l, v)\n}",
"func (v *Boo) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson42239ddeDecodeMs... | [
"0.73436594",
"0.73405373",
"0.72584677",
"0.72040373",
"0.71776104",
"0.71510446",
"0.7143438",
"0.71413064",
"0.71286225",
"0.7112999",
"0.7103849",
"0.71005577",
"0.7097653",
"0.7085183",
"0.70850646",
"0.7081146",
"0.70403785",
"0.70357895",
"0.7030433",
"0.7028725",
"0.7... | 0.7077145 | 16 |
MarshalJSON supports json.Marshaler interface | func (v ItemCheckResponse) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson6a975c40EncodeJsonBenchmark2(&w, v)
return w.Buffer.BuildBytes(), w.Error
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Marshal(v Marshaler) ([]byte, error) {\n\tw := jwriter.Writer{}\n\tv.MarshalEasyJSON(&w)\n\treturn w.BuildBytes()\n}",
"func Marshal(v interface{}) ([]byte, error) {\n\tif ImplementsPreJSONMarshaler(v) {\n\t\terr := v.(PreJSONMarshaler).PreMarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t... | [
"0.75134",
"0.7502133",
"0.7500753",
"0.74823195",
"0.7446766",
"0.7371689",
"0.73370403",
"0.7304601",
"0.72591853",
"0.72539127",
"0.72181046",
"0.717537",
"0.7162588",
"0.7161582",
"0.71608186",
"0.7072197",
"0.70587647",
"0.7044735",
"0.7022404",
"0.6973228",
"0.6963657",... | 0.0 | -1 |
MarshalEasyJSON supports easyjson.Marshaler interface | func (v ItemCheckResponse) MarshalEasyJSON(w *jwriter.Writer) {
easyjson6a975c40EncodeJsonBenchmark2(w, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v item) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeGithubComZhekabyGoGeneratorMongoRequestwrapperTests(w, v)\n}",
"func (v Fruit) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeBackendInternalModels11(w, v)\n}",
"func (v BlitzedItemResponse) MarshalEasyJSON(w *jwriter.Wr... | [
"0.77204984",
"0.7672636",
"0.7653424",
"0.7591104",
"0.7549626",
"0.7543635",
"0.7506079",
"0.74917865",
"0.74814856",
"0.74776804",
"0.7472024",
"0.74326074",
"0.74075466",
"0.74005824",
"0.7393129",
"0.7387327",
"0.7384699",
"0.7380124",
"0.7379066",
"0.73720104",
"0.73705... | 0.747845 | 9 |
UnmarshalJSON supports json.Unmarshaler interface | func (v *ItemCheckResponse) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson6a975c40DecodeJsonBenchmark2(&r, v)
return r.Error()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (j *jsonNative) UnmarshalJSON(input []byte) error {\n\tfs := fflib.NewFFLexer(input)\n\treturn j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)\n}",
"func unmarshalJSON(j extv1.JSON, output *any) error {\n\tif len(j.Raw) == 0 {\n\t\treturn nil\n\t}\n\treturn json.Unmarshal(j.Raw, output)\n}",
"func (j ... | [
"0.70113605",
"0.698139",
"0.6947301",
"0.6867781",
"0.68005323",
"0.67680764",
"0.6741481",
"0.67051035",
"0.6688701",
"0.66797084",
"0.6676911",
"0.6669605",
"0.6661001",
"0.66579056",
"0.6652777",
"0.66498846",
"0.6632663",
"0.663189",
"0.6627629",
"0.66243863",
"0.6612909... | 0.62590677 | 81 |
UnmarshalEasyJSON supports easyjson.Unmarshaler interface | func (v *ItemCheckResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson6a975c40DecodeJsonBenchmark2(l, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v *BlitzedItemResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson6a975c40DecodeJsonBenchmark4(l, v)\n}",
"func (v *Fruit) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjsonD2b7633eDecodeBackendInternalModels11(l, v)\n}",
"func (v *Boo) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson42239ddeDecodeMs... | [
"0.73436594",
"0.73405373",
"0.72584677",
"0.72040373",
"0.71776104",
"0.71510446",
"0.7143438",
"0.71413064",
"0.7112999",
"0.7103849",
"0.71005577",
"0.7097653",
"0.7085183",
"0.70850646",
"0.7081146",
"0.7077145",
"0.70403785",
"0.70357895",
"0.7030433",
"0.7028725",
"0.70... | 0.71286225 | 8 |
MarshalJSON supports json.Marshaler interface | func (v DocumentResponse) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson6a975c40EncodeJsonBenchmark3(&w, v)
return w.Buffer.BuildBytes(), w.Error
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Marshal(v Marshaler) ([]byte, error) {\n\tw := jwriter.Writer{}\n\tv.MarshalEasyJSON(&w)\n\treturn w.BuildBytes()\n}",
"func Marshal(v interface{}) ([]byte, error) {\n\tif ImplementsPreJSONMarshaler(v) {\n\t\terr := v.(PreJSONMarshaler).PreMarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t... | [
"0.75134",
"0.7502133",
"0.7500753",
"0.74823195",
"0.7446766",
"0.7371689",
"0.73370403",
"0.7304601",
"0.72591853",
"0.72539127",
"0.72181046",
"0.717537",
"0.7162588",
"0.7161582",
"0.71608186",
"0.7072197",
"0.70587647",
"0.7044735",
"0.7022404",
"0.6973228",
"0.6963657",... | 0.0 | -1 |
MarshalEasyJSON supports easyjson.Marshaler interface | func (v DocumentResponse) MarshalEasyJSON(w *jwriter.Writer) {
easyjson6a975c40EncodeJsonBenchmark3(w, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v item) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeGithubComZhekabyGoGeneratorMongoRequestwrapperTests(w, v)\n}",
"func (v Fruit) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeBackendInternalModels11(w, v)\n}",
"func (v BlitzedItemResponse) MarshalEasyJSON(w *jwriter.Wr... | [
"0.77204984",
"0.7672636",
"0.7653424",
"0.7591104",
"0.7549626",
"0.7506079",
"0.74917865",
"0.74814856",
"0.747845",
"0.74776804",
"0.7472024",
"0.74326074",
"0.74075466",
"0.74005824",
"0.7393129",
"0.7387327",
"0.7384699",
"0.7380124",
"0.7379066",
"0.73720104",
"0.737055... | 0.7543635 | 5 |
UnmarshalJSON supports json.Unmarshaler interface | func (v *DocumentResponse) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson6a975c40DecodeJsonBenchmark3(&r, v)
return r.Error()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (j *jsonNative) UnmarshalJSON(input []byte) error {\n\tfs := fflib.NewFFLexer(input)\n\treturn j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)\n}",
"func unmarshalJSON(j extv1.JSON, output *any) error {\n\tif len(j.Raw) == 0 {\n\t\treturn nil\n\t}\n\treturn json.Unmarshal(j.Raw, output)\n}",
"func (j ... | [
"0.70113605",
"0.698139",
"0.6947301",
"0.6867781",
"0.68005323",
"0.67680764",
"0.6741481",
"0.67051035",
"0.6688701",
"0.66797084",
"0.6676911",
"0.6669605",
"0.6661001",
"0.66579056",
"0.6652777",
"0.66498846",
"0.6632663",
"0.663189",
"0.6627629",
"0.66243863",
"0.6612909... | 0.6215216 | 97 |
UnmarshalEasyJSON supports easyjson.Unmarshaler interface | func (v *DocumentResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson6a975c40DecodeJsonBenchmark3(l, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v *BlitzedItemResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson6a975c40DecodeJsonBenchmark4(l, v)\n}",
"func (v *Fruit) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjsonD2b7633eDecodeBackendInternalModels11(l, v)\n}",
"func (v *Boo) UnmarshalEasyJSON(l *jlexer.Lexer) {\n\teasyjson42239ddeDecodeMs... | [
"0.73436594",
"0.73405373",
"0.72584677",
"0.72040373",
"0.71776104",
"0.71510446",
"0.7143438",
"0.71413064",
"0.71286225",
"0.7112999",
"0.7103849",
"0.7097653",
"0.7085183",
"0.70850646",
"0.7081146",
"0.7077145",
"0.70403785",
"0.70357895",
"0.7030433",
"0.7028725",
"0.70... | 0.71005577 | 11 |
MarshalJSON supports json.Marshaler interface | func (v BlitzedItemResponse) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson6a975c40EncodeJsonBenchmark4(&w, v)
return w.Buffer.BuildBytes(), w.Error
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func Marshal(v Marshaler) ([]byte, error) {\n\tw := jwriter.Writer{}\n\tv.MarshalEasyJSON(&w)\n\treturn w.BuildBytes()\n}",
"func Marshal(v interface{}) ([]byte, error) {\n\tif ImplementsPreJSONMarshaler(v) {\n\t\terr := v.(PreJSONMarshaler).PreMarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t... | [
"0.75134",
"0.7502133",
"0.7500753",
"0.74823195",
"0.7446766",
"0.7371689",
"0.73370403",
"0.7304601",
"0.72591853",
"0.72539127",
"0.72181046",
"0.717537",
"0.7162588",
"0.7161582",
"0.71608186",
"0.7072197",
"0.70587647",
"0.7044735",
"0.7022404",
"0.6973228",
"0.6963657",... | 0.6460338 | 78 |
MarshalEasyJSON supports easyjson.Marshaler interface | func (v BlitzedItemResponse) MarshalEasyJSON(w *jwriter.Writer) {
easyjson6a975c40EncodeJsonBenchmark4(w, v)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"func (v item) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeGithubComZhekabyGoGeneratorMongoRequestwrapperTests(w, v)\n}",
"func (v Fruit) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeBackendInternalModels11(w, v)\n}",
"func (ce *CustomEvent) MarshalEasyJSON(w *jwriter.Writer) ... | [
"0.77204984",
"0.7672636",
"0.7591104",
"0.7549626",
"0.7543635",
"0.7506079",
"0.74917865",
"0.74814856",
"0.747845",
"0.74776804",
"0.7472024",
"0.74326074",
"0.74075466",
"0.74005824",
"0.7393129",
"0.7387327",
"0.7384699",
"0.7380124",
"0.7379066",
"0.73720104",
"0.737055... | 0.7653424 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.